diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-06-12 14:05:12 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-06-12 14:05:12 +0000 |
commit | ee048b25dd0d2a412271a17e954619702dcfae53 (patch) | |
tree | eb377dd5ccfc18ee857a05f6d10cff77cac49520 /app | |
parent | 6921d720d21eb2862d377cc0cd80f41e4150d6a9 (diff) | |
download | infinity-for-reddit-ee048b25dd0d2a412271a17e954619702dcfae53.tar infinity-for-reddit-ee048b25dd0d2a412271a17e954619702dcfae53.tar.gz infinity-for-reddit-ee048b25dd0d2a412271a17e954619702dcfae53.tar.bz2 infinity-for-reddit-ee048b25dd0d2a412271a17e954619702dcfae53.tar.lz infinity-for-reddit-ee048b25dd0d2a412271a17e954619702dcfae53.tar.xz infinity-for-reddit-ee048b25dd0d2a412271a17e954619702dcfae53.tar.zst infinity-for-reddit-ee048b25dd0d2a412271a17e954619702dcfae53.zip |
Fix bugs related to favoriting multireddits. Add some fonts.
Diffstat (limited to 'app')
21 files changed, 108 insertions, 18 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java index 4be79e91..51939d7f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java @@ -125,7 +125,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp); multiReddit.setFavorite(false); FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, - mAccessToken, mAccountName, false, multiReddit, + mAccessToken, false, multiReddit, new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { @@ -151,7 +151,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< ((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp); multiReddit.setFavorite(true); FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, - mAccessToken, mAccountName, true, multiReddit, + mAccessToken, true, multiReddit, new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { @@ -213,7 +213,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp); multiReddit.setFavorite(false); FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, - mAccessToken, mAccountName, false, multiReddit, + mAccessToken, false, multiReddit, new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { @@ -239,7 +239,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< ((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp); multiReddit.setFavorite(true); FavoriteMultiReddit.favoriteMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, - mAccessToken, mAccountName, true, multiReddit, + mAccessToken, true, multiReddit, new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java index 2c15fa33..2c49eccb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertMultiRedditAsyncTask.java @@ -1,7 +1,6 @@ package ml.docilealligator.infinityforreddit.AsyncTask; import android.os.AsyncTask; -import android.util.Log; import java.util.ArrayList; import java.util.Collections; @@ -14,6 +13,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; public class InsertMultiRedditAsyncTask extends AsyncTask<Void, Void, Void> { private MultiRedditDao multiRedditDao; private ArrayList<MultiReddit> multiReddits; + private MultiReddit multiReddit; private String accountName; private InsertMultiRedditAsyncTaskListener insertMultiRedditAsyncTaskListener; @@ -26,15 +26,27 @@ public class InsertMultiRedditAsyncTask extends AsyncTask<Void, Void, Void> { this.insertMultiRedditAsyncTaskListener = insertMultiRedditAsyncTaskListener; } + public InsertMultiRedditAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, + MultiReddit multiReddit, + InsertMultiRedditAsyncTaskListener insertMultiRedditAsyncTaskListener) { + multiRedditDao = redditDataRoomDatabase.multiRedditDao(); + this.multiReddit = multiReddit; + this.insertMultiRedditAsyncTaskListener = insertMultiRedditAsyncTaskListener; + } + @Override protected Void doInBackground(Void... voids) { + if (multiReddit != null) { + multiRedditDao.insert(multiReddit); + return null; + } + List<MultiReddit> existingMultiReddits = multiRedditDao.getAllMultiRedditsList(accountName); Collections.sort(multiReddits, (multiReddit, t1) -> multiReddit.getName().compareToIgnoreCase(t1.getName())); List<String> deletedMultiredditNames = new ArrayList<>(); compareTwoMultiRedditList(multiReddits, existingMultiReddits, deletedMultiredditNames); for (String deleted : deletedMultiredditNames) { - Log.i("asdfasdfs", "s " + deleted + accountName); multiRedditDao.deleteMultiReddit(deleted, accountName); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontFamily.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontFamily.java index 8b43545f..cad7a532 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontFamily.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/ContentFontFamily.java @@ -9,7 +9,9 @@ public enum ContentFontFamily { RobotoCondensed(R.style.ContentFontFamily_RobotoCondensed, "RobotoCondensed"), HarmoniaSans(R.style.ContentFontFamily_HarmoniaSans, "HarmoniaSans"), Selawk(R.style.ContentFontFamily_Selawk, "Selawk"), - Inter(R.style.ContentFontFamily_Inter, "Inter"); + Inter(R.style.ContentFontFamily_Inter, "Inter"), + Manrope(R.style.ContentFontFamily_Manrope, "Manrope"), + Rubik(R.style.ContentFontFamily_Rubik, "Rubik"); private int resId; private String title; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontFamily.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontFamily.java index 40540060..88e89660 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontFamily.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/FontFamily.java @@ -9,7 +9,9 @@ public enum FontFamily { RobotoCondensed(R.style.FontFamily_RobotoCondensed, "RobotoCondensed"), HarmoniaSans(R.style.FontFamily_HarmoniaSans, "HarmoniaSans"), Selawk(R.style.FontFamily_Selawk, "Selawk"), - Inter(R.style.FontFamily_Inter, "Inter"); + Inter(R.style.FontFamily_Inter, "Inter"), + Manrope(R.style.FontFamily_Manrope, "Manrope"), + Rubik(R.style.FontFamily_Rubik, "Rubik"); private int resId; private String title; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontFamily.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontFamily.java index 9e348bec..17ebf3bd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontFamily.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Font/TitleFontFamily.java @@ -9,7 +9,9 @@ public enum TitleFontFamily { RobotoCondensed(R.style.TitleFontFamily_RobotoCondensed, "RobotoCondensed"), HarmoniaSans(R.style.TitleFontFamily_HarmoniaSans, "HarmoniaSans"), Selawk(R.style.TitleFontFamily_Selawk, "Selawk"), - Inter(R.style.TitleFontFamily_Inter, "Inter"); + Inter(R.style.TitleFontFamily_Inter, "Inter"), + Manrope(R.style.TitleFontFamily_Manrope, "Manrope"), + Rubik(R.style.TitleFontFamily_Rubik, "Rubik"); private int resId; private String title; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/MultiRedditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/MultiRedditListingFragment.java index 89311f15..1a58e526 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/MultiRedditListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/MultiRedditListingFragment.java @@ -49,7 +49,6 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm public static final String EXTRA_ACCOUNT_NAME = "EAN"; public static final String EXTRA_ACCESS_TOKEN = "EAT"; - private static final String INSERT_MULTI_REDDIT_STATE = "ISSS"; @BindView(R.id.swipe_refresh_layout_multi_reddit_listing_fragment) SwipeRefreshLayout mSwipeRefreshLayout; @@ -78,7 +77,6 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm private AppCompatActivity mActivity; private RequestManager mGlide; private LinearLayoutManager mLinearLayoutManager; - private boolean mInsertSuccess = false; public MultiRedditListingFragment() { // Required empty public constructor diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/FavoriteMultiReddit.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/FavoriteMultiReddit.java index 54142d08..8c976245 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/FavoriteMultiReddit.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MultiReddit/FavoriteMultiReddit.java @@ -2,12 +2,11 @@ package ml.docilealligator.infinityforreddit.MultiReddit; import androidx.annotation.NonNull; -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import ml.docilealligator.infinityforreddit.AsyncTask.InsertMultiRedditAsyncTask; import ml.docilealligator.infinityforreddit.API.RedditAPI; +import ml.docilealligator.infinityforreddit.AsyncTask.InsertMultiRedditAsyncTask; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Utils.APIUtils; import retrofit2.Call; @@ -22,7 +21,7 @@ public class FavoriteMultiReddit { } public static void favoriteMultiReddit(Retrofit oauthRetrofit, RedditDataRoomDatabase redditDataRoomDatabase, - String accessToken, String accountName, boolean makeFavorite, + String accessToken, boolean makeFavorite, MultiReddit multiReddit, FavoriteMultiRedditListener favoriteMultiRedditListener) { Map<String, String> params = new HashMap<>(); params.put(APIUtils.MULTIPATH_KEY, multiReddit.getPath()); @@ -33,10 +32,8 @@ public class FavoriteMultiReddit { @Override public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { if (response.isSuccessful()) { - multiReddit.setFavorite(true); - ArrayList<MultiReddit> singleMultiRedditList = new ArrayList<>(); - singleMultiRedditList.add(multiReddit); - new InsertMultiRedditAsyncTask(redditDataRoomDatabase, singleMultiRedditList, accountName, + multiReddit.setFavorite(makeFavorite); + new InsertMultiRedditAsyncTask(redditDataRoomDatabase, multiReddit, favoriteMultiRedditListener::success).execute(); } else { favoriteMultiRedditListener.failed(); diff --git a/app/src/main/res/font/manrope.xml b/app/src/main/res/font/manrope.xml new file mode 100644 index 00000000..0193f184 --- /dev/null +++ b/app/src/main/res/font/manrope.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<font-family xmlns:app="http://schemas.android.com/apk/res-auto"> + <font + app:fontStyle="normal" + app:fontWeight="500" + app:font="@font/manrope_medium" /> + + <font + app:fontStyle="normal" + app:fontWeight="700" + app:font="@font/manrope_bold" /> + + <font + app:fontStyle="normal" + app:fontWeight="300" + app:font="@font/manrope_light" /> +</font-family>
\ No newline at end of file diff --git a/app/src/main/res/font/manrope_bold.ttf b/app/src/main/res/font/manrope_bold.ttf Binary files differnew file mode 100644 index 00000000..0b2be328 --- /dev/null +++ b/app/src/main/res/font/manrope_bold.ttf diff --git a/app/src/main/res/font/manrope_light.ttf b/app/src/main/res/font/manrope_light.ttf Binary files differnew file mode 100644 index 00000000..5a771c80 --- /dev/null +++ b/app/src/main/res/font/manrope_light.ttf diff --git a/app/src/main/res/font/manrope_medium.ttf b/app/src/main/res/font/manrope_medium.ttf Binary files differnew file mode 100644 index 00000000..e704d983 --- /dev/null +++ b/app/src/main/res/font/manrope_medium.ttf diff --git a/app/src/main/res/font/manrope_regular.ttf b/app/src/main/res/font/manrope_regular.ttf Binary files differnew file mode 100644 index 00000000..8f414180 --- /dev/null +++ b/app/src/main/res/font/manrope_regular.ttf diff --git a/app/src/main/res/font/rubik.xml b/app/src/main/res/font/rubik.xml new file mode 100644 index 00000000..50596309 --- /dev/null +++ b/app/src/main/res/font/rubik.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<font-family xmlns:app="http://schemas.android.com/apk/res-auto"> + <font + app:fontStyle="normal" + app:fontWeight="400" + app:font="@font/rubik_regular" /> + + <font + app:fontStyle="normal" + app:fontWeight="700" + app:font="@font/rubik_bold" /> + + <font + app:fontStyle="normal" + app:fontWeight="300" + app:font="@font/rubik_light" /> + + <font + app:fontStyle="italic" + app:fontWeight="300" + app:font="@font/rubik_light_italic" /> + + <font + app:fontStyle="italic" + app:fontWeight="400" + app:font="@font/rubik_italic" /> + + <font + app:fontStyle="italic" + app:fontWeight="700" + app:font="@font/rubik_bold_italic" /> +</font-family>
\ No newline at end of file diff --git a/app/src/main/res/font/rubik_bold.ttf b/app/src/main/res/font/rubik_bold.ttf Binary files differnew file mode 100644 index 00000000..4e77930f --- /dev/null +++ b/app/src/main/res/font/rubik_bold.ttf diff --git a/app/src/main/res/font/rubik_bold_italic.ttf b/app/src/main/res/font/rubik_bold_italic.ttf Binary files differnew file mode 100644 index 00000000..f6322472 --- /dev/null +++ b/app/src/main/res/font/rubik_bold_italic.ttf diff --git a/app/src/main/res/font/rubik_italic.ttf b/app/src/main/res/font/rubik_italic.ttf Binary files differnew file mode 100644 index 00000000..2ddac98e --- /dev/null +++ b/app/src/main/res/font/rubik_italic.ttf diff --git a/app/src/main/res/font/rubik_light.ttf b/app/src/main/res/font/rubik_light.ttf Binary files differnew file mode 100644 index 00000000..8189d848 --- /dev/null +++ b/app/src/main/res/font/rubik_light.ttf diff --git a/app/src/main/res/font/rubik_light_italic.ttf b/app/src/main/res/font/rubik_light_italic.ttf Binary files differnew file mode 100644 index 00000000..8a9ae95a --- /dev/null +++ b/app/src/main/res/font/rubik_light_italic.ttf diff --git a/app/src/main/res/font/rubik_regular.ttf b/app/src/main/res/font/rubik_regular.ttf Binary files differnew file mode 100644 index 00000000..52b59ca4 --- /dev/null +++ b/app/src/main/res/font/rubik_regular.ttf diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 5040291b..e5bcf611 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -131,6 +131,8 @@ <item>Harmonia Sans</item> <item>Selawk</item> <item>Inter</item> + <item>Manrope</item> + <item>Rubik</item> </string-array> <string-array name="settings_font_family_values"> @@ -141,6 +143,8 @@ <item>HarmoniaSans</item> <item>Selawk</item> <item>Inter</item> + <item>Manrope</item> + <item>Rubik</item> </string-array> <string-array name="settings_tab_post_type"> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 214e9a66..6e46c6cf 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -262,6 +262,14 @@ <item name="font_family">@font/inter</item> </style> + <style name="FontFamily.Manrope"> + <item name="font_family">@font/manrope</item> + </style> + + <style name="FontFamily.Rubik"> + <item name="font_family">@font/rubik</item> + </style> + <style name="TitleFontFamily" /> <style name="TitleFontFamily.Default"> @@ -292,6 +300,14 @@ <item name="title_font_family">@font/inter</item> </style> + <style name="TitleFontFamily.Manrope"> + <item name="title_font_family">@font/manrope</item> + </style> + + <style name="TitleFontFamily.Rubik"> + <item name="title_font_family">@font/rubik</item> + </style> + <style name="ContentFontFamily" /> <style name="ContentFontFamily.Default"> @@ -322,6 +338,14 @@ <item name="content_font_family">@font/inter</item> </style> + <style name="ContentFontFamily.Manrope"> + <item name="content_font_family">@font/manrope</item> + </style> + + <style name="ContentFontFamily.Rubik"> + <item name="content_font_family">@font/rubik</item> + </style> + <style name="Theme" /> <style name="Theme.Normal"> |