cleanup: add and use overridden method

This commit is contained in:
Eric House 2021-10-14 12:09:34 -07:00
parent a0f1f1d045
commit ba5a141b3f
5 changed files with 11 additions and 6 deletions

View file

@ -233,7 +233,7 @@ public class BTUtils {
private static void loadOwnMac( Context context ) private static void loadOwnMac( Context context )
{ {
sMyMacAddr = DBUtils.getStringFor( context, KEY_OWN_MAC, null ); sMyMacAddr = DBUtils.getStringFor( context, KEY_OWN_MAC );
} }
private static void storeOwnMac( String macAddr ) private static void storeOwnMac( String macAddr )

View file

@ -2410,6 +2410,11 @@ public class DBUtils {
} }
} }
public static String getStringFor( Context context, String key )
{
return getStringFor( context, key, null );
}
public static String getStringFor( Context context, String key, String dflt ) public static String getStringFor( Context context, String key, String dflt )
{ {
return getStringFor( context, key, null, dflt ); return getStringFor( context, key, null, dflt );

View file

@ -1125,7 +1125,7 @@ public class DictsDelegate extends ListDelegateBase
static String prevSelFor( Context context, int lang ) static String prevSelFor( Context context, int lang )
{ {
String key = keyForLang( lang ); String key = keyForLang( lang );
return DBUtils.getStringFor( context, key, null ); return DBUtils.getStringFor( context, key );
} }
@Override @Override

View file

@ -189,7 +189,7 @@ public class WiDirService extends XWService {
Assert.assertNull( s_peersSet ); Assert.assertNull( s_peersSet );
s_peersSet = new HashSet<>(); s_peersSet = new HashSet<>();
String peers = DBUtils.getStringFor( context, PEERS_LIST_KEY, null ); String peers = DBUtils.getStringFor( context, PEERS_LIST_KEY );
if ( null != peers ) { if ( null != peers ) {
String[] macs = TextUtils.split( peers, "," ); String[] macs = TextUtils.split( peers, "," );
for ( String mac : macs ) { for ( String mac : macs ) {
@ -244,7 +244,7 @@ public class WiDirService extends XWService {
{ {
if ( enabled() ) { if ( enabled() ) {
if ( null == sMacAddress && null != context ) { if ( null == sMacAddress && null != context ) {
sMacAddress = DBUtils.getStringFor( context, MAC_ADDR_KEY, null ); sMacAddress = DBUtils.getStringFor( context, MAC_ADDR_KEY );
} }
} }
Log.d( TAG, "getMyMacAddress() => %s", sMacAddress ); Log.d( TAG, "getMyMacAddress() => %s", sMacAddress );
@ -1119,7 +1119,7 @@ public class WiDirService extends XWService {
Log.d( TAG, "Got my MAC Address: %s and name: %s", sMacAddress, Log.d( TAG, "Got my MAC Address: %s and name: %s", sMacAddress,
sDeviceName ); sDeviceName );
String stored = DBUtils.getStringFor( context, MAC_ADDR_KEY, null ); String stored = DBUtils.getStringFor( context, MAC_ADDR_KEY );
Assert.assertTrue( null == stored || stored.equals(sMacAddress) ); Assert.assertTrue( null == stored || stored.equals(sMacAddress) );
if ( null == stored ) { if ( null == stored ) {
DBUtils.setStringFor( context, MAC_ADDR_KEY, sMacAddress ); DBUtils.setStringFor( context, MAC_ADDR_KEY, sMacAddress );

View file

@ -135,7 +135,7 @@ public class FBMService extends FirebaseMessagingService {
public static String getFCMDevID( Context context ) public static String getFCMDevID( Context context )
{ {
Assert.assertTrueNR( null != BuildConfig.KEY_FCMID ); Assert.assertTrueNR( null != BuildConfig.KEY_FCMID );
String result = DBUtils.getStringFor( context, BuildConfig.KEY_FCMID, null ); String result = DBUtils.getStringFor( context, BuildConfig.KEY_FCMID );
if ( null == result ) { if ( null == result ) {
getTokenAsync( context ); getTokenAsync( context );