Finally fixed java.lang.RuntimeException: Canvas: trying to draw too large bitmap. Rewrite some AsyncTasks using Executor.

This commit is contained in:
Alex Ning 2021-01-23 23:07:54 +08:00
parent 61b94718ef
commit 012dca977a
18 changed files with 198 additions and 263 deletions

View File

@ -22,8 +22,6 @@ import com.r0adkll.slidr.Slidr;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import java.util.concurrent.Executor;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -33,7 +31,6 @@ import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
@ -61,8 +58,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
@BindView(R.id.toolbar_account_posts_activity) @BindView(R.id.toolbar_account_posts_activity)
Toolbar toolbar; Toolbar toolbar;
@Inject @Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
@Named("default") @Named("default")
SharedPreferences mSharedPreferences; SharedPreferences mSharedPreferences;
@Inject @Inject
@ -73,8 +68,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
SharedPreferences mCurrentAccountSharedPreferences; SharedPreferences mCurrentAccountSharedPreferences;
@Inject @Inject
CustomThemeWrapper mCustomThemeWrapper; CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
private boolean isInLazyMode = false; private boolean isInLazyMode = false;
private String mAccessToken; private String mAccessToken;
private String mAccountName; private String mAccountName;

View File

@ -32,8 +32,6 @@ import org.commonmark.ext.gfm.tables.TableBlock;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import java.util.concurrent.Executor;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -101,8 +99,6 @@ public class CommentActivity extends BaseActivity {
SharedPreferences mCurrentAccountSharedPreferences; SharedPreferences mCurrentAccountSharedPreferences;
@Inject @Inject
CustomThemeWrapper mCustomThemeWrapper; CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
private String mAccessToken; private String mAccessToken;
private String parentFullname; private String parentFullname;
private int parentDepth; private int parentDepth;

View File

@ -23,7 +23,6 @@ import com.google.android.material.snackbar.Snackbar;
import com.r0adkll.slidr.Slidr; import com.r0adkll.slidr.Slidr;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.Executor;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -78,8 +77,6 @@ public class CreateMultiRedditActivity extends BaseActivity {
SharedPreferences mCurrentAccountSharedPreferences; SharedPreferences mCurrentAccountSharedPreferences;
@Inject @Inject
CustomThemeWrapper mCustomThemeWrapper; CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
private String mAccessToken; private String mAccessToken;
private String mAccountName; private String mAccountName;
private ArrayList<String> mSubreddits; private ArrayList<String> mSubreddits;

View File

@ -5,6 +5,7 @@ import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
@ -29,6 +30,8 @@ import com.google.gson.JsonSyntaxException;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import java.util.concurrent.Executor;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -37,8 +40,8 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.adapters.CustomThemeListingRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.adapters.CustomThemeListingRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.asynctasks.ChangeThemeNameAsyncTask; import ml.docilealligator.infinityforreddit.asynctasks.ChangeThemeNameAsyncTask;
import ml.docilealligator.infinityforreddit.asynctasks.DeleteThemeAsyncTask; import ml.docilealligator.infinityforreddit.asynctasks.DeleteThemeAsyncTask;
import ml.docilealligator.infinityforreddit.asynctasks.GetCustomThemeAsyncTask; import ml.docilealligator.infinityforreddit.asynctasks.GetCustomTheme;
import ml.docilealligator.infinityforreddit.asynctasks.InsertCustomThemeAsyncTask; import ml.docilealligator.infinityforreddit.asynctasks.InsertCustomTheme;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CreateThemeBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.CreateThemeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.CustomThemeOptionsBottomSheetFragment; import ml.docilealligator.infinityforreddit.bottomsheetfragments.CustomThemeOptionsBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme; import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
@ -82,6 +85,8 @@ public class CustomThemeListingActivity extends BaseActivity implements
@Inject @Inject
@Named("amoled_theme") @Named("amoled_theme")
SharedPreferences amoledThemeSharedPreferences; SharedPreferences amoledThemeSharedPreferences;
@Inject
Executor executor;
public CustomThemeViewModel customThemeViewModel; public CustomThemeViewModel customThemeViewModel;
@Override @Override
@ -183,7 +188,8 @@ public class CustomThemeListingActivity extends BaseActivity implements
@Override @Override
public void shareTheme(String themeName) { public void shareTheme(String themeName) {
new GetCustomThemeAsyncTask(redditDataRoomDatabase, themeName, customTheme -> { GetCustomTheme.getCustomTheme(executor, new Handler(), redditDataRoomDatabase, themeName,
customTheme -> {
if (customTheme != null) { if (customTheme != null) {
String jsonModel = customTheme.getJSONModel(); String jsonModel = customTheme.getJSONModel();
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
@ -197,7 +203,7 @@ public class CustomThemeListingActivity extends BaseActivity implements
} else { } else {
Snackbar.make(coordinatorLayout, R.string.cannot_find_theme, Snackbar.LENGTH_SHORT).show(); Snackbar.make(coordinatorLayout, R.string.cannot_find_theme, Snackbar.LENGTH_SHORT).show();
} }
}).execute(); });
} }
@Override @Override
@ -277,9 +283,9 @@ public class CustomThemeListingActivity extends BaseActivity implements
} }
private void checkDuplicateAndImportTheme(CustomTheme customTheme, boolean checkDuplicate) { private void checkDuplicateAndImportTheme(CustomTheme customTheme, boolean checkDuplicate) {
new InsertCustomThemeAsyncTask(redditDataRoomDatabase, lightThemeSharedPreferences, InsertCustomTheme.insertCustomTheme(executor, new Handler(), redditDataRoomDatabase, lightThemeSharedPreferences,
darkThemeSharedPreferences, amoledThemeSharedPreferences, customTheme, checkDuplicate, darkThemeSharedPreferences, amoledThemeSharedPreferences, customTheme, checkDuplicate,
new InsertCustomThemeAsyncTask.InsertCustomThemeAsyncTaskListener() { new InsertCustomTheme.InsertCustomThemeListener() {
@Override @Override
public void success() { public void success() {
Toast.makeText(CustomThemeListingActivity.this, R.string.import_theme_success, Toast.LENGTH_SHORT).show(); Toast.makeText(CustomThemeListingActivity.this, R.string.import_theme_success, Toast.LENGTH_SHORT).show();
@ -327,6 +333,6 @@ public class CustomThemeListingActivity extends BaseActivity implements
}) })
.show(); .show();
} }
}).execute(); });
} }
} }

View File

@ -4,6 +4,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.Toast; import android.widget.Toast;
@ -20,6 +21,7 @@ import com.google.android.material.snackbar.Snackbar;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.Executor;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -27,8 +29,8 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.adapters.CustomizeThemeRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.adapters.CustomizeThemeRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.asynctasks.GetCustomThemeAsyncTask; import ml.docilealligator.infinityforreddit.asynctasks.GetCustomTheme;
import ml.docilealligator.infinityforreddit.asynctasks.InsertCustomThemeAsyncTask; import ml.docilealligator.infinityforreddit.asynctasks.InsertCustomTheme;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme; import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeSettingsItem; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeSettingsItem;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
@ -74,6 +76,8 @@ public class CustomizeThemeActivity extends BaseActivity {
RedditDataRoomDatabase redditDataRoomDatabase; RedditDataRoomDatabase redditDataRoomDatabase;
@Inject @Inject
CustomThemeWrapper customThemeWrapper; CustomThemeWrapper customThemeWrapper;
@Inject
Executor mExecutor;
private String themeName; private String themeName;
private boolean isPredefinedTheme; private boolean isPredefinedTheme;
@ -112,8 +116,7 @@ public class CustomizeThemeActivity extends BaseActivity {
if (customThemeSettingsItems == null) { if (customThemeSettingsItems == null) {
if (getIntent().hasExtra(EXTRA_THEME_TYPE)) { if (getIntent().hasExtra(EXTRA_THEME_TYPE)) {
int themeType = getIntent().getIntExtra(EXTRA_THEME_TYPE, EXTRA_LIGHT_THEME); int themeType = getIntent().getIntExtra(EXTRA_THEME_TYPE, EXTRA_LIGHT_THEME);
GetCustomTheme.getCustomTheme(mExecutor, new Handler(), redditDataRoomDatabase, themeType, customTheme -> {
new GetCustomThemeAsyncTask(redditDataRoomDatabase, themeType, customTheme -> {
if (customTheme == null) { if (customTheme == null) {
isPredefinedTheme = true; isPredefinedTheme = true;
switch (themeType) { switch (themeType) {
@ -147,7 +150,7 @@ public class CustomizeThemeActivity extends BaseActivity {
adapter = new CustomizeThemeRecyclerViewAdapter(this, themeName, isPredefinedTheme); adapter = new CustomizeThemeRecyclerViewAdapter(this, themeName, isPredefinedTheme);
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
adapter.setCustomThemeSettingsItem(customThemeSettingsItems); adapter.setCustomThemeSettingsItem(customThemeSettingsItems);
}).execute(); });
} else { } else {
isPredefinedTheme = getIntent().getBooleanExtra(EXTRA_IS_PREDEFIINED_THEME, false); isPredefinedTheme = getIntent().getBooleanExtra(EXTRA_IS_PREDEFIINED_THEME, false);
themeName = getIntent().getStringExtra(EXTRA_THEME_NAME); themeName = getIntent().getStringExtra(EXTRA_THEME_NAME);
@ -163,13 +166,13 @@ public class CustomizeThemeActivity extends BaseActivity {
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
adapter.setCustomThemeSettingsItem(customThemeSettingsItems); adapter.setCustomThemeSettingsItem(customThemeSettingsItems);
} else { } else {
new GetCustomThemeAsyncTask(redditDataRoomDatabase, themeName, GetCustomTheme.getCustomTheme(mExecutor, new Handler(), redditDataRoomDatabase,
customTheme -> { themeName, customTheme -> {
customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem( customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem(
CustomizeThemeActivity.this, customTheme, androidVersion); CustomizeThemeActivity.this, customTheme, androidVersion);
adapter.setCustomThemeSettingsItem(customThemeSettingsItems); adapter.setCustomThemeSettingsItem(customThemeSettingsItems);
}).execute(); });
} }
} }
} else { } else {
@ -206,13 +209,13 @@ public class CustomizeThemeActivity extends BaseActivity {
return true; return true;
} }
CustomTheme customTheme = CustomTheme.convertSettingsItemsToCustomTheme(customThemeSettingsItems, themeName); CustomTheme customTheme = CustomTheme.convertSettingsItemsToCustomTheme(customThemeSettingsItems, themeName);
new InsertCustomThemeAsyncTask(redditDataRoomDatabase, lightThemeSharedPreferences, InsertCustomTheme.insertCustomTheme(mExecutor, new Handler(), redditDataRoomDatabase, lightThemeSharedPreferences,
darkThemeSharedPreferences, amoledThemeSharedPreferences, customTheme, darkThemeSharedPreferences, amoledThemeSharedPreferences, customTheme,
false, () -> { false, () -> {
Toast.makeText(CustomizeThemeActivity.this, R.string.saved, Toast.LENGTH_SHORT).show(); Toast.makeText(CustomizeThemeActivity.this, R.string.saved, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new RecreateActivityEvent()); EventBus.getDefault().post(new RecreateActivityEvent());
finish(); finish();
}).execute(); });
} }
return true; return true;

View File

@ -39,6 +39,7 @@ import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils; import ml.docilealligator.infinityforreddit.utils.Utils;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -49,7 +50,6 @@ public class EditCommentActivity extends BaseActivity {
public static final String EXTRA_CONTENT = "EC"; public static final String EXTRA_CONTENT = "EC";
public static final String EXTRA_FULLNAME = "EF"; public static final String EXTRA_FULLNAME = "EF";
public static final String EXTRA_ACCESS_TOKEN = "EAT";
public static final String EXTRA_POSITION = "EP"; public static final String EXTRA_POSITION = "EP";
static final String EXTRA_EDITED_COMMENT_CONTENT = "EECC"; static final String EXTRA_EDITED_COMMENT_CONTENT = "EECC";
@ -72,6 +72,9 @@ public class EditCommentActivity extends BaseActivity {
@Named("default") @Named("default")
SharedPreferences mSharedPreferences; SharedPreferences mSharedPreferences;
@Inject @Inject
@Named("current_account")
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper; CustomThemeWrapper mCustomThemeWrapper;
private String mFullName; private String mFullName;
private String mAccessToken; private String mAccessToken;
@ -102,7 +105,7 @@ public class EditCommentActivity extends BaseActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mFullName = getIntent().getStringExtra(EXTRA_FULLNAME); mFullName = getIntent().getStringExtra(EXTRA_FULLNAME);
mAccessToken = getIntent().getStringExtra(EXTRA_ACCESS_TOKEN); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mCommentContent = getIntent().getStringExtra(EXTRA_CONTENT); mCommentContent = getIntent().getStringExtra(EXTRA_CONTENT);
contentEditText.setText(mCommentContent); contentEditText.setText(mCommentContent);

View File

@ -24,8 +24,6 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.r0adkll.slidr.Slidr; import com.r0adkll.slidr.Slidr;
import java.util.concurrent.Executor;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -86,8 +84,6 @@ public class EditMultiRedditActivity extends BaseActivity {
SharedPreferences mCurrentAccountSharedPreferences; SharedPreferences mCurrentAccountSharedPreferences;
@Inject @Inject
CustomThemeWrapper mCustomThemeWrapper; CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
private String mAccessToken; private String mAccessToken;
private String mAccountName; private String mAccountName;
private MultiReddit multiReddit; private MultiReddit multiReddit;

View File

@ -53,7 +53,6 @@ public class EditPostActivity extends BaseActivity {
static final String EXTRA_TITLE = "ET"; static final String EXTRA_TITLE = "ET";
static final String EXTRA_CONTENT = "EC"; static final String EXTRA_CONTENT = "EC";
static final String EXTRA_FULLNAME = "EF"; static final String EXTRA_FULLNAME = "EF";
static final String EXTRA_ACCESS_TOKEN = "EAT";
@BindView(R.id.coordinator_layout_edit_post_activity) @BindView(R.id.coordinator_layout_edit_post_activity)
CoordinatorLayout coordinatorLayout; CoordinatorLayout coordinatorLayout;
@ -76,6 +75,9 @@ public class EditPostActivity extends BaseActivity {
@Named("default") @Named("default")
SharedPreferences mSharedPreferences; SharedPreferences mSharedPreferences;
@Inject @Inject
@Named("current_account")
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper; CustomThemeWrapper mCustomThemeWrapper;
private String mFullName; private String mFullName;
private String mAccessToken; private String mAccessToken;
@ -110,7 +112,7 @@ public class EditPostActivity extends BaseActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mFullName = getIntent().getStringExtra(EXTRA_FULLNAME); mFullName = getIntent().getStringExtra(EXTRA_FULLNAME);
mAccessToken = getIntent().getStringExtra(EXTRA_ACCESS_TOKEN); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
titleTextView.setText(getIntent().getStringExtra(EXTRA_TITLE)); titleTextView.setText(getIntent().getStringExtra(EXTRA_TITLE));
mPostContent = getIntent().getStringExtra(EXTRA_CONTENT); mPostContent = getIntent().getStringExtra(EXTRA_CONTENT);
contentEditText.setText(mPostContent); contentEditText.setText(mPostContent);

View File

@ -7,6 +7,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -122,8 +123,8 @@ public class GiveAwardActivity extends BaseActivity {
.setPositiveButton(R.string.yes, (dialogInterface, i) -> { .setPositiveButton(R.string.yes, (dialogInterface, i) -> {
boolean isAnonymous = switchMaterial.isChecked(); boolean isAnonymous = switchMaterial.isChecked();
GiveAward.giveAwardV2(mOauthRetrofit, mAccessToken, thingFullname, award.getId(), GiveAward.giveAwardV2(mExecutor, new Handler(), mOauthRetrofit, mAccessToken,
isAnonymous, new GiveAward.GiveAwardListener() { thingFullname, award.getId(), isAnonymous, new GiveAward.GiveAwardListener() {
@Override @Override
public void success(String awardsHTML, int awardCount) { public void success(String awardsHTML, int awardCount) {
Intent data = new Intent(); Intent data = new Intent();

View File

@ -1612,7 +1612,6 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
return true; return true;
case R.id.action_edit_view_post_detail_activity: case R.id.action_edit_view_post_detail_activity:
Intent editPostIntent = new Intent(this, EditPostActivity.class); Intent editPostIntent = new Intent(this, EditPostActivity.class);
editPostIntent.putExtra(EditPostActivity.EXTRA_ACCESS_TOKEN, mAccessToken);
editPostIntent.putExtra(EditPostActivity.EXTRA_FULLNAME, mPost.getFullName()); editPostIntent.putExtra(EditPostActivity.EXTRA_FULLNAME, mPost.getFullName());
editPostIntent.putExtra(EditPostActivity.EXTRA_TITLE, mPost.getTitle()); editPostIntent.putExtra(EditPostActivity.EXTRA_TITLE, mPost.getTitle());
editPostIntent.putExtra(EditPostActivity.EXTRA_CONTENT, mPost.getSelfText()); editPostIntent.putExtra(EditPostActivity.EXTRA_CONTENT, mPost.getSelfText());

View File

@ -883,7 +883,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (preview != null) { if (preview != null) {
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight()); ((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
if (mImageViewWidth > preview.getPreviewWidth()) { if (mImageViewWidth > preview.getPreviewWidth()) {
mGlide.load(preview.getPreviewUrl()).override(Target.SIZE_ORIGINAL).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView); mGlide.load(preview.getPreviewUrl()).override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView);
} else { } else {
mGlide.load(preview.getPreviewUrl()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView); mGlide.load(preview.getPreviewUrl()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView);
} }
@ -1500,7 +1500,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
preview.setPreviewWidth(preview.getPreviewWidth() / divisor); preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
preview.setPreviewHeight(preview.getPreviewHeight() / divisor); preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
divisor *= 2; divisor *= 2;
} while (preview.getPreviewWidth() * preview.getPreviewHeight() / divisor / divisor > 10_000_000); } while (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000);
} }
return preview; return preview;
@ -1537,7 +1537,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
} else { } else {
if (mImageViewWidth > preview.getPreviewWidth()) { if (mImageViewWidth > preview.getPreviewWidth()) {
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
} else { } else {
imageRequestBuilder.into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView); imageRequestBuilder.into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
} }
@ -1569,7 +1569,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); .into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
} else { } else {
if (mImageViewWidth > preview.getPreviewWidth()) { if (mImageViewWidth > preview.getPreviewWidth()) {
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
} else { } else {
imageRequestBuilder.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); imageRequestBuilder.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
} }
@ -1601,7 +1601,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
.into(((PostDetailLinkViewHolder) holder).mImageView); .into(((PostDetailLinkViewHolder) holder).mImageView);
} else { } else {
if (mImageViewWidth > preview.getPreviewWidth()) { if (mImageViewWidth > preview.getPreviewWidth()) {
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailLinkViewHolder) holder).mImageView); imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailLinkViewHolder) holder).mImageView);
} else { } else {
imageRequestBuilder.into(((PostDetailLinkViewHolder) holder).mImageView); imageRequestBuilder.into(((PostDetailLinkViewHolder) holder).mImageView);
} }
@ -1632,7 +1632,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailGalleryViewHolder) holder).mImageView); imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailGalleryViewHolder) holder).mImageView);
} else { } else {
if (mImageViewWidth > preview.getPreviewWidth()) { if (mImageViewWidth > preview.getPreviewWidth()) {
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailGalleryViewHolder) holder).mImageView); imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostDetailGalleryViewHolder) holder).mImageView);
} else { } else {
imageRequestBuilder.into(((PostDetailGalleryViewHolder) holder).mImageView); imageRequestBuilder.into(((PostDetailGalleryViewHolder) holder).mImageView);
} }

View File

@ -10,6 +10,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -1067,14 +1068,16 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) { if (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000) {
Log.i("afasfasdf", "ssss " + preview.getPreviewUrl());
int divisor = 2; int divisor = 2;
do { do {
preview.setPreviewWidth(preview.getPreviewWidth() / divisor); preview.setPreviewWidth(preview.getPreviewWidth() / divisor);
preview.setPreviewHeight(preview.getPreviewHeight() / divisor); preview.setPreviewHeight(preview.getPreviewHeight() / divisor);
divisor *= 2; divisor *= 2;
} while (preview.getPreviewWidth() * preview.getPreviewHeight() / divisor / divisor > 10_000_000); } while (preview.getPreviewWidth() * preview.getPreviewHeight() > 10_000_000);
} }
Log.i("afasfasdf", "s " + preview.getPreviewWidth() * preview.getPreviewHeight() + " " + preview.getPreviewHeight() + " " + preview.getPreviewWidth() + " " + preview.getPreviewUrl());
return preview; return preview;
} }
@ -1116,7 +1119,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
.into(((PostWithPreviewTypeViewHolder) holder).imageView); .into(((PostWithPreviewTypeViewHolder) holder).imageView);
} else { } else {
if (mImageViewWidth > preview.getPreviewWidth()) { if (mImageViewWidth > preview.getPreviewWidth()) {
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostWithPreviewTypeViewHolder) holder).imageView); imageRequestBuilder.override(preview.getPreviewWidth(), preview.getPreviewHeight()).into(((PostWithPreviewTypeViewHolder) holder).imageView);
} else { } else {
imageRequestBuilder.into(((PostWithPreviewTypeViewHolder) holder).imageView); imageRequestBuilder.into(((PostWithPreviewTypeViewHolder) holder).imageView);
} }

View File

@ -0,0 +1,45 @@
package ml.docilealligator.infinityforreddit.asynctasks;
import android.os.Handler;
import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
public class GetCustomTheme {
public static void getCustomTheme(Executor executor, Handler handler,
RedditDataRoomDatabase redditDataRoomDatabase,
String customThemeName,
GetCustomThemeListener getCustomThemeListener) {
executor.execute(() -> {
CustomTheme customTheme = redditDataRoomDatabase.customThemeDao().getCustomTheme(customThemeName);
handler.post(() -> getCustomThemeListener.success(customTheme));
});
}
public static void getCustomTheme(Executor executor, Handler handler,
RedditDataRoomDatabase redditDataRoomDatabase,
int themeType,
GetCustomThemeListener getCustomThemeListener) {
executor.execute(() -> {
CustomTheme customTheme;
switch (themeType) {
case CustomThemeSharedPreferencesUtils.DARK:
customTheme = redditDataRoomDatabase.customThemeDao().getDarkCustomTheme();
break;
case CustomThemeSharedPreferencesUtils.AMOLED:
customTheme = redditDataRoomDatabase.customThemeDao().getAmoledCustomTheme();
break;
default:
customTheme = redditDataRoomDatabase.customThemeDao().getLightCustomTheme();
}
handler.post(() -> getCustomThemeListener.success(customTheme));
});
}
public interface GetCustomThemeListener {
void success(CustomTheme customTheme);
}
}

View File

@ -1,60 +0,0 @@
package ml.docilealligator.infinityforreddit.asynctasks;
import android.os.AsyncTask;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
public class GetCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> {
private RedditDataRoomDatabase redditDataRoomDatabase;
private String customThemeName;
private int themeType;
private GetCustomThemeAsyncTaskListener getCustomThemeAsyncTaskListener;
private CustomTheme customTheme;
public interface GetCustomThemeAsyncTaskListener {
void success(CustomTheme customTheme);
}
public GetCustomThemeAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase,
String customThemeName,
GetCustomThemeAsyncTaskListener getCustomThemeAsyncTaskListener) {
this.redditDataRoomDatabase = redditDataRoomDatabase;
this.customThemeName = customThemeName;
this.getCustomThemeAsyncTaskListener = getCustomThemeAsyncTaskListener;
}
public GetCustomThemeAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase,
int themeType,
GetCustomThemeAsyncTaskListener getCustomThemeAsyncTaskListener) {
this.redditDataRoomDatabase = redditDataRoomDatabase;
this.themeType = themeType;
this.getCustomThemeAsyncTaskListener = getCustomThemeAsyncTaskListener;
}
@Override
protected Void doInBackground(Void... voids) {
if (customThemeName != null) {
customTheme = redditDataRoomDatabase.customThemeDao().getCustomTheme(customThemeName);
} else {
switch (themeType) {
case CustomThemeSharedPreferencesUtils.DARK:
customTheme = redditDataRoomDatabase.customThemeDao().getDarkCustomTheme();
break;
case CustomThemeSharedPreferencesUtils.AMOLED:
customTheme = redditDataRoomDatabase.customThemeDao().getAmoledCustomTheme();
break;
default:
customTheme = redditDataRoomDatabase.customThemeDao().getLightCustomTheme();
}
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
getCustomThemeAsyncTaskListener.success(customTheme);
}
}

View File

@ -0,0 +1,56 @@
package ml.docilealligator.infinityforreddit.asynctasks;
import android.content.SharedPreferences;
import android.os.Handler;
import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
public class InsertCustomTheme {
public static void insertCustomTheme(Executor executor, Handler handler,
RedditDataRoomDatabase redditDataRoomDatabase,
SharedPreferences lightThemeSharedPreferences,
SharedPreferences darkThemeSharedPreferences,
SharedPreferences amoledThemeSharedPreferences,
CustomTheme customTheme, boolean checkDuplicate,
InsertCustomThemeListener insertCustomThemeListener) {
executor.execute(() -> {
if (checkDuplicate) {
if (redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name) != null) {
handler.post(insertCustomThemeListener::duplicate);
}
}
CustomTheme previousTheme = redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name);
if (customTheme.isLightTheme) {
redditDataRoomDatabase.customThemeDao().unsetLightTheme();
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, lightThemeSharedPreferences);
} else if (previousTheme != null && previousTheme.isLightTheme) {
lightThemeSharedPreferences.edit().clear().apply();
}
if (customTheme.isDarkTheme) {
redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, darkThemeSharedPreferences);
} else if (previousTheme != null && previousTheme.isDarkTheme) {
darkThemeSharedPreferences.edit().clear().apply();
}
if (customTheme.isAmoledTheme) {
redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, amoledThemeSharedPreferences);
} else if (previousTheme != null && previousTheme.isAmoledTheme) {
amoledThemeSharedPreferences.edit().clear().apply();
}
redditDataRoomDatabase.customThemeDao().insert(customTheme);
handler.post(insertCustomThemeListener::success);
});
}
public interface InsertCustomThemeListener {
void success();
default void duplicate() {}
}
}

View File

@ -1,80 +0,0 @@
package ml.docilealligator.infinityforreddit.asynctasks;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
public class InsertCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> {
private RedditDataRoomDatabase redditDataRoomDatabase;
private SharedPreferences lightThemeSharedPreferences;
private SharedPreferences darkThemeSharedPreferences;
private SharedPreferences amoledThemeSharedPreferences;
private CustomTheme customTheme;
private boolean checkDuplicate;
private InsertCustomThemeAsyncTaskListener insertCustomThemeAsyncTaskListener;
private boolean isDuplicate = false;
public interface InsertCustomThemeAsyncTaskListener {
void success();
default void duplicate() {}
}
public InsertCustomThemeAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase,
SharedPreferences lightThemeSharedPreferences,
SharedPreferences darkThemeSharedPreferences,
SharedPreferences amoledThemeSharedPreferences,
CustomTheme customTheme, boolean checkDuplicate,
InsertCustomThemeAsyncTaskListener insertCustomThemeAsyncTaskListener) {
this.redditDataRoomDatabase = redditDataRoomDatabase;
this.lightThemeSharedPreferences = lightThemeSharedPreferences;
this.darkThemeSharedPreferences = darkThemeSharedPreferences;
this.amoledThemeSharedPreferences = amoledThemeSharedPreferences;
this.customTheme = customTheme;
this.checkDuplicate = checkDuplicate;
this.insertCustomThemeAsyncTaskListener = insertCustomThemeAsyncTaskListener;
}
@Override
protected Void doInBackground(Void... voids) {
if (checkDuplicate) {
if (redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name) != null) {
isDuplicate = true;
return null;
}
}
CustomTheme previousTheme = redditDataRoomDatabase.customThemeDao().getCustomTheme(customTheme.name);
if (customTheme.isLightTheme) {
redditDataRoomDatabase.customThemeDao().unsetLightTheme();
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, lightThemeSharedPreferences);
} else if (previousTheme != null && previousTheme.isLightTheme) {
lightThemeSharedPreferences.edit().clear().apply();
}
if (customTheme.isDarkTheme) {
redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, darkThemeSharedPreferences);
} else if (previousTheme != null && previousTheme.isDarkTheme) {
darkThemeSharedPreferences.edit().clear().apply();
}
if (customTheme.isAmoledTheme) {
redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, amoledThemeSharedPreferences);
} else if (previousTheme != null && previousTheme.isAmoledTheme) {
amoledThemeSharedPreferences.edit().clear().apply();
}
redditDataRoomDatabase.customThemeDao().insert(customTheme);
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
if (isDuplicate) {
insertCustomThemeAsyncTaskListener.duplicate();
} else {
insertCustomThemeAsyncTaskListener.success();
}
}
}

View File

@ -1,6 +1,6 @@
package ml.docilealligator.infinityforreddit.award; package ml.docilealligator.infinityforreddit.award;
import android.os.AsyncTask; import android.os.Handler;
import android.text.Html; import android.text.Html;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -11,6 +11,7 @@ import org.json.JSONObject;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.apis.RedditAPI; import ml.docilealligator.infinityforreddit.apis.RedditAPI;
import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.APIUtils;
@ -26,8 +27,9 @@ public class GiveAward {
void failed(int code, String message); void failed(int code, String message);
} }
public static void giveAwardV2(Retrofit oauthRetrofit, String accessToken, String thingFullName, String awardId, public static void giveAwardV2(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
boolean isAnonymous, GiveAwardListener giveAwardListener) { String thingFullName, String awardId, boolean isAnonymous,
GiveAwardListener giveAwardListener) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put(APIUtils.GILD_TYPE, awardId); params.put(APIUtils.GILD_TYPE, awardId);
params.put(APIUtils.IS_ANONYMOUS, Boolean.toString(isAnonymous)); params.put(APIUtils.IS_ANONYMOUS, Boolean.toString(isAnonymous));
@ -36,7 +38,7 @@ public class GiveAward {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
new ParseResponseAsyncTask(response.body(), new ParseResponseAsyncTask.ParseResponseAsyncTaskListener() { executor.execute(() -> parseResponse(handler, response.body(), new ParseResponseAsyncTaskListener() {
@Override @Override
public void success(String awardsHTML, int awardCount) { public void success(String awardsHTML, int awardCount) {
giveAwardListener.success(awardsHTML, awardCount); giveAwardListener.success(awardsHTML, awardCount);
@ -46,7 +48,7 @@ public class GiveAward {
public void failed(String errorMessage) { public void failed(String errorMessage) {
giveAwardListener.failed(response.code(), response.body()); giveAwardListener.failed(response.code(), response.body());
} }
}).execute(); }));
} else { } else {
giveAwardListener.failed(response.code(), response.body()); giveAwardListener.failed(response.code(), response.body());
} }
@ -59,27 +61,7 @@ public class GiveAward {
}); });
} }
private static class ParseResponseAsyncTask extends AsyncTask<Void, Void, Void> { private static void parseResponse(Handler handler, String response, ParseResponseAsyncTaskListener parseResponseAsyncTaskListener) {
private String response;
private boolean error = false;
private String awardsHTML;
private int awardCount;
private String errorMessage = null;
private ParseResponseAsyncTaskListener parseResponseAsyncTaskListener;
public ParseResponseAsyncTask(String response, ParseResponseAsyncTaskListener parseResponseAsyncTaskListener) {
this.response = response;
this.parseResponseAsyncTaskListener = parseResponseAsyncTaskListener;
}
interface ParseResponseAsyncTaskListener {
void success(String awardsHTML, int awardCount);
void failed(String errorMessage);
}
@Override
protected Void doInBackground(Void... voids) {
try { try {
//Check for error //Check for error
JSONObject responseObject = new JSONObject(response).getJSONObject(JSONUtils.JSON_KEY); JSONObject responseObject = new JSONObject(response).getJSONObject(JSONUtils.JSON_KEY);
@ -94,9 +76,8 @@ public class GiveAward {
} else { } else {
errorString = errorArray.getString(0); errorString = errorArray.getString(0);
} }
errorMessage = errorString.substring(0, 1).toUpperCase() + errorString.substring(1); String errorMessage = errorString.substring(0, 1).toUpperCase() + errorString.substring(1);
error = true; handler.post(() -> parseResponseAsyncTaskListener.failed(errorMessage));
return null;
} }
} }
} catch (JSONException ignore) {} } catch (JSONException ignore) {}
@ -104,7 +85,7 @@ public class GiveAward {
try { try {
JSONArray awardingsArray = new JSONObject(response).getJSONArray(JSONUtils.ALL_AWARDINGS_KEY); JSONArray awardingsArray = new JSONObject(response).getJSONArray(JSONUtils.ALL_AWARDINGS_KEY);
StringBuilder awardingsBuilder = new StringBuilder(); StringBuilder awardingsBuilder = new StringBuilder();
awardCount = 0; int awardCount = 0;
for (int i = 0; i < awardingsArray.length(); i++) { for (int i = 0; i < awardingsArray.length(); i++) {
JSONObject award = awardingsArray.getJSONObject(i); JSONObject award = awardingsArray.getJSONObject(i);
int count = award.getInt(JSONUtils.COUNT_KEY); int count = award.getInt(JSONUtils.COUNT_KEY);
@ -113,22 +94,17 @@ public class GiveAward {
awardingsBuilder.append("<img src=\"").append(Html.escapeHtml(iconUrl)).append("\"> ").append("x").append(count).append(" "); awardingsBuilder.append("<img src=\"").append(Html.escapeHtml(iconUrl)).append("\"> ").append("x").append(count).append(" ");
} }
awardsHTML = awardingsBuilder.toString(); String awardsHTML = awardingsBuilder.toString();
int finalAwardCount = awardCount;
handler.post(() -> parseResponseAsyncTaskListener.success(awardsHTML, finalAwardCount));
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
error = true; handler.post(() -> parseResponseAsyncTaskListener.failed(null));
} }
return null;
} }
@Override interface ParseResponseAsyncTaskListener {
protected void onPostExecute(Void aVoid) { void success(String awardsHTML, int awardCount);
super.onPostExecute(aVoid); void failed(String errorMessage);
if (error) {
parseResponseAsyncTaskListener.failed(errorMessage);
} else {
parseResponseAsyncTaskListener.success(awardsHTML, awardCount);
}
}
} }
} }

View File

@ -108,7 +108,6 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag
editTextView.setOnClickListener(view -> { editTextView.setOnClickListener(view -> {
Intent intent = new Intent(activity, EditCommentActivity.class); Intent intent = new Intent(activity, EditCommentActivity.class);
intent.putExtra(EditCommentActivity.EXTRA_ACCESS_TOKEN, accessToken);
intent.putExtra(EditCommentActivity.EXTRA_FULLNAME, comment.getFullName()); intent.putExtra(EditCommentActivity.EXTRA_FULLNAME, comment.getFullName());
intent.putExtra(EditCommentActivity.EXTRA_CONTENT, comment.getCommentMarkdown()); intent.putExtra(EditCommentActivity.EXTRA_CONTENT, comment.getCommentMarkdown());
intent.putExtra(EditCommentActivity.EXTRA_POSITION, bundle.getInt(EXTRA_POSITION)); intent.putExtra(EditCommentActivity.EXTRA_POSITION, bundle.getInt(EXTRA_POSITION));