android: frontend: gamelist: Add swipe to refresh gesture.
This commit is contained in:
parent
c596ee14e2
commit
7206007bc3
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
|
@ -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>
|
@ -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>
|
Loading…
x
Reference in New Issue
Block a user