From 3a621e290190e67f777e4f442398a4db120aa7af Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sat, 18 Jul 2020 12:45:40 +0800 Subject: Fix subreddits not showing in SelectedSubredditsActivity when editing a multireddit by clicking Editing Multireddit in MultiRedditOptionsBottomSheetFragment. Support gfycat.com/ifr/. --- .../infinityforreddit/Activity/EditMultiRedditActivity.java | 2 -- .../infinityforreddit/Activity/LinkResolverActivity.java | 4 ++-- .../MultiRedditOptionsBottomSheetFragment.java | 8 +++++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditMultiRedditActivity.java index 4d3943d7..60945420 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditMultiRedditActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditMultiRedditActivity.java @@ -42,7 +42,6 @@ import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import retrofit2.Retrofit; public class EditMultiRedditActivity extends BaseActivity { - public static final String EXTRA_MULTI_REDDIT = "EMR"; public static final String EXTRA_MULTI_PATH = "EMP"; private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 1; private static final String NULL_ACCESS_TOKEN_STATE = "NATS"; @@ -126,7 +125,6 @@ public class EditMultiRedditActivity extends BaseActivity { bindView(); } } else { - multiReddit = getIntent().getParcelableExtra(EXTRA_MULTI_REDDIT); multipath = getIntent().getStringExtra(EXTRA_MULTI_PATH); getCurrentAccountAndBindView(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java index 95e98f40..15a072d8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java @@ -39,7 +39,7 @@ public class LinkResolverActivity extends AppCompatActivity { private static final String MULTIREDDIT_PATTERN = "/user/\\w+/m/\\w+/?"; private static final String MULTIREDDIT_PATTERN_2 = "/[rR]/(\\w+\\+?)+/?"; private static final String REDD_IT_POST_PATTERN = "/\\w+/?"; - private static final String GFYCAT_PATTERN = "/[\\w-]+$"; + private static final String GFYCAT_PATTERN = "(/ifr)?/[\\w-]+$"; private static final String REDGIFS_PATTERN = "/watch/[\\w-]+$"; private static final String IMGUR_GALLERY_PATTERN = "/gallery/\\w+/?"; private static final String IMGUR_ALBUM_PATTERN = "/(album|a)/\\w+/?"; @@ -185,7 +185,7 @@ public class LinkResolverActivity extends AppCompatActivity { } else if (authority.contains("gfycat.com")) { if (path.matches(GFYCAT_PATTERN)) { Intent intent = new Intent(this, ViewVideoActivity.class); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, path.substring(1)); + intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, path.substring(path.lastIndexOf("/") + 1)); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false)); startActivity(intent); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/MultiRedditOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/MultiRedditOptionsBottomSheetFragment.java index 27a9ccdc..8c7d49cd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/MultiRedditOptionsBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/MultiRedditOptionsBottomSheetFragment.java @@ -48,9 +48,11 @@ public class MultiRedditOptionsBottomSheetFragment extends RoundedBottomSheetDia MultiReddit multiReddit = getArguments().getParcelable(EXTRA_MULTI_REDDIT); editMultiRedditTextView.setOnClickListener(view -> { - Intent editIntent = new Intent(subscribedThingListingActivity, EditMultiRedditActivity.class); - editIntent.putExtra(EditMultiRedditActivity.EXTRA_MULTI_REDDIT, multiReddit); - startActivity(editIntent); + if (multiReddit != null) { + Intent editIntent = new Intent(subscribedThingListingActivity, EditMultiRedditActivity.class); + editIntent.putExtra(EditMultiRedditActivity.EXTRA_MULTI_PATH, multiReddit.getPath()); + startActivity(editIntent); + } dismiss(); }); -- cgit v1.2.3