mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +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();
|
||||
Bundle multiRedditBundle = new Bundle();
|
||||
multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||
multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
|
||||
multiRedditSortTypeBottomSheetFragment.setArguments(multiRedditBundle);
|
||||
break;
|
||||
case PostDataSource.TYPE_USER:
|
||||
|
@ -723,7 +723,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
} else {
|
||||
bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, false);
|
||||
}
|
||||
bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
|
||||
sortTypeBottomSheetFragment.setArguments(bundle);
|
||||
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
|
||||
return true;
|
||||
|
@ -164,7 +164,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
|
||||
Bundle bottomSheetBundle = new Bundle();
|
||||
bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
|
||||
bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
|
||||
sortTypeBottomSheetFragment.setArguments(bottomSheetBundle);
|
||||
|
||||
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
|
||||
|
@ -29,15 +29,12 @@ import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||
public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
||||
|
||||
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)
|
||||
TextView bestTypeTextView;
|
||||
@BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment)
|
||||
TextView hotTypeTextView;
|
||||
@BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment)
|
||||
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)
|
||||
TextView risingTypeTextView;
|
||||
@BindView(R.id.top_type_text_view_sort_type_bottom_sheet_fragment)
|
||||
@ -79,15 +76,6 @@ public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen
|
||||
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 -> {
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RISING));
|
||||
dismiss();
|
||||
|
@ -247,56 +247,38 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (sortType.getType().value.equals(SortType.Type.RANDOM.value)) {
|
||||
ParsePost.parsePost(response.body(), locale, new ParsePost.ParsePostListener() {
|
||||
@Override
|
||||
public void onParsePostSuccess(Post post) {
|
||||
ArrayList<Post> singlePostList = new ArrayList<>();
|
||||
singlePostList.add(post);
|
||||
callback.onResult(singlePostList, null, null);
|
||||
hasPostLiveData.postValue(true);
|
||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||
}
|
||||
|
||||
@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);
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParsePostsListingFail() {
|
||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
|
||||
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
|
||||
public void onParsePostsListingFail() {
|
||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED,
|
||||
"code: " + response.code() + " message: " + response.message()));
|
||||
@ -388,56 +370,38 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (sortType.getType().value.equals(SortType.Type.RANDOM.value)) {
|
||||
ParsePost.parsePost(response.body(), locale, new ParsePost.ParsePostListener() {
|
||||
@Override
|
||||
public void onParsePostSuccess(Post post) {
|
||||
ArrayList<Post> singlePostList = new ArrayList<>();
|
||||
singlePostList.add(post);
|
||||
callback.onResult(singlePostList, null, null);
|
||||
hasPostLiveData.postValue(true);
|
||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||
}
|
||||
|
||||
@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);
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParsePostsListingFail() {
|
||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
|
||||
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
|
||||
public void onParsePostsListingFail() {
|
||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED,
|
||||
"code: " + response + " message: " + response.message()));
|
||||
|
@ -68,25 +68,6 @@
|
||||
android:textSize="?attr/font_default"
|
||||
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
|
||||
android:id="@+id/rising_type_text_view_sort_type_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user