mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
cleanup: never return null
This commit is contained in:
parent
34d5ef291c
commit
42575f1380
8 changed files with 20 additions and 26 deletions
|
@ -797,7 +797,7 @@ public class DBUtils {
|
|||
|
||||
public static long[] getRowIDsFor( Context context, String relayID )
|
||||
{
|
||||
long[] result = null;
|
||||
long[] result = {};
|
||||
String[] columns = { ROW_ID };
|
||||
String selection = DBHelper.RELAYID + "='" + relayID + "'";
|
||||
initDB( context );
|
||||
|
@ -814,7 +814,7 @@ public class DBUtils {
|
|||
|
||||
public static long[] getRowIDsFor( Context context, int gameID )
|
||||
{
|
||||
long[] result = null;
|
||||
long[] result = {};
|
||||
String[] columns = { ROW_ID };
|
||||
String selection = String.format( DBHelper.GAMEID + "=%d", gameID );
|
||||
initDB( context );
|
||||
|
@ -836,7 +836,7 @@ public class DBUtils {
|
|||
public static boolean haveGame( Context context, int gameID )
|
||||
{
|
||||
long[] rows = getRowIDsFor( context, gameID );
|
||||
return rows != null && 0 < rows.length;
|
||||
return 0 < rows.length;
|
||||
}
|
||||
|
||||
public static boolean haveGame( Context context, long rowid )
|
||||
|
@ -1607,7 +1607,7 @@ public class DBUtils {
|
|||
|
||||
public static long[] getGroupGames( Context context, long groupID )
|
||||
{
|
||||
long[] result = null;
|
||||
long[] result = {};
|
||||
initDB( context );
|
||||
String[] columns = { ROW_ID, DBHelper.HASMSGS };
|
||||
String selection = String.format( "%s=%d", DBHelper.GROUPID, groupID );
|
||||
|
|
|
@ -2271,10 +2271,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
if ( null != relayIDs ) {
|
||||
for ( String relayID : relayIDs ) {
|
||||
long[] rowids = DBUtils.getRowIDsFor( m_activity, relayID );
|
||||
if ( null != rowids ) {
|
||||
for ( long rowid : rowids ) {
|
||||
reloadGame( rowid );
|
||||
}
|
||||
for ( long rowid : rowids ) {
|
||||
reloadGame( rowid );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2289,13 +2287,11 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
outer:
|
||||
for ( String relayID : relayIDs ) {
|
||||
long[] rowids = DBUtils.getRowIDsFor( m_activity, relayID );
|
||||
if ( null != rowids ) {
|
||||
for ( long rowid : rowids ) {
|
||||
if ( GameUtils.gameDictsHere( m_activity, rowid ) ) {
|
||||
launchGame( rowid );
|
||||
launched = true;
|
||||
break outer;
|
||||
}
|
||||
for ( long rowid : rowids ) {
|
||||
if ( GameUtils.gameDictsHere( m_activity, rowid ) ) {
|
||||
launchGame( rowid );
|
||||
launched = true;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2390,7 +2386,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
{
|
||||
boolean handled = false;
|
||||
long[] rowids = DBUtils.getRowIDsFor( m_activity, gameID );
|
||||
if ( null != rowids && 0 < rowids.length ) {
|
||||
if ( 0 < rowids.length ) {
|
||||
launchGame( rowids[0] );
|
||||
handled = true;
|
||||
}
|
||||
|
|
|
@ -550,7 +550,7 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba
|
|||
Log.d( TAG, "handleMessage(gameID=%d): got message", gameID );
|
||||
MQTTServiceHelper helper = new MQTTServiceHelper( context, from );
|
||||
long[] rowids = DBUtils.getRowIDsFor( context, gameID );
|
||||
Log.d( TAG, "got %d rows for gameID %d", rowids == null ? 0 : rowids.length, gameID );
|
||||
Log.d( TAG, "got %d rows for gameID %d", rowids.length, gameID );
|
||||
if ( 0 == rowids.length ) {
|
||||
notifyNotHere( context, from.mqtt_devID, gameID );
|
||||
} else {
|
||||
|
|
|
@ -377,7 +377,7 @@ public class NFCUtils {
|
|||
switch ( typ[0] ) {
|
||||
case MESSAGE:
|
||||
long[] rowids = DBUtils.getRowIDsFor( context, gameID[0] );
|
||||
if ( null == rowids || 0 == rowids.length ) {
|
||||
if ( 0 == rowids.length ) {
|
||||
addReplyFor( new byte[]{REPLY_NOGAME}, gameID[0] );
|
||||
} else {
|
||||
for ( long rowid : rowids ) {
|
||||
|
|
|
@ -755,11 +755,9 @@ public class RelayService extends XWJIService
|
|||
String relayID = relayIDs[ii];
|
||||
BackMoveResult bmr = bmrs[ii];
|
||||
long[] rowids = DBUtils.getRowIDsFor( this, relayID );
|
||||
if ( null != rowids ) {
|
||||
for ( long rowid : rowids ) {
|
||||
GameUtils.postMoveNotification( this, rowid, bmr,
|
||||
locals.get(ii) );
|
||||
}
|
||||
for ( long rowid : rowids ) {
|
||||
GameUtils.postMoveNotification( this, rowid, bmr,
|
||||
locals.get(ii) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -779,7 +779,7 @@ public class WiDirService extends XWService {
|
|||
private void makeGame( NetLaunchInfo nli, String senderMac )
|
||||
{
|
||||
long[] rowids = DBUtils.getRowIDsFor( this, nli.gameID() );
|
||||
if ( null == rowids || 0 == rowids.length ) {
|
||||
if ( 0 == rowids.length ) {
|
||||
CommsAddrRec addr = nli.makeAddrRec( this );
|
||||
long rowid = GameUtils.makeNewMultiGame( this, nli,
|
||||
m_sink,
|
||||
|
|
|
@ -63,7 +63,7 @@ abstract class XWServiceHelper {
|
|||
{
|
||||
ReceiveResult result;
|
||||
long[] rowids = DBUtils.getRowIDsFor( mContext, gameID );
|
||||
if ( null == rowids || 0 == rowids.length ) {
|
||||
if ( 0 == rowids.length ) {
|
||||
result = ReceiveResult.GAME_GONE;
|
||||
} else {
|
||||
result = ReceiveResult.UNCONSUMED;
|
||||
|
|
|
@ -288,7 +288,7 @@ public class DUtilCtxt {
|
|||
String pauserName, String expl )
|
||||
{
|
||||
long[] rowids = DBUtils.getRowIDsFor( m_context, gameID );
|
||||
Log.d( TAG, "got %d games with gameid", null == rowids ? 0 : rowids.length );
|
||||
Log.d( TAG, "got %d games with gameid", rowids.length );
|
||||
|
||||
final boolean isPause = UNPAUSED != pauseType;
|
||||
|
||||
|
|
Loading…
Reference in a new issue