Last active
January 10, 2019 19:21
-
-
Save prof18/ac5463e4293c09bfb9f62aebb0064791 to your computer and use it in GitHub Desktop.
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
Parser parser = new Parser(); | |
parser.execute(urlString); | |
parser.onFinish(new Parser.OnTaskCompleted() { | |
//what to do when the parsing is done | |
@Override | |
public void onTaskCompleted(ArrayList<Article> list) { | |
//list is an Array List with all article's information | |
//set the adapter to recycler view | |
mAdapter = new ArticleAdapter(list, R.layout.row, MainActivity.this); | |
mRecyclerView.setAdapter(mAdapter); | |
progressBar.setVisibility(View.GONE); | |
mSwipeRefreshLayout.setRefreshing(false); | |
} | |
//what to do in case of error | |
@Override | |
public void onError() { | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
progressBar.setVisibility(View.GONE); | |
mSwipeRefreshLayout.setRefreshing(false); | |
Toast.makeText(MainActivity.this, "Unable to load data.", | |
Toast.LENGTH_LONG).show(); | |
Log.i("Unable to load ", "articles"); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment