From 0f4ced56699cb99e89a9eb6c2625c404c35fb25e Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Fri, 24 Sep 2021 21:07:26 -0400 Subject: Update AGP, reorganize libraries --- .../infinityforreddit/settings/AcknowledgementFragment.java | 6 ------ 1 file changed, 6 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AcknowledgementFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AcknowledgementFragment.java index 2f2aa91e..c5a3690d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AcknowledgementFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AcknowledgementFragment.java @@ -50,12 +50,6 @@ public class AcknowledgementFragment extends Fragment { acknowledgements.add(new Acknowledgement("Glide", "A fast and efficient open source media management and image loading framework for Android", Uri.parse("https://github.com/bumptech/glide"))); - acknowledgements.add(new Acknowledgement("RxAndroid", - "Android specific bindings for RxJava 2", - Uri.parse("https://github.com/ReactiveX/RxAndroid"))); - acknowledgements.add(new Acknowledgement("RxJava", - "Reactive extensions for the JVM", - Uri.parse("https://github.com/ReactiveX/RxJava"))); acknowledgements.add(new Acknowledgement("Retrofit", "Type-safe HTTP client for Android and Java by Square, Inc.", Uri.parse("https://github.com/square/retrofit"))); -- cgit v1.2.3 From e46408296488d1989159335b75f8181f05ca5afd Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Fri, 24 Sep 2021 21:08:09 -0400 Subject: Migrate from JCenter where possible --- .../infinityforreddit/activities/ViewImgurMediaActivity.java | 4 ++-- .../infinityforreddit/activities/ViewRedditGalleryActivity.java | 4 ++-- .../infinityforreddit/activities/ViewVideoActivity.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImgurMediaActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImgurMediaActivity.java index 8aab0011..20d3440f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImgurMediaActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImgurMediaActivity.java @@ -21,8 +21,8 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.viewpager.widget.ViewPager; -import com.thefuntasty.hauler.DragDirection; -import com.thefuntasty.hauler.HaulerView; +import app.futured.hauler.DragDirection; +import app.futured.hauler.HaulerView; import org.json.JSONArray; import org.json.JSONException; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java index b5047cc6..61a5066f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java @@ -17,8 +17,8 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.viewpager.widget.ViewPager; -import com.thefuntasty.hauler.DragDirection; -import com.thefuntasty.hauler.HaulerView; +import app.futured.hauler.DragDirection; +import app.futured.hauler.HaulerView; import java.util.ArrayList; import java.util.concurrent.Executor; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index f82e85b7..3f17763b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -55,8 +55,8 @@ import com.google.android.exoplayer2.upstream.cache.SimpleCache; import com.google.android.exoplayer2.util.Util; import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.snackbar.Snackbar; -import com.thefuntasty.hauler.DragDirection; -import com.thefuntasty.hauler.HaulerView; +import app.futured.hauler.DragDirection; +import app.futured.hauler.HaulerView; import org.apache.commons.io.FilenameUtils; -- cgit v1.2.3 From 92c76f2e12c414f8607068f9d91d47c53473b463 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Fri, 24 Sep 2021 21:10:15 -0400 Subject: Update a bunch of libraries --- .../infinityforreddit/activities/SearchActivity.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java index 66369953..c7cbf120 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -203,13 +203,13 @@ public class SearchActivity extends BaseActivity { simpleSearchView.setOnQueryTextListener(new SimpleSearchView.OnQueryTextListener() { @Override - public boolean onQueryTextSubmit(String query) { + public boolean onQueryTextSubmit(@NonNull String query) { search(query); return true; } @Override - public boolean onQueryTextChange(String newText) { + public boolean onQueryTextChange(@NonNull String newText) { if (!newText.isEmpty()) { if (subredditAutocompleteCall != null) { subredditAutocompleteCall.cancel(); @@ -384,11 +384,10 @@ public class SearchActivity extends BaseActivity { protected void onStart() { super.onStart(); simpleSearchView.showSearch(false); - simpleSearchView.getSearchEditText().requestFocus(); + simpleSearchView.requestFocus(); if (query != null) { - simpleSearchView.getSearchEditText().setText(query); - simpleSearchView.getSearchEditText().setSelection(query.length()); + simpleSearchView.setQuery(query, false); query = null; } @@ -403,13 +402,13 @@ public class SearchActivity extends BaseActivity { super.onPause(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { - imm.hideSoftInputFromWindow(simpleSearchView.getSearchEditText().getWindowToken(), 0); + imm.hideSoftInputFromWindow(simpleSearchView.getWindowToken(), 0); } } @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { - if (simpleSearchView.onActivityResult(requestCode, resultCode, data)) { + if (data != null && simpleSearchView.onActivityResult(requestCode, resultCode, data)) { return; } -- cgit v1.2.3 From 2b17931628a4d1612d344e9359fbb630c118efff Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Fri, 24 Sep 2021 21:10:59 -0400 Subject: Use some empty implementations of listeners --- .../activities/SearchActivity.java | 26 ++++----------------- .../activities/ViewImageOrGifActivity.java | 27 +--------------------- .../adapters/PostDetailRecyclerViewAdapter.java | 12 +--------- .../adapters/PostRecyclerViewAdapter.java | 24 ++----------------- .../ViewRedditGalleryImageOrGifFragment.java | 27 +--------------------- 5 files changed, 9 insertions(+), 107 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java index c7cbf120..eab43461 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -20,7 +20,9 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.RecyclerView; +import com.ferfalk.simplesearchview.SimpleOnQueryTextListener; import com.ferfalk.simplesearchview.SimpleSearchView; +import com.ferfalk.simplesearchview.SimpleSearchViewListener; import com.google.android.material.appbar.AppBarLayout; import com.r0adkll.slidr.Slidr; @@ -154,26 +156,11 @@ public class SearchActivity extends BaseActivity { simpleSearchView.setHint(getText(R.string.search_only_users_hint)); } - simpleSearchView.setOnSearchViewListener(new SimpleSearchView.SearchViewListener() { - @Override - public void onSearchViewShown() { - - } - + simpleSearchView.setOnSearchViewListener(new SimpleSearchViewListener() { @Override public void onSearchViewClosed() { finish(); } - - @Override - public void onSearchViewShownAnimation() { - - } - - @Override - public void onSearchViewClosedAnimation() { - - } }); mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null); @@ -201,7 +188,7 @@ public class SearchActivity extends BaseActivity { finish(); }); - simpleSearchView.setOnQueryTextListener(new SimpleSearchView.OnQueryTextListener() { + simpleSearchView.setOnQueryTextListener(new SimpleOnQueryTextListener() { @Override public boolean onQueryTextSubmit(@NonNull String query) { search(query); @@ -244,11 +231,6 @@ public class SearchActivity extends BaseActivity { } return false; } - - @Override - public boolean onQueryTextCleared() { - return false; - } }); if (savedInstanceState != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java index 9602da8b..e2d10e55 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImageOrGifActivity.java @@ -266,12 +266,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa final SubsamplingScaleImageView view = mImageView.getSSIV(); if (view != null) { - view.setOnImageEventListener(new SubsamplingScaleImageView.OnImageEventListener() { - @Override - public void onReady() { - - } - + view.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() { @Override public void onImageLoaded() { view.setMinimumDpi(80); @@ -280,26 +275,6 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa view.setQuickScaleEnabled(true); view.resetScaleAndCenter(); } - - @Override - public void onPreviewLoadError(Exception e) { - - } - - @Override - public void onImageLoadError(Exception e) { - - } - - @Override - public void onTileLoadError(Exception e) { - - } - - @Override - public void onPreviewReleased() { - - } }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index e7a673cc..4c3ee7e3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -1727,7 +1727,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter cues) { - - } - @Override public void onRenderedFirstFrame() { mGlide.clear(previewImageView); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 93a4ef30..6bc1ec30 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -2758,7 +2758,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter cues) { - - } - @Override public void onRenderedFirstFrame() { mGlide.clear(previewImageView); @@ -3987,7 +3977,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter cues) { - - } - @Override public void onRenderedFirstFrame() { mGlide.clear(previewImageView); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java index cee6d404..05f0ab7a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java @@ -153,12 +153,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { final SubsamplingScaleImageView view = imageView.getSSIV(); if (view != null) { - view.setOnImageEventListener(new SubsamplingScaleImageView.OnImageEventListener() { - @Override - public void onReady() { - - } - + view.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() { @Override public void onImageLoaded() { view.setMinimumDpi(80); @@ -167,26 +162,6 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { view.setQuickScaleEnabled(true); view.resetScaleAndCenter(); } - - @Override - public void onPreviewLoadError(Exception e) { - - } - - @Override - public void onImageLoadError(Exception e) { - - } - - @Override - public void onTileLoadError(Exception e) { - - } - - @Override - public void onPreviewReleased() { - - } }); } } -- cgit v1.2.3 From 14a09c725ffd5fc78acaa00831b28962995ea10b Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Fri, 24 Sep 2021 21:28:11 -0400 Subject: Use NotificationChannelCompat features --- .../services/DownloadMediaService.java | 20 +++++++---------- .../services/DownloadRedditVideoService.java | 20 +++++++---------- .../services/MaterialYouService.java | 25 +++++++++++----------- .../services/SubmitPostService.java | 21 ++++++++---------- .../infinityforreddit/utils/NotificationUtils.java | 22 +++++++++---------- 5 files changed, 48 insertions(+), 60 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java index e5534ef9..f0a551fe 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java @@ -1,8 +1,6 @@ package ml.docilealligator.infinityforreddit.services; import android.app.Notification; -import android.app.NotificationChannel; -import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.ContentResolver; @@ -22,6 +20,7 @@ import android.os.Message; import android.os.Process; import android.provider.MediaStore; +import androidx.core.app.NotificationChannelCompat; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import androidx.documentfile.provider.DocumentFile; @@ -367,16 +366,13 @@ public class DownloadMediaService extends Service { int mediaType = intent.getIntExtra(EXTRA_MEDIA_TYPE, EXTRA_MEDIA_TYPE_IMAGE); builder = new NotificationCompat.Builder(this, getNotificationChannelId(mediaType)); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationChannel serviceChannel; - serviceChannel = new NotificationChannel( - getNotificationChannelId(mediaType), - getNotificationChannel(mediaType), - NotificationManager.IMPORTANCE_LOW - ); - - notificationManager.createNotificationChannel(serviceChannel); - } + NotificationChannelCompat serviceChannel = + new NotificationChannelCompat.Builder( + getNotificationChannelId(mediaType), + NotificationManagerCompat.IMPORTANCE_LOW) + .setName(getNotificationChannel(mediaType)) + .build(); + notificationManager.createNotificationChannel(serviceChannel); int randomNotificationIdOffset = new Random().nextInt(10000); switch (intent.getIntExtra(EXTRA_MEDIA_TYPE, EXTRA_MEDIA_TYPE_IMAGE)) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java index a398871e..2079e024 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java @@ -1,8 +1,6 @@ package ml.docilealligator.infinityforreddit.services; import android.app.Notification; -import android.app.NotificationChannel; -import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.ContentResolver; @@ -26,6 +24,7 @@ import android.os.Message; import android.os.Process; import android.provider.MediaStore; +import androidx.core.app.NotificationChannelCompat; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import androidx.documentfile.provider.DocumentFile; @@ -501,16 +500,13 @@ public class DownloadRedditVideoService extends Service { String subredditName = intent.getStringExtra(EXTRA_SUBREDDIT); String fileNameWithoutExtension = subredditName + "-" + intent.getStringExtra(EXTRA_POST_ID); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationChannel serviceChannel; - serviceChannel = new NotificationChannel( - NotificationUtils.CHANNEL_ID_DOWNLOAD_REDDIT_VIDEO, - NotificationUtils.CHANNEL_DOWNLOAD_REDDIT_VIDEO, - NotificationManager.IMPORTANCE_LOW - ); - - notificationManager.createNotificationChannel(serviceChannel); - } + NotificationChannelCompat serviceChannel = + new NotificationChannelCompat.Builder( + NotificationUtils.CHANNEL_ID_DOWNLOAD_REDDIT_VIDEO, + NotificationManagerCompat.IMPORTANCE_LOW) + .setName(NotificationUtils.CHANNEL_DOWNLOAD_REDDIT_VIDEO) + .build(); + notificationManager.createNotificationChannel(serviceChannel); int randomNotificationIdOffset = new Random().nextInt(10000); startForeground( diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java index 66bd4e0b..40059987 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/MaterialYouService.java @@ -1,16 +1,14 @@ package ml.docilealligator.infinityforreddit.services; import android.app.Notification; -import android.app.NotificationChannel; -import android.app.NotificationManager; import android.app.Service; import android.content.Intent; import android.content.SharedPreferences; -import android.os.Build; import android.os.Handler; import android.os.IBinder; import androidx.annotation.Nullable; +import androidx.core.app.NotificationChannelCompat; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; @@ -60,16 +58,17 @@ public class MaterialYouService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { ((Infinity) getApplication()).getAppComponent().inject(this); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationChannel serviceChannel = new NotificationChannel( - NotificationUtils.CHANNEL_ID_MATERIAL_YOU, - NotificationUtils.CHANNEL_MATERIAL_YOU, - NotificationManager.IMPORTANCE_LOW - ); - - NotificationManagerCompat manager = NotificationManagerCompat.from(this); - manager.createNotificationChannel(serviceChannel); - } + + NotificationChannelCompat serviceChannel = + new NotificationChannelCompat.Builder( + NotificationUtils.CHANNEL_ID_MATERIAL_YOU, + NotificationManagerCompat.IMPORTANCE_LOW) + .setName(NotificationUtils.CHANNEL_MATERIAL_YOU) + .build(); + + NotificationManagerCompat manager = NotificationManagerCompat.from(this); + manager.createNotificationChannel(serviceChannel); + Notification notification = new NotificationCompat.Builder(this, NotificationUtils.CHANNEL_ID_MATERIAL_YOU) .setContentTitle(getString(R.string.material_you_notification_title)) .setContentText(getString(R.string.please_wait)) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java index e22bc541..f1ba75f3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java @@ -1,13 +1,10 @@ package ml.docilealligator.infinityforreddit.services; import android.app.Notification; -import android.app.NotificationChannel; -import android.app.NotificationManager; import android.app.Service; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; @@ -19,6 +16,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.app.NotificationChannelCompat; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; @@ -164,16 +162,15 @@ public class SubmitPostService extends Service { public int onStartCommand(Intent intent, int flags, int startId) { ((Infinity) getApplication()).getAppComponent().inject(this); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationChannel serviceChannel = new NotificationChannel( - NotificationUtils.CHANNEL_SUBMIT_POST, - NotificationUtils.CHANNEL_SUBMIT_POST, - NotificationManager.IMPORTANCE_LOW - ); + NotificationChannelCompat serviceChannel = + new NotificationChannelCompat.Builder( + NotificationUtils.CHANNEL_SUBMIT_POST, + NotificationManagerCompat.IMPORTANCE_LOW) + .setName(NotificationUtils.CHANNEL_SUBMIT_POST) + .build(); - NotificationManagerCompat manager = NotificationManagerCompat.from(this); - manager.createNotificationChannel(serviceChannel); - } + NotificationManagerCompat manager = NotificationManagerCompat.from(this); + manager.createNotificationChannel(serviceChannel); int randomNotificationIdOffset = new Random().nextInt(10000); int postType = intent.getIntExtra(EXTRA_POST_TYPE, EXTRA_POST_TEXT_OR_LINK); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/NotificationUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/NotificationUtils.java index 5552271f..459a0170 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/NotificationUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/NotificationUtils.java @@ -1,10 +1,8 @@ package ml.docilealligator.infinityforreddit.utils; -import android.app.NotificationChannel; -import android.app.NotificationManager; import android.content.Context; -import android.os.Build; +import androidx.core.app.NotificationChannelCompat; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; @@ -40,10 +38,11 @@ public class NotificationUtils { Context context, String title, String content, String summary, String channelId, String channelName, String group, int color) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT); - notificationManager.createNotificationChannel(channel); - } + NotificationChannelCompat channel = + new NotificationChannelCompat.Builder(channelId, NotificationManagerCompat.IMPORTANCE_DEFAULT) + .setName(channelName) + .build(); + notificationManager.createNotificationChannel(channel); return new NotificationCompat.Builder(context.getApplicationContext(), channelId) .setContentTitle(title) @@ -60,10 +59,11 @@ public class NotificationUtils { public static NotificationCompat.Builder buildSummaryNotification(Context context, NotificationManagerCompat notificationManager, String title, String content, String channelId, String channelName, String group, int color) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT); - notificationManager.createNotificationChannel(channel); - } + NotificationChannelCompat channel = + new NotificationChannelCompat.Builder(channelId, NotificationManagerCompat.IMPORTANCE_DEFAULT) + .setName(channelName) + .build(); + notificationManager.createNotificationChannel(channel); return new NotificationCompat.Builder(context, channelId) .setContentTitle(title) -- cgit v1.2.3 From a5ca6ac2bcc82c339706a84d4949c0f4b4e33540 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Fri, 24 Sep 2021 21:28:22 -0400 Subject: Use FragmentContainerView --- .../infinityforreddit/activities/SearchSubredditsResultActivity.java | 5 +++-- .../infinityforreddit/activities/SearchUsersResultActivity.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java index 3b6ead1a..ae115534 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java @@ -122,11 +122,12 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName); bundle.putBoolean(SubredditListingFragment.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)); mFragment.setArguments(bundle); - getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_search_subreddits_result_activity, mFragment).commit(); } else { mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); - getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_search_subreddits_result_activity, mFragment).commit(); } + getSupportFragmentManager().beginTransaction() + .replace(R.id.frame_layout_search_subreddits_result_activity, mFragment) + .commit(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java index 2fbfc150..58db6bc7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java @@ -119,11 +119,12 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT bundle.putString(UserListingFragment.EXTRA_ACCOUNT_NAME, mAccountName); bundle.putBoolean(UserListingFragment.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)); mFragment.setArguments(bundle); - getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_search_users_result_activity, mFragment).commit(); } else { mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE); - getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_search_users_result_activity, mFragment).commit(); } + getSupportFragmentManager().beginTransaction() + .replace(R.id.frame_layout_search_users_result_activity, mFragment) + .commit(); } @Override -- cgit v1.2.3 From d1740f77d1692f5c0772833f4683ad4aa464f8aa Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Fri, 24 Sep 2021 21:28:33 -0400 Subject: Fix some deprecations --- .../AcknowledgementRecyclerViewAdapter.java | 2 +- .../adapters/AwardRecyclerViewAdapter.java | 2 +- .../FlairBottomSheetRecyclerViewAdapter.java | 10 +++--- .../adapters/FollowedUsersRecyclerViewAdapter.java | 40 +++++++++++----------- .../adapters/MessageRecyclerViewAdapter.java | 4 +-- .../MultiRedditListingRecyclerViewAdapter.java | 20 +++++------ .../PostFilterUsageRecyclerViewAdapter.java | 2 +- .../PrivateMessagesDetailRecyclerViewAdapter.java | 4 +-- .../adapters/ReportReasonRecyclerViewAdapter.java | 10 +++--- .../adapters/RulesRecyclerViewAdapter.java | 6 ++-- .../SearchActivityRecyclerViewAdapter.java | 4 +-- .../SelectedSubredditsRecyclerViewAdapter.java | 6 ++-- .../adapters/UserFlairRecyclerViewAdapter.java | 6 ++-- .../infinityforreddit/utils/APIUtils.java | 2 +- .../infinityforreddit/utils/UploadImageUtils.java | 2 +- 15 files changed, 60 insertions(+), 60 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java index c6f7ee56..9d9b0843 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java @@ -35,7 +35,7 @@ public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter { - itemOnClickListener.onClick(awards.get(getAdapterPosition())); + itemOnClickListener.onClick(awards.get(getBindingAdapterPosition())); }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java index 4d738aa3..399726d0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java @@ -44,7 +44,7 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter { View dialogView = ((Activity) context).getLayoutInflater().inflate(R.layout.dialog_edit_flair, null); @@ -59,7 +59,7 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter { - Flair flair = flairs.get(holder.getAdapterPosition()); + Flair flair = flairs.get(holder.getBindingAdapterPosition()); flair.setText(flairEditText.getText().toString()); itemClickListener.onClick(flair); }) @@ -68,13 +68,13 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter holder.editFlairImageView.performClick()); } else { - holder.itemView.setOnClickListener(view -> itemClickListener.onClick(flairs.get(holder.getAdapterPosition()))); + holder.itemView.setOnClickListener(view -> itemClickListener.onClick(flairs.get(holder.getBindingAdapterPosition()))); } - holder.flairTextView.setText(flairs.get(holder.getAdapterPosition()).getText()); + holder.flairTextView.setText(flairs.get(holder.getBindingAdapterPosition()).getText()); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java index a077569e..89bae0c9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java @@ -106,8 +106,8 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter 0) ? mFavoriteSubscribedUserData.size() + 2 : 0; - if (!mSubscribedUserData.get(viewHolder.getAdapterPosition() - offset).getIconUrl().equals("")) { - glide.load(mSubscribedUserData.get(viewHolder.getAdapterPosition() - offset).getIconUrl()) + if (!mSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl().equals("")) { + glide.load(mSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) @@ -117,16 +117,16 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter { - int position = getAdapterPosition() - 1; + int position = getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteSubscribedUserData.size() > position) { Intent intent = new Intent(mContext, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mFavoriteSubscribedUserData.get(position).getName()); @@ -214,7 +214,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter { - int position = getAdapterPosition() - 1; + int position = getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteSubscribedUserData.size() > position) { if(mFavoriteSubscribedUserData.get(position).isFavorite()) { favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp); @@ -225,7 +225,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mFavoriteSubscribedUserData.size() > position) { mFavoriteSubscribedUserData.get(position).setFavorite(false); } @@ -235,7 +235,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mFavoriteSubscribedUserData.size() > position) { mFavoriteSubscribedUserData.get(position).setFavorite(true); } @@ -251,7 +251,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mFavoriteSubscribedUserData.size() > position) { mFavoriteSubscribedUserData.get(position).setFavorite(true); } @@ -261,7 +261,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mFavoriteSubscribedUserData.size() > position) { mFavoriteSubscribedUserData.get(position).setFavorite(false); } @@ -290,7 +290,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter { int offset = (mFavoriteSubscribedUserData != null && mFavoriteSubscribedUserData.size() > 0) ? mFavoriteSubscribedUserData.size() + 2 : 0; - int position = getAdapterPosition() - offset; + int position = getBindingAdapterPosition() - offset; if(position >= 0 && mSubscribedUserData.size() > position) { Intent intent = new Intent(mContext, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mSubscribedUserData.get(position).getName()); @@ -301,7 +301,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter { int offset = (mFavoriteSubscribedUserData != null && mFavoriteSubscribedUserData.size() > 0) ? mFavoriteSubscribedUserData.size() + 2 : 0; - int position = getAdapterPosition() - offset; + int position = getBindingAdapterPosition() - offset; if(position >= 0 && mSubscribedUserData.size() > position) { if(mSubscribedUserData.get(position).isFavorite()) { @@ -313,7 +313,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mSubscribedUserData.size() > position) { mSubscribedUserData.get(position).setFavorite(false); } @@ -323,7 +323,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mSubscribedUserData.size() > position) { mSubscribedUserData.get(position).setFavorite(true); } @@ -339,7 +339,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mSubscribedUserData.size() > position) { mSubscribedUserData.get(position).setFavorite(true); } @@ -349,7 +349,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mSubscribedUserData.size() > position) { mSubscribedUserData.get(position).setFavorite(false); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java index 2c283669..3925d59c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java @@ -201,7 +201,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter replies = message.getReplies(); Message displayedMessage; @@ -240,7 +240,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter 0) ? mFavoriteMultiReddits.size() + 2 : 0; - MultiReddit multiReddit = mMultiReddits.get(holder.getAdapterPosition() - offset); + MultiReddit multiReddit = mMultiReddits.get(holder.getBindingAdapterPosition() - offset); name = multiReddit.getDisplayName(); iconUrl = multiReddit.getIconUrl(); if(multiReddit.isFavorite()) { @@ -134,7 +134,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { - int position = holder.getAdapterPosition() - offset; + int position = holder.getBindingAdapterPosition() - offset; if(position >= 0 && mMultiReddits.size() > position) { mMultiReddits.get(position).setFavorite(false); } @@ -144,7 +144,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< @Override public void failed() { Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show(); - int position = holder.getAdapterPosition() - offset; + int position = holder.getBindingAdapterPosition() - offset; if(position >= 0 && mMultiReddits.size() > position) { mMultiReddits.get(position).setFavorite(true); } @@ -160,7 +160,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { - int position = holder.getAdapterPosition() - offset; + int position = holder.getBindingAdapterPosition() - offset; if(position >= 0 && mMultiReddits.size() > position) { mMultiReddits.get(position).setFavorite(true); } @@ -170,7 +170,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< @Override public void failed() { Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show(); - int position = holder.getAdapterPosition() - offset; + int position = holder.getBindingAdapterPosition() - offset; if(position >= 0 && mMultiReddits.size() > position) { mMultiReddits.get(position).setFavorite(false); } @@ -202,7 +202,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< } ((MultiRedditViewHolder) holder).multiRedditNameTextView.setText(name); } else if (holder instanceof FavoriteMultiRedditViewHolder) { - MultiReddit multiReddit = mFavoriteMultiReddits.get(holder.getAdapterPosition() - 1); + MultiReddit multiReddit = mFavoriteMultiReddits.get(holder.getBindingAdapterPosition() - 1); String name = multiReddit.getDisplayName(); String iconUrl = multiReddit.getIconUrl(); if(multiReddit.isFavorite()) { @@ -220,7 +220,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { - int position = holder.getAdapterPosition() - 1; + int position = holder.getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteMultiReddits.size() > position) { mFavoriteMultiReddits.get(position).setFavorite(false); } @@ -230,7 +230,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< @Override public void failed() { Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show(); - int position = holder.getAdapterPosition() - 1; + int position = holder.getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteMultiReddits.size() > position) { mFavoriteMultiReddits.get(position).setFavorite(true); } @@ -246,7 +246,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { - int position = holder.getAdapterPosition() - 1; + int position = holder.getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteMultiReddits.size() > position) { mFavoriteMultiReddits.get(position).setFavorite(true); } @@ -256,7 +256,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< @Override public void failed() { Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show(); - int position = holder.getAdapterPosition() - 1; + int position = holder.getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteMultiReddits.size() > position) { mFavoriteMultiReddits.get(position).setFavorite(false); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostFilterUsageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostFilterUsageRecyclerViewAdapter.java index d6d4c938..e8c92df3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostFilterUsageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostFilterUsageRecyclerViewAdapter.java @@ -86,7 +86,7 @@ public class PostFilterUsageRecyclerViewAdapter extends RecyclerView.Adapter { - onItemClickListener.onClick(postFilterUsages.get(getAdapterPosition())); + onItemClickListener.onClick(postFilterUsages.get(getBindingAdapterPosition())); }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java index 190b8ad5..8fe78d79 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java @@ -117,10 +117,10 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { Message message; - if (holder.getAdapterPosition() == 0) { + if (holder.getBindingAdapterPosition() == 0) { message = mMessage; } else { - message = mMessage.getReplies().get(holder.getAdapterPosition() - 1); + message = mMessage.getReplies().get(holder.getBindingAdapterPosition() - 1); } if (message != null) { if (holder instanceof MessageViewHolder) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java index 5e5572ff..80e57a5a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java @@ -42,9 +42,9 @@ public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter= generalReasons.size()) { - reportReason = rules.get(holder.getAdapterPosition() - generalReasons.size()); + reportReason = rules.get(holder.getBindingAdapterPosition() - generalReasons.size()); } else { - reportReason = generalReasons.get(holder.getAdapterPosition()); + reportReason = generalReasons.get(holder.getBindingAdapterPosition()); } ((ReasonViewHolder) holder).reasonTextView.setText(reportReason.getReportReason()); ((ReasonViewHolder) holder).checkBox.setChecked(reportReason.isSelected()); @@ -119,10 +119,10 @@ public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter= generalReasons.size()) { - rules.get(getAdapterPosition() - generalReasons.size()).setSelected(checkBox.isChecked()); + if (getBindingAdapterPosition() >= generalReasons.size()) { + rules.get(getBindingAdapterPosition() - generalReasons.size()).setSelected(checkBox.isChecked()); } else { - generalReasons.get(getAdapterPosition()).setSelected(checkBox.isChecked()); + generalReasons.get(getBindingAdapterPosition()).setSelected(checkBox.isChecked()); } }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java index 51d55400..454ecdd4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java @@ -82,11 +82,11 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter { if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) { - itemOnClickListener.onClick(recentSearchQueries.get(getAdapterPosition()).getSearchQuery()); + itemOnClickListener.onClick(recentSearchQueries.get(getBindingAdapterPosition()).getSearchQuery()); } }); deleteImageView.setOnClickListener(view -> { - itemOnClickListener.onDelete(recentSearchQueries.get(getAdapterPosition())); + itemOnClickListener.onDelete(recentSearchQueries.get(getBindingAdapterPosition())); }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SelectedSubredditsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SelectedSubredditsRecyclerViewAdapter.java index e6bbe441..ad57d3ba 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SelectedSubredditsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SelectedSubredditsRecyclerViewAdapter.java @@ -39,10 +39,10 @@ public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter< @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if (holder instanceof SubredditViewHolder) { - ((SubredditViewHolder) holder).subredditNameTextView.setText(subreddits.get(holder.getAdapterPosition())); + ((SubredditViewHolder) holder).subredditNameTextView.setText(subreddits.get(holder.getBindingAdapterPosition())); ((SubredditViewHolder) holder).deleteButton.setOnClickListener(view -> { - subreddits.remove(holder.getAdapterPosition()); - notifyItemRemoved(holder.getAdapterPosition()); + subreddits.remove(holder.getBindingAdapterPosition()); + notifyItemRemoved(holder.getBindingAdapterPosition()); }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserFlairRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserFlairRecyclerViewAdapter.java index 1f05380b..d260bb0d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserFlairRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserFlairRecyclerViewAdapter.java @@ -43,7 +43,7 @@ public class UserFlairRecyclerViewAdapter extends RecyclerView.Adapter { - itemClickListener.onClick(userFlairs.get(getAdapterPosition()), false); + itemClickListener.onClick(userFlairs.get(getBindingAdapterPosition()), false); }); editUserFlairImageView.setOnClickListener(view -> { - itemClickListener.onClick(userFlairs.get(getAdapterPosition()), true); + itemClickListener.onClick(userFlairs.get(getBindingAdapterPosition()), true); }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java index 465a31eb..5078692d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java @@ -120,6 +120,6 @@ public class APIUtils { } public static RequestBody getRequestBody(String s) { - return RequestBody.create(MediaType.parse("text/plain"), s); + return RequestBody.create(s, MediaType.parse("text/plain")); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/UploadImageUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/UploadImageUtils.java index c7b5f728..e0bf7c25 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/UploadImageUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/UploadImageUtils.java @@ -50,7 +50,7 @@ public class UploadImageUtils { image.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] byteArray = stream.toByteArray(); - RequestBody fileBody = RequestBody.create(MediaType.parse("application/octet-stream"), byteArray); + RequestBody fileBody = RequestBody.create(byteArray, MediaType.parse("application/octet-stream")); MultipartBody.Part fileToUpload = MultipartBody.Part.createFormData("file", "post_image.jpg", fileBody); RedditAPI uploadMediaToAWSApi = uploadMediaRetrofit.create(RedditAPI.class); -- cgit v1.2.3