Created
September 24, 2018 23:06
-
-
Save coding-catie/3077a4b693071e404bab77f522d66d87 to your computer and use it in GitHub Desktop.
Mayat - MyNewsLoader
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
package com.example.android.mynewsappone; | |
import android.content.AsyncTaskLoader; | |
import android.content.Context; | |
import android.support.v7.app.AppCompatActivity; | |
import java.util.List; | |
public class MyNewsLoader extends AsyncTaskLoader<List<MyNews>> { | |
private String mUrl; | |
public MyNewsLoader(Context context, String url) { | |
super(context); | |
mUrl = url; | |
} | |
@Override | |
protected void onStartLoading() { | |
forceLoad(); | |
} | |
@Override | |
public List<MyNews> loadInBackground() { | |
if (mUrl == null) { | |
return null; | |
} | |
List<MyNews> newsList = MyNewsQueryUtils.fetchNewsData(mUrl); | |
return newsList; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment