Add infinite progressbar before the first time apps are displayed

This commit is contained in:
Schoumi 2019-07-30 17:26:39 +02:00
parent a10cc837df
commit 93a8e57b09
2 changed files with 30 additions and 4 deletions

View File

@ -87,10 +87,6 @@ public class AppListFragment extends Fragment implements ComputeAppListTask.List
applistBinding.appList.setLayoutManager(new LinearLayoutManager(context));
if (packageManager != null) {
if(startupRefresh) {
startRefresh();
startupRefresh = false;
}
applistBinding.noPackageManager.setVisibility(View.GONE);
adapter = new ApplicationListAdapter(context, onAppClickListener);
applistBinding.appList.setAdapter(adapter);
@ -182,6 +178,10 @@ public class AppListFragment extends Fragment implements ComputeAppListTask.List
private void displayAppListAsync() {
applistBinding.noAppFound.setVisibility(View.GONE);
if (applications.isEmpty()) {
applistBinding.retrieveApp.setVisibility(View.VISIBLE);
applistBinding.logo.setVisibility(View.VISIBLE);
}
new ComputeAppListTask(
new WeakReference<>(packageManager),
@ -193,9 +193,17 @@ public class AppListFragment extends Fragment implements ComputeAppListTask.List
@Override
public void onAppsComputed(List<ApplicationViewModel> apps) {
this.applications = apps;
applistBinding.retrieveApp.setVisibility(View.GONE);
applistBinding.logo.setVisibility(View.GONE);
applistBinding.noAppFound.setVisibility(apps.isEmpty() ? View.VISIBLE : View.GONE);
if(adapter != null) {
adapter.displayAppList(apps);
}
if(!apps.isEmpty()) {
if(startupRefresh) {
startRefresh();
startupRefresh = false;
}
}
}
}

View File

@ -57,6 +57,24 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/logo"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:src="@mipmap/ic_launcher"
android:layout_width="150dp"
android:layout_height="150dp" />
<ProgressBar
android:id="@+id/retrieve_app"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/logo" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"