Last active
August 29, 2015 14:12
-
-
Save emedinaa/40c5103ebde30b798ce4 to your computer and use it in GitHub Desktop.
Example AsyncTaskLoader
This file contains hidden or 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
public class MyLoader extends AsyncTaskLoader<String> { | |
boolean isLoading = false; | |
String result =null; | |
public PromotionsLoader(Context context) | |
{ | |
super(context); | |
connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
} | |
@Override | |
public String loadInBackground() { | |
if(NetworkConnectivityUtils.hasNetworkConnectivity(connectivityManager)) | |
{ | |
/* | |
Aquí | |
*/ | |
result =strJSON; | |
}catch(Throwable e) | |
{ | |
//FLog.v(" MyLoader error", e); | |
e.printStackTrace(); | |
return null; | |
} | |
}else | |
{ | |
result=null; | |
} | |
isLoading = false; | |
return result; | |
} | |
@Override | |
protected void onStartLoading() { | |
forceLoad(); | |
} | |
@Override | |
public void forceLoad() { | |
super.forceLoad(); | |
} | |
} | |
//------------------------------------------- | |
@Override | |
public void onActivityCreated(Bundle savedInstanceState) | |
{ | |
super.onActivityCreated(savedInstanceState); | |
getLoaderManager().initLoader(LOADER_ID, null, this); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment