Skip to content

Instantly share code, notes, and snippets.

@harshalbhakta
Created August 31, 2013 10:01
Show Gist options
  • Select an option

  • Save harshalbhakta/6397309 to your computer and use it in GitHub Desktop.

Select an option

Save harshalbhakta/6397309 to your computer and use it in GitHub Desktop.
public void loadUpdates(boolean loadWordADay)
{
try
{
if (Util.isNetworkAvailable(this))
{
sendProgress(ProgressMode.UPDATE_STARTED.ordinal());
//-- Update Word of the day
if(loadWordADay) {
Util.updateWordOfTheDay();
sendProgress(ProgressMode.WORD_A_DAY_UPDATE_COMPLETE.ordinal());
}
// Note: made delete first and then update to ensure words not to be looped are all cleared
//-- Remove deleted words
Util.removeDeletedWords();
sendProgress(ProgressMode.DELETE_COMPLETE.ordinal());
//-- Update words & sentences.
Util.updateWords();
sendProgress(ProgressMode.UPDATE_COMPLETE.ordinal());
}else
{
sendProgress(ProgressMode.NETWORK_CONNECTIVITY_FAILED.ordinal());
Thread.sleep(1000);
sendProgress(ProgressMode.UPDATE_FAILED.ordinal());
}
// wait for some time before setting old subtitle
Thread.sleep(2000);
// to change subtitle status back to the default subtitle
sendProgress(ProgressMode.RESET_TITLE.ordinal());
}catch (Exception e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment