mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-26 09:58:20 +01:00
fix NPE in studylist; cleanup duplicated method
This commit is contained in:
parent
4d9c7c97ba
commit
7e515b19c9
4 changed files with 11 additions and 38 deletions
|
@ -814,7 +814,7 @@ public class BoardDelegate extends DelegateBase
|
|||
cmd = JNICmd.CMD_TOGGLE_TRAY;
|
||||
break;
|
||||
case R.id.games_menu_study:
|
||||
StudyListActivity.launchOrAlert( m_activity, m_gi.dictLang, this );
|
||||
StudyListDelegate.launchOrAlert( m_activity, m_gi.dictLang, this );
|
||||
break;
|
||||
case R.id.board_menu_game_netstats:
|
||||
m_jniThread.handle( JNICmd.CMD_NETSTATS, R.string.netstats_title );
|
||||
|
|
|
@ -749,7 +749,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
break;
|
||||
|
||||
case R.id.games_menu_study:
|
||||
StudyListActivity.launchOrAlert( m_activity, StudyListDelegate.NO_LANG, this );
|
||||
StudyListDelegate.launchOrAlert( m_activity, StudyListDelegate.NO_LANG, this );
|
||||
break;
|
||||
|
||||
case R.id.games_menu_about:
|
||||
|
|
|
@ -19,46 +19,16 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
|
||||
public class StudyListActivity extends XWListActivity {
|
||||
|
||||
private StudyListDelegate m_dlgt;
|
||||
|
||||
@Override
|
||||
protected void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
m_dlgt = new StudyListDelegate( this, savedInstanceState );
|
||||
super.onCreate( savedInstanceState, m_dlgt );
|
||||
StudyListDelegate dlgt =
|
||||
new StudyListDelegate( this, savedInstanceState );
|
||||
super.onCreate( savedInstanceState, dlgt );
|
||||
}
|
||||
|
||||
public static void launchOrAlert( Context context, int lang,
|
||||
DlgDelegate.HasDlgDelegate dlg )
|
||||
{
|
||||
String msg = null;
|
||||
if ( 0 == DBUtils.studyListLangs( context ).length ) {
|
||||
msg = LocUtils.getString( context, R.string.study_no_lists );
|
||||
} else if ( StudyListDelegate.NO_LANG != lang &&
|
||||
0 == DBUtils.studyListWords( context, lang ).length ) {
|
||||
String langname = DictLangCache.getLangName( context, lang );
|
||||
msg = LocUtils.getString( context, R.string.study_no_lang_fmt, langname );
|
||||
} else {
|
||||
Intent intent = new Intent( context, StudyListActivity.class );
|
||||
if ( StudyListDelegate.NO_LANG != lang ) {
|
||||
intent.putExtra( StudyListDelegate.START_LANG, lang );
|
||||
}
|
||||
context.startActivity( intent );
|
||||
}
|
||||
|
||||
if ( null != msg ) {
|
||||
dlg.showOKOnlyDialog( msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import android.widget.ListView;
|
|||
import android.widget.Spinner;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
@ -50,7 +51,7 @@ public class StudyListDelegate extends ListDelegateBase
|
|||
implements OnItemSelectedListener, SelectableItem,
|
||||
View.OnLongClickListener, View.OnClickListener {
|
||||
|
||||
public static final int NO_LANG = -1;
|
||||
protected static final int NO_LANG = -1;
|
||||
|
||||
protected static final String START_LANG = "START_LANG";
|
||||
|
||||
|
@ -59,7 +60,7 @@ public class StudyListDelegate extends ListDelegateBase
|
|||
private View m_pickView; // LinearLayout, actually
|
||||
private int[] m_langCodes;
|
||||
private String[] m_words;
|
||||
private HashSet<Integer> m_checkeds;
|
||||
private Set<Integer> m_checkeds;
|
||||
private int m_langPosition;
|
||||
private SLWordsAdapter m_adapter;
|
||||
private ListView m_list;
|
||||
|
@ -78,6 +79,7 @@ public class StudyListDelegate extends ListDelegateBase
|
|||
|
||||
m_spinner = (Spinner)findViewById( R.id.pick_lang_spinner );
|
||||
m_pickView = findViewById( R.id.pick_lang );
|
||||
m_checkeds = new HashSet<Integer>();
|
||||
|
||||
initOrFinish( getIntent() );
|
||||
}
|
||||
|
@ -247,7 +249,8 @@ public class StudyListDelegate extends ListDelegateBase
|
|||
{
|
||||
int lang = m_langCodes[m_langPosition];
|
||||
m_words = DBUtils.studyListWords( m_activity, lang );
|
||||
m_checkeds = new HashSet<Integer>();
|
||||
|
||||
m_checkeds.clear();
|
||||
|
||||
makeAdapter();
|
||||
|
||||
|
|
Loading…
Reference in a new issue