confirm before deleting all words

This commit is contained in:
Eric House 2014-01-29 07:43:45 -08:00
parent b5d4b6b778
commit 21f2936e87
2 changed files with 28 additions and 2 deletions

View file

@ -2213,5 +2213,8 @@
<string name="slmenu_copy_all">Copy to clipboard</string>
<string name="slmenu_clear_all">Clear all</string>
<string name="confirm_studylist_clear">Are you sure you want to
remove all the words in this list?\n\n(This action cannot be
undone.)</string>
</resources>

View file

@ -19,6 +19,7 @@
package org.eehouse.android.xw4;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@ -33,9 +34,13 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import junit.framework.Assert;
public class StudyList extends XWListActivity
implements OnItemSelectedListener {
private static final int CLEAR_ACTION = 1;
private Spinner m_spinner;
private int[] m_langCodes;
private String[] m_words;
@ -75,8 +80,7 @@ public class StudyList extends XWListActivity
clipboard.setText( TextUtils.join( "\n", m_words ) );
break;
case R.id.clear_all:
DBUtils.studyListClear( this, m_langCodes[m_position] );
initOrFinish();
showConfirmThen( R.string.confirm_studylist_clear, CLEAR_ACTION );
break;
default:
handled = false;
@ -84,6 +88,25 @@ public class StudyList extends XWListActivity
return handled;
}
//////////////////////////////////////////////////
// DlgDelegate.DlgClickNotify interface
//////////////////////////////////////////////////
@Override
public void dlgButtonClicked( int id, int which, Object[] params )
{
if ( AlertDialog.BUTTON_POSITIVE == which ) {
switch ( id ) {
case CLEAR_ACTION:
DBUtils.studyListClear( this, m_langCodes[m_position] );
initOrFinish();
break;
default:
Assert.fail();
break;
}
}
}
//////////////////////////////////////////////////
// AdapterView.OnItemSelectedListener interface
//////////////////////////////////////////////////