mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
move interface; add some logging.
This commit is contained in:
parent
91e95eb48b
commit
a82051739b
3 changed files with 47 additions and 12 deletions
|
@ -393,5 +393,6 @@
|
||||||
<string name="button_reply">Reply</string>
|
<string name="button_reply">Reply</string>
|
||||||
<string name="compose_chat">Message for all devices</string>
|
<string name="compose_chat">Message for all devices</string>
|
||||||
|
|
||||||
<string name="notify_title">notify_title</string>
|
<string name="notify_title">Crosswords data</string>
|
||||||
|
<string name="notify_body">New game data available on relay</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -32,32 +32,58 @@ import java.util.HashSet;
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||||
|
|
||||||
public class DispatchNotify extends Activity {
|
public class DispatchNotify extends Activity {
|
||||||
|
|
||||||
|
public interface HandleRelaysIface {
|
||||||
|
void HandleRelaysIDs( final String[] relayIDs );
|
||||||
|
}
|
||||||
|
|
||||||
private static HashSet<Activity> s_running = new HashSet<Activity>();
|
private static HashSet<Activity> s_running = new HashSet<Activity>();
|
||||||
|
private static HandleRelaysIface s_handler;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate( Bundle savedInstanceState )
|
protected void onCreate( Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
|
Utils.logf( "DispatchNotify.onCreate()" );
|
||||||
super.onCreate( savedInstanceState );
|
super.onCreate( savedInstanceState );
|
||||||
|
|
||||||
if ( s_running.isEmpty() ) {
|
Intent intent = getIntent();
|
||||||
|
String[] relayIDs =
|
||||||
|
intent.getStringArrayExtra( getString(R.string.relayids_extra) );
|
||||||
|
|
||||||
|
if ( null != s_handler ) {
|
||||||
|
Utils.logf( "calling s_handler" );
|
||||||
|
s_handler.HandleRelaysIDs( relayIDs );
|
||||||
|
} else if ( s_running.isEmpty() ) {
|
||||||
Utils.logf( "DispatchNotify: nothing running" );
|
Utils.logf( "DispatchNotify: nothing running" );
|
||||||
startActivity( new Intent( this, GamesList.class ) );
|
startActivity( new Intent( this, GamesList.class ) );
|
||||||
} else {
|
} else {
|
||||||
Utils.logf( "DispatchNotify: something running" );
|
Utils.logf( "DispatchNotify: something running" );
|
||||||
Intent intent = getIntent();
|
|
||||||
String[] relayIDs =
|
|
||||||
intent.getStringArrayExtra(getString(R.string.relayids_extra));
|
|
||||||
String ids = "new moves available; need to inval";
|
String ids = "new moves available; need to inval";
|
||||||
for ( String id : relayIDs ) {
|
for ( String id : relayIDs ) {
|
||||||
ids += " " + id ;
|
ids += " " + id ;
|
||||||
}
|
}
|
||||||
|
|
||||||
Toast.makeText( this, ids, Toast.LENGTH_SHORT).show();
|
// Toast.makeText( this, ids, Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
// for ( Activity activity : s_running ) {
|
||||||
|
// if ( activity instanceof DispatchNotify.HandleRelaysIface ) {
|
||||||
|
// DispatchNotify.HandleRelaysIface iface =
|
||||||
|
// (DispatchNotify.HandleRelaysIface)activity;
|
||||||
|
// iface.HandleRelaysIDs( relayIDs );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onNewIntent( Intent intent )
|
||||||
|
{
|
||||||
|
Utils.logf( "DispatchNotify.onNewIntent() called" );
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetRunning( Activity running )
|
public static void SetRunning( Activity running )
|
||||||
{
|
{
|
||||||
s_running.add( running );
|
s_running.add( running );
|
||||||
|
@ -68,4 +94,8 @@ public class DispatchNotify extends Activity {
|
||||||
s_running.remove( running );
|
s_running.remove( running );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetRelayIDsHandler( HandleRelaysIface iface )
|
||||||
|
{
|
||||||
|
s_handler = iface;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ import junit.framework.Assert;
|
||||||
import org.eehouse.android.xw4.jni.*;
|
import org.eehouse.android.xw4.jni.*;
|
||||||
|
|
||||||
public class GamesList extends XWListActivity
|
public class GamesList extends XWListActivity
|
||||||
implements RelayService.HandleRelaysIface {
|
implements DispatchNotify.HandleRelaysIface {
|
||||||
|
|
||||||
private static final int WARN_NODICT = Utils.DIALOG_LAST + 1;
|
private static final int WARN_NODICT = Utils.DIALOG_LAST + 1;
|
||||||
private static final int CONFIRM_DELETE_ALL = Utils.DIALOG_LAST + 2;
|
private static final int CONFIRM_DELETE_ALL = Utils.DIALOG_LAST + 2;
|
||||||
|
@ -140,29 +140,33 @@ public class GamesList extends XWListActivity
|
||||||
|
|
||||||
FirstRunDialog.show( this, false );
|
FirstRunDialog.show( this, false );
|
||||||
|
|
||||||
RelayActivity.RestartTimer( this );
|
RelayReceiver.RestartTimer( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
protected void onStart()
|
||||||
{
|
{
|
||||||
super.onStart();
|
super.onStart();
|
||||||
RelayService.SetRelayIDsHandler( this );
|
DispatchNotify.SetRelayIDsHandler( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
super.onStop();
|
super.onStop();
|
||||||
RelayService.SetRelayIDsHandler( null );
|
DispatchNotify.SetRelayIDsHandler( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
// RelayService.SetRelayIDsHandler interface
|
// DispatchNotify.HandleRelaysIface interface
|
||||||
public void HandleRelaysIDs( final String[] relayIDs )
|
public void HandleRelaysIDs( final String[] relayIDs )
|
||||||
{
|
{
|
||||||
m_handler.post( new Runnable() {
|
m_handler.post( new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if ( null != relayIDs && relayIDs.length > 0 ) {
|
if ( null == relayIDs ) {
|
||||||
|
Utils.logf( "relayIDs null" );
|
||||||
|
} else if ( relayIDs.length == 0 ) {
|
||||||
|
Utils.logf( "relayIDs empty" );
|
||||||
|
} else {
|
||||||
for ( String relayID : relayIDs ) {
|
for ( String relayID : relayIDs ) {
|
||||||
Utils.logf( "HandleRelaysIDs: got %s", relayID );
|
Utils.logf( "HandleRelaysIDs: got %s", relayID );
|
||||||
String path = DBUtils.getPathFor( GamesList.this,
|
String path = DBUtils.getPathFor( GamesList.this,
|
||||||
|
|
Loading…
Reference in a new issue