mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Fix bugs related to favoriting multireddits. Add some fonts.
This commit is contained in:
parent
6921d720d2
commit
ee048b25dd
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
17
app/src/main/res/font/manrope.xml
Normal file
17
app/src/main/res/font/manrope.xml
Normal file
@ -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>
|
BIN
app/src/main/res/font/manrope_bold.ttf
Normal file
BIN
app/src/main/res/font/manrope_bold.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/manrope_light.ttf
Normal file
BIN
app/src/main/res/font/manrope_light.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/manrope_medium.ttf
Normal file
BIN
app/src/main/res/font/manrope_medium.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/manrope_regular.ttf
Normal file
BIN
app/src/main/res/font/manrope_regular.ttf
Normal file
Binary file not shown.
32
app/src/main/res/font/rubik.xml
Normal file
32
app/src/main/res/font/rubik.xml
Normal file
@ -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>
|
BIN
app/src/main/res/font/rubik_bold.ttf
Normal file
BIN
app/src/main/res/font/rubik_bold.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/rubik_bold_italic.ttf
Normal file
BIN
app/src/main/res/font/rubik_bold_italic.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/rubik_italic.ttf
Normal file
BIN
app/src/main/res/font/rubik_italic.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/rubik_light.ttf
Normal file
BIN
app/src/main/res/font/rubik_light.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/rubik_light_italic.ttf
Normal file
BIN
app/src/main/res/font/rubik_light_italic.ttf
Normal file
Binary file not shown.
BIN
app/src/main/res/font/rubik_regular.ttf
Normal file
BIN
app/src/main/res/font/rubik_regular.ttf
Normal file
Binary file not shown.
@ -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">
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user