Updated layout

This commit is contained in:
SSimco 2024-10-13 20:01:12 +03:00
parent deb307ef95
commit 47a4a43774
10 changed files with 32 additions and 12 deletions

View File

@ -14,6 +14,7 @@ import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
@ -58,7 +59,10 @@ public class GameAdapter extends ListAdapter<Game, GameAdapter.ViewHolder> {
@Override
public void submitList(@Nullable List<Game> list) {
orignalGameList = list;
if (filterText == null || filterText.isBlank() || orignalGameList == null) {
if (orignalGameList == null) {
orignalGameList = new ArrayList<>();
}
if (filterText == null || filterText.isBlank()) {
super.submitList(orignalGameList);
return;
}

View File

@ -37,7 +37,7 @@ public class GameDetailsFragment extends Fragment {
binding.titleDlc.setText(String.valueOf(game.dlc()));
binding.titleTimePlayed.setText(getTimePlayed(game));
binding.titleLastPlayed.setText(getLastPlayedDate(game));
binding.titleId.setText(String.valueOf(game.titleId()));
binding.titleId.setText(String.format("%016x", game.titleId()));
binding.titleRegion.setText(getRegionName(game));
NavigationUI.setupWithNavController(binding.gameDetailsToolbar, NavHostFragment.findNavController(this), new AppBarConfiguration.Builder().build());
return binding.getRoot();

View File

@ -24,11 +24,14 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.HashSet;
import info.cemu.Cemu.R;
import info.cemu.Cemu.databinding.FragmentGamesBinding;
import info.cemu.Cemu.emulation.EmulationActivity;
import info.cemu.Cemu.nativeinterface.NativeGameTitles;
import info.cemu.Cemu.nativeinterface.NativeGameTitles.Game;
import info.cemu.Cemu.nativeinterface.NativeSettings;
import info.cemu.Cemu.settings.SettingsActivity;
import info.cemu.Cemu.settings.SettingsFragment;
@ -38,10 +41,12 @@ public class GamesFragment extends Fragment {
private GameViewModel gameViewModel;
private boolean refreshing = false;
private final Handler handler = new Handler(Looper.getMainLooper());
private HashSet<String> currentGamePaths = new HashSet<>();
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
currentGamePaths = new HashSet<>(NativeSettings.getGamesPaths());
gameAdapter = new GameAdapter(game -> {
Intent intent = new Intent(getContext(), EmulationActivity.class);
intent.putExtra(EmulationActivity.LAUNCH_PATH, game.path());
@ -56,6 +61,11 @@ public class GamesFragment extends Fragment {
@Override
public void onResume() {
super.onResume();
var gamePaths = new HashSet<>(NativeSettings.getGamesPaths());
if (!currentGamePaths.equals(gamePaths)) {
currentGamePaths = gamePaths;
NativeGameTitles.reloadGameTitles();
}
}
@Override

View File

@ -39,6 +39,9 @@ public class NativeGameTitles {
if (!isFavorite && other.isFavorite) {
return 1;
}
if (name.equals(other.name)) {
return Long.compare(titleId, other.titleId);
}
return name.compareTo(other.name);
}
}

View File

@ -7,7 +7,7 @@ import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.checkbox.MaterialCheckBox;
import com.google.android.material.materialswitch.MaterialSwitch;
import info.cemu.Cemu.R;
import info.cemu.Cemu.guibasecomponents.RecyclerViewItem;
@ -16,13 +16,13 @@ import info.cemu.Cemu.nativeinterface.NativeGraphicPacks;
public class GraphicPackRecyclerViewItem implements RecyclerViewItem {
private static class GraphicPackViewHolder extends RecyclerView.ViewHolder {
TextView name;
MaterialCheckBox enableCheckBox;
MaterialSwitch enableToggle;
TextView description;
public GraphicPackViewHolder(View itemView) {
super(itemView);
name = itemView.findViewById(R.id.graphic_pack_name);
enableCheckBox = itemView.findViewById(R.id.graphic_pack_enable_checkbox);
enableToggle = itemView.findViewById(R.id.graphic_pack_enable_toggle);
description = itemView.findViewById(R.id.graphic_pack_description);
}
}
@ -48,7 +48,7 @@ public class GraphicPackRecyclerViewItem implements RecyclerViewItem {
} else {
graphicPackViewHolder.description.setText(R.string.graphic_pack_no_description);
}
graphicPackViewHolder.enableCheckBox.setChecked(graphicPack.isActive());
graphicPackViewHolder.enableCheckBox.addOnCheckedStateChangedListener((materialCheckBox, i) -> graphicPack.setActive(materialCheckBox.isChecked()));
graphicPackViewHolder.enableToggle.setChecked(graphicPack.isActive());
graphicPackViewHolder.enableToggle.setOnCheckedChangeListener((materialCheckBox, isChecked) -> graphicPack.setActive(isChecked));
}
}

View File

@ -12,8 +12,9 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="vertical"
android:padding="16dp">
android:padding="8dp">
<TextView
android:id="@+id/button_text"

View File

@ -4,6 +4,7 @@
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="?selectableItemBackground"
android:orientation="vertical"
android:padding="8dp">

View File

@ -12,9 +12,9 @@
android:contentDescription="@string/graphic_pack_name"
android:textSize="24sp" />
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/graphic_pack_enable_checkbox"
android:layout_width="match_parent"
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/graphic_pack_enable_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/graphic_pack_enabled_checkbox_label" />

View File

@ -13,7 +13,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:padding="16dp"
android:padding="8dp"
android:text="Button text"
android:textAppearance="?attr/textAppearanceHeadline6"
tools:ignore="HardcodedText" />

View File

@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?selectableItemBackground"
android:orientation="vertical"
android:padding="8dp">