aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-06-23 03:36:17 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-06-23 03:36:17 +0000
commit421315f0c6c8452ce85b57b1335e489cb3a518ee (patch)
tree2a4f867d96bcb57fa3ca3d58267351da774a16d0
parent405cac91e81d3cc2219a7c9e7163ff079e6d0e7a (diff)
downloadinfinity-for-reddit-421315f0c6c8452ce85b57b1335e489cb3a518ee.tar
infinity-for-reddit-421315f0c6c8452ce85b57b1335e489cb3a518ee.tar.gz
infinity-for-reddit-421315f0c6c8452ce85b57b1335e489cb3a518ee.tar.bz2
infinity-for-reddit-421315f0c6c8452ce85b57b1335e489cb3a518ee.tar.lz
infinity-for-reddit-421315f0c6c8452ce85b57b1335e489cb3a518ee.tar.xz
infinity-for-reddit-421315f0c6c8452ce85b57b1335e489cb3a518ee.tar.zst
infinity-for-reddit-421315f0c6c8452ce85b57b1335e489cb3a518ee.zip
Fix flair cannot be applied when submitting posts. Fix crash in FollowedUsersRecyclerViewAdapter.
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post/SubmitPost.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java1
-rw-r--r--app/src/main/res/layout/fragment_sidebar.xml2
7 files changed, 16 insertions, 12 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java
index effbd8fb..c041f64e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java
@@ -547,7 +547,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
} else {
mMemu.findItem(R.id.action_send_post_link_activity).setEnabled(true);
mMemu.findItem(R.id.action_send_post_link_activity).getIcon().setAlpha(255);
- if (submitTextOrLinkPostEvent.errorMessage == null) {
+ if (submitTextOrLinkPostEvent.errorMessage == null || submitTextOrLinkPostEvent.errorMessage.equals("")) {
Snackbar.make(coordinatorLayout, R.string.post_failed, Snackbar.LENGTH_SHORT).show();
} else {
Snackbar.make(coordinatorLayout, submitTextOrLinkPostEvent.errorMessage.substring(0, 1).toUpperCase()
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java
index a713b24f..a3e3accc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java
@@ -547,7 +547,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
} else {
mMemu.findItem(R.id.action_send_post_text_activity).setEnabled(true);
mMemu.findItem(R.id.action_send_post_text_activity).getIcon().setAlpha(255);
- if (submitTextOrLinkPostEvent.errorMessage == null) {
+ if (submitTextOrLinkPostEvent.errorMessage == null || submitTextOrLinkPostEvent.errorMessage.equals("")) {
Snackbar.make(coordinatorLayout, R.string.post_failed, Snackbar.LENGTH_SHORT).show();
} else {
Snackbar.make(coordinatorLayout, submitTextOrLinkPostEvent.errorMessage.substring(0, 1).toUpperCase()
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java
index a60cf1e1..5e2cf2da 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java
@@ -294,7 +294,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
@Override
public String getPopupText(int position) {
switch (getItemViewType(position)) {
- case VIEW_TYPE_USER_DIVIDER:
+ case VIEW_TYPE_USER:
int offset = (mFavoriteSubscribedUserData != null && mFavoriteSubscribedUserData.size() > 0) ?
mFavoriteSubscribedUserData.size() + 2 : 0;
return mSubscribedUserData.get(position - offset).getName().substring(0, 1).toUpperCase();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/SubmitPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/SubmitPost.java
index 9e27bce1..7b4762a6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/SubmitPost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/SubmitPost.java
@@ -21,6 +21,7 @@ import java.util.Locale;
import java.util.Map;
import ml.docilealligator.infinityforreddit.API.RedditAPI;
+import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
import okhttp3.MediaType;
@@ -34,7 +35,7 @@ import retrofit2.Retrofit;
public class SubmitPost {
public static void submitTextOrLinkPost(Retrofit oauthRetrofit, String accessToken,
Locale locale, String subredditName, String title, String content,
- String flair, boolean isSpoiler, boolean isNSFW, String kind,
+ Flair flair, boolean isSpoiler, boolean isNSFW, String kind,
SubmitPostListener submitPostListener) {
submitPost(oauthRetrofit, accessToken, locale, subredditName, title, content,
flair, isSpoiler, isNSFW, kind, null, submitPostListener);
@@ -42,7 +43,7 @@ public class SubmitPost {
public static void submitImagePost(Retrofit oauthRetrofit, Retrofit uploadMediaRetrofit,
String accessToken, Locale locale,
- String subredditName, String title, Bitmap image, String flair,
+ String subredditName, String title, Bitmap image, Flair flair,
boolean isSpoiler, boolean isNSFW, SubmitPostListener submitPostListener) {
uploadImage(oauthRetrofit, uploadMediaRetrofit, accessToken, image,
new UploadImageListener() {
@@ -63,7 +64,7 @@ public class SubmitPost {
public static void submitVideoPost(Retrofit oauthRetrofit, Retrofit uploadMediaRetrofit,
Retrofit uploadVideoRetrofit, String accessToken,
Locale locale, String subredditName, String title, byte[] buffer, String mimeType,
- Bitmap posterBitmap, String flair, boolean isSpoiler, boolean isNSFW,
+ Bitmap posterBitmap, Flair flair, boolean isSpoiler, boolean isNSFW,
SubmitPostListener submitPostListener) {
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
@@ -157,7 +158,7 @@ public class SubmitPost {
private static void submitPost(Retrofit oauthRetrofit, String accessToken,
Locale locale, String subredditName, String title, String content,
- String flair, boolean isSpoiler, boolean isNSFW, String kind,
+ Flair flair, boolean isSpoiler, boolean isNSFW, String kind,
@Nullable String posterUrl, SubmitPostListener submitPostListener) {
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
@@ -186,7 +187,8 @@ public class SubmitPost {
}
if (flair != null) {
- params.put(APIUtils.FLAIR_TEXT_KEY, flair);
+ params.put(APIUtils.FLAIR_TEXT_KEY, flair.getText());
+ params.put(APIUtils.FLAIR_ID_KEY, flair.getId());
}
params.put(APIUtils.SPOILER_KEY, Boolean.toString(isSpoiler));
params.put(APIUtils.NSFW_KEY, Boolean.toString(isNSFW));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java
index 5177e415..eb8ffd3c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java
@@ -34,11 +34,12 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SubmitImagePostEvent;
import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent;
import ml.docilealligator.infinityforreddit.Event.SubmitVideoPostEvent;
+import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.NotificationUtils;
import ml.docilealligator.infinityforreddit.Post.Post;
-import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Post.SubmitPost;
+import ml.docilealligator.infinityforreddit.R;
import retrofit2.Retrofit;
public class SubmitPostService extends Service {
@@ -68,7 +69,7 @@ public class SubmitPostService extends Service {
private String mAccessToken;
private String subredditName;
private String title;
- private String flair;
+ private Flair flair;
private boolean isSpoiler;
private boolean isNSFW;
private String content;
@@ -90,7 +91,7 @@ public class SubmitPostService extends Service {
mAccessToken = intent.getStringExtra(EXTRA_ACCESS_TOKEN);
subredditName = intent.getStringExtra(EXTRA_SUBREDDIT_NAME);
title = intent.getStringExtra(EXTRA_TITLE);
- flair = intent.getStringExtra(EXTRA_FLAIR);
+ flair = intent.getParcelableExtra(EXTRA_FLAIR);
isSpoiler = intent.getBooleanExtra(EXTRA_IS_SPOILER, false);
isNSFW = intent.getBooleanExtra(EXTRA_IS_NSFW, false);
int postType = intent.getIntExtra(EXTRA_POST_TYPE, EXTRA_POST_TEXT_OR_LINK);
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 029b4197..89b85bbe 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java
@@ -83,6 +83,7 @@ public class APIUtils {
public static final String LINK_KEY = "link";
public static final String FLAIR_TEMPLATE_ID_KEY = "flair_template_id";
+ public static final String FLAIR_ID_KEY = "flair_id";
public static final String MAKE_FAVORITE_KEY = "make_favorite";
diff --git a/app/src/main/res/layout/fragment_sidebar.xml b/app/src/main/res/layout/fragment_sidebar.xml
index 118bbd0e..1dc53a1b 100644
--- a/app/src/main/res/layout/fragment_sidebar.xml
+++ b/app/src/main/res/layout/fragment_sidebar.xml
@@ -16,7 +16,7 @@
android:id="@+id/markdown_recycler_view_sidebar_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:padding="16dp"
+ android:padding="8dp"
android:clipToPadding="false" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>