mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 07:41:51 +01:00
Simplify if/else
This commit is contained in:
parent
0febdfb715
commit
82ac2b3223
@ -125,31 +125,23 @@ public class CatalogueListPresenter extends BasePresenter {
|
|||||||
// If going to search mode
|
// If going to search mode
|
||||||
else if (mSearchName.equals("") && !query.equals("")) {
|
else if (mSearchName.equals("") && !query.equals("")) {
|
||||||
mSearchMode = true;
|
mSearchMode = true;
|
||||||
mSearchName = query;
|
|
||||||
adapter.setItems(new ArrayList<>());
|
|
||||||
getMangasFromSearch(1);
|
|
||||||
}
|
}
|
||||||
// If going to normal mode
|
// If going to normal mode
|
||||||
else if (!mSearchName.equals("") && query.equals("")) {
|
else if (!mSearchName.equals("") && query.equals("")) {
|
||||||
mSearchMode = false;
|
mSearchMode = false;
|
||||||
mSearchName = query;
|
|
||||||
adapter.setItems(new ArrayList<>());
|
|
||||||
getMangasFromSource(1);
|
|
||||||
}
|
|
||||||
// If query changes
|
|
||||||
else {
|
|
||||||
mSearchName = query;
|
|
||||||
adapter.setItems(new ArrayList<>());
|
|
||||||
getMangasFromSearch(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mSearchName = query;
|
||||||
|
adapter.getItems().clear();
|
||||||
|
loadMoreMangas(1);
|
||||||
view.setScrollListener();
|
view.setScrollListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadMoreMangas(int page) {
|
public void loadMoreMangas(int page) {
|
||||||
if (!mSearchMode) {
|
if (mSearchMode) {
|
||||||
getMangasFromSource(page);
|
|
||||||
} else {
|
|
||||||
getMangasFromSearch(page);
|
getMangasFromSearch(page);
|
||||||
|
} else {
|
||||||
|
getMangasFromSource(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ public abstract class Source {
|
|||||||
.flatMap(response -> Observable.just(parsePopularMangasFromHtml(response)));
|
.flatMap(response -> Observable.just(parsePopularMangasFromHtml(response)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get mangas from the source with a query
|
||||||
public Observable<List<Manga>> searchMangasFromNetwork(String query, int page) {
|
public Observable<List<Manga>> searchMangasFromNetwork(String query, int page) {
|
||||||
return mNetworkService
|
return mNetworkService
|
||||||
.getStringResponse(getSearchUrl(query, page), mNetworkService.NULL_CACHE_CONTROL, mRequestHeaders)
|
.getStringResponse(getSearchUrl(query, page), mNetworkService.NULL_CACHE_CONTROL, mRequestHeaders)
|
||||||
|
Loading…
Reference in New Issue
Block a user