android: Show a hint when the gamelist is empty

This commit is contained in:
FearlessTobi 2020-04-01 20:59:57 +02:00 committed by xperia64
parent 67c485a793
commit 889bd64386
3 changed files with 28 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
@ -22,6 +23,7 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
private GameAdapter mAdapter;
private RecyclerView mRecyclerView;
private TextView mTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -62,6 +64,7 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
@Override
public void refresh() {
mPresenter.refresh();
updateTextView();
}
@Override
@ -69,9 +72,15 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
if (mAdapter != null) {
mAdapter.swapCursor(games);
}
updateTextView();
}
private void updateTextView() {
mTextView.setVisibility(mAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
}
private void findViews(View root) {
mRecyclerView = root.findViewById(R.id.grid_games);
mTextView = root.findViewById(R.id.gamelist_empty_text);
}
}

View File

@ -9,13 +9,25 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/grid_games"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
tools:listitem="@layout/card_game"/>
android:layout_height="match_parent">
<TextView
android:id="@+id/gamelist_empty_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/empty_gamelist"
android:visibility="gone"
android:textSize="18sp"
android:gravity="center"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/grid_games"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/card_game" />
</RelativeLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</FrameLayout>

View File

@ -125,6 +125,7 @@
<string name="external_storage_not_mounted">The external storage needs to be available in order to use Citra</string>
<string name="select_dir">Select This Directory</string>
<string name="empty_gamelist">No files were found or no game directory has been selected yet.</string>
<!-- Software Keyboard -->
<string name="software_keyboard">Software Keyboard</string>