From 927c4f12a04ca402dee7f70805a0e0fef81970ed Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 14 Oct 2017 12:51:51 -0700 Subject: [PATCH] make tap on thumbnail select/deselect Working around there being a border around the game-type image area. With this change long-tapping works only on the right 2/3 of the region. There might be a fix, but it's still better than there being a hole (the border) in the thing where behavior's different. --- .../org/eehouse/android/xw4/GameListItem.java | 49 +++++++++++-------- .../src/main/res/layout/game_list_item.xml | 5 +- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListItem.java index 2301c75ac..f3cd41e91 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListItem.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListItem.java @@ -90,16 +90,6 @@ public class GameListItem extends LinearLayout m_lastMoveTime = 0; m_loadingCount = 0; m_dsdel = new DrawSelDelegate( this ); - - setOnClickListener( new View.OnClickListener() { - @Override - public void onClick( View v ) { - // if selected, just un-select - if ( null != m_summary ) { - m_cb.itemClicked( GameListItem.this, m_summary ); - } - } - } ); } public GameSummary getSummary() @@ -174,13 +164,32 @@ public class GameListItem extends LinearLayout } // View.OnClickListener interface - public void onClick( View view ) { - m_expanded = !m_expanded; - DBUtils.setExpanded( m_rowid, m_expanded ); + public void onClick( View view ) + { + int id = view.getId(); + switch ( id ) { + case R.id.expander: + m_expanded = !m_expanded; + DBUtils.setExpanded( m_rowid, m_expanded ); - makeThumbnailIf( m_expanded ); + makeThumbnailIf( m_expanded ); - showHide(); + showHide(); + break; + + case R.id.view_loaded: + toggleSelected(); + break; + + case R.id.right_side: + if ( null != m_summary ) { + m_cb.itemClicked( GameListItem.this, m_summary ); + } + break; + default: + Assert.assertFalse(BuildConfig.DEBUG); + break; + } } private void findViews() @@ -191,12 +200,15 @@ public class GameListItem extends LinearLayout m_expandButton.setOnClickListener( this ); m_viewUnloaded = (TextView)findViewById( R.id.view_unloaded ); m_viewLoaded = findViewById( R.id.view_loaded ); + m_viewLoaded.setOnClickListener( this ); m_list = (LinearLayout)findViewById( R.id.player_list ); m_state = (TextView)findViewById( R.id.state ); m_modTime = (TextView)findViewById( R.id.modtime ); m_gameTypeImage = (ImageView)findViewById( R.id.game_type_marker ); m_thumb = (ImageView)findViewById( R.id.thumbnail ); m_role = (TextView)findViewById( R.id.role ); + + findViewById( R.id.right_side ).setOnClickListener( this ); } private void setLoaded( boolean loaded ) @@ -317,12 +329,6 @@ public class GameListItem extends LinearLayout int iconID = summary.isMultiGame() ? R.drawable.multigame__gen : R.drawable.sologame__gen; m_gameTypeImage.setImageResource( iconID ); - m_gameTypeImage.setOnClickListener( new View.OnClickListener() { - @Override - public void onClick( View view ) { - toggleSelected(); - } - } ); boolean hasChat = summary.isMultiGame(); if ( hasChat ) { @@ -427,6 +433,7 @@ public class GameListItem extends LinearLayout // } // GameListAdapter.ClickHandler interface + @Override public void longClicked() { toggleSelected(); diff --git a/xwords4/android/app/src/main/res/layout/game_list_item.xml b/xwords4/android/app/src/main/res/layout/game_list_item.xml index 77972e134..2591b7afe 100644 --- a/xwords4/android/app/src/main/res/layout/game_list_item.xml +++ b/xwords4/android/app/src/main/res/layout/game_list_item.xml @@ -61,9 +61,12 @@ -