Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
front: Long-click gallery item to jump straight to game activity.
  • Loading branch information
littleguy77 committed Jun 7, 2015
1 parent 75a023d commit 18991b0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/paulscode/android/mupen64plusae/GalleryActivity.java
Expand Up @@ -527,6 +527,12 @@ public void onGalleryItemClick( GalleryItem item )
mDrawerLayout.openDrawer( GravityCompat.START );
}

public boolean onGalleryItemLongClick( GalleryItem item )
{
launchGameActivity( item.romFile.getAbsolutePath(), item.md5, false );
return true;
}

@Override
public boolean onKeyDown( int keyCode, KeyEvent event )
{
Expand Down
16 changes: 15 additions & 1 deletion src/paulscode/android/mupen64plusae/GalleryItem.java
Expand Up @@ -34,6 +34,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
Expand Down Expand Up @@ -119,7 +120,8 @@ public int compare( GalleryItem item1, GalleryItem item2 )
}
}

public static class ViewHolder extends RecyclerView.ViewHolder implements OnClickListener
public static class ViewHolder extends RecyclerView.ViewHolder implements OnClickListener,
OnLongClickListener
{
public GalleryItem item;
private Context mContext;
Expand All @@ -129,6 +131,7 @@ public ViewHolder( Context context, View view )
super( view );
mContext = context;
view.setOnClickListener( this );
view.setOnLongClickListener( this );
}

@Override
Expand All @@ -146,6 +149,17 @@ public void onClick( View view )
activity.onGalleryItemClick( item );
}
}

@Override
public boolean onLongClick( View view )
{
if( mContext instanceof GalleryActivity )
{
GalleryActivity activity = (GalleryActivity) mContext;
return activity.onGalleryItemLongClick( item );
}
return false;
}
}

public static class Adapter extends RecyclerView.Adapter<ViewHolder>
Expand Down

0 comments on commit 18991b0

Please sign in to comment.