summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-10-11 20:51:23 +0200
committerJosJuice <josjuice@gmail.com>2020-10-19 20:03:47 +0200
commit6380c65ff858c9147e5f7d7da21219db52853682 (patch)
tree03a1bc32b26234237a7314eba34a93756c799ac1 /Source/Android/app/src/main/java
parent5e70dda4cc2ad9b1ecc9bda8b1b30916a3ee1661 (diff)
Android: Refetch game metadata after returning from settings
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java8
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java16
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java19
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java6
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesView.java5
5 files changed, 54 insertions, 0 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java
index 5fd27ad5ab..5e813fd099 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java
@@ -121,6 +121,14 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
}
/**
+ * Re-fetches game metadata from the game file cache.
+ */
+ public void refetchMetadata()
+ {
+ notifyItemRangeChanged(0, getItemCount());
+ }
+
+ /**
* Launches the game that was clicked on.
*
* @param view The card representing the game the user wants to play.
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java
index c2993edbf3..77c792fca7 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java
@@ -87,6 +87,10 @@ public final class MainActivity extends AppCompatActivity implements MainView
mPresenter.addDirIfNeeded(this);
+ // In case the user changed a setting that affects how games are displayed,
+ // such as system language, cover downloading...
+ refetchMetadata();
+
if (sShouldRescanLibrary)
{
GameFileCacheService.startRescan(this);
@@ -256,6 +260,18 @@ public final class MainActivity extends AppCompatActivity implements MainView
}
}
+ private void refetchMetadata()
+ {
+ for (Platform platform : Platform.values())
+ {
+ PlatformGamesView fragment = getPlatformGamesView(platform);
+ if (fragment != null)
+ {
+ fragment.refetchMetadata();
+ }
+ }
+ }
+
@Nullable
private PlatformGamesView getPlatformGamesView(Platform platform)
{
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java
index 4f3146ef05..c53de7e0cb 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java
@@ -32,6 +32,7 @@ import org.dolphinemu.dolphinemu.utils.StartupHandler;
import org.dolphinemu.dolphinemu.utils.TvUtil;
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
+import java.util.ArrayList;
import java.util.Collection;
public final class TvMainActivity extends FragmentActivity implements MainView
@@ -42,6 +43,8 @@ public final class TvMainActivity extends FragmentActivity implements MainView
private BrowseSupportFragment mBrowseFragment;
+ private ArrayList<ArrayObjectAdapter> mGameRows = new ArrayList<>();
+
@Override
protected void onCreate(Bundle savedInstanceState)
{
@@ -72,6 +75,10 @@ public final class TvMainActivity extends FragmentActivity implements MainView
mPresenter.addDirIfNeeded(this);
+ // In case the user changed a setting that affects how games are displayed,
+ // such as system language, cover downloading...
+ refetchMetadata();
+
if (sShouldRescanLibrary)
{
GameFileCacheService.startRescan(this);
@@ -185,6 +192,14 @@ public final class TvMainActivity extends FragmentActivity implements MainView
buildRowsAdapter();
}
+ private void refetchMetadata()
+ {
+ for (ArrayObjectAdapter row : mGameRows)
+ {
+ row.notifyArrayItemRangeChanged(0, row.size());
+ }
+ }
+
/**
* Callback from AddDirectoryActivity. Applies any changes necessary to the GameGridActivity.
*
@@ -247,6 +262,7 @@ public final class TvMainActivity extends FragmentActivity implements MainView
private void buildRowsAdapter()
{
ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
+ mGameRows.clear();
if (PermissionsHandler.hasWriteAccess(this))
{
@@ -281,6 +297,9 @@ public final class TvMainActivity extends FragmentActivity implements MainView
ArrayObjectAdapter row = new ArrayObjectAdapter(new GameRowPresenter());
row.addAll(0, gameFiles);
+ // Keep a reference to the row in case we need to refresh it.
+ mGameRows.add(row);
+
// Create a header for this row.
HeaderItem header = new HeaderItem(platform.toInt(), platform.getHeaderName());
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java
index 83040034ae..50d2499705 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java
@@ -85,6 +85,12 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
}
}
+ @Override
+ public void refetchMetadata()
+ {
+ mAdapter.refetchMetadata();
+ }
+
private void findViews(View root)
{
mRecyclerView = root.findViewById(R.id.grid_games);
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesView.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesView.java
index 50b3e25ba7..918f40c6e0 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesView.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesView.java
@@ -25,4 +25,9 @@ public interface PlatformGamesView
* To be called when the game file cache is updated.
*/
void showGames();
+
+ /**
+ * Re-fetches game metadata from the game file cache.
+ */
+ void refetchMetadata();
}