mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 13:20:27 -06:00
Android: Refetch game metadata after returning from settings
This commit is contained in:
@ -120,6 +120,14 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
|
|||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-fetches game metadata from the game file cache.
|
||||||
|
*/
|
||||||
|
public void refetchMetadata()
|
||||||
|
{
|
||||||
|
notifyItemRangeChanged(0, getItemCount());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launches the game that was clicked on.
|
* Launches the game that was clicked on.
|
||||||
*
|
*
|
||||||
|
@ -87,6 +87,10 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
|||||||
|
|
||||||
mPresenter.addDirIfNeeded(this);
|
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)
|
if (sShouldRescanLibrary)
|
||||||
{
|
{
|
||||||
GameFileCacheService.startRescan(this);
|
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
|
@Nullable
|
||||||
private PlatformGamesView getPlatformGamesView(Platform platform)
|
private PlatformGamesView getPlatformGamesView(Platform platform)
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,7 @@ import org.dolphinemu.dolphinemu.utils.StartupHandler;
|
|||||||
import org.dolphinemu.dolphinemu.utils.TvUtil;
|
import org.dolphinemu.dolphinemu.utils.TvUtil;
|
||||||
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
|
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public final class TvMainActivity extends FragmentActivity implements MainView
|
public final class TvMainActivity extends FragmentActivity implements MainView
|
||||||
@ -42,6 +43,8 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
|
|
||||||
private BrowseSupportFragment mBrowseFragment;
|
private BrowseSupportFragment mBrowseFragment;
|
||||||
|
|
||||||
|
private ArrayList<ArrayObjectAdapter> mGameRows = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
@ -72,6 +75,10 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
|
|
||||||
mPresenter.addDirIfNeeded(this);
|
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)
|
if (sShouldRescanLibrary)
|
||||||
{
|
{
|
||||||
GameFileCacheService.startRescan(this);
|
GameFileCacheService.startRescan(this);
|
||||||
@ -185,6 +192,14 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
buildRowsAdapter();
|
buildRowsAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void refetchMetadata()
|
||||||
|
{
|
||||||
|
for (ArrayObjectAdapter row : mGameRows)
|
||||||
|
{
|
||||||
|
row.notifyArrayItemRangeChanged(0, row.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback from AddDirectoryActivity. Applies any changes necessary to the GameGridActivity.
|
* 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()
|
private void buildRowsAdapter()
|
||||||
{
|
{
|
||||||
ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
|
ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
|
||||||
|
mGameRows.clear();
|
||||||
|
|
||||||
if (PermissionsHandler.hasWriteAccess(this))
|
if (PermissionsHandler.hasWriteAccess(this))
|
||||||
{
|
{
|
||||||
@ -281,6 +297,9 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
ArrayObjectAdapter row = new ArrayObjectAdapter(new GameRowPresenter());
|
ArrayObjectAdapter row = new ArrayObjectAdapter(new GameRowPresenter());
|
||||||
row.addAll(0, gameFiles);
|
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.
|
// Create a header for this row.
|
||||||
HeaderItem header = new HeaderItem(platform.toInt(), platform.getHeaderName());
|
HeaderItem header = new HeaderItem(platform.toInt(), platform.getHeaderName());
|
||||||
|
|
||||||
|
@ -85,6 +85,12 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refetchMetadata()
|
||||||
|
{
|
||||||
|
mAdapter.refetchMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
private void findViews(View root)
|
private void findViews(View root)
|
||||||
{
|
{
|
||||||
mRecyclerView = root.findViewById(R.id.grid_games);
|
mRecyclerView = root.findViewById(R.id.grid_games);
|
||||||
|
@ -25,4 +25,9 @@ public interface PlatformGamesView
|
|||||||
* To be called when the game file cache is updated.
|
* To be called when the game file cache is updated.
|
||||||
*/
|
*/
|
||||||
void showGames();
|
void showGames();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-fetches game metadata from the game file cache.
|
||||||
|
*/
|
||||||
|
void refetchMetadata();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user