Fixed a bug which causes the app crash when starting ViewImageActivity from ViewPostDetailActivity.

This commit is contained in:
Alex Ning 2018-08-11 00:05:20 +08:00
parent 362634d1c7
commit c0eaf2d3bb
2 changed files with 3 additions and 40 deletions

View File

@ -535,43 +535,4 @@ class BestPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.View
}
}
}
/*private static class LoadSubredditIconAsyncTask extends AsyncTask<Void, Void, Void> {
private final WeakReference<Context> contextWeakReference;
private final WeakReference<CircleImageView> 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);
}
}
}
}*/
}

View File

@ -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);
}
});