Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
AEFeinstein committed Jan 15, 2023
1 parent d2d8968 commit f3046e0
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 43 deletions.
1 change: 1 addition & 0 deletions mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
Expand Down
19 changes: 10 additions & 9 deletions mobile/src/main/java/com/gelakinetic/mtgfam/FamiliarActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,8 @@ private boolean processIntent(@NonNull Intent intent) {
this.finish();
shouldSelectItem = false;
}
} catch (SQLiteException | FamiliarDbException | CursorIndexOutOfBoundsException e) {
} catch (SQLiteException | FamiliarDbException |
CursorIndexOutOfBoundsException e) {
e.printStackTrace();
} finally {
if (null != cursor) {
Expand Down Expand Up @@ -1581,10 +1582,10 @@ public void clearLoading() {
*/
public int getResourceIdFromAttr(int attr) {
assert getTheme() != null;
TypedArray ta = getTheme().obtainStyledAttributes(new int[]{attr});
int resId = ta.getResourceId(0, 0);
ta.recycle();
return resId;
try (TypedArray ta = getTheme().obtainStyledAttributes(new int[]{attr})) {
int resId = ta.getResourceId(0, 0);
return resId;
}
}

/**
Expand All @@ -1595,10 +1596,10 @@ public int getResourceIdFromAttr(int attr) {
*/
public static int getResourceIdFromAttr(Context c, int attr) {
assert c.getTheme() != null;
TypedArray ta = c.getTheme().obtainStyledAttributes(new int[]{attr});
int resId = ta.getResourceId(0, 0);
ta.recycle();
return resId;
try (TypedArray ta = c.getTheme().obtainStyledAttributes(new int[]{attr})) {
int resId = ta.getResourceId(0, 0);
return resId;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import com.gelakinetic.mtgfam.helpers.database.FamiliarDbException;
import com.gelakinetic.mtgfam.helpers.database.FamiliarDbHandle;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Random;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,30 +175,30 @@ public void onCreate(Bundle savedInstanceState) {

/* Get the different rarities out of resources to populate the list of choices with */
Resources res = getResources();
TypedArray mRarityNamesTemp = res.obtainTypedArray(R.array.rarities);
int i = mRarityNamesTemp.length();
mRarityNames = new String[i];
mRarityCodes = new char[i];

if (savedInstanceState != null) {
mSelectedFormat = savedInstanceState.getInt(SAVED_FORMAT_KEY);
mRarityCheckedIndices = savedInstanceState.getIntArray(SAVED_RARITY_KEY);
mSetCheckedIndices = savedInstanceState.getIntArray(SAVED_SET_KEY);
} else {
mRarityCheckedIndices = new int[0];
mSelectedFormat = -1;
}
try (TypedArray mRarityNamesTemp = res.obtainTypedArray(R.array.rarities)) {
int i = mRarityNamesTemp.length();
mRarityNames = new String[i];
mRarityCodes = new char[i];

if (savedInstanceState != null) {
mSelectedFormat = savedInstanceState.getInt(SAVED_FORMAT_KEY);
mRarityCheckedIndices = savedInstanceState.getIntArray(SAVED_RARITY_KEY);
mSetCheckedIndices = savedInstanceState.getIntArray(SAVED_SET_KEY);
} else {
mRarityCheckedIndices = new int[0];
mSelectedFormat = -1;
}

while (i-- > 0) {
int resID = mRarityNamesTemp.peekValue(i).resourceId;
String resEntryName = res.getResourceEntryName(resID);
int p = resEntryName.lastIndexOf("_");
if (-1 != p && p + 1 < resEntryName.length())
mRarityCodes[i] = resEntryName.charAt(p + 1);
else mRarityCodes[i] = ' ';
mRarityNames[i] = res.getString(resID);
while (i-- > 0) {
int resID = mRarityNamesTemp.peekValue(i).resourceId;
String resEntryName = res.getResourceEntryName(resID);
int p = resEntryName.lastIndexOf("_");
if (-1 != p && p + 1 < resEntryName.length())
mRarityCodes[i] = resEntryName.charAt(p + 1);
else mRarityCodes[i] = ' ';
mRarityNames[i] = res.getString(resID);
}
}
mRarityNamesTemp.recycle();
}

/**
Expand Down
17 changes: 10 additions & 7 deletions mobile/src/main/java/com/gelakinetic/mtgfam/helpers/BuildDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@
*/
class BuildDate {
/**
* http://stackoverflow.com/questions/7607165/how-to-write-build-time-stamp-into-apk
* <a href="http://stackoverflow.com/questions/7607165/how-to-write-build-time-stamp-into-apk">...</a>
*
* @param context the application context
* @return a Date object with the time the APK was built
*/
public static Date get(Context context) {
assert context.getPackageManager() != null;
try {
assert context.getPackageManager() != null;
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0);
ZipFile zf = new ZipFile(ai.sourceDir);
ZipEntry ze = zf.getEntry("classes.dex");
long time = ze.getTime();
return new Date(time);
} catch (PackageManager.NameNotFoundException | IOException e) {
try (ZipFile zf = new ZipFile(ai.sourceDir)) {
ZipEntry ze = zf.getEntry("classes.dex");
long time = ze.getTime();
return new Date(time);
} catch (IOException e) {
return new GregorianCalendar(1990, 2, 13).getTime();
}
} catch (PackageManager.NameNotFoundException e) {
return new GregorianCalendar(1990, 2, 13).getTime();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ public void bindView(@NonNull View view, Context context, @NonNull Cursor cursor
* @return the resource ID
*/
private int getResourceIdFromAttr(int attr) {
TypedArray ta = mTheme.obtainStyledAttributes(new int[]{attr});
int resId = ta.getResourceId(0, 0);
ta.recycle();
return resId;
try (TypedArray ta = mTheme.obtainStyledAttributes(new int[]{attr})) {
int resId = ta.getResourceId(0, 0);
return resId;
}
}
}

0 comments on commit f3046e0

Please sign in to comment.