Added empty state text to updates/installed apps.
Both of these reuse the text that was used in 0.102.
This commit is contained in:
parent
854b19eee6
commit
6891752672
@ -32,6 +32,7 @@ import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.R;
|
||||
@ -43,6 +44,8 @@ import org.fdroid.fdroid.views.apps.AppListItemController;
|
||||
public class InstalledAppsActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
private InstalledAppListAdapter adapter;
|
||||
private RecyclerView appList;
|
||||
private TextView emptyState;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -59,10 +62,12 @@ public class InstalledAppsActivity extends AppCompatActivity implements LoaderMa
|
||||
|
||||
adapter = new InstalledAppListAdapter(this);
|
||||
|
||||
RecyclerView appList = (RecyclerView) findViewById(R.id.app_list);
|
||||
appList = (RecyclerView) findViewById(R.id.app_list);
|
||||
appList.setHasFixedSize(true);
|
||||
appList.setLayoutManager(new LinearLayoutManager(this));
|
||||
appList.setAdapter(adapter);
|
||||
|
||||
emptyState = (TextView) findViewById(R.id.empty_state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,6 +90,14 @@ public class InstalledAppsActivity extends AppCompatActivity implements LoaderMa
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
|
||||
adapter.setApps(cursor);
|
||||
|
||||
if (adapter.getItemCount() == 0) {
|
||||
appList.setVisibility(View.GONE);
|
||||
emptyState.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
appList.setVisibility(View.VISIBLE);
|
||||
emptyState.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,22 +5,28 @@ import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
public class UpdatesViewBinder {
|
||||
|
||||
private final UpdatesAdapter adapter;
|
||||
private final RecyclerView list;
|
||||
private final TextView emptyState;
|
||||
|
||||
public UpdatesViewBinder(AppCompatActivity activity, FrameLayout parent) {
|
||||
View view = activity.getLayoutInflater().inflate(R.layout.main_tab_updates, parent, true);
|
||||
|
||||
adapter = new UpdatesAdapter(activity);
|
||||
adapter.registerAdapterDataObserver(adapterChangeListener);
|
||||
|
||||
RecyclerView list = (RecyclerView) view.findViewById(R.id.list);
|
||||
list = (RecyclerView) view.findViewById(R.id.list);
|
||||
list.setHasFixedSize(true);
|
||||
list.setLayoutManager(new LinearLayoutManager(activity));
|
||||
list.setAdapter(adapter);
|
||||
|
||||
emptyState = (TextView) view.findViewById(R.id.empty_state);
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
@ -30,4 +36,32 @@ public class UpdatesViewBinder {
|
||||
public void unbind() {
|
||||
adapter.stopListeningForStatusUpdates();
|
||||
}
|
||||
|
||||
private void updateEmptyState() {
|
||||
if (adapter.getItemCount() == 0) {
|
||||
list.setVisibility(View.GONE);
|
||||
emptyState.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
list.setVisibility(View.VISIBLE);
|
||||
emptyState.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
private final RecyclerView.AdapterDataObserver adapterChangeListener = new RecyclerView.AdapterDataObserver() {
|
||||
@Override
|
||||
public void onChanged() {
|
||||
updateEmptyState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRangeInserted(int positionStart, int itemCount) {
|
||||
updateEmptyState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRangeRemoved(int positionStart, int itemCount) {
|
||||
updateEmptyState();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -16,6 +16,18 @@
|
||||
app:theme="?attr/actionBarTheme"
|
||||
app:popupTheme="?attr/actionBarPopupTheme" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_state"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/toolbar"
|
||||
style="@style/AppListEmptyText"
|
||||
android:visibility="gone"
|
||||
android:text="@string/empty_installed_app_list" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/app_list"
|
||||
android:layout_width="0dp"
|
||||
|
@ -5,6 +5,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_state"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
style="@style/AppListEmptyText"
|
||||
android:visibility="gone"
|
||||
android:text="@string/empty_can_update_app_list" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
tools:listitem="@layout/app_list_item"
|
||||
|
Loading…
x
Reference in New Issue
Block a user