add a selected-check to group header

And make it so tapping there selects
This commit is contained in:
Eric House 2020-08-20 15:40:55 -07:00
parent 9aca3bded7
commit 8385d7f5b2
2 changed files with 33 additions and 12 deletions

View file

@ -1,6 +1,6 @@
/* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */ /* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */
/* /*
* Copyright 2012 by Eric House (xwords@eehouse.org). All rights * Copyright 2012 - 2020 by Eric House (xwords@eehouse.org). All rights
* reserved. * reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -24,6 +24,7 @@ import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import org.eehouse.android.xw4.loc.LocUtils; import org.eehouse.android.xw4.loc.LocUtils;
@ -33,7 +34,7 @@ public class GameListGroup extends ExpiringLinearLayout
View.OnClickListener, View.OnClickListener,
View.OnLongClickListener View.OnLongClickListener
{ {
private static final String TAG = GameListGroup.class.getSimpleName();
private long m_groupID; private long m_groupID;
private boolean m_expanded; private boolean m_expanded;
private SelectableItem m_cb; private SelectableItem m_cb;
@ -43,6 +44,7 @@ public class GameListGroup extends ExpiringLinearLayout
private int m_nGames; private int m_nGames;
private DrawSelDelegate m_dsdel; private DrawSelDelegate m_dsdel;
private ImageButton m_expandButton; private ImageButton m_expandButton;
private ImageView m_check;
public static GameListGroup makeForPosition( Context context, public static GameListGroup makeForPosition( Context context,
View convertView, View convertView,
@ -89,6 +91,8 @@ public class GameListGroup extends ExpiringLinearLayout
super.onFinishInflate(); super.onFinishInflate();
m_etv = (TextView)findViewById( R.id.game_name ); m_etv = (TextView)findViewById( R.id.game_name );
m_expandButton = (ImageButton)findViewById( R.id.expander ); m_expandButton = (ImageButton)findViewById( R.id.expander );
m_check = (ImageView)findViewById( R.id.group_check );
m_check.setOnClickListener( this );
// click on me OR the button expands/contracts... // click on me OR the button expands/contracts...
setOnClickListener( this ); setOnClickListener( this );
@ -119,6 +123,7 @@ public class GameListGroup extends ExpiringLinearLayout
} }
// GameListAdapter.ClickHandler interface // GameListAdapter.ClickHandler interface
@Override
public void longClicked() public void longClicked()
{ {
toggleSelected(); toggleSelected();
@ -129,6 +134,7 @@ public class GameListGroup extends ExpiringLinearLayout
m_selected = !m_selected; m_selected = !m_selected;
m_dsdel.showSelected( m_selected ); m_dsdel.showSelected( m_selected );
m_cb.itemToggled( this, m_selected ); m_cb.itemToggled( this, m_selected );
m_check.setImageResource(m_selected ? R.drawable.ic_check_circle : 0);
} }
////////////////////////////////////////////////// //////////////////////////////////////////////////
@ -148,10 +154,17 @@ public class GameListGroup extends ExpiringLinearLayout
////////////////////////////////////////////////// //////////////////////////////////////////////////
public void onClick( View view ) public void onClick( View view )
{ {
if ( 0 < m_nGames ) { int id = view.getId();
m_expanded = !m_expanded; switch ( id ) {
m_gcb.onGroupExpandedChanged( this, m_expanded ); case R.id.group_check:
setButton(); toggleSelected();
break;
default:
if ( 0 < m_nGames ) {
m_expanded = !m_expanded;
m_gcb.onGroupExpandedChanged( this, m_expanded );
setButton();
}
} }
} }

View file

@ -8,12 +8,20 @@
style="@style/group_items" style="@style/group_items"
> >
<TextView android:id="@+id/game_name"
style="@style/expander_label"
/>
<ImageButton android:id="@+id/expander" <!-- 42dp: same as game_view_container in game_list_item.xml -->
style="@style/expander_button" <ImageView android:id="@+id/group_check"
/> android:layout_width="42dp"
android:layout_height="30dp"
android:gravity="left"
/>
<TextView android:id="@+id/game_name"
style="@style/expander_label"
/>
<ImageButton android:id="@+id/expander"
style="@style/expander_button"
/>
</org.eehouse.android.xw4.GameListGroup> </org.eehouse.android.xw4.GameListGroup>