From ee048b25dd0d2a412271a17e954619702dcfae53 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 12 Jun 2020 22:05:12 +0800 Subject: Fix bugs related to favoriting multireddits. Add some fonts. --- .../MultiRedditListingRecyclerViewAdapter.java | 8 +++--- .../AsyncTask/InsertMultiRedditAsyncTask.java | 16 +++++++++-- .../infinityforreddit/Font/ContentFontFamily.java | 4 ++- .../infinityforreddit/Font/FontFamily.java | 4 ++- .../infinityforreddit/Font/TitleFontFamily.java | 4 ++- .../Fragment/MultiRedditListingFragment.java | 2 -- .../MultiReddit/FavoriteMultiReddit.java | 11 +++---- app/src/main/res/font/manrope.xml | 17 +++++++++++ app/src/main/res/font/manrope_bold.ttf | Bin 0 -> 92240 bytes app/src/main/res/font/manrope_light.ttf | Bin 0 -> 92412 bytes app/src/main/res/font/manrope_medium.ttf | Bin 0 -> 92472 bytes app/src/main/res/font/manrope_regular.ttf | Bin 0 -> 92380 bytes app/src/main/res/font/rubik.xml | 32 +++++++++++++++++++++ app/src/main/res/font/rubik_bold.ttf | Bin 0 -> 136068 bytes app/src/main/res/font/rubik_bold_italic.ttf | Bin 0 -> 139280 bytes app/src/main/res/font/rubik_italic.ttf | Bin 0 -> 136160 bytes app/src/main/res/font/rubik_light.ttf | Bin 0 -> 130688 bytes app/src/main/res/font/rubik_light_italic.ttf | Bin 0 -> 133940 bytes app/src/main/res/font/rubik_regular.ttf | Bin 0 -> 133376 bytes app/src/main/res/values/arrays.xml | 4 +++ app/src/main/res/values/styles.xml | 24 ++++++++++++++++ 21 files changed, 108 insertions(+), 18 deletions(-) create mode 100644 app/src/main/res/font/manrope.xml create mode 100644 app/src/main/res/font/manrope_bold.ttf create mode 100644 app/src/main/res/font/manrope_light.ttf create mode 100644 app/src/main/res/font/manrope_medium.ttf create mode 100644 app/src/main/res/font/manrope_regular.ttf create mode 100644 app/src/main/res/font/rubik.xml create mode 100644 app/src/main/res/font/rubik_bold.ttf create mode 100644 app/src/main/res/font/rubik_bold_italic.ttf create mode 100644 app/src/main/res/font/rubik_italic.ttf create mode 100644 app/src/main/res/font/rubik_light.ttf create mode 100644 app/src/main/res/font/rubik_light_italic.ttf create mode 100644 app/src/main/res/font/rubik_regular.ttf (limited to 'app') 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 { private MultiRedditDao multiRedditDao; private ArrayList multiReddits; + private MultiReddit multiReddit; private String accountName; private InsertMultiRedditAsyncTaskListener insertMultiRedditAsyncTaskListener; @@ -26,15 +26,27 @@ public class InsertMultiRedditAsyncTask extends AsyncTask { 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 existingMultiReddits = multiRedditDao.getAllMultiRedditsList(accountName); Collections.sort(multiReddits, (multiReddit, t1) -> multiReddit.getName().compareToIgnoreCase(t1.getName())); List 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 params = new HashMap<>(); params.put(APIUtils.MULTIPATH_KEY, multiReddit.getPath()); @@ -33,10 +32,8 @@ public class FavoriteMultiReddit { @Override public void onResponse(@NonNull Call call, @NonNull Response response) { if (response.isSuccessful()) { - multiReddit.setFavorite(true); - ArrayList 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 @@ + + + + + + + + \ 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 new file mode 100644 index 00000000..0b2be328 Binary files /dev/null and b/app/src/main/res/font/manrope_bold.ttf differ diff --git a/app/src/main/res/font/manrope_light.ttf b/app/src/main/res/font/manrope_light.ttf new file mode 100644 index 00000000..5a771c80 Binary files /dev/null and b/app/src/main/res/font/manrope_light.ttf differ diff --git a/app/src/main/res/font/manrope_medium.ttf b/app/src/main/res/font/manrope_medium.ttf new file mode 100644 index 00000000..e704d983 Binary files /dev/null and b/app/src/main/res/font/manrope_medium.ttf differ diff --git a/app/src/main/res/font/manrope_regular.ttf b/app/src/main/res/font/manrope_regular.ttf new file mode 100644 index 00000000..8f414180 Binary files /dev/null and b/app/src/main/res/font/manrope_regular.ttf differ 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 @@ + + + + + + + + + + + + + + \ 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 new file mode 100644 index 00000000..4e77930f Binary files /dev/null and b/app/src/main/res/font/rubik_bold.ttf differ diff --git a/app/src/main/res/font/rubik_bold_italic.ttf b/app/src/main/res/font/rubik_bold_italic.ttf new file mode 100644 index 00000000..f6322472 Binary files /dev/null and b/app/src/main/res/font/rubik_bold_italic.ttf differ diff --git a/app/src/main/res/font/rubik_italic.ttf b/app/src/main/res/font/rubik_italic.ttf new file mode 100644 index 00000000..2ddac98e Binary files /dev/null and b/app/src/main/res/font/rubik_italic.ttf differ diff --git a/app/src/main/res/font/rubik_light.ttf b/app/src/main/res/font/rubik_light.ttf new file mode 100644 index 00000000..8189d848 Binary files /dev/null and b/app/src/main/res/font/rubik_light.ttf differ diff --git a/app/src/main/res/font/rubik_light_italic.ttf b/app/src/main/res/font/rubik_light_italic.ttf new file mode 100644 index 00000000..8a9ae95a Binary files /dev/null and b/app/src/main/res/font/rubik_light_italic.ttf differ diff --git a/app/src/main/res/font/rubik_regular.ttf b/app/src/main/res/font/rubik_regular.ttf new file mode 100644 index 00000000..52b59ca4 Binary files /dev/null and b/app/src/main/res/font/rubik_regular.ttf differ 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 @@ Harmonia Sans Selawk Inter + Manrope + Rubik @@ -141,6 +143,8 @@ HarmoniaSans Selawk Inter + Manrope + Rubik 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 @@ @font/inter + + + + + + + + + + + +