mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-02 14:27:10 +01:00
Remove code related to post sorty type Random.
This commit is contained in:
parent
11e1591fd4
commit
50de0d84c6
@ -252,7 +252,6 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
|
|||||||
multiRedditSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
multiRedditSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||||
Bundle multiRedditBundle = new Bundle();
|
Bundle multiRedditBundle = new Bundle();
|
||||||
multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||||
multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
|
|
||||||
multiRedditSortTypeBottomSheetFragment.setArguments(multiRedditBundle);
|
multiRedditSortTypeBottomSheetFragment.setArguments(multiRedditBundle);
|
||||||
break;
|
break;
|
||||||
case PostDataSource.TYPE_USER:
|
case PostDataSource.TYPE_USER:
|
||||||
|
@ -723,7 +723,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
} else {
|
} else {
|
||||||
bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, false);
|
bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, false);
|
||||||
}
|
}
|
||||||
bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
|
|
||||||
sortTypeBottomSheetFragment.setArguments(bundle);
|
sortTypeBottomSheetFragment.setArguments(bundle);
|
||||||
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
|
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
|
||||||
return true;
|
return true;
|
||||||
|
@ -164,7 +164,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||||
Bundle bottomSheetBundle = new Bundle();
|
Bundle bottomSheetBundle = new Bundle();
|
||||||
bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||||
bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
|
|
||||||
sortTypeBottomSheetFragment.setArguments(bottomSheetBundle);
|
sortTypeBottomSheetFragment.setArguments(bottomSheetBundle);
|
||||||
|
|
||||||
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
|
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
|
||||||
|
@ -29,15 +29,12 @@ import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
|||||||
public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
||||||
|
|
||||||
public static final String EXTRA_NO_BEST_TYPE = "ENBT";
|
public static final String EXTRA_NO_BEST_TYPE = "ENBT";
|
||||||
public static final String EXTRA_NO_RANDOM_TYPE = "ENRT";
|
|
||||||
@BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment)
|
||||||
TextView bestTypeTextView;
|
TextView bestTypeTextView;
|
||||||
@BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment)
|
||||||
TextView hotTypeTextView;
|
TextView hotTypeTextView;
|
||||||
@BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment)
|
||||||
TextView newTypeTextView;
|
TextView newTypeTextView;
|
||||||
@BindView(R.id.random_type_text_view_sort_type_bottom_sheet_fragment)
|
|
||||||
TextView randomTypeTextView;
|
|
||||||
@BindView(R.id.rising_type_text_view_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.rising_type_text_view_sort_type_bottom_sheet_fragment)
|
||||||
TextView risingTypeTextView;
|
TextView risingTypeTextView;
|
||||||
@BindView(R.id.top_type_text_view_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.top_type_text_view_sort_type_bottom_sheet_fragment)
|
||||||
@ -79,15 +76,6 @@ public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen
|
|||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (getArguments() == null || (getArguments().containsKey(EXTRA_NO_RANDOM_TYPE) && getArguments().getBoolean(EXTRA_NO_RANDOM_TYPE))) {
|
|
||||||
randomTypeTextView.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
randomTypeTextView.setOnClickListener(view -> {
|
|
||||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RANDOM));
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
risingTypeTextView.setOnClickListener(view -> {
|
risingTypeTextView.setOnClickListener(view -> {
|
||||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RISING));
|
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RISING));
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -247,56 +247,38 @@ 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()) {
|
||||||
if (sortType.getType().value.equals(SortType.Type.RANDOM.value)) {
|
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
|
||||||
ParsePost.parsePost(response.body(), locale, new ParsePost.ParsePostListener() {
|
new ParsePost.ParsePostsListingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onParsePostSuccess(Post post) {
|
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
|
||||||
ArrayList<Post> singlePostList = new ArrayList<>();
|
String nextPageKey;
|
||||||
singlePostList.add(post);
|
if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
|
||||||
callback.onResult(singlePostList, null, null);
|
nextPageKey = null;
|
||||||
hasPostLiveData.postValue(true);
|
} else {
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
nextPageKey = lastItem;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onParsePostFail() {
|
|
||||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing data"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
|
|
||||||
new ParsePost.ParsePostsListingListener() {
|
|
||||||
@Override
|
|
||||||
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
|
|
||||||
String nextPageKey;
|
|
||||||
if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
|
|
||||||
nextPageKey = null;
|
|
||||||
} else {
|
|
||||||
nextPageKey = lastItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newPosts.size() != 0) {
|
|
||||||
postLinkedHashSet.addAll(newPosts);
|
|
||||||
callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
|
|
||||||
hasPostLiveData.postValue(true);
|
|
||||||
} else if (nextPageKey != null) {
|
|
||||||
loadBestPostsInitial(callback, nextPageKey);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
postLinkedHashSet.addAll(newPosts);
|
|
||||||
callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
|
|
||||||
hasPostLiveData.postValue(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if (newPosts.size() != 0) {
|
||||||
public void onParsePostsListingFail() {
|
postLinkedHashSet.addAll(newPosts);
|
||||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
|
callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
|
||||||
|
hasPostLiveData.postValue(true);
|
||||||
|
} else if (nextPageKey != null) {
|
||||||
|
loadBestPostsInitial(callback, nextPageKey);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
postLinkedHashSet.addAll(newPosts);
|
||||||
|
callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
|
||||||
|
hasPostLiveData.postValue(false);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onParsePostsListingFail() {
|
||||||
|
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED,
|
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED,
|
||||||
"code: " + response.code() + " message: " + response.message()));
|
"code: " + response.code() + " message: " + response.message()));
|
||||||
@ -388,56 +370,38 @@ 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()) {
|
||||||
if (sortType.getType().value.equals(SortType.Type.RANDOM.value)) {
|
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
|
||||||
ParsePost.parsePost(response.body(), locale, new ParsePost.ParsePostListener() {
|
new ParsePost.ParsePostsListingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onParsePostSuccess(Post post) {
|
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
|
||||||
ArrayList<Post> singlePostList = new ArrayList<>();
|
String nextPageKey;
|
||||||
singlePostList.add(post);
|
if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
|
||||||
callback.onResult(singlePostList, null, null);
|
nextPageKey = null;
|
||||||
hasPostLiveData.postValue(true);
|
} else {
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
nextPageKey = lastItem;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onParsePostFail() {
|
|
||||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing data"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
|
|
||||||
new ParsePost.ParsePostsListingListener() {
|
|
||||||
@Override
|
|
||||||
public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
|
|
||||||
String nextPageKey;
|
|
||||||
if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
|
|
||||||
nextPageKey = null;
|
|
||||||
} else {
|
|
||||||
nextPageKey = lastItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newPosts.size() != 0) {
|
|
||||||
postLinkedHashSet.addAll(newPosts);
|
|
||||||
callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
|
|
||||||
hasPostLiveData.postValue(true);
|
|
||||||
} else if (nextPageKey != null) {
|
|
||||||
loadSubredditPostsInitial(callback, nextPageKey);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
postLinkedHashSet.addAll(newPosts);
|
|
||||||
callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
|
|
||||||
hasPostLiveData.postValue(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if (newPosts.size() != 0) {
|
||||||
public void onParsePostsListingFail() {
|
postLinkedHashSet.addAll(newPosts);
|
||||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
|
callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
|
||||||
|
hasPostLiveData.postValue(true);
|
||||||
|
} else if (nextPageKey != null) {
|
||||||
|
loadSubredditPostsInitial(callback, nextPageKey);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
postLinkedHashSet.addAll(newPosts);
|
||||||
|
callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
|
||||||
|
hasPostLiveData.postValue(false);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onParsePostsListingFail() {
|
||||||
|
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED,
|
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED,
|
||||||
"code: " + response + " message: " + response.message()));
|
"code: " + response + " message: " + response.message()));
|
||||||
|
@ -68,25 +68,6 @@
|
|||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_default"
|
||||||
app:drawableTint="?attr/primaryTextColor" />
|
app:drawableTint="?attr/primaryTextColor" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/random_type_text_view_sort_type_bottom_sheet_fragment"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:clickable="true"
|
|
||||||
android:drawableStart="@drawable/ic_random_24"
|
|
||||||
android:drawablePadding="48dp"
|
|
||||||
android:focusable="true"
|
|
||||||
android:fontFamily="?attr/font_family"
|
|
||||||
android:paddingStart="32dp"
|
|
||||||
android:paddingTop="16dp"
|
|
||||||
android:paddingEnd="32dp"
|
|
||||||
android:paddingBottom="16dp"
|
|
||||||
android:text="@string/sort_random"
|
|
||||||
android:textColor="?attr/primaryTextColor"
|
|
||||||
android:textSize="?attr/font_default"
|
|
||||||
app:drawableTint="?attr/primaryTextColor" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/rising_type_text_view_sort_type_bottom_sheet_fragment"
|
android:id="@+id/rising_type_text_view_sort_type_bottom_sheet_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user