mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
use delete button in XWListItem instead of context menu item for DictsActivity too.
This commit is contained in:
parent
f9a561bd2a
commit
73980a3c50
2 changed files with 17 additions and 17 deletions
|
@ -4,9 +4,6 @@
|
||||||
<item android:id="@+id/dicts_item_select"
|
<item android:id="@+id/dicts_item_select"
|
||||||
android:title="@string/dicts_item_select"
|
android:title="@string/dicts_item_select"
|
||||||
/>
|
/>
|
||||||
<item android:id="@+id/dicts_item_delete"
|
|
||||||
android:title="@string/dicts_item_delete"
|
|
||||||
/>
|
|
||||||
<item android:id="@+id/dicts_item_details"
|
<item android:id="@+id/dicts_item_details"
|
||||||
android:title="@string/dicts_item_details"
|
android:title="@string/dicts_item_details"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -39,7 +39,8 @@ import android.content.SharedPreferences;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
public class DictsActivity extends ListActivity
|
public class DictsActivity extends ListActivity
|
||||||
implements View.OnClickListener {
|
implements View.OnClickListener,
|
||||||
|
XWListItem.DeleteCallback {
|
||||||
String[] m_dicts;
|
String[] m_dicts;
|
||||||
|
|
||||||
private class DictListAdapter extends XWListAdapter {
|
private class DictListAdapter extends XWListAdapter {
|
||||||
|
@ -58,6 +59,12 @@ public class DictsActivity extends ListActivity
|
||||||
= (XWListItem)factory.inflate( R.layout.list_item, null );
|
= (XWListItem)factory.inflate( R.layout.list_item, null );
|
||||||
view.setPosition( position );
|
view.setPosition( position );
|
||||||
view.setText( m_dicts[position] );
|
view.setText( m_dicts[position] );
|
||||||
|
|
||||||
|
if ( !GameUtils.dictIsBuiltin( DictsActivity.this,
|
||||||
|
m_dicts[position] ) ) {
|
||||||
|
view.setDeleteCallback( DictsActivity.this );
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,8 +95,8 @@ public class DictsActivity extends ListActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu( ContextMenu menu, View view,
|
public void onCreateContextMenu( ContextMenu menu, View view,
|
||||||
ContextMenuInfo menuInfo ) {
|
ContextMenuInfo menuInfo )
|
||||||
|
{
|
||||||
super.onCreateContextMenu( menu, view, menuInfo );
|
super.onCreateContextMenu( menu, view, menuInfo );
|
||||||
|
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
@ -97,12 +104,6 @@ public class DictsActivity extends ListActivity
|
||||||
|
|
||||||
AdapterView.AdapterContextMenuInfo info
|
AdapterView.AdapterContextMenuInfo info
|
||||||
= (AdapterView.AdapterContextMenuInfo)menuInfo;
|
= (AdapterView.AdapterContextMenuInfo)menuInfo;
|
||||||
|
|
||||||
String dict = m_dicts[info.position];
|
|
||||||
if ( GameUtils.dictIsBuiltin( this, dict ) ) {
|
|
||||||
MenuItem item = menu.findItem( R.id.dicts_item_delete );
|
|
||||||
item.setVisible( false );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,11 +128,6 @@ public class DictsActivity extends ListActivity
|
||||||
editor.putString( key, m_dicts[info.position] );
|
editor.putString( key, m_dicts[info.position] );
|
||||||
editor.commit();
|
editor.commit();
|
||||||
break;
|
break;
|
||||||
case R.id.dicts_item_delete:
|
|
||||||
GameUtils.deleteDict( this, m_dicts[info.position] );
|
|
||||||
mkListAdapter();
|
|
||||||
handled = true;
|
|
||||||
break;
|
|
||||||
case R.id.dicts_item_details:
|
case R.id.dicts_item_details:
|
||||||
Utils.notImpl( this );
|
Utils.notImpl( this );
|
||||||
break;
|
break;
|
||||||
|
@ -140,6 +136,13 @@ public class DictsActivity extends ListActivity
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteCallback interface
|
||||||
|
public void deleteCalled( int myPosition )
|
||||||
|
{
|
||||||
|
GameUtils.deleteDict( this, m_dicts[myPosition] );
|
||||||
|
mkListAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
private void mkListAdapter()
|
private void mkListAdapter()
|
||||||
{
|
{
|
||||||
m_dicts = GameUtils.dictList( this );
|
m_dicts = GameUtils.dictList( this );
|
||||||
|
|
Loading…
Reference in a new issue