diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-04-06 14:48:36 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-04-06 14:48:36 +0000 |
commit | 98a66a8bb780e083dd82a34bdff240ce132a755c (patch) | |
tree | a99e2f14bba99f4a2610614af5161edf00f45035 /app/src/main | |
parent | 68d8aaf61d8d3f3357fdadb16a44f04acbf5ae86 (diff) | |
download | infinity-for-reddit-98a66a8bb780e083dd82a34bdff240ce132a755c.tar infinity-for-reddit-98a66a8bb780e083dd82a34bdff240ce132a755c.tar.gz infinity-for-reddit-98a66a8bb780e083dd82a34bdff240ce132a755c.tar.bz2 infinity-for-reddit-98a66a8bb780e083dd82a34bdff240ce132a755c.tar.lz infinity-for-reddit-98a66a8bb780e083dd82a34bdff240ce132a755c.tar.xz infinity-for-reddit-98a66a8bb780e083dd82a34bdff240ce132a755c.tar.zst infinity-for-reddit-98a66a8bb780e083dd82a34bdff240ce132a755c.zip |
Fix post filter usage not retain after saving the post filter again.
Diffstat (limited to '')
4 files changed, 12 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java index 96aafb97..30118395 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -133,6 +133,7 @@ public class ParsePost { } if (data.has(JSONUtils.CROSSPOST_PARENT_LIST)) { //Cross post + //data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0) out of bounds???????????? data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0); Post crosspostParent = parseBasicData(data); Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed, @@ -227,7 +228,7 @@ public class ParsePost { JSONArray thumbnailPreviews = images.getJSONArray(JSONUtils.RESOLUTIONS_KEY); for (int i = 0; i < thumbnailPreviews.length(); i++) { - JSONObject thumbnailPreview = images.getJSONArray(JSONUtils.RESOLUTIONS_KEY).getJSONObject(2); + JSONObject thumbnailPreview = images.getJSONArray(JSONUtils.RESOLUTIONS_KEY).getJSONObject(i); String thumbnailPreviewUrl = thumbnailPreview.getString(JSONUtils.URL_KEY); int thumbnailPreviewWidth = thumbnailPreview.getInt(JSONUtils.WIDTH_KEY); int thumbnailPreviewHeight = thumbnailPreview.getInt(JSONUtils.HEIGHT_KEY); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterUsageDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterUsageDao.java index a0ba8843..c94a67f7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterUsageDao.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterUsageDao.java @@ -14,6 +14,9 @@ public interface PostFilterUsageDao { @Query("SELECT * FROM post_filter_usage WHERE name = :name") LiveData<List<PostFilterUsage>> getAllPostFilterUsageLiveData(String name); + @Query("SELECT * FROM post_filter_usage WHERE name = :name") + List<PostFilterUsage> getAllPostFilterUsage(String name); + @Insert(onConflict = OnConflictStrategy.REPLACE) void insertPostFilterUsage(PostFilterUsage postFilterUsage); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java index c7f10885..2f14ba6f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/SavePostFilter.java @@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.postfilter; import android.os.Handler; +import java.util.List; import java.util.concurrent.Executor; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; @@ -19,10 +20,15 @@ public class SavePostFilter { redditDataRoomDatabase.postFilterDao().getPostFilter(postFilter.name) != null) { handler.post(savePostFilterListener::duplicate); } else { + List<PostFilterUsage> postFilterUsages = redditDataRoomDatabase.postFilterUsageDao().getAllPostFilterUsage(originalName); if (!originalName.equals(postFilter.name)) { redditDataRoomDatabase.postFilterDao().deletePostFilter(originalName); } redditDataRoomDatabase.postFilterDao().insert(postFilter); + for (PostFilterUsage postFilterUsage : postFilterUsages) { + postFilterUsage.name = postFilter.name; + redditDataRoomDatabase.postFilterUsageDao().insertPostFilterUsage(postFilterUsage); + } handler.post(savePostFilterListener::success); } }); diff --git a/app/src/main/res/drawable-night/ic_home_black_24dp.xml b/app/src/main/res/drawable-night/ic_home_black_24dp.xml index a35f1eff..c112c91b 100644 --- a/app/src/main/res/drawable-night/ic_home_black_24dp.xml +++ b/app/src/main/res/drawable-night/ic_home_black_24dp.xml @@ -5,5 +5,5 @@ android:viewportHeight="24"> <path android:pathData="M12,5.69l5,4.5V18h-2v-6H9v6H7v-7.81l5,-4.5M12,3L2,12h3v8h6v-6h2v6h6v-8h3L12,3z" - android:fillColor="#000000"/> + android:fillColor="#FFFFFF"/> </vector> |