Last active
September 11, 2020 12:20
-
-
Save Sunilkumarr/9fad0460c512999d5ba1b703236c4fbd to your computer and use it in GitHub Desktop.
Android group list from server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stpes: | |
1. Note make sure to call this in async task or some other task as this below method is server call. | |
2. Make sure to store syncChannelFeed.getUpdatedAt() in SharedPreferences to call next time to get the updated group details if any. | |
3. Use the below code and added some TODO in below method please read that. | |
//// TODO: Store the default value in SharedPreferences as 10000 and Once the response is received store that time in SharedPreferences using syncChannelFeed.getUpdatedAt() and pass that shared SharedPreferences value to this method for calling; | |
public List<Channel> getGroupList(Context context, String updatedAtTime) { | |
ChannelClientService channelClientService = ChannelClientService.getInstance(context); | |
SyncChannelFeed syncChannelFeed = channelClientService.getChannelFeed(updatedAtTime); | |
if (syncChannelFeed == null) { | |
return null; | |
} | |
if (syncChannelFeed.isSuccess()) { | |
ChannelService.getInstance(context).processChannelList(syncChannelFeed.getResponse()); | |
// TODO: Save the updated at time in SharedPreferences to get the updated groups or new groups next time pass it in getGroupList method | |
syncChannelFeed.getUpdatedAt(); | |
} | |
//Here finally fetch the data from local data base so that you will get all stored groups | |
// Calling getAllChannels to get list of channels from db which are stored after server call. | |
List<Channel> channelList = ChannelDatabaseService.getInstance(context).getAllChannels(); | |
return channelList; | |
} | |
4. Clear the shared pref on your app logout. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment