[Cleanup] Fixing Warnings

This commit is contained in:
Prathamesh More 2021-11-27 14:06:49 +05:30
parent 1fdd537253
commit fa976b1cba
68 changed files with 242 additions and 498 deletions

View file

@ -84,30 +84,23 @@ public class HistoryStore extends SQLiteOpenHelper {
database.insert(RecentStoreColumns.NAME, null, values);
// if our db is too large, delete the extra items
Cursor oldest = null;
try {
oldest =
database.query(
RecentStoreColumns.NAME,
new String[] {RecentStoreColumns.TIME_PLAYED},
null,
null,
null,
null,
RecentStoreColumns.TIME_PLAYED + " ASC");
try (Cursor oldest = database.query(
RecentStoreColumns.NAME,
new String[]{RecentStoreColumns.TIME_PLAYED},
null,
null,
null,
null,
RecentStoreColumns.TIME_PLAYED + " ASC")) {
if (oldest != null && oldest.getCount() > MAX_ITEMS_IN_DB) {
oldest.moveToPosition(oldest.getCount() - MAX_ITEMS_IN_DB);
long timeOfRecordToKeep = oldest.getLong(0);
database.delete(
RecentStoreColumns.NAME,
RecentStoreColumns.TIME_PLAYED + " < ?",
new String[] {String.valueOf(timeOfRecordToKeep)});
}
} finally {
if (oldest != null) {
oldest.close();
RecentStoreColumns.NAME,
RecentStoreColumns.TIME_PLAYED + " < ?",
new String[]{String.valueOf(timeOfRecordToKeep)});
}
}
} finally {

View file

@ -40,14 +40,11 @@ public class SongPlayCountStore extends SQLiteOpenHelper {
@NonNull
private static final Interpolator sInterpolator = new AccelerateInterpolator(1.5f);
// how high to multiply the interpolation curve
@SuppressWarnings("FieldCanBeLocal")
private static final int INTERPOLATOR_HEIGHT = 50;
// how high the base value is. The ratio of the Height to Base is what really matters
@SuppressWarnings("FieldCanBeLocal")
private static final int INTERPOLATOR_BASE = 25;
@SuppressWarnings("FieldCanBeLocal")
private static final int ONE_WEEK_IN_MS = 1000 * 60 * 60 * 24 * 7;
@NonNull
@ -257,7 +254,7 @@ public class SongPlayCountStore extends SQLiteOpenHelper {
for (int i = 0; i < NUM_WEEKS - weekDiff; i++) {
playCounts[i + weekDiff] = cursor.getInt(getColumnIndexForWeek(i));
}
} else if (weekDiff < 0) {
} else {
// time is shifted backwards (by user) - nor typical behavior but we
// will still handle it