Android: Refetch game metadata after returning from settings
This commit is contained in:
parent
5e70dda4cc
commit
6380c65ff8
|
@ -120,6 +120,14 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-fetches game metadata from the game file cache.
|
||||
*/
|
||||
public void refetchMetadata()
|
||||
{
|
||||
notifyItemRangeChanged(0, getItemCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches the game that was clicked on.
|
||||
*
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue