From c0eaf2d3bb599503d35753c69854d62275775f17 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sat, 11 Aug 2018 00:05:20 +0800 Subject: Fixed a bug which causes the app crash when starting ViewImageActivity from ViewPostDetailActivity. --- .../BestPostRecyclerViewAdapter.java | 39 ---------------------- .../infinityforreddit/ViewPostDetailActivity.java | 4 ++- 2 files changed, 3 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BestPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BestPostRecyclerViewAdapter.java index ed3fd0dd..38838a00 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/BestPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BestPostRecyclerViewAdapter.java @@ -535,43 +535,4 @@ class BestPostRecyclerViewAdapter extends RecyclerView.Adapter { - private final WeakReference contextWeakReference; - private final WeakReference circleImageViewWeakReference; - - private SubredditDao subredditDao; - private String subredditName; - private String iconImageUrl; - - LoadSubredditIconAsyncTask(Context context, CircleImageView iconImageView, SubredditDao subredditDao, String subredditName) { - contextWeakReference = new WeakReference<>(context); - circleImageViewWeakReference = new WeakReference<>(iconImageView); - this.subredditDao = subredditDao; - this.subredditName = subredditName; - } - - @Override - protected Void doInBackground(Void... voids) { - if(subredditDao.getSubredditData(subredditName) != null) { - iconImageUrl = subredditDao.getSubredditData(subredditName).getIconUrl(); - } - return null; - } - - @Override - protected void onPostExecute(Void aVoid) { - super.onPostExecute(aVoid); - Context context = contextWeakReference.get(); - CircleImageView circleImageView = circleImageViewWeakReference.get(); - - if(context != null && circleImageView != null) { - if(iconImageUrl != null) { - Glide.with(context).load(iconImageUrl).into(circleImageView); - } else { - Glide.with(context).load(R.drawable.subreddit_default_icon).into(circleImageView); - } - } - } - }*/ } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java index c65d5ab8..3245ddf9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java @@ -141,8 +141,10 @@ public class ViewPostDetailActivity extends AppCompatActivity { @Override public void onClick(View view) { Intent intent = new Intent(ViewPostDetailActivity.this, ViewImageActivity.class); - intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, mPostData.getPreviewUrl()); + intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, mPostData.getUrl()); intent.putExtra(ViewImageActivity.TITLE_KEY, mPostData.getTitle()); + intent.putExtra(ViewImageActivity.SUBREDDIT_KEY, mPostData.getSubredditName()); + intent.putExtra(ViewImageActivity.ID_KEY, mPostData.getId()); startActivity(intent); } }); -- cgit v1.2.3