cleanup: never return null

This commit is contained in:
Eric House 2020-08-29 13:38:32 -07:00
parent 34d5ef291c
commit 42575f1380
8 changed files with 20 additions and 26 deletions

View file

@ -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 );

View file

@ -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;
}

View file

@ -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 {

View file

@ -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 ) {

View file

@ -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) );
}
}
}

View file

@ -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,

View file

@ -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;

View file

@ -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;