mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-14 08:01:38 +01:00
move lookup dialog into superclass so can be used from dict browser.
This commit is contained in:
parent
308720186d
commit
84044fa9ee
5 changed files with 42 additions and 23 deletions
|
@ -72,7 +72,6 @@ public class BoardActivity extends XWActivity
|
|||
private static final int DLG_DELETED = DLG_OKONLY + 8;
|
||||
private static final int DLG_INVITE = DLG_OKONLY + 9;
|
||||
private static final int DLG_SCORES_BLK = DLG_OKONLY + 10;
|
||||
private static final int DLG_LOOKUP = DLG_OKONLY + 11;
|
||||
|
||||
private static final int CHAT_REQUEST = 1;
|
||||
private static final int SCREEN_ON_TIME = 10 * 60 * 1000; // 10 mins
|
||||
|
@ -332,15 +331,6 @@ public class BoardActivity extends XWActivity
|
|||
}
|
||||
break;
|
||||
|
||||
case DLG_LOOKUP:
|
||||
LookupView view = (LookupView)Utils.inflate( this, R.layout.lookup );
|
||||
dialog = new AlertDialog.Builder( this )
|
||||
.setView( view )
|
||||
.create();
|
||||
view.setDialog( dialog, DLG_LOOKUP );
|
||||
view.setWords( m_words, m_gi.dictLang );
|
||||
break;
|
||||
|
||||
default:
|
||||
// just drop it; super.onCreateDialog likely failed
|
||||
break;
|
||||
|
@ -696,7 +686,7 @@ public class BoardActivity extends XWActivity
|
|||
cmd = JNIThread.JNICmd.CMD_TRADE;
|
||||
break;
|
||||
case LOOKUP_ACTION:
|
||||
launchLookup( m_words );
|
||||
launchLookup( m_words, m_gi.dictLang );
|
||||
break;
|
||||
default:
|
||||
Assert.fail();
|
||||
|
@ -1014,7 +1004,7 @@ public class BoardActivity extends XWActivity
|
|||
{
|
||||
post( new Runnable() {
|
||||
public void run() {
|
||||
launchLookup( wordsToArray( words ) );
|
||||
launchLookup( wordsToArray( words ), m_gi.dictLang );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
@ -1324,7 +1314,8 @@ public class BoardActivity extends XWActivity
|
|||
}
|
||||
break;
|
||||
case JNIThread.GOT_WORDS:
|
||||
launchLookup( wordsToArray((String)msg.obj) );
|
||||
launchLookup( wordsToArray((String)msg.obj),
|
||||
m_gi.dictLang );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1608,12 +1599,6 @@ public class BoardActivity extends XWActivity
|
|||
return wordsArray;
|
||||
}
|
||||
|
||||
private void launchLookup( String[] words )
|
||||
{
|
||||
m_words = words;
|
||||
showDialog( DLG_LOOKUP );
|
||||
}
|
||||
|
||||
private void setupPasswdVars()
|
||||
{
|
||||
String fmt = getString( R.string.msg_ask_password );
|
||||
|
|
|
@ -45,7 +45,7 @@ public class DictBrowseActivity extends XWListActivity
|
|||
public static final String DICT_NAME = "DICT_NAME";
|
||||
|
||||
private int m_dictClosure = 0;
|
||||
|
||||
private int m_lang = 0; // FIX ME
|
||||
|
||||
// - Steps to reproduce the problem:
|
||||
// Create ListView, set custom adapter which implements ListAdapter and
|
||||
|
@ -167,8 +167,8 @@ public class DictBrowseActivity extends XWListActivity
|
|||
public void onClick( View view )
|
||||
{
|
||||
TextView text = (TextView)view;
|
||||
String str = text.getText().toString();
|
||||
Utils.showf( this, "Not yet ready to lookup word %s", str );
|
||||
String[] words = { text.getText().toString() };
|
||||
launchLookup( words, m_lang );
|
||||
}
|
||||
|
||||
private void findButtonClicked()
|
||||
|
|
|
@ -43,7 +43,8 @@ public class DlgDelegate {
|
|||
public static final int CONFIRM_THEN = 4;
|
||||
public static final int TEXT_OR_HTML_THEN = 5;
|
||||
public static final int DLG_DICTGONE = 6;
|
||||
public static final int DIALOG_LAST = DLG_DICTGONE;
|
||||
public static final int DLG_LOOKUP = 7;
|
||||
public static final int DIALOG_LAST = DLG_LOOKUP;
|
||||
|
||||
public static final int TEXT_BTN = AlertDialog.BUTTON_POSITIVE;
|
||||
public static final int HTML_BTN = AlertDialog.BUTTON_NEGATIVE;
|
||||
|
@ -55,6 +56,8 @@ public class DlgDelegate {
|
|||
private static final String MSGID = "msgid";
|
||||
private static final String PREFSKEY = "prefskey";
|
||||
private static final String POSBUTTON = "posbutton";
|
||||
private static final String WORDS = "words";
|
||||
private static final String LANG = "lang";
|
||||
|
||||
// Cache a couple of callback implementations that never change:
|
||||
private DialogInterface.OnClickListener m_cbkOnClickLstnr = null;
|
||||
|
@ -73,6 +76,8 @@ public class DlgDelegate {
|
|||
private Activity m_activity;
|
||||
private DlgClickNotify m_clickCallback;
|
||||
private String m_dictName = null;
|
||||
private String[] m_words = null;
|
||||
private int m_wordsLang = -1;
|
||||
|
||||
public DlgDelegate( Activity activity, DlgClickNotify callback,
|
||||
Bundle bundle )
|
||||
|
@ -86,6 +91,8 @@ public class DlgDelegate {
|
|||
m_msgID = bundle.getInt( MSGID );
|
||||
m_posButton = bundle.getInt( POSBUTTON );
|
||||
m_prefsKey = bundle.getInt( PREFSKEY );
|
||||
m_words = bundle.getStringArray( WORDS );
|
||||
m_wordsLang = bundle.getInt( LANG );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,6 +103,8 @@ public class DlgDelegate {
|
|||
outState.putInt( MSGID, m_msgID );
|
||||
outState.putInt( POSBUTTON, m_posButton );
|
||||
outState.putInt( PREFSKEY, m_prefsKey );
|
||||
outState.putStringArray( WORDS, m_words );
|
||||
outState.putInt( LANG, m_wordsLang );
|
||||
}
|
||||
|
||||
public Dialog onCreateDialog( int id )
|
||||
|
@ -120,6 +129,14 @@ public class DlgDelegate {
|
|||
case DLG_DICTGONE:
|
||||
dialog = createDictGoneDialog();
|
||||
break;
|
||||
case DLG_LOOKUP:
|
||||
LookupView view = (LookupView)Utils.inflate( m_activity, R.layout.lookup );
|
||||
dialog = new AlertDialog.Builder( m_activity )
|
||||
.setView( view )
|
||||
.create();
|
||||
view.setDialog( dialog, DLG_LOOKUP );
|
||||
view.setWords( m_words, m_wordsLang );
|
||||
break;
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
@ -225,6 +242,13 @@ public class DlgDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
public void launchLookup( String[] words, int lang )
|
||||
{
|
||||
m_words = words;
|
||||
m_wordsLang = lang;
|
||||
m_activity.showDialog( DLG_LOOKUP );
|
||||
}
|
||||
|
||||
private Dialog createAboutDialog()
|
||||
{
|
||||
final View view = Utils.inflate( m_activity, R.layout.about_dlg );
|
||||
|
|
|
@ -151,6 +151,11 @@ public class XWActivity extends Activity
|
|||
m_delegate.doSyncMenuitem();
|
||||
}
|
||||
|
||||
protected void launchLookup( String[] words, int lang )
|
||||
{
|
||||
m_delegate.launchLookup( words, lang );
|
||||
}
|
||||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
public void dlgButtonClicked( int id, int which )
|
||||
{
|
||||
|
|
|
@ -153,4 +153,9 @@ public class XWListActivity extends ListActivity
|
|||
Assert.fail();
|
||||
}
|
||||
|
||||
protected void launchLookup( String[] words, int lang )
|
||||
{
|
||||
m_delegate.launchLookup( words, lang );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue