mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 20:57:25 +01:00
Remove SubredditFilter completely.
This commit is contained in:
parent
97b5c5d5c6
commit
60908860b7
@ -46,12 +46,6 @@
|
|||||||
android:parentActivityName=".activities.SettingsActivity"
|
android:parentActivityName=".activities.SettingsActivity"
|
||||||
android:theme="@style/AppTheme.NoActionBar"
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity
|
|
||||||
android:name=".activities.SubredditFilterPopularAndAllActivity"
|
|
||||||
android:label="@string/subreddit_filter_popular_and_all_activity_label"
|
|
||||||
android:parentActivityName=".activities.SettingsActivity"
|
|
||||||
android:theme="@style/AppTheme.NoActionBar"
|
|
||||||
android:windowSoftInputMode="adjustResize" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.FetchRandomSubredditOrPostActivity"
|
android:name=".activities.FetchRandomSubredditOrPostActivity"
|
||||||
android:parentActivityName=".activities.MainActivity"
|
android:parentActivityName=".activities.MainActivity"
|
||||||
|
@ -38,7 +38,6 @@ import ml.docilealligator.infinityforreddit.activities.SelectedSubredditsActivit
|
|||||||
import ml.docilealligator.infinityforreddit.activities.SendPrivateMessageActivity;
|
import ml.docilealligator.infinityforreddit.activities.SendPrivateMessageActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.SettingsActivity;
|
import ml.docilealligator.infinityforreddit.activities.SettingsActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.SubmitCrosspostActivity;
|
import ml.docilealligator.infinityforreddit.activities.SubmitCrosspostActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.SubredditFilterPopularAndAllActivity;
|
|
||||||
import ml.docilealligator.infinityforreddit.activities.SubredditMultiselectionActivity;
|
import ml.docilealligator.infinityforreddit.activities.SubredditMultiselectionActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.SubredditSelectionActivity;
|
import ml.docilealligator.infinityforreddit.activities.SubredditSelectionActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.SubscribedThingListingActivity;
|
import ml.docilealligator.infinityforreddit.activities.SubscribedThingListingActivity;
|
||||||
@ -230,8 +229,6 @@ public interface AppComponent {
|
|||||||
|
|
||||||
void inject(MiscellaneousPreferenceFragment miscellaneousPreferenceFragment);
|
void inject(MiscellaneousPreferenceFragment miscellaneousPreferenceFragment);
|
||||||
|
|
||||||
void inject(SubredditFilterPopularAndAllActivity subredditFilterPopularAndAllActivity);
|
|
||||||
|
|
||||||
void inject(CustomizePostFilterActivity customizePostFilterActivity);
|
void inject(CustomizePostFilterActivity customizePostFilterActivity);
|
||||||
|
|
||||||
void inject(PostHistoryFragment postHistoryFragment);
|
void inject(PostHistoryFragment postHistoryFragment);
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
|
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
||||||
|
|
||||||
|
public class FetchPostFilterAndReadPosts {
|
||||||
|
public interface FetchPostFilterAndReadPostsListener {
|
||||||
|
void success(PostFilter postFilter, ArrayList<ReadPost> readPostList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fetchPostFilterAndReadPosts(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor,
|
||||||
|
Handler handler, String accountName, int postFilterUsage,
|
||||||
|
String nameOfUsage, FetchPostFilterAndReadPostsListener fetchPostFilterAndReadPostsListener) {
|
||||||
|
executor.execute(() -> {
|
||||||
|
List<PostFilter> postFilters = redditDataRoomDatabase.postFilterDao().getValidPostFilters(postFilterUsage, nameOfUsage);
|
||||||
|
PostFilter mergedPostFilter = PostFilter.mergePostFilter(postFilters);
|
||||||
|
if (accountName != null) {
|
||||||
|
ArrayList<ReadPost> readPosts = (ArrayList<ReadPost>) redditDataRoomDatabase.readPostDao().getAllReadPosts(accountName);
|
||||||
|
handler.post(() -> fetchPostFilterAndReadPostsListener.success(mergedPostFilter, readPosts));
|
||||||
|
} else {
|
||||||
|
handler.post(() -> fetchPostFilterAndReadPostsListener.success(mergedPostFilter, null));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -26,8 +26,6 @@ import ml.docilealligator.infinityforreddit.recentsearchquery.RecentSearchQuery;
|
|||||||
import ml.docilealligator.infinityforreddit.recentsearchquery.RecentSearchQueryDao;
|
import ml.docilealligator.infinityforreddit.recentsearchquery.RecentSearchQueryDao;
|
||||||
import ml.docilealligator.infinityforreddit.subreddit.SubredditDao;
|
import ml.docilealligator.infinityforreddit.subreddit.SubredditDao;
|
||||||
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
|
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilter;
|
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilterDao;
|
|
||||||
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditDao;
|
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditDao;
|
||||||
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData;
|
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserDao;
|
import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserDao;
|
||||||
@ -37,7 +35,7 @@ import ml.docilealligator.infinityforreddit.user.UserData;
|
|||||||
|
|
||||||
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
|
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
|
||||||
SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class,
|
SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class,
|
||||||
SubredditFilter.class, ReadPost.class, PostFilter.class, PostFilterUsage.class}, version = 15)
|
ReadPost.class, PostFilter.class, PostFilterUsage.class}, version = 16)
|
||||||
public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
||||||
private static RedditDataRoomDatabase INSTANCE;
|
private static RedditDataRoomDatabase INSTANCE;
|
||||||
|
|
||||||
@ -50,7 +48,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
|||||||
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,
|
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,
|
||||||
MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9,
|
MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9,
|
||||||
MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13,
|
MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13,
|
||||||
MIGRATION_13_14, MIGRATION_14_15)
|
MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,8 +72,6 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
|||||||
|
|
||||||
public abstract RecentSearchQueryDao recentSearchQueryDao();
|
public abstract RecentSearchQueryDao recentSearchQueryDao();
|
||||||
|
|
||||||
public abstract SubredditFilterDao subredditFilterDao();
|
|
||||||
|
|
||||||
public abstract ReadPostDao readPostDao();
|
public abstract ReadPostDao readPostDao();
|
||||||
|
|
||||||
public abstract PostFilterDao postFilterDao();
|
public abstract PostFilterDao postFilterDao();
|
||||||
@ -306,4 +302,11 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
|||||||
"name_of_usage TEXT NOT NULL, PRIMARY KEY(name, usage, name_of_usage), FOREIGN KEY(name) REFERENCES post_filter(name) ON DELETE CASCADE)");
|
"name_of_usage TEXT NOT NULL, PRIMARY KEY(name, usage, name_of_usage), FOREIGN KEY(name) REFERENCES post_filter(name) ON DELETE CASCADE)");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final Migration MIGRATION_15_16 = new Migration(15, 16) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("DROP TABLE subreddit_filter");
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,168 +0,0 @@
|
|||||||
package ml.docilealligator.infinityforreddit.activities;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
import android.widget.EditText;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import ml.docilealligator.infinityforreddit.adapters.SubredditFilterRecyclerViewAdapter;
|
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.DeleteSubredditFilter;
|
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.InsertSubredditFilter;
|
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilter;
|
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilterViewModel;
|
|
||||||
|
|
||||||
public class SubredditFilterPopularAndAllActivity extends BaseActivity {
|
|
||||||
|
|
||||||
private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 1;
|
|
||||||
@BindView(R.id.coordinator_layout_subreddit_filter_popular_and_all_activity)
|
|
||||||
CoordinatorLayout coordinatorLayout;
|
|
||||||
@BindView(R.id.appbar_layout_subreddit_filter_popular_and_all_activity)
|
|
||||||
AppBarLayout appBarLayout;
|
|
||||||
@BindView(R.id.toolbar_subreddit_filter_popular_and_all_activity)
|
|
||||||
Toolbar toolbar;
|
|
||||||
@BindView(R.id.recycler_view_subreddit_filter_popular_and_all_activity)
|
|
||||||
RecyclerView recyclerView;
|
|
||||||
@BindView(R.id.fab_subreddit_filter_popular_and_all_activity)
|
|
||||||
FloatingActionButton fab;
|
|
||||||
@Inject
|
|
||||||
@Named("default")
|
|
||||||
SharedPreferences sharedPreferences;
|
|
||||||
@Inject
|
|
||||||
RedditDataRoomDatabase redditDataRoomDatabase;
|
|
||||||
@Inject
|
|
||||||
CustomThemeWrapper customThemeWrapper;
|
|
||||||
SubredditFilterViewModel subredditFilterViewModel;
|
|
||||||
private SubredditFilterRecyclerViewAdapter adapter;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
|
||||||
|
|
||||||
setImmersiveModeNotApplicable();
|
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_subreddit_filter_popular_and_all);
|
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
|
|
||||||
applyCustomTheme();
|
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
||||||
|
|
||||||
adapter = new SubredditFilterRecyclerViewAdapter(subredditFilter -> DeleteSubredditFilter.deleteSubredditFilter(redditDataRoomDatabase, subredditFilter, () -> {}));
|
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
|
||||||
recyclerView.setAdapter(adapter);
|
|
||||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
||||||
@Override
|
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
|
||||||
if (dy > 0) {
|
|
||||||
fab.hide();
|
|
||||||
} else if (dy < 0) {
|
|
||||||
fab.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
subredditFilterViewModel = new ViewModelProvider(this,
|
|
||||||
new SubredditFilterViewModel.Factory(redditDataRoomDatabase))
|
|
||||||
.get(SubredditFilterViewModel.class);
|
|
||||||
subredditFilterViewModel.getSubredditFilterLiveData().observe(this, subredditFilters -> adapter.updateSubredditsName(subredditFilters));
|
|
||||||
|
|
||||||
fab.setOnClickListener(view -> {
|
|
||||||
EditText thingEditText = (EditText) getLayoutInflater().inflate(R.layout.dialog_go_to_thing_edit_text, null);
|
|
||||||
thingEditText.requestFocus();
|
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
if (imm != null) {
|
|
||||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
|
||||||
}
|
|
||||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
|
||||||
.setTitle(R.string.choose_a_subreddit)
|
|
||||||
.setView(thingEditText)
|
|
||||||
.setPositiveButton(R.string.ok, (dialogInterface, i)
|
|
||||||
-> {
|
|
||||||
if (imm != null) {
|
|
||||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
|
||||||
}
|
|
||||||
SubredditFilter subredditFilter = new SubredditFilter(thingEditText.getText().toString(), SubredditFilter.TYPE_POPULAR_AND_ALL);
|
|
||||||
InsertSubredditFilter.insertSubredditFilter(redditDataRoomDatabase, subredditFilter,
|
|
||||||
() -> {});
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.cancel, null)
|
|
||||||
.setNeutralButton(R.string.search, (dialogInterface, i) -> {
|
|
||||||
if (imm != null) {
|
|
||||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent intent = new Intent(this, SearchActivity.class);
|
|
||||||
intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_SUBREDDITS, true);
|
|
||||||
startActivityForResult(intent, SUBREDDIT_SEARCH_REQUEST_CODE);
|
|
||||||
})
|
|
||||||
.setOnDismissListener(dialogInterface -> {
|
|
||||||
if (imm != null) {
|
|
||||||
imm.hideSoftInputFromWindow(thingEditText.getWindowToken(), 0);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
|
||||||
if (item.getItemId() == android.R.id.home) {
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE && resultCode == RESULT_OK && data != null) {
|
|
||||||
SubredditFilter subredditFilter = new SubredditFilter(data.getStringExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_NAME), SubredditFilter.TYPE_POPULAR_AND_ALL);
|
|
||||||
InsertSubredditFilter.insertSubredditFilter(redditDataRoomDatabase, subredditFilter,
|
|
||||||
() -> {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SharedPreferences getDefaultSharedPreferences() {
|
|
||||||
return sharedPreferences;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected CustomThemeWrapper getCustomThemeWrapper() {
|
|
||||||
return customThemeWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void applyCustomTheme() {
|
|
||||||
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1950,7 +1950,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
}
|
}
|
||||||
|
|
||||||
void markPostRead(Post post) {
|
void markPostRead(Post post) {
|
||||||
if (mAccessToken != null && !post.isRead()) {
|
if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
|
||||||
post.markAsRead();
|
post.markAsRead();
|
||||||
cardView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
|
cardView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
|
||||||
titleTextView.setTextColor(mReadPostTitleColor);
|
titleTextView.setTextColor(mReadPostTitleColor);
|
||||||
@ -2077,7 +2077,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
}
|
}
|
||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
((PostBaseViewHolder) this).markPostRead(post);
|
markPostRead(post);
|
||||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||||
if (post.isGfycat()) {
|
if (post.isGfycat()) {
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
|
||||||
@ -3009,7 +3009,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
}
|
}
|
||||||
|
|
||||||
void markPostRead(Post post) {
|
void markPostRead(Post post) {
|
||||||
if (mAccessToken != null && !post.isRead()) {
|
if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
|
||||||
post.markAsRead();
|
post.markAsRead();
|
||||||
itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
|
itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
|
||||||
titleTextView.setTextColor(mReadPostTitleColor);
|
titleTextView.setTextColor(mReadPostTitleColor);
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
package ml.docilealligator.infinityforreddit.adapters;
|
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilter;
|
|
||||||
|
|
||||||
public class SubredditFilterRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
||||||
private List<SubredditFilter> subredditFilters;
|
|
||||||
private ItemClickListener itemClickListener;
|
|
||||||
|
|
||||||
public SubredditFilterRecyclerViewAdapter(ItemClickListener itemClickListener) {
|
|
||||||
this.itemClickListener = itemClickListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ItemClickListener {
|
|
||||||
void onItemDelete(SubredditFilter subredditFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
return new SubredditNameViewHolder(LayoutInflater.from(parent.getContext())
|
|
||||||
.inflate(R.layout.item_selected_subreddit, parent, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
|
||||||
if (holder instanceof SubredditNameViewHolder) {
|
|
||||||
((SubredditNameViewHolder) holder).subredditRedditNameTextView.setText(subredditFilters.get(position).getSubredditName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return subredditFilters == null ? 0 : subredditFilters.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateSubredditsName(List<SubredditFilter> subredditFilters) {
|
|
||||||
this.subredditFilters = subredditFilters;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
class SubredditNameViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
@BindView(R.id.subreddit_name_item_selected_subreddit)
|
|
||||||
TextView subredditRedditNameTextView;
|
|
||||||
@BindView(R.id.delete_image_view_item_selected_subreddit)
|
|
||||||
ImageView deleteImageView;
|
|
||||||
|
|
||||||
public SubredditNameViewHolder(@NonNull View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
|
|
||||||
ButterKnife.bind(this, itemView);
|
|
||||||
|
|
||||||
deleteImageView.setOnClickListener(view -> {
|
|
||||||
itemClickListener.onItemDelete(subredditFilters.get(getAdapterPosition()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -52,6 +52,7 @@ import org.greenrobot.eventbus.Subscribe;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
@ -63,10 +64,10 @@ import im.ene.toro.exoplayer.ExoCreator;
|
|||||||
import im.ene.toro.media.PlaybackInfo;
|
import im.ene.toro.media.PlaybackInfo;
|
||||||
import im.ene.toro.media.VolumeInfo;
|
import im.ene.toro.media.VolumeInfo;
|
||||||
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
|
||||||
|
import ml.docilealligator.infinityforreddit.FetchPostFilterAndReadPosts;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
|
||||||
import ml.docilealligator.infinityforreddit.PostFragmentContentScrollingInterface;
|
import ml.docilealligator.infinityforreddit.PostFragmentContentScrollingInterface;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
@ -105,10 +106,9 @@ import ml.docilealligator.infinityforreddit.events.ShowThumbnailOnTheRightInComp
|
|||||||
import ml.docilealligator.infinityforreddit.post.Post;
|
import ml.docilealligator.infinityforreddit.post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.post.PostDataSource;
|
import ml.docilealligator.infinityforreddit.post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.post.PostViewModel;
|
import ml.docilealligator.infinityforreddit.post.PostViewModel;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.FetchReadPosts;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.FetchSubredditFilters;
|
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilter;
|
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -135,7 +135,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
|
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
|
||||||
private static final String RECYCLER_VIEW_POSITION_STATE = "RVPS";
|
private static final String RECYCLER_VIEW_POSITION_STATE = "RVPS";
|
||||||
private static final String READ_POST_LIST_STATE = "RPLS";
|
private static final String READ_POST_LIST_STATE = "RPLS";
|
||||||
private static final String SUBREDDIT_FILTER_LIST_STATE = "SFLS";
|
|
||||||
private static final String HIDE_READ_POSTS_INDEX_STATE = "HRPIS";
|
private static final String HIDE_READ_POSTS_INDEX_STATE = "HRPIS";
|
||||||
private static final String POST_FILTER_STATE = "PFS";
|
private static final String POST_FILTER_STATE = "PFS";
|
||||||
|
|
||||||
@ -180,12 +179,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
@Named("post_history")
|
@Named("post_history")
|
||||||
SharedPreferences mPostHistorySharedPreferences;
|
SharedPreferences mPostHistorySharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper customThemeWrapper;
|
|
||||||
@Inject
|
|
||||||
ExoCreator exoCreator;
|
|
||||||
@Inject
|
|
||||||
@Named("post_feed_scrolled_position_cache")
|
@Named("post_feed_scrolled_position_cache")
|
||||||
SharedPreferences postFeedScrolledPositionSharedPreferences;
|
SharedPreferences mPostFeedScrolledPositionSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
@Inject
|
||||||
|
ExoCreator mExoCreator;
|
||||||
|
@Inject
|
||||||
|
Executor mExecutor;
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private AppCompatActivity activity;
|
private AppCompatActivity activity;
|
||||||
private LinearLayoutManager mLinearLayoutManager;
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
@ -222,7 +223,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
private boolean vibrateWhenActionTriggered;
|
private boolean vibrateWhenActionTriggered;
|
||||||
private float swipeActionThreshold;
|
private float swipeActionThreshold;
|
||||||
private ItemTouchHelper touchHelper;
|
private ItemTouchHelper touchHelper;
|
||||||
private ArrayList<SubredditFilter> subredditFilterList;
|
|
||||||
private ArrayList<ReadPost> readPosts;
|
private ArrayList<ReadPost> readPosts;
|
||||||
private Unbinder unbinder;
|
private Unbinder unbinder;
|
||||||
|
|
||||||
@ -387,15 +387,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
|
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
|
||||||
readPosts = savedInstanceState.getParcelableArrayList(READ_POST_LIST_STATE);
|
readPosts = savedInstanceState.getParcelableArrayList(READ_POST_LIST_STATE);
|
||||||
subredditFilterList = savedInstanceState.getParcelableArrayList(SUBREDDIT_FILTER_LIST_STATE);
|
|
||||||
hideReadPostsIndex = savedInstanceState.getInt(HIDE_READ_POSTS_INDEX_STATE, 0);
|
hideReadPostsIndex = savedInstanceState.getInt(HIDE_READ_POSTS_INDEX_STATE, 0);
|
||||||
postFilter = savedInstanceState.getParcelable(POST_FILTER_STATE);
|
postFilter = savedInstanceState.getParcelable(POST_FILTER_STATE);
|
||||||
} else {
|
} else {
|
||||||
//TODO: Initialize PostFilter
|
|
||||||
postFilter = getArguments().getParcelable(EXTRA_FILTER);
|
postFilter = getArguments().getParcelable(EXTRA_FILTER);
|
||||||
if (postFilter == null) {
|
|
||||||
postFilter = new PostFilter();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mPostRecyclerView.setOnTouchListener((view, motionEvent) -> {
|
mPostRecyclerView.setOnTouchListener((view, motionEvent) -> {
|
||||||
@ -422,25 +417,30 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||||
accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
accountName = getArguments().getString(EXTRA_ACCOUNT_NAME);
|
||||||
postFilter.allowNSFW = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
|
|
||||||
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
|
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
|
||||||
savePostFeedScrolledPosition = mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION, false);
|
savePostFeedScrolledPosition = mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION, false);
|
||||||
Locale locale = getResources().getConfiguration().locale;
|
Locale locale = getResources().getConfiguration().locale;
|
||||||
|
|
||||||
|
int usage;
|
||||||
|
String nameOfUsage;
|
||||||
|
|
||||||
if (postType == PostDataSource.TYPE_SEARCH) {
|
if (postType == PostDataSource.TYPE_SEARCH) {
|
||||||
subredditName = getArguments().getString(EXTRA_NAME);
|
subredditName = getArguments().getString(EXTRA_NAME);
|
||||||
query = getArguments().getString(EXTRA_QUERY);
|
query = getArguments().getString(EXTRA_QUERY);
|
||||||
|
|
||||||
|
usage = PostFilterUsage.SEARCH_TYPE;
|
||||||
|
nameOfUsage = PostFilterUsage.NO_USAGE;
|
||||||
|
|
||||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, SortType.Type.RELEVANCE.name());
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, SortType.Type.RELEVANCE.name());
|
||||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, SortType.Time.ALL.name());
|
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, SortType.Time.ALL.name());
|
||||||
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale,
|
mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, true,
|
windowWidth, accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
exoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
mPostViewModel.retryLoadingMore();
|
mPostViewModel.retryLoadingMore();
|
||||||
@ -480,6 +480,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
});
|
});
|
||||||
} else if (postType == PostDataSource.TYPE_SUBREDDIT) {
|
} else if (postType == PostDataSource.TYPE_SUBREDDIT) {
|
||||||
subredditName = getArguments().getString(EXTRA_NAME);
|
subredditName = getArguments().getString(EXTRA_NAME);
|
||||||
|
|
||||||
|
usage = PostFilterUsage.SUBREDDIT_TYPE;
|
||||||
|
nameOfUsage = subredditName;
|
||||||
|
|
||||||
String sort;
|
String sort;
|
||||||
String sortTime = null;
|
String sortTime = null;
|
||||||
|
|
||||||
@ -497,10 +501,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale,
|
mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, displaySubredditName,
|
windowWidth, accessToken, accountName, postType, postLayout, displaySubredditName,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
exoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
mPostViewModel.retryLoadingMore();
|
mPostViewModel.retryLoadingMore();
|
||||||
@ -538,6 +542,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
});
|
});
|
||||||
} else if (postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
} else if (postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
||||||
multiRedditPath = getArguments().getString(EXTRA_NAME);
|
multiRedditPath = getArguments().getString(EXTRA_NAME);
|
||||||
|
|
||||||
|
usage = PostFilterUsage.MULTIREDDIT_TYPE;
|
||||||
|
nameOfUsage = multiRedditPath;
|
||||||
|
|
||||||
String sort;
|
String sort;
|
||||||
String sortTime = null;
|
String sortTime = null;
|
||||||
|
|
||||||
@ -557,10 +565,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale,
|
mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, true,
|
windowWidth, accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
exoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
mPostViewModel.retryLoadingMore();
|
mPostViewModel.retryLoadingMore();
|
||||||
@ -599,6 +607,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
} else if (postType == PostDataSource.TYPE_USER) {
|
} else if (postType == PostDataSource.TYPE_USER) {
|
||||||
username = getArguments().getString(EXTRA_USER_NAME);
|
username = getArguments().getString(EXTRA_USER_NAME);
|
||||||
where = getArguments().getString(EXTRA_USER_WHERE);
|
where = getArguments().getString(EXTRA_USER_WHERE);
|
||||||
|
|
||||||
|
usage = PostFilterUsage.USER_TYPE;
|
||||||
|
nameOfUsage = username;
|
||||||
|
|
||||||
if (where != null && where.equals(PostDataSource.USER_WHERE_SUBMITTED)) {
|
if (where != null && where.equals(PostDataSource.USER_WHERE_SUBMITTED)) {
|
||||||
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mFetchPostInfoLinearLayout.getLayoutParams();
|
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mFetchPostInfoLinearLayout.getLayoutParams();
|
||||||
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
@ -615,10 +627,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale,
|
mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, true,
|
windowWidth, accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
exoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
mPostViewModel.retryLoadingMore();
|
mPostViewModel.retryLoadingMore();
|
||||||
@ -657,6 +669,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
usage = PostFilterUsage.HOME_TYPE;
|
||||||
|
nameOfUsage = PostFilterUsage.NO_USAGE;
|
||||||
|
|
||||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.BEST.name());
|
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.BEST.name());
|
||||||
if (sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
if (sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
||||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name());
|
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name());
|
||||||
@ -667,10 +682,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
|
||||||
mRedgifsRetrofit, mRedditDataRoomDatabase, customThemeWrapper, locale,
|
mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale,
|
||||||
windowWidth, accessToken, accountName, postType, postLayout, true,
|
windowWidth, accessToken, accountName, postType, postLayout, true,
|
||||||
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
|
||||||
exoCreator, new PostRecyclerViewAdapter.Callback() {
|
mExoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
mPostViewModel.retryLoadingMore();
|
mPostViewModel.retryLoadingMore();
|
||||||
@ -715,25 +730,60 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (accountName != null && !accountName.equals("")) {
|
if (accountName != null && !accountName.equals("")) {
|
||||||
if (mPostHistorySharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false) && readPosts == null) {
|
if (mPostHistorySharedPreferences.getBoolean(accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false) && readPosts == null) {
|
||||||
if (getArguments().getBoolean(EXTRA_DISABLE_READ_POSTS, false)) {
|
if (getArguments().getBoolean(EXTRA_DISABLE_READ_POSTS, false)) {
|
||||||
initializeAndBindPostViewModel(accessToken);
|
if (postFilter == null) {
|
||||||
|
FetchPostFilterAndReadPosts.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
|
||||||
|
new Handler(), null, usage, nameOfUsage, (postFilter, readPostList) -> {
|
||||||
|
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||||
|
this.postFilter = postFilter;
|
||||||
|
postFilter.allowNSFW = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
|
||||||
|
initializeAndBindPostViewModel(accessToken);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
initializeAndBindPostViewModel(accessToken);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
FetchReadPosts.fetchReadPosts(mRedditDataRoomDatabase, accountName,
|
FetchPostFilterAndReadPosts.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
|
||||||
postType == PostDataSource.TYPE_SUBREDDIT && subredditName != null && (subredditName.equals("all") || subredditName.equals("popular")),
|
new Handler(), accountName, usage, nameOfUsage, (postFilter, readPostList) -> {
|
||||||
(readPosts, subredditFilters) -> {
|
|
||||||
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||||
this.readPosts = readPosts;
|
if (this.postFilter == null) {
|
||||||
this.subredditFilterList = subredditFilters;
|
this.postFilter = postFilter;
|
||||||
|
postFilter.allowNSFW = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
|
||||||
|
}
|
||||||
|
this.readPosts = readPostList;
|
||||||
initializeAndBindPostViewModel(accessToken);
|
initializeAndBindPostViewModel(accessToken);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
initializeAndBindPostViewModel(accessToken);
|
if (postFilter == null) {
|
||||||
|
FetchPostFilterAndReadPosts.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
|
||||||
|
new Handler(), null, usage, nameOfUsage, (postFilter, readPostList) -> {
|
||||||
|
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||||
|
this.postFilter = postFilter;
|
||||||
|
postFilter.allowNSFW = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
|
||||||
|
initializeAndBindPostViewModel(accessToken);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
initializeAndBindPostViewModel(accessToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
initializeAndBindPostViewModelForAnonymous(accessToken);
|
if (postFilter == null) {
|
||||||
|
FetchPostFilterAndReadPosts.fetchPostFilterAndReadPosts(mRedditDataRoomDatabase, mExecutor,
|
||||||
|
new Handler(), null, usage, nameOfUsage, (postFilter, readPostList) -> {
|
||||||
|
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||||
|
this.postFilter = postFilter;
|
||||||
|
postFilter.allowNSFW = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
|
||||||
|
initializeAndBindPostViewModelForAnonymous(accessToken);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
initializeAndBindPostViewModelForAnonymous(accessToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vibrateWhenActionTriggered = mSharedPreferences.getBoolean(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED, true);
|
vibrateWhenActionTriggered = mSharedPreferences.getBoolean(SharedPreferencesUtils.VIBRATE_WHEN_ACTION_TRIGGERED, true);
|
||||||
@ -849,33 +899,26 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
if (postType == PostDataSource.TYPE_SEARCH) {
|
if (postType == PostDataSource.TYPE_SEARCH) {
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
||||||
accountName, mSharedPreferences,
|
accountName, mSharedPreferences,
|
||||||
postFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType,
|
mPostFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType,
|
||||||
postFilter, readPosts)).get(PostViewModel.class);
|
postFilter, readPosts)).get(PostViewModel.class);
|
||||||
} else if (postType == PostDataSource.TYPE_SUBREDDIT) {
|
} else if (postType == PostDataSource.TYPE_SUBREDDIT) {
|
||||||
if (subredditName.equals("all") || subredditName.equals("popular")) {
|
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
accountName, mSharedPreferences,
|
||||||
accountName, mSharedPreferences,
|
mPostFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
|
||||||
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
|
postFilter, readPosts)).get(PostViewModel.class);
|
||||||
postFilter, readPosts, subredditFilterList)).get(PostViewModel.class);
|
|
||||||
} else {
|
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
|
||||||
accountName, mSharedPreferences,
|
|
||||||
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
|
|
||||||
postFilter, readPosts)).get(PostViewModel.class);
|
|
||||||
}
|
|
||||||
} else if (postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
} else if (postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
||||||
accountName, mSharedPreferences,
|
accountName, mSharedPreferences,
|
||||||
postFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType,
|
mPostFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType,
|
||||||
postFilter, readPosts)).get(PostViewModel.class);
|
postFilter, readPosts)).get(PostViewModel.class);
|
||||||
} else if (postType == PostDataSource.TYPE_USER) {
|
} else if (postType == PostDataSource.TYPE_USER) {
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
||||||
accountName, mSharedPreferences,
|
accountName, mSharedPreferences,
|
||||||
postFeedScrolledPositionSharedPreferences, username, postType, sortType, postFilter,
|
mPostFeedScrolledPositionSharedPreferences, username, postType, sortType, postFilter,
|
||||||
where, readPosts)).get(PostViewModel.class);
|
where, readPosts)).get(PostViewModel.class);
|
||||||
} else {
|
} else {
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
accountName, mSharedPreferences, postFeedScrolledPositionSharedPreferences,
|
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
|
||||||
postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
|
postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -887,53 +930,30 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
if (postType == PostDataSource.TYPE_SEARCH) {
|
if (postType == PostDataSource.TYPE_SEARCH) {
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
||||||
accountName, mSharedPreferences,
|
accountName, mSharedPreferences,
|
||||||
postFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType,
|
mPostFeedScrolledPositionSharedPreferences, subredditName, query, postType, sortType,
|
||||||
postFilter, readPosts)).get(PostViewModel.class);
|
postFilter, readPosts)).get(PostViewModel.class);
|
||||||
} else if (postType == PostDataSource.TYPE_SUBREDDIT) {
|
} else if (postType == PostDataSource.TYPE_SUBREDDIT) {
|
||||||
if (subredditName.equals("all") || subredditName.equals("popular")) {
|
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
||||||
if (subredditFilterList != null) {
|
accountName, mSharedPreferences,
|
||||||
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
mPostFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
|
||||||
accountName, mSharedPreferences,
|
postFilter, readPosts)).get(PostViewModel.class);
|
||||||
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
|
|
||||||
postFilter, readPosts, subredditFilterList)).get(PostViewModel.class);
|
|
||||||
} else {
|
|
||||||
FetchSubredditFilters.fetchSubredditFilters(mRedditDataRoomDatabase, subredditFilters -> {
|
|
||||||
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
|
||||||
subredditFilterList = subredditFilters;
|
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
|
||||||
accountName, mSharedPreferences,
|
|
||||||
postFeedScrolledPositionSharedPreferences, subredditName, postType,
|
|
||||||
sortType, postFilter, readPosts, subredditFilterList)).get(PostViewModel.class);
|
|
||||||
|
|
||||||
bindPostViewModel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
|
||||||
accountName, mSharedPreferences,
|
|
||||||
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType, postFilter,
|
|
||||||
readPosts)).get(PostViewModel.class);
|
|
||||||
}
|
|
||||||
} else if (postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
} else if (postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
||||||
accountName, mSharedPreferences,
|
accountName, mSharedPreferences,
|
||||||
postFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType, postFilter,
|
mPostFeedScrolledPositionSharedPreferences, multiRedditPath, postType, sortType, postFilter,
|
||||||
readPosts)).get(PostViewModel.class);
|
readPosts)).get(PostViewModel.class);
|
||||||
} else if (postType == PostDataSource.TYPE_USER) {
|
} else if (postType == PostDataSource.TYPE_USER) {
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(accessToken == null ? mRetrofit : mOauthRetrofit, accessToken,
|
||||||
accountName, mSharedPreferences,
|
accountName, mSharedPreferences,
|
||||||
postFeedScrolledPositionSharedPreferences, username, postType, sortType, postFilter,
|
mPostFeedScrolledPositionSharedPreferences, username, postType, sortType, postFilter,
|
||||||
where, readPosts)).get(PostViewModel.class);
|
where, readPosts)).get(PostViewModel.class);
|
||||||
} else {
|
} else {
|
||||||
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mOauthRetrofit, accessToken,
|
||||||
accountName, mSharedPreferences, postFeedScrolledPositionSharedPreferences,
|
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
|
||||||
postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
|
postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPostViewModel != null) {
|
bindPostViewModel();
|
||||||
bindPostViewModel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindPostViewModel() {
|
private void bindPostViewModel() {
|
||||||
@ -1020,18 +1040,18 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
private void initializeSwipeActionDrawable() {
|
private void initializeSwipeActionDrawable() {
|
||||||
if (swipeRightAction == SharedPreferencesUtils.SWIPE_ACITON_DOWNVOTE) {
|
if (swipeRightAction == SharedPreferencesUtils.SWIPE_ACITON_DOWNVOTE) {
|
||||||
backgroundSwipeRight = new ColorDrawable(customThemeWrapper.getDownvoted());
|
backgroundSwipeRight = new ColorDrawable(mCustomThemeWrapper.getDownvoted());
|
||||||
drawableSwipeRight = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_arrow_downward_black_24dp, null);
|
drawableSwipeRight = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_arrow_downward_black_24dp, null);
|
||||||
} else {
|
} else {
|
||||||
backgroundSwipeRight = new ColorDrawable(customThemeWrapper.getUpvoted());
|
backgroundSwipeRight = new ColorDrawable(mCustomThemeWrapper.getUpvoted());
|
||||||
drawableSwipeRight = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_arrow_upward_black_24dp, null);
|
drawableSwipeRight = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_arrow_upward_black_24dp, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (swipeLeftAction == SharedPreferencesUtils.SWIPE_ACITON_UPVOTE) {
|
if (swipeLeftAction == SharedPreferencesUtils.SWIPE_ACITON_UPVOTE) {
|
||||||
backgroundSwipeLeft = new ColorDrawable(customThemeWrapper.getUpvoted());
|
backgroundSwipeLeft = new ColorDrawable(mCustomThemeWrapper.getUpvoted());
|
||||||
drawableSwipeLeft = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_arrow_upward_black_24dp, null);
|
drawableSwipeLeft = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_arrow_upward_black_24dp, null);
|
||||||
} else {
|
} else {
|
||||||
backgroundSwipeLeft = new ColorDrawable(customThemeWrapper.getDownvoted());
|
backgroundSwipeLeft = new ColorDrawable(mCustomThemeWrapper.getDownvoted());
|
||||||
drawableSwipeLeft = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_arrow_downward_black_24dp, null);
|
drawableSwipeLeft = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_arrow_downward_black_24dp, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1047,7 +1067,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
|
outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
|
||||||
outState.putParcelableArrayList(READ_POST_LIST_STATE, readPosts);
|
outState.putParcelableArrayList(READ_POST_LIST_STATE, readPosts);
|
||||||
outState.putParcelableArrayList(SUBREDDIT_FILTER_LIST_STATE, subredditFilterList);
|
|
||||||
if (mAdapter != null) {
|
if (mAdapter != null) {
|
||||||
outState.putInt(HIDE_READ_POSTS_INDEX_STATE, mAdapter.getHideReadPostsIndex());
|
outState.putInt(HIDE_READ_POSTS_INDEX_STATE, mAdapter.getHideReadPostsIndex());
|
||||||
}
|
}
|
||||||
@ -1074,7 +1093,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
String accountNameForCache = accountName == null ? SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_ANONYMOUS : accountName;
|
String accountNameForCache = accountName == null ? SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_ANONYMOUS : accountName;
|
||||||
String key = accountNameForCache + SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_FRONT_PAGE_BASE;
|
String key = accountNameForCache + SharedPreferencesUtils.FRONT_PAGE_SCROLLED_POSITION_FRONT_PAGE_BASE;
|
||||||
String value = currentPost.getFullName();
|
String value = currentPost.getFullName();
|
||||||
postFeedScrolledPositionSharedPreferences.edit().putString(key, value).apply();
|
mPostFeedScrolledPositionSharedPreferences.edit().putString(key, value).apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1215,9 +1234,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyTheme() {
|
public void applyTheme() {
|
||||||
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCircularProgressBarBackground());
|
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
|
||||||
mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent());
|
mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
|
||||||
mFetchPostInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor());
|
mFetchPostInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1231,6 +1250,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
@Override
|
@Override
|
||||||
public void changePostFilter(PostFilter postFilter) {
|
public void changePostFilter(PostFilter postFilter) {
|
||||||
this.postFilter = postFilter;
|
this.postFilter = postFilter;
|
||||||
|
postFilter.allowNSFW = mNsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false);
|
||||||
if (mPostViewModel != null) {
|
if (mPostViewModel != null) {
|
||||||
mPostViewModel.changePostFilter(postFilter);
|
mPostViewModel.changePostFilter(postFilter);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilter;
|
|
||||||
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.Utils;
|
import ml.docilealligator.infinityforreddit.utils.Utils;
|
||||||
|
|
||||||
@ -30,11 +29,6 @@ public class ParsePost {
|
|||||||
new ParsePostDataAsyncTask(response, nPosts, postFilter, readPostList, parsePostsListingListener).execute();
|
new ParsePostDataAsyncTask(response, nPosts, postFilter, readPostList, parsePostsListingListener).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void parsePosts(String response, int nPosts, PostFilter postFilter, List<ReadPost> readPostList,
|
|
||||||
List<SubredditFilter> subredditFilterList, ParsePostsListingListener parsePostsListingListener) {
|
|
||||||
new ParsePostDataAsyncTask(response, nPosts, postFilter, readPostList, subredditFilterList, parsePostsListingListener).execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void parsePost(String response, ParsePostListener parsePostListener) {
|
public static void parsePost(String response, ParsePostListener parsePostListener) {
|
||||||
PostFilter postFilter = new PostFilter();
|
PostFilter postFilter = new PostFilter();
|
||||||
postFilter.allowNSFW = true;
|
postFilter.allowNSFW = true;
|
||||||
@ -498,7 +492,6 @@ public class ParsePost {
|
|||||||
private int nPosts;
|
private int nPosts;
|
||||||
private PostFilter postFilter;
|
private PostFilter postFilter;
|
||||||
private List<ReadPost> readPostList;
|
private List<ReadPost> readPostList;
|
||||||
private List<SubredditFilter> subredditFilterList;
|
|
||||||
private ParsePostsListingListener parsePostsListingListener;
|
private ParsePostsListingListener parsePostsListingListener;
|
||||||
private ParsePostListener parsePostListener;
|
private ParsePostListener parsePostListener;
|
||||||
private LinkedHashSet<Post> newPosts;
|
private LinkedHashSet<Post> newPosts;
|
||||||
@ -524,12 +517,6 @@ public class ParsePost {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParsePostDataAsyncTask(String response, int nPosts, PostFilter postFilter, List<ReadPost> readPostList,
|
|
||||||
List<SubredditFilter> subredditFilterList, ParsePostsListingListener parsePostsListingListener) {
|
|
||||||
this(response, nPosts, postFilter, readPostList, parsePostsListingListener);
|
|
||||||
this.subredditFilterList = subredditFilterList;
|
|
||||||
}
|
|
||||||
|
|
||||||
ParsePostDataAsyncTask(String response, PostFilter postFilter,
|
ParsePostDataAsyncTask(String response, PostFilter postFilter,
|
||||||
ParsePostListener parsePostListener) {
|
ParsePostListener parsePostListener) {
|
||||||
this.parsePostListener = parsePostListener;
|
this.parsePostListener = parsePostListener;
|
||||||
@ -581,19 +568,10 @@ public class ParsePost {
|
|||||||
if (allData.getJSONObject(i).getString(JSONUtils.KIND_KEY).equals("t3")) {
|
if (allData.getJSONObject(i).getString(JSONUtils.KIND_KEY).equals("t3")) {
|
||||||
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
||||||
Post post = parseBasicData(data);
|
Post post = parseBasicData(data);
|
||||||
boolean availablePost = true;
|
|
||||||
if (readPostHashSet != null && readPostHashSet.contains(ReadPost.convertPost(post))) {
|
if (readPostHashSet != null && readPostHashSet.contains(ReadPost.convertPost(post))) {
|
||||||
post.markAsRead();
|
post.markAsRead();
|
||||||
}
|
}
|
||||||
if (subredditFilterList != null) {
|
if (PostFilter.isPostAllowed(post, postFilter)) {
|
||||||
for (SubredditFilter subredditFilter : subredditFilterList) {
|
|
||||||
if (subredditFilter.getSubredditName().equals(post.getSubredditName())) {
|
|
||||||
availablePost = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (availablePost && PostFilter.isPostAllowed(post, postFilter)) {
|
|
||||||
newPosts.add(post);
|
newPosts.add(post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,10 @@ import java.util.LinkedHashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilter;
|
|
||||||
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
@ -48,7 +47,6 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
private SortType sortType;
|
private SortType sortType;
|
||||||
private PostFilter postFilter;
|
private PostFilter postFilter;
|
||||||
private List<ReadPost> readPostList;
|
private List<ReadPost> readPostList;
|
||||||
private List<SubredditFilter> subredditFilterList;
|
|
||||||
private String userWhere;
|
private String userWhere;
|
||||||
private String multiRedditPath;
|
private String multiRedditPath;
|
||||||
private LinkedHashSet<Post> postLinkedHashSet;
|
private LinkedHashSet<Post> postLinkedHashSet;
|
||||||
@ -82,7 +80,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
PostDataSource(Retrofit retrofit, String accessToken, String accountName,
|
PostDataSource(Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
String path, int postType, SortType sortType, PostFilter postFilter,
|
String path, int postType, SortType sortType, PostFilter postFilter,
|
||||||
List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList) {
|
List<ReadPost> readPostList) {
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
this.accountName = accountName;
|
this.accountName = accountName;
|
||||||
@ -116,7 +114,6 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
}
|
}
|
||||||
this.postFilter = postFilter;
|
this.postFilter = postFilter;
|
||||||
this.readPostList = readPostList;
|
this.readPostList = readPostList;
|
||||||
this.subredditFilterList = subredditFilterList;
|
|
||||||
postLinkedHashSet = new LinkedHashSet<>();
|
postLinkedHashSet = new LinkedHashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +370,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, subredditFilterList,
|
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList,
|
||||||
new ParsePost.ParsePostsListingListener() {
|
new ParsePost.ParsePostsListingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
|
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
|
||||||
@ -447,7 +444,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList, subredditFilterList,
|
ParsePost.parsePosts(response.body(), -1, postFilter, readPostList,
|
||||||
new ParsePost.ParsePostsListingListener() {
|
new ParsePost.ParsePostsListingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
|
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
|
||||||
|
@ -12,7 +12,6 @@ import java.util.List;
|
|||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilter;
|
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
class PostDataSourceFactory extends DataSource.Factory {
|
class PostDataSourceFactory extends DataSource.Factory {
|
||||||
@ -28,7 +27,6 @@ class PostDataSourceFactory extends DataSource.Factory {
|
|||||||
private PostFilter postFilter;
|
private PostFilter postFilter;
|
||||||
private String userWhere;
|
private String userWhere;
|
||||||
private List<ReadPost> readPostList;
|
private List<ReadPost> readPostList;
|
||||||
private List<SubredditFilter> subredditFilterList;
|
|
||||||
|
|
||||||
private PostDataSource postDataSource;
|
private PostDataSource postDataSource;
|
||||||
private MutableLiveData<PostDataSource> postDataSourceLiveData;
|
private MutableLiveData<PostDataSource> postDataSourceLiveData;
|
||||||
@ -52,7 +50,7 @@ class PostDataSourceFactory extends DataSource.Factory {
|
|||||||
PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName,
|
PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
String subredditName, int postType, SortType sortType, PostFilter postFilter,
|
String subredditName, int postType, SortType sortType, PostFilter postFilter,
|
||||||
List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList) {
|
List<ReadPost> readPostList) {
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
this.accountName = accountName;
|
this.accountName = accountName;
|
||||||
@ -64,7 +62,6 @@ class PostDataSourceFactory extends DataSource.Factory {
|
|||||||
this.sortType = sortType;
|
this.sortType = sortType;
|
||||||
this.postFilter = postFilter;
|
this.postFilter = postFilter;
|
||||||
this.readPostList = readPostList;
|
this.readPostList = readPostList;
|
||||||
this.subredditFilterList = subredditFilterList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName,
|
PostDataSourceFactory(Retrofit retrofit, String accessToken, String accountName,
|
||||||
@ -118,7 +115,7 @@ class PostDataSourceFactory extends DataSource.Factory {
|
|||||||
Log.i("asdasfd", "s5 " + (postFilter == null));
|
Log.i("asdasfd", "s5 " + (postFilter == null));
|
||||||
postDataSource = new PostDataSource(retrofit, accessToken, accountName,
|
postDataSource = new PostDataSource(retrofit, accessToken, accountName,
|
||||||
sharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType,
|
sharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType,
|
||||||
sortType, postFilter, readPostList, subredditFilterList);
|
sortType, postFilter, readPostList);
|
||||||
} else {
|
} else {
|
||||||
postDataSource = new PostDataSource(retrofit, accessToken, accountName,
|
postDataSource = new PostDataSource(retrofit, accessToken, accountName,
|
||||||
sharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType,
|
sharedPreferences, postFeedScrolledPositionSharedPreferences, subredditName, postType,
|
||||||
|
@ -19,7 +19,6 @@ import ml.docilealligator.infinityforreddit.NetworkState;
|
|||||||
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
import ml.docilealligator.infinityforreddit.readpost.ReadPost;
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilter;
|
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class PostViewModel extends ViewModel {
|
public class PostViewModel extends ViewModel {
|
||||||
@ -68,10 +67,10 @@ public class PostViewModel extends ViewModel {
|
|||||||
public PostViewModel(Retrofit retrofit, String accessToken, String accountName,
|
public PostViewModel(Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences cache, String subredditName,
|
SharedPreferences sharedPreferences, SharedPreferences cache, String subredditName,
|
||||||
int postType, SortType sortType, PostFilter postFilter,
|
int postType, SortType sortType, PostFilter postFilter,
|
||||||
List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList) {
|
List<ReadPost> readPostList) {
|
||||||
postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, accountName,
|
postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, accountName,
|
||||||
sharedPreferences, cache, subredditName, postType, sortType, postFilter,
|
sharedPreferences, cache, subredditName, postType, sortType, postFilter,
|
||||||
readPostList, subredditFilterList);
|
readPostList);
|
||||||
|
|
||||||
initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(),
|
initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(),
|
||||||
PostDataSource::getInitialLoadStateLiveData);
|
PostDataSource::getInitialLoadStateLiveData);
|
||||||
@ -213,7 +212,6 @@ public class PostViewModel extends ViewModel {
|
|||||||
private PostFilter postFilter;
|
private PostFilter postFilter;
|
||||||
private String userWhere;
|
private String userWhere;
|
||||||
private List<ReadPost> readPostList;
|
private List<ReadPost> readPostList;
|
||||||
private List<SubredditFilter> subredditFilterList;
|
|
||||||
|
|
||||||
public Factory(Retrofit retrofit, String accessToken, String accountName,
|
public Factory(Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
|
||||||
@ -245,25 +243,6 @@ public class PostViewModel extends ViewModel {
|
|||||||
this.readPostList = readPostList;
|
this.readPostList = readPostList;
|
||||||
}
|
}
|
||||||
|
|
||||||
//With subreddit filter
|
|
||||||
public Factory(Retrofit retrofit, String accessToken, String accountName,
|
|
||||||
SharedPreferences sharedPreferences,
|
|
||||||
SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditName,
|
|
||||||
int postType, SortType sortType, PostFilter postFilter,
|
|
||||||
List<ReadPost> readPostList, List<SubredditFilter> subredditFilterList) {
|
|
||||||
this.retrofit = retrofit;
|
|
||||||
this.accessToken = accessToken;
|
|
||||||
this.accountName = accountName;
|
|
||||||
this.sharedPreferences = sharedPreferences;
|
|
||||||
this.postFeedScrolledPositionSharedPreferences = postFeedScrolledPositionSharedPreferences;
|
|
||||||
this.subredditName = subredditName;
|
|
||||||
this.postType = postType;
|
|
||||||
this.sortType = sortType;
|
|
||||||
this.postFilter = postFilter;
|
|
||||||
this.readPostList = readPostList;
|
|
||||||
this.subredditFilterList = subredditFilterList;
|
|
||||||
}
|
|
||||||
|
|
||||||
//User posts
|
//User posts
|
||||||
public Factory(Retrofit retrofit, String accessToken, String accountName,
|
public Factory(Retrofit retrofit, String accessToken, String accountName,
|
||||||
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditName,
|
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences, String subredditName,
|
||||||
@ -310,7 +289,7 @@ public class PostViewModel extends ViewModel {
|
|||||||
} else if (postType == PostDataSource.TYPE_SUBREDDIT || postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
} else if (postType == PostDataSource.TYPE_SUBREDDIT || postType == PostDataSource.TYPE_MULTI_REDDIT) {
|
||||||
return (T) new PostViewModel(retrofit, accessToken, accountName, sharedPreferences,
|
return (T) new PostViewModel(retrofit, accessToken, accountName, sharedPreferences,
|
||||||
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
|
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
|
||||||
postFilter, readPostList, subredditFilterList);
|
postFilter, readPostList);
|
||||||
} else {
|
} else {
|
||||||
return (T) new PostViewModel(retrofit, accessToken, accountName, sharedPreferences,
|
return (T) new PostViewModel(retrofit, accessToken, accountName, sharedPreferences,
|
||||||
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
|
postFeedScrolledPositionSharedPreferences, subredditName, postType, sortType,
|
||||||
|
@ -9,6 +9,7 @@ import androidx.room.Entity;
|
|||||||
import androidx.room.Ignore;
|
import androidx.room.Ignore;
|
||||||
import androidx.room.PrimaryKey;
|
import androidx.room.PrimaryKey;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -167,6 +168,60 @@ public class PostFilter implements Parcelable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PostFilter mergePostFilter(List<PostFilter> postFilterList) {
|
||||||
|
PostFilter postFilter = new PostFilter();
|
||||||
|
if (postFilterList.size() == 1) {
|
||||||
|
return postFilterList.get(0);
|
||||||
|
}
|
||||||
|
StringBuilder stringBuilder;
|
||||||
|
postFilter.name = "Merged";
|
||||||
|
for (PostFilter p : postFilterList) {
|
||||||
|
postFilter.maxVote = Math.min(p.maxVote, postFilter.maxVote);
|
||||||
|
postFilter.minVote = Math.max(p.minVote, postFilter.minVote);
|
||||||
|
postFilter.maxComments = Math.min(p.maxComments, postFilter.maxComments);
|
||||||
|
postFilter.minComments = Math.max(p.minComments, postFilter.minComments);
|
||||||
|
postFilter.maxAwards = Math.min(p.maxAwards, postFilter.maxAwards);
|
||||||
|
postFilter.minAwards = Math.max(p.minAwards, postFilter.minAwards);
|
||||||
|
|
||||||
|
postFilter.onlyNSFW = p.onlyNSFW ? p.onlyNSFW : postFilter.onlyNSFW;
|
||||||
|
postFilter.onlySpoiler = p.onlySpoiler ? p.onlySpoiler : postFilter.onlySpoiler;
|
||||||
|
|
||||||
|
postFilter.postTitleExcludesRegex = p.postTitleExcludesRegex.equals("") ? postFilter.postTitleExcludesRegex : p.postTitleExcludesRegex;
|
||||||
|
stringBuilder = new StringBuilder(postFilter.postTitleExcludesStrings);
|
||||||
|
stringBuilder.append(",").append(p.postTitleExcludesStrings);
|
||||||
|
postFilter.postTitleExcludesStrings = stringBuilder.toString();
|
||||||
|
|
||||||
|
postFilter.excludeSubreddits = p.excludeSubreddits.equals("") ? postFilter.excludeSubreddits : p.postTitleExcludesRegex;
|
||||||
|
stringBuilder = new StringBuilder(postFilter.excludeSubreddits);
|
||||||
|
stringBuilder.append(",").append(p.excludeSubreddits);
|
||||||
|
postFilter.excludeSubreddits = stringBuilder.toString();
|
||||||
|
|
||||||
|
postFilter.excludeUsers = p.excludeUsers.equals("") ? postFilter.excludeUsers : p.postTitleExcludesRegex;
|
||||||
|
stringBuilder = new StringBuilder(postFilter.excludeUsers);
|
||||||
|
stringBuilder.append(",").append(p.excludeUsers);
|
||||||
|
postFilter.excludeUsers = stringBuilder.toString();
|
||||||
|
|
||||||
|
postFilter.containFlairs = p.containFlairs.equals("") ? postFilter.containFlairs : p.postTitleExcludesRegex;
|
||||||
|
stringBuilder = new StringBuilder(postFilter.containFlairs);
|
||||||
|
stringBuilder.append(",").append(p.containFlairs);
|
||||||
|
postFilter.containFlairs = stringBuilder.toString();
|
||||||
|
|
||||||
|
postFilter.excludeFlairs = p.excludeFlairs.equals("") ? postFilter.excludeFlairs : p.postTitleExcludesRegex;
|
||||||
|
stringBuilder = new StringBuilder(postFilter.excludeFlairs);
|
||||||
|
stringBuilder.append(",").append(p.excludeFlairs);
|
||||||
|
postFilter.excludeFlairs = stringBuilder.toString();
|
||||||
|
|
||||||
|
postFilter.containTextType = p.containTextType || postFilter.containTextType;
|
||||||
|
postFilter.containLinkType = p.containLinkType || postFilter.containLinkType;
|
||||||
|
postFilter.containImageType = p.containImageType || postFilter.containImageType;
|
||||||
|
postFilter.containGifType = p.containGifType || postFilter.containGifType;
|
||||||
|
postFilter.containVideoType = p.containVideoType || postFilter.containVideoType;
|
||||||
|
postFilter.containGalleryType = p.containGalleryType || postFilter.containGalleryType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return postFilter;
|
||||||
|
}
|
||||||
|
|
||||||
protected PostFilter(Parcel in) {
|
protected PostFilter(Parcel in) {
|
||||||
name = in.readString();
|
name = in.readString();
|
||||||
maxVote = in.readInt();
|
maxVote = in.readInt();
|
||||||
|
@ -25,4 +25,7 @@ public interface PostFilterDao {
|
|||||||
|
|
||||||
@Query("SELECT * FROM post_filter")
|
@Query("SELECT * FROM post_filter")
|
||||||
LiveData<List<PostFilter>> getAllPostFiltersLiveData();
|
LiveData<List<PostFilter>> getAllPostFiltersLiveData();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM post_filter WHERE post_filter.name IN (SELECT post_filter_usage.name FROM post_filter_usage WHERE usage = :usage AND name_of_usage = :nameOfUsage)")
|
||||||
|
List<PostFilter> getValidPostFilters(int usage, String nameOfUsage);
|
||||||
}
|
}
|
||||||
|
@ -5,49 +5,42 @@ import android.os.AsyncTask;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.subredditfilter.SubredditFilter;
|
|
||||||
|
|
||||||
public class FetchReadPosts {
|
public class FetchReadPosts {
|
||||||
|
|
||||||
public interface FetchReadPostsListener {
|
public interface FetchReadPostsListener {
|
||||||
void success(ArrayList<ReadPost> readPosts, ArrayList<SubredditFilter> subredditFilters);
|
void success(ArrayList<ReadPost> readPosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fetchReadPosts(RedditDataRoomDatabase redditDataRoomDatabase, String username,
|
public static void fetchReadPosts(RedditDataRoomDatabase redditDataRoomDatabase, String username,
|
||||||
boolean fetchSubredditFilter, FetchReadPostsListener fetchReadPostsListener) {
|
FetchReadPostsListener fetchReadPostsListener) {
|
||||||
new FetchAllReadPostsAsyncTask(redditDataRoomDatabase, username, fetchSubredditFilter, fetchReadPostsListener).execute();
|
new FetchAllReadPostsAsyncTask(redditDataRoomDatabase, username, fetchReadPostsListener).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FetchAllReadPostsAsyncTask extends AsyncTask<Void, Void, Void> {
|
private static class FetchAllReadPostsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
private RedditDataRoomDatabase redditDataRoomDatabase;
|
private RedditDataRoomDatabase redditDataRoomDatabase;
|
||||||
private String username;
|
private String username;
|
||||||
private boolean fetchSubredditFilter;
|
|
||||||
private FetchReadPostsListener fetchReadPostsListener;
|
private FetchReadPostsListener fetchReadPostsListener;
|
||||||
private ArrayList<ReadPost> readPosts;
|
private ArrayList<ReadPost> readPosts;
|
||||||
private ArrayList<SubredditFilter> subredditFilters;
|
|
||||||
|
|
||||||
private FetchAllReadPostsAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, String username,
|
private FetchAllReadPostsAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, String username,
|
||||||
boolean fetchSubredditFilter, FetchReadPostsListener fetchReadPostsListener) {
|
FetchReadPostsListener fetchReadPostsListener) {
|
||||||
this.redditDataRoomDatabase = redditDataRoomDatabase;
|
this.redditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.fetchSubredditFilter = fetchSubredditFilter;
|
|
||||||
this.fetchReadPostsListener = fetchReadPostsListener;
|
this.fetchReadPostsListener = fetchReadPostsListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
readPosts = (ArrayList<ReadPost>) redditDataRoomDatabase.readPostDao().getAllReadPosts(username);
|
readPosts = (ArrayList<ReadPost>) redditDataRoomDatabase.readPostDao().getAllReadPosts(username);
|
||||||
if (fetchSubredditFilter) {
|
|
||||||
subredditFilters = (ArrayList<SubredditFilter>) redditDataRoomDatabase.subredditFilterDao().getAllSubredditFilters();
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(Void aVoid) {
|
||||||
super.onPostExecute(aVoid);
|
super.onPostExecute(aVoid);
|
||||||
fetchReadPostsListener.success(readPosts, subredditFilters);
|
fetchReadPostsListener.success(readPosts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
package ml.docilealligator.infinityforreddit.settings;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.activities.SubredditFilterPopularAndAllActivity;
|
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
|
||||||
|
|
||||||
public class FilterPreferenceFragment extends PreferenceFragmentCompat {
|
|
||||||
|
|
||||||
private Activity activity;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
|
||||||
setPreferencesFromResource(R.xml.filter_preferences, rootKey);
|
|
||||||
|
|
||||||
Preference subredditFilterPopularAndAllPreference = findPreference(SharedPreferencesUtils.SUBREDDIT_FILTER_POPULAR_AND_ALL);
|
|
||||||
|
|
||||||
subredditFilterPopularAndAllPreference.setOnPreferenceClickListener(preference -> {
|
|
||||||
Intent intent = new Intent(activity, SubredditFilterPopularAndAllActivity.class);
|
|
||||||
activity.startActivity(intent);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(@NonNull Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
activity = (Activity) context;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package ml.docilealligator.infinityforreddit.subredditfilter;
|
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|
||||||
|
|
||||||
public class DeleteSubredditFilter {
|
|
||||||
public interface DeleteSubredditFilterListener {
|
|
||||||
void success();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void deleteSubredditFilter(RedditDataRoomDatabase redditDataRoomDatabase, SubredditFilter subredditFilter,
|
|
||||||
DeleteSubredditFilterListener deleteSubredditFilterListener) {
|
|
||||||
new DeleteSubredditFilterAsyncTask(redditDataRoomDatabase, subredditFilter, deleteSubredditFilterListener).execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class DeleteSubredditFilterAsyncTask extends AsyncTask<Void, Void, Void> {
|
|
||||||
private RedditDataRoomDatabase redditDataRoomDatabase;
|
|
||||||
private SubredditFilter subredditFilter;
|
|
||||||
private DeleteSubredditFilterListener deleteSubredditFilterListener;
|
|
||||||
|
|
||||||
DeleteSubredditFilterAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, SubredditFilter subredditFilter,
|
|
||||||
DeleteSubredditFilterListener deleteSubredditFilterListener) {
|
|
||||||
this.redditDataRoomDatabase = redditDataRoomDatabase;
|
|
||||||
this.subredditFilter = subredditFilter;
|
|
||||||
this.deleteSubredditFilterListener = deleteSubredditFilterListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Void doInBackground(Void... voids) {
|
|
||||||
redditDataRoomDatabase.subredditFilterDao().deleteSubredditFilter(subredditFilter);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(Void aVoid) {
|
|
||||||
super.onPostExecute(aVoid);
|
|
||||||
deleteSubredditFilterListener.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package ml.docilealligator.infinityforreddit.subredditfilter;
|
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|
||||||
|
|
||||||
public class FetchSubredditFilters {
|
|
||||||
public interface FetchSubredditFiltersListener {
|
|
||||||
void success(ArrayList<SubredditFilter>subredditFilters);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fetchSubredditFilters(RedditDataRoomDatabase redditDataRoomDatabase,
|
|
||||||
FetchSubredditFiltersListener fetchSubredditFiltersListener) {
|
|
||||||
new FetchSubredditFiltersAsyncTask(redditDataRoomDatabase, fetchSubredditFiltersListener).execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class FetchSubredditFiltersAsyncTask extends AsyncTask<Void, Void, Void> {
|
|
||||||
private RedditDataRoomDatabase redditDataRoomDatabase;
|
|
||||||
private ArrayList<SubredditFilter> subredditFilters;
|
|
||||||
private FetchSubredditFiltersListener fetchSubredditFiltersListener;
|
|
||||||
|
|
||||||
FetchSubredditFiltersAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase,
|
|
||||||
FetchSubredditFiltersListener fetchSubredditFiltersListener) {
|
|
||||||
this.redditDataRoomDatabase = redditDataRoomDatabase;
|
|
||||||
this.fetchSubredditFiltersListener = fetchSubredditFiltersListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Void doInBackground(Void... voids) {
|
|
||||||
subredditFilters = (ArrayList<SubredditFilter>) redditDataRoomDatabase.subredditFilterDao().getAllSubredditFilters();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(Void aVoid) {
|
|
||||||
super.onPostExecute(aVoid);
|
|
||||||
fetchSubredditFiltersListener.success(subredditFilters);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package ml.docilealligator.infinityforreddit.subredditfilter;
|
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|
||||||
|
|
||||||
public class InsertSubredditFilter {
|
|
||||||
public interface InsertSubredditFilterListener {
|
|
||||||
void success();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void insertSubredditFilter(RedditDataRoomDatabase redditDataRoomDatabase, SubredditFilter subredditFilter,
|
|
||||||
InsertSubredditFilterListener insertSubredditFilterListener) {
|
|
||||||
new InsertSubredditFilterAsyncTask(redditDataRoomDatabase, subredditFilter, insertSubredditFilterListener).execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class InsertSubredditFilterAsyncTask extends AsyncTask<Void, Void, Void> {
|
|
||||||
private RedditDataRoomDatabase redditDataRoomDatabase;
|
|
||||||
private SubredditFilter subredditFilter;
|
|
||||||
private InsertSubredditFilterListener insertSubredditFilterListener;
|
|
||||||
|
|
||||||
InsertSubredditFilterAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, SubredditFilter subredditFilter,
|
|
||||||
InsertSubredditFilterListener insertSubredditFilterListener) {
|
|
||||||
this.redditDataRoomDatabase = redditDataRoomDatabase;
|
|
||||||
this.subredditFilter = subredditFilter;
|
|
||||||
this.insertSubredditFilterListener = insertSubredditFilterListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Void doInBackground(Void... voids) {
|
|
||||||
redditDataRoomDatabase.subredditFilterDao().insert(subredditFilter);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(Void aVoid) {
|
|
||||||
super.onPostExecute(aVoid);
|
|
||||||
insertSubredditFilterListener.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
package ml.docilealligator.infinityforreddit.subredditfilter;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.room.ColumnInfo;
|
|
||||||
import androidx.room.Entity;
|
|
||||||
|
|
||||||
@Entity(tableName = "subreddit_filter", primaryKeys = {"subreddit_name", "type"})
|
|
||||||
public class SubredditFilter implements Parcelable {
|
|
||||||
public static int TYPE_POPULAR_AND_ALL = 0;
|
|
||||||
@NonNull
|
|
||||||
@ColumnInfo(name = "subreddit_name")
|
|
||||||
private String subredditName;
|
|
||||||
@ColumnInfo(name = "type")
|
|
||||||
private int type;
|
|
||||||
|
|
||||||
public SubredditFilter(@NonNull String subredditName, int type) {
|
|
||||||
this.subredditName = subredditName;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SubredditFilter(Parcel in) {
|
|
||||||
subredditName = in.readString();
|
|
||||||
type = in.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<SubredditFilter> CREATOR = new Creator<SubredditFilter>() {
|
|
||||||
@Override
|
|
||||||
public SubredditFilter createFromParcel(Parcel in) {
|
|
||||||
return new SubredditFilter(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubredditFilter[] newArray(int size) {
|
|
||||||
return new SubredditFilter[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public String getSubredditName() {
|
|
||||||
return subredditName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubredditName(@NonNull String subredditName) {
|
|
||||||
this.subredditName = subredditName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(int type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel parcel, int i) {
|
|
||||||
parcel.writeString(subredditName);
|
|
||||||
parcel.writeInt(type);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package ml.docilealligator.infinityforreddit.subredditfilter;
|
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
|
||||||
import androidx.room.Dao;
|
|
||||||
import androidx.room.Delete;
|
|
||||||
import androidx.room.Insert;
|
|
||||||
import androidx.room.OnConflictStrategy;
|
|
||||||
import androidx.room.Query;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Dao
|
|
||||||
public interface SubredditFilterDao {
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
|
||||||
void insert(SubredditFilter subredditFilter);
|
|
||||||
|
|
||||||
@Query("SELECT * FROM subreddit_filter")
|
|
||||||
LiveData<List<SubredditFilter>> getAllSubredditFiltersLiveData();
|
|
||||||
|
|
||||||
@Query("SELECT * FROM subreddit_filter")
|
|
||||||
List<SubredditFilter> getAllSubredditFilters();
|
|
||||||
|
|
||||||
@Delete
|
|
||||||
void deleteSubredditFilter(SubredditFilter subredditFilter);
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
package ml.docilealligator.infinityforreddit.subredditfilter;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.lifecycle.LiveData;
|
|
||||||
import androidx.lifecycle.ViewModel;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
|
||||||
|
|
||||||
public class SubredditFilterViewModel extends ViewModel {
|
|
||||||
private LiveData<List<SubredditFilter>> subredditFilterLiveData;
|
|
||||||
|
|
||||||
public SubredditFilterViewModel(RedditDataRoomDatabase redditDataRoomDatabase) {
|
|
||||||
subredditFilterLiveData = redditDataRoomDatabase.subredditFilterDao().getAllSubredditFiltersLiveData();
|
|
||||||
}
|
|
||||||
|
|
||||||
public LiveData<List<SubredditFilter>> getSubredditFilterLiveData() {
|
|
||||||
return subredditFilterLiveData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Factory extends ViewModelProvider.NewInstanceFactory {
|
|
||||||
private RedditDataRoomDatabase redditDataRoomDatabase;
|
|
||||||
|
|
||||||
public Factory(RedditDataRoomDatabase redditDataRoomDatabase) {
|
|
||||||
this.redditDataRoomDatabase = redditDataRoomDatabase;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
|
||||||
return (T) new SubredditFilterViewModel(redditDataRoomDatabase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/coordinator_layout_subreddit_filter_popular_and_all_activity"
|
|
||||||
tools:context=".activities.SubredditFilterPopularAndAllActivity">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
|
||||||
android:id="@+id/appbar_layout_subreddit_filter_popular_and_all_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
|
||||||
android:id="@+id/collapsing_toolbar_layout_subreddit_filter_popular_and_all_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layout_scrollFlags="scroll|enterAlways"
|
|
||||||
app:titleEnabled="false"
|
|
||||||
app:toolbarId="@+id/toolbar_subreddit_filter_popular_and_all_activity">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar_subreddit_filter_popular_and_all_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:minHeight="?attr/actionBarSize"
|
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
|
||||||
app:navigationIcon="?attr/homeAsUpIndicator" />
|
|
||||||
|
|
||||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view_subreddit_filter_popular_and_all_activity"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/fab_subreddit_filter_popular_and_all_activity"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="@dimen/fab_margin"
|
|
||||||
android:layout_gravity="bottom|end"
|
|
||||||
app:backgroundTint="?attr/colorPrimaryLightTheme"
|
|
||||||
app:srcCompat="@drawable/ic_add_day_night_24dp"
|
|
||||||
app:tint="@android:color/white" />
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
app:icon="@drawable/ic_info_preference_24dp"
|
|
||||||
app:summary="@string/restart_app_see_changes"
|
|
||||||
app:enabled="false" />
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
app:title="@string/settings_subreddit_filter_category" />
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
app:key="subreddit_filter_popular_and_all"
|
|
||||||
app:title="@string/settings_subreddit_filter_popular_and_all" />
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
Loading…
Reference in New Issue
Block a user