mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
if GamesList is frontmost when we have relayIDs to update then just
call the interface it's registered. Otherwise post notification.
This commit is contained in:
parent
ad9a249042
commit
8e8c4f4d31
1 changed files with 26 additions and 12 deletions
|
@ -40,7 +40,12 @@ import org.eehouse.android.xw4.jni.GameSummary;
|
||||||
|
|
||||||
public class RelayService extends Service {
|
public class RelayService extends Service {
|
||||||
|
|
||||||
|
public interface HandleRelaysIface {
|
||||||
|
public void HandleRelaysIDs( String[] relayIDs );
|
||||||
|
}
|
||||||
|
|
||||||
private static NotificationManager s_nm;
|
private static NotificationManager s_nm;
|
||||||
|
private static HandleRelaysIface s_handler = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate()
|
public void onCreate()
|
||||||
|
@ -152,6 +157,11 @@ public class RelayService extends Service {
|
||||||
s_nm.cancel( R.string.relayids_extra );
|
s_nm.cancel( R.string.relayids_extra );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetRelayIDsHandler( HandleRelaysIface iface )
|
||||||
|
{
|
||||||
|
s_handler = iface;
|
||||||
|
}
|
||||||
|
|
||||||
//@Override
|
//@Override
|
||||||
// protected int onStartCommand( Intent intent, int flags, int startId )
|
// protected int onStartCommand( Intent intent, int flags, int startId )
|
||||||
|
@ -163,21 +173,25 @@ public class RelayService extends Service {
|
||||||
|
|
||||||
private void setupNotification( String[] relayIDs )
|
private void setupNotification( String[] relayIDs )
|
||||||
{
|
{
|
||||||
Notification notification =
|
if ( null != s_handler ) {
|
||||||
new Notification( R.drawable.icon48x48,
|
s_handler.HandleRelaysIDs( relayIDs );
|
||||||
getString(R.string.notify_title),
|
} else {
|
||||||
System.currentTimeMillis());
|
Intent intent = new Intent( this, DispatchNotify.class );
|
||||||
|
//intent.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP );
|
||||||
|
intent.putExtra( getString(R.string.relayids_extra), relayIDs );
|
||||||
|
|
||||||
Intent intent = new Intent(this, GamesList.class);
|
PendingIntent pi = PendingIntent.
|
||||||
// intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
getActivity( this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT );
|
||||||
intent.putExtra( getString(R.string.relayids_extra), relayIDs );
|
Notification notification =
|
||||||
|
new Notification( R.drawable.icon48x48,
|
||||||
|
getString(R.string.notify_title),
|
||||||
|
System.currentTimeMillis() );
|
||||||
|
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||||
|
|
||||||
PendingIntent pi = PendingIntent.
|
notification.setLatestEventInfo( this, "bazz", "bar", pi );
|
||||||
getActivity( this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT );
|
|
||||||
|
|
||||||
notification.setLatestEventInfo( this, "bazz", "bar", pi );
|
|
||||||
|
|
||||||
s_nm.notify( R.string.relayids_extra, notification );
|
s_nm.notify( R.string.relayids_extra, notification );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] collectIDs( int[] nBytes )
|
private String[] collectIDs( int[] nBytes )
|
||||||
|
|
Loading…
Reference in a new issue