-
Notifications
You must be signed in to change notification settings - Fork 14
/
ChangelogParserAsyncTask.java
52 lines (43 loc) · 1.5 KB
/
ChangelogParserAsyncTask.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.michaelflisar.changelog.internal;
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.widget.ProgressBar;
import com.michaelflisar.changelog.ChangelogBuilder;
import com.michaelflisar.changelog.interfaces.IRecyclerViewItem;
import java.util.List;
/**
* Created by flisar on 06.03.2018.
*/
public class ChangelogParserAsyncTask extends AsyncTask<Void, Void, List<IRecyclerViewItem>> {
private Context mContext;
private ProgressBar mPbLoading;
private ChangelogRecyclerViewAdapter mAdapter;
private ChangelogBuilder mBuilder;
public ChangelogParserAsyncTask(Context context, ProgressBar pbLoading, ChangelogRecyclerViewAdapter adapter, ChangelogBuilder builder) {
mContext = context;
mPbLoading = pbLoading;
mAdapter = adapter;
mBuilder = builder;
}
@Override
protected List<IRecyclerViewItem> doInBackground(Void... params) {
try {
if (mBuilder != null) {
return mBuilder.getRecyclerViewItems(mContext);
}
} catch (Exception e) {
Log.e(Constants.DEBUG_TAG, "Exception occured while building changelog's RecyclerView items", e);
}
return null;
}
protected void onPostExecute(List<IRecyclerViewItem> result) {
if (result != null) {
mAdapter.setItems(result);
}
if (mPbLoading != null) {
mPbLoading.setVisibility(View.GONE);
}
}
}