android: frontend: gamelist: Add swipe to refresh gesture.

This commit is contained in:
bunnei 2019-08-29 00:22:30 -04:00
parent dc47b8a034
commit 9ed543a2ca
5 changed files with 27 additions and 19 deletions

View File

@ -38,10 +38,6 @@ public final class MainPresenter {
mView.launchSettingsActivity(SettingsFile.FILE_NAME_CONFIG);
return true;
case R.id.menu_refresh:
refeshGameList();
return true;
case R.id.button_add_directory:
mView.launchFileListActivity();
return true;

View File

@ -226,10 +226,6 @@ public final class TvMainActivity extends FragmentActivity implements MainView {
R.drawable.ic_add_tv,
R.string.add_directory_title));
rowItems.add(new TvSettingsItem(R.id.menu_refresh,
R.drawable.ic_refresh_tv,
R.string.grid_menu_refresh));
// Create a header for this row.
HeaderItem header =
new HeaderItem(R.string.preferences_settings, getString(R.string.preferences_settings));

View File

@ -4,14 +4,17 @@ import android.database.Cursor;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.citra.citra_android.DolphinApplication;
import org.citra.citra_android.R;
import org.citra.citra_android.adapters.GameAdapter;
import org.citra.citra_android.model.GameDatabase;
public final class PlatformGamesFragment extends Fragment implements PlatformGamesView {
private PlatformGamesPresenter mPresenter = new PlatformGamesPresenter(this);
@ -46,6 +49,18 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(6));
// Add swipe down to refresh gesture
final SwipeRefreshLayout pullToRefresh = view.findViewById(R.id.refresh_grid_games);
pullToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
GameDatabase databaseHelper = DolphinApplication.databaseHelper;
databaseHelper.scanLibrary(databaseHelper.getWritableDatabase());
refresh();
pullToRefresh.setRefreshing(false);
}
});
}
@Override

View File

@ -4,12 +4,18 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/grid_games"
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refresh_grid_games"
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="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/grid_games"
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.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>

View File

@ -8,9 +8,4 @@
android:icon="@drawable/ic_settings_core"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_refresh"
android:title="@string/grid_menu_refresh"
android:icon="@drawable/ic_refresh"
app:showAsAction="ifRoom"/>
</menu>