Show loading progress bar in catalogue
This commit is contained in:
parent
991e4d40d0
commit
19eeb18d0d
@ -58,6 +58,7 @@ public class CatalogueListPresenter extends BasePresenter {
|
||||
initializeSearch();
|
||||
initializeMangaDetailsLoader();
|
||||
|
||||
view.showProgressBar();
|
||||
getMangasFromSource(1);
|
||||
}
|
||||
|
||||
@ -154,6 +155,7 @@ public class CatalogueListPresenter extends BasePresenter {
|
||||
.map(this::networkToLocalManga)
|
||||
.toList()
|
||||
.subscribe(newMangas -> {
|
||||
view.hideProgressBar();
|
||||
adapter.addItems(newMangas);
|
||||
if (mMangaDetailPublishSubject != null)
|
||||
mMangaDetailPublishSubject.onNext(Observable.just(newMangas));
|
||||
@ -174,7 +176,6 @@ public class CatalogueListPresenter extends BasePresenter {
|
||||
mSearchViewPublishSubject.onNext(Observable.just(query));
|
||||
}
|
||||
|
||||
|
||||
private void queryFromSearch(String query) {
|
||||
// If search button clicked
|
||||
if (mSearchName.equals("") && query.equals("")) {
|
||||
@ -191,11 +192,15 @@ public class CatalogueListPresenter extends BasePresenter {
|
||||
|
||||
mSearchName = query;
|
||||
adapter.getItems().clear();
|
||||
view.showProgressBar();
|
||||
view.resetScrollListener();
|
||||
loadMoreMangas(1);
|
||||
}
|
||||
|
||||
public void loadMoreMangas(int page) {
|
||||
if (page > 1) {
|
||||
view.showGridProgressBar();
|
||||
}
|
||||
if (mSearchMode) {
|
||||
getMangasFromSearch(page);
|
||||
} else {
|
||||
|
@ -7,6 +7,7 @@ import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
@ -24,6 +25,12 @@ public class CatalogueListActivity extends BaseActivity implements CatalogueList
|
||||
@Bind(R.id.gridView)
|
||||
GridView manga_list;
|
||||
|
||||
@Bind(R.id.progress)
|
||||
ProgressBar progress;
|
||||
|
||||
@Bind(R.id.progress_grid)
|
||||
ProgressBar progress_grid;
|
||||
|
||||
private CatalogueListPresenter presenter;
|
||||
|
||||
private EndlessScrollListener scrollListener;
|
||||
@ -100,6 +107,22 @@ public class CatalogueListActivity extends BaseActivity implements CatalogueList
|
||||
scrollListener.resetScroll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showProgressBar() {
|
||||
progress.setVisibility(ProgressBar.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showGridProgressBar() {
|
||||
progress_grid.setVisibility(ProgressBar.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideProgressBar() {
|
||||
progress.setVisibility(ProgressBar.GONE);
|
||||
progress_grid.setVisibility(ProgressBar.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageView getImageView(int position) {
|
||||
View v = manga_list.getChildAt(position -
|
||||
|
@ -11,5 +11,8 @@ public interface CatalogueListView extends BaseView {
|
||||
void setAdapter(EasyAdapter adapter);
|
||||
void setScrollListener();
|
||||
void resetScrollListener();
|
||||
void showProgressBar();
|
||||
void showGridProgressBar();
|
||||
void hideProgressBar();
|
||||
ImageView getImageView(int position);
|
||||
}
|
||||
|
@ -11,9 +11,18 @@
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/toolbar"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical|center_horizontal"
|
||||
android:visibility="gone" />
|
||||
|
||||
<GridView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/gridView"
|
||||
android:padding="10dp"
|
||||
android:clipToPadding="false"
|
||||
@ -25,4 +34,12 @@
|
||||
android:fastScrollEnabled="true"
|
||||
tools:listitem="@layout/item_catalogue" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_grid"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|center_horizontal"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user