diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/CommentActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/CommentActivity.java index b6e3f770..c2fd87cf 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/CommentActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/CommentActivity.java @@ -204,7 +204,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA builder.linkColor(linkColor); } }; - Markwon postBodyMarkwon = MarkdownUtils.createFullRedditMarkwon(this, + Markwon postBodyMarkwon = MarkdownUtils.createFullRedditMarkwon(getApplication(), miscPlugin, parentTextColor, parentSpoilerBackgroundColor, null); MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter(); binding.commentContentMarkdownView.setLayoutManager(new LinearLayoutManagerBugFixed(this)); @@ -226,7 +226,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA setSupportActionBar(binding.commentToolbar); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); if (savedInstanceState != null) { selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/EditPostActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/EditPostActivity.java index 855ea354..8337b54e 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/EditPostActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/EditPostActivity.java @@ -172,7 +172,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled contentEditText.setText(mPost.getSelfText()); linkEditText.setText(mPost.getUrl()); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); if (mPost.getUrl() != null && mPost.getUrl().matches(picturePattern)) { loadImage(); @@ -354,7 +354,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled Uri imageUri = data.getData(); mExecutor.execute(() -> { try { - Bitmap bitmap = Glide.with(this).asBitmap().load(imageUri).submit().get(); + Bitmap bitmap = Glide.with(getApplication()).asBitmap().load(imageUri).submit().get(); String imageUrlOrError = UploadImageUtils.uploadImage(mRetrofit, mAccessToken, bitmap); handler.post(() -> { if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) { diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/EditProfileActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/EditProfileActivity.java index ffcc9d21..b2799ede 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/EditProfileActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/EditProfileActivity.java @@ -38,7 +38,6 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; -import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import eu.toldi.infinityforlemmy.Infinity; import eu.toldi.infinityforlemmy.R; import eu.toldi.infinityforlemmy.RedditDataRoomDatabase; @@ -52,6 +51,7 @@ import eu.toldi.infinityforlemmy.user.UserViewModel; import eu.toldi.infinityforlemmy.utils.EditProfileUtils; import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils; import eu.toldi.infinityforlemmy.utils.Utils; +import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; @@ -135,7 +135,7 @@ public class EditProfileActivity extends BaseActivity { startPickImage(PICK_IMAGE_AVATAR_REQUEST_CODE); }); - final RequestManager glide = Glide.with(this); + final RequestManager glide = Glide.with(getApplication()); final UserViewModel.Factory userViewModelFactory = new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName); final UserViewModel userViewModel = diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/FullMarkdownActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/FullMarkdownActivity.java index 0c398f04..f9e11d0a 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/FullMarkdownActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/FullMarkdownActivity.java @@ -29,12 +29,6 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; -import io.noties.markwon.AbstractMarkwonPlugin; -import io.noties.markwon.Markwon; -import io.noties.markwon.MarkwonConfiguration; -import io.noties.markwon.MarkwonPlugin; -import io.noties.markwon.core.MarkwonTheme; -import io.noties.markwon.recycler.MarkwonAdapter; import eu.toldi.infinityforlemmy.Infinity; import eu.toldi.infinityforlemmy.R; import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper; @@ -45,6 +39,12 @@ import eu.toldi.infinityforlemmy.customviews.slidr.Slidr; import eu.toldi.infinityforlemmy.events.SwitchAccountEvent; import eu.toldi.infinityforlemmy.markdown.MarkdownUtils; import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils; +import io.noties.markwon.AbstractMarkwonPlugin; +import io.noties.markwon.Markwon; +import io.noties.markwon.MarkwonConfiguration; +import io.noties.markwon.MarkwonPlugin; +import io.noties.markwon.core.MarkwonTheme; +import io.noties.markwon.recycler.MarkwonAdapter; public class FullMarkdownActivity extends BaseActivity { @@ -138,7 +138,7 @@ public class FullMarkdownActivity extends BaseActivity { builder.linkColor(linkColor); } }; - Markwon markwon = MarkdownUtils.createFullRedditMarkwon(this, + Markwon markwon = MarkdownUtils.createFullRedditMarkwon(getApplication(), miscPlugin, markdownColor, spoilerBackgroundColor, null); MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter(); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostGalleryActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostGalleryActivity.java index afa8d632..686aa1d8 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostGalleryActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostGalleryActivity.java @@ -214,7 +214,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostImageActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostImageActivity.java index c1bc06f7..e11b9a24 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostImageActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostImageActivity.java @@ -228,7 +228,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostLinkActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostLinkActivity.java index 0040ba67..03a1c3fb 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostLinkActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostLinkActivity.java @@ -217,7 +217,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostPollActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostPollActivity.java index 4a2ba117..cbf03903 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostPollActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostPollActivity.java @@ -219,7 +219,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostTextActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostTextActivity.java index 8256625d..b20f58e1 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostTextActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostTextActivity.java @@ -208,7 +208,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostVideoActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostVideoActivity.java index b9ed5fd6..6734c35b 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostVideoActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/PostVideoActivity.java @@ -216,7 +216,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); player = new ExoPlayer.Builder(this).build(); videoPlayerView.setPlayer(player); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubmitCrosspostActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubmitCrosspostActivity.java index 47348dc2..2fe6f747 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubmitCrosspostActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubmitCrosspostActivity.java @@ -204,7 +204,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubredditMultiselectionActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubredditMultiselectionActivity.java index 417fbaf9..09e4042f 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubredditMultiselectionActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/SubredditMultiselectionActivity.java @@ -127,7 +127,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); mSwipeRefreshLayout.setEnabled(false); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/TrendingActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/TrendingActivity.java index 68f7308e..3e796252 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/TrendingActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/TrendingActivity.java @@ -152,7 +152,7 @@ public class TrendingActivity extends BaseActivity { mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); @@ -201,7 +201,7 @@ public class TrendingActivity extends BaseActivity { isRefreshing = true; errorLinearLayout.setVisibility(View.GONE); - Glide.with(this).clear(errorImageView); + Glide.with(getApplication()).clear(errorImageView); swipeRefreshLayout.setRefreshing(true); trendingSearches = null; adapter.setTrendingSearches(null); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewImageOrGifActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewImageOrGifActivity.java index 3c487d3e..4185e4e5 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewImageOrGifActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewImageOrGifActivity.java @@ -161,7 +161,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa Slidr.attach(this, new SlidrConfig.Builder().position(SlidrPosition.VERTICAL).distanceThreshold(0.125f).build()); } - glide = Glide.with(this); + glide = Glide.with(getApplication()); handler = new Handler(); diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java index 146b7c78..7ac1c63f 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewSubredditDetailActivity.java @@ -506,7 +506,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp setSupportActionBar(toolbar); setToolbarGoToTop(toolbar); - glide = Glide.with(this); + glide = Glide.with(getApplication()); Locale locale = getResources().getConfiguration().locale; MarkwonPlugin miscPlugin = new AbstractMarkwonPlugin() { diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java index e5ee5e0f..8c2c0f57 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/ViewUserDetailActivity.java @@ -434,7 +434,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele }); } - glide = Glide.with(this); + glide = Glide.with(getApplication()); Locale locale = getResources().getConfiguration().locale; MarkwonPlugin miscPlugin = new AbstractMarkwonPlugin() { diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/activities/WikiActivity.java b/app/src/main/java/eu/toldi/infinityforlemmy/activities/WikiActivity.java index 70975c4d..9fc3fb6b 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/activities/WikiActivity.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/activities/WikiActivity.java @@ -35,16 +35,9 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; -import eu.toldi.infinityforlemmy.RetrofitHolder; -import io.noties.markwon.AbstractMarkwonPlugin; -import io.noties.markwon.Markwon; -import io.noties.markwon.MarkwonConfiguration; -import io.noties.markwon.MarkwonPlugin; -import io.noties.markwon.core.MarkwonTheme; -import io.noties.markwon.recycler.MarkwonAdapter; -import me.saket.bettermovementmethod.BetterLinkMovementMethod; import eu.toldi.infinityforlemmy.Infinity; import eu.toldi.infinityforlemmy.R; +import eu.toldi.infinityforlemmy.RetrofitHolder; import eu.toldi.infinityforlemmy.apis.RedditAPI; import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment; import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper; @@ -57,10 +50,16 @@ import eu.toldi.infinityforlemmy.markdown.MarkdownUtils; import eu.toldi.infinityforlemmy.utils.JSONUtils; import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils; import eu.toldi.infinityforlemmy.utils.Utils; +import io.noties.markwon.AbstractMarkwonPlugin; +import io.noties.markwon.Markwon; +import io.noties.markwon.MarkwonConfiguration; +import io.noties.markwon.MarkwonPlugin; +import io.noties.markwon.core.MarkwonTheme; +import io.noties.markwon.recycler.MarkwonAdapter; +import me.saket.bettermovementmethod.BetterLinkMovementMethod; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; -import retrofit2.Retrofit; public class WikiActivity extends BaseActivity { @@ -139,7 +138,7 @@ public class WikiActivity extends BaseActivity { } } - mGlide = Glide.with(this); + mGlide = Glide.with(getApplication()); swipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true)); swipeRefreshLayout.setOnRefreshListener(this::loadWiki); @@ -176,7 +175,7 @@ public class WikiActivity extends BaseActivity { urlMenuBottomSheetFragment.show(getSupportFragmentManager(), null); return true; }; - markwon = MarkdownUtils.createFullRedditMarkwon(this, + markwon = MarkdownUtils.createFullRedditMarkwon(getApplication(), miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener); markwonAdapter = MarkdownUtils.createTablesAdapter(); @@ -219,7 +218,7 @@ public class WikiActivity extends BaseActivity { swipeRefreshLayout.setRefreshing(true); - Glide.with(this).clear(mFetchWikiInfoImageView); + Glide.with(getApplication()).clear(mFetchWikiInfoImageView); mFetchWikiInfoLinearLayout.setVisibility(View.GONE); retrofit.getRetrofit().create(RedditAPI.class).getWikiPage(getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME), getIntent().getStringExtra(EXTRA_WIKI_PATH)).enqueue(new Callback() {