Browse Source
replace DownloadCheckerAsyncTask, close #825
renovate/org.robolectric-robolectric-4.x
Austin Huang
4 years ago
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
2 changed files with
23 additions and
68 deletions
-
app/src/main/java/awais/instagrabber/adapters/viewholder/FeedGridItemViewHolder.java
-
app/src/main/java/awais/instagrabber/asyncs/DownloadedCheckerAsyncTask.java
|
|
@ -19,11 +19,11 @@ import java.util.List; |
|
|
|
|
|
|
|
import awais.instagrabber.R; |
|
|
|
import awais.instagrabber.adapters.FeedAdapterV2; |
|
|
|
import awais.instagrabber.asyncs.DownloadedCheckerAsyncTask; |
|
|
|
import awais.instagrabber.databinding.ItemFeedGridBinding; |
|
|
|
import awais.instagrabber.models.PostsLayoutPreferences; |
|
|
|
import awais.instagrabber.repositories.responses.Media; |
|
|
|
import awais.instagrabber.repositories.responses.User; |
|
|
|
import awais.instagrabber.utils.DownloadUtils; |
|
|
|
import awais.instagrabber.utils.ResponseBodyUtils; |
|
|
|
import awais.instagrabber.utils.TextUtils; |
|
|
|
|
|
|
@ -102,8 +102,7 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder { |
|
|
|
binding.typeIcon.setVisibility(View.VISIBLE); |
|
|
|
binding.typeIcon.setImageResource(typeIconRes); |
|
|
|
} |
|
|
|
final DownloadedCheckerAsyncTask task = new DownloadedCheckerAsyncTask(result -> { |
|
|
|
final List<Boolean> checkList = result.get(media.getPk()); |
|
|
|
final List<Boolean> checkList = DownloadUtils.checkDownloaded(media); |
|
|
|
if (checkList == null || checkList.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
@ -125,8 +124,6 @@ public class FeedGridItemViewHolder extends RecyclerView.ViewHolder { |
|
|
|
break; |
|
|
|
default: |
|
|
|
} |
|
|
|
}); |
|
|
|
task.execute(media); |
|
|
|
} |
|
|
|
|
|
|
|
private void setThumbImage(final String thumbnailUrl) { |
|
|
|
|
|
@ -1,42 +0,0 @@ |
|
|
|
package awais.instagrabber.asyncs; |
|
|
|
|
|
|
|
import android.os.AsyncTask; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import awais.instagrabber.repositories.responses.Media; |
|
|
|
import awais.instagrabber.utils.DownloadUtils; |
|
|
|
|
|
|
|
public final class DownloadedCheckerAsyncTask extends AsyncTask<Media, Void, Map<String, List<Boolean>>> { |
|
|
|
private static final String TAG = "DownloadedCheckerAsyncTask"; |
|
|
|
|
|
|
|
private final OnCheckResultListener listener; |
|
|
|
|
|
|
|
public DownloadedCheckerAsyncTask(final OnCheckResultListener listener) { |
|
|
|
this.listener = listener; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected Map<String, List<Boolean>> doInBackground(final Media... feedModels) { |
|
|
|
if (feedModels == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
final Map<String, List<Boolean>> map = new HashMap<>(); |
|
|
|
for (final Media media : feedModels) { |
|
|
|
map.put(media.getPk(), DownloadUtils.checkDownloaded(media)); |
|
|
|
} |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onPostExecute(final Map<String, List<Boolean>> result) { |
|
|
|
if (listener == null) return; |
|
|
|
listener.onResult(result); |
|
|
|
} |
|
|
|
|
|
|
|
public interface OnCheckResultListener { |
|
|
|
void onResult(final Map<String, List<Boolean>> result); |
|
|
|
} |
|
|
|
} |