-
-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sort by usage #1212
base: main
Are you sure you want to change the base?
Sort by usage #1212
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -47,6 +47,7 @@ public static class LoyaltyCardDbIds { | |||||||
public static final String LAST_USED = "lastused"; | ||||||||
public static final String ZOOM_LEVEL = "zoomlevel"; | ||||||||
public static final String ARCHIVE_STATUS = "archive"; | ||||||||
public static final String USAGE_NUMBER = "usagenumber"; | ||||||||
} | ||||||||
|
||||||||
public static class LoyaltyCardDbIdsGroups { | ||||||||
|
@@ -65,7 +66,9 @@ public static class LoyaltyCardDbFTS { | |||||||
public enum LoyaltyCardOrder { | ||||||||
Alpha, | ||||||||
LastUsed, | ||||||||
Expiry | ||||||||
Expiry, | ||||||||
|
||||||||
UsageNumber | ||||||||
Comment on lines
+70
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done ! |
||||||||
} | ||||||||
|
||||||||
public enum LoyaltyCardOrderDirection { | ||||||||
|
@@ -103,6 +106,7 @@ public void onCreate(SQLiteDatabase db) { | |||||||
LoyaltyCardDbIds.HEADER_COLOR + " INTEGER," + | ||||||||
LoyaltyCardDbIds.CARD_ID + " TEXT not null," + | ||||||||
LoyaltyCardDbIds.BARCODE_ID + " TEXT," + | ||||||||
LoyaltyCardDbIds.USAGE_NUMBER + " INTEGER DEFAULT '0', " + | ||||||||
LoyaltyCardDbIds.BARCODE_TYPE + " TEXT," + | ||||||||
LoyaltyCardDbIds.STAR_STATUS + " INTEGER DEFAULT '0'," + | ||||||||
LoyaltyCardDbIds.LAST_USED + " INTEGER DEFAULT '0', " + | ||||||||
|
@@ -189,6 +193,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | |||||||
LoyaltyCardDbIds.HEADER_COLOR + " INTEGER," + | ||||||||
LoyaltyCardDbIds.CARD_ID + " TEXT not null," + | ||||||||
LoyaltyCardDbIds.BARCODE_ID + " TEXT," + | ||||||||
LoyaltyCardDbIds.USAGE_NUMBER + " INTEGER DEFAULT '0', " + | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong, this will only be executed when users are on database version 9. So existing installations won't get the usage column. This should be removed (there should be an extra upgrade at the end and the DATABASE_VERSION variable needs to be increased). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in progress.. |
||||||||
LoyaltyCardDbIds.BARCODE_TYPE + " TEXT," + | ||||||||
LoyaltyCardDbIds.STAR_STATUS + " INTEGER DEFAULT '0' )"); | ||||||||
|
||||||||
|
@@ -202,6 +207,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | |||||||
LoyaltyCardDbIds.HEADER_COLOR + " ," + | ||||||||
LoyaltyCardDbIds.CARD_ID + " ," + | ||||||||
LoyaltyCardDbIds.BARCODE_ID + " ," + | ||||||||
LoyaltyCardDbIds.USAGE_NUMBER + " , " + | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||
LoyaltyCardDbIds.BARCODE_TYPE + " ," + | ||||||||
LoyaltyCardDbIds.STAR_STATUS + ")" + | ||||||||
" SELECT " + | ||||||||
|
@@ -214,6 +220,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | |||||||
LoyaltyCardDbIds.HEADER_COLOR + " ," + | ||||||||
LoyaltyCardDbIds.CARD_ID + " ," + | ||||||||
LoyaltyCardDbIds.BARCODE_ID + " ," + | ||||||||
LoyaltyCardDbIds.USAGE_NUMBER + " , " + | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||
" NULLIF(" + LoyaltyCardDbIds.BARCODE_TYPE + ",'') ," + | ||||||||
LoyaltyCardDbIds.STAR_STATUS + | ||||||||
" FROM " + LoyaltyCardDbIds.TABLE); | ||||||||
|
@@ -230,6 +237,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | |||||||
LoyaltyCardDbIds.HEADER_COLOR + " INTEGER," + | ||||||||
LoyaltyCardDbIds.CARD_ID + " TEXT not null," + | ||||||||
LoyaltyCardDbIds.BARCODE_ID + " TEXT," + | ||||||||
LoyaltyCardDbIds.USAGE_NUMBER + " INTEGER DEFAULT '0', " + | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||||||||
LoyaltyCardDbIds.BARCODE_TYPE + " TEXT," + | ||||||||
LoyaltyCardDbIds.STAR_STATUS + " INTEGER DEFAULT '0' )"); | ||||||||
|
||||||||
|
@@ -243,6 +251,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | |||||||
LoyaltyCardDbIds.HEADER_COLOR + " ," + | ||||||||
LoyaltyCardDbIds.CARD_ID + " ," + | ||||||||
LoyaltyCardDbIds.BARCODE_ID + " ," + | ||||||||
LoyaltyCardDbIds.USAGE_NUMBER + " , " + | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||||||||
LoyaltyCardDbIds.BARCODE_TYPE + " ," + | ||||||||
LoyaltyCardDbIds.STAR_STATUS + ")" + | ||||||||
" SELECT " + | ||||||||
|
@@ -416,6 +425,7 @@ public static long insertLoyaltyCard( | |||||||
contentValues.put(LoyaltyCardDbIds.BALANCE_TYPE, balanceType != null ? balanceType.getCurrencyCode() : null); | ||||||||
contentValues.put(LoyaltyCardDbIds.CARD_ID, cardId); | ||||||||
contentValues.put(LoyaltyCardDbIds.BARCODE_ID, barcodeId); | ||||||||
contentValues.put(LoyaltyCardDbIds.USAGE_NUMBER, 0); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is below |
||||||||
contentValues.put(LoyaltyCardDbIds.BARCODE_TYPE, barcodeType != null ? barcodeType.name() : null); | ||||||||
contentValues.put(LoyaltyCardDbIds.HEADER_COLOR, headerColor); | ||||||||
contentValues.put(LoyaltyCardDbIds.STAR_STATUS, starStatus); | ||||||||
|
@@ -437,7 +447,7 @@ public static boolean updateLoyaltyCard( | |||||||
final Date validFrom, final Date expiry, final BigDecimal balance, | ||||||||
final Currency balanceType, final String cardId, final String barcodeId, | ||||||||
final CatimaBarcode barcodeType, final Integer headerColor, final int starStatus, | ||||||||
final Long lastUsed, final int archiveStatus) { | ||||||||
final Long lastUsed, final int archiveStatus ) { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whitespace change is unnecessary.
Suggested change
|
||||||||
database.beginTransaction(); | ||||||||
|
||||||||
// Card | ||||||||
|
@@ -477,6 +487,24 @@ public static boolean updateLoyaltyCardArchiveStatus(SQLiteDatabase database, fi | |||||||
return (rowsUpdated == 1); | ||||||||
} | ||||||||
|
||||||||
public static boolean updateLoyaltyCardUsageNumber(SQLiteDatabase database, final int id) { | ||||||||
|
||||||||
LoyaltyCard to_update_card = getLoyaltyCard(database,id); | ||||||||
int usage_number = to_update_card.usage_number + 1; | ||||||||
|
||||||||
ContentValues contentValues = new ContentValues(); | ||||||||
|
||||||||
contentValues.put(LoyaltyCardDbIds.USAGE_NUMBER, usage_number); | ||||||||
Log.d("updateLoyaltyCardULevel", "Card Id = " + id + " usage number = " + usage_number); | ||||||||
int rowsUpdated = database.update(LoyaltyCardDbIds.TABLE, contentValues, | ||||||||
whereAttrs(LoyaltyCardDbIds.ID), | ||||||||
withArgs(to_update_card.id)); | ||||||||
Log.d("updateLoyaltyCardZLevel", "Rows changed = " + rowsUpdated); | ||||||||
|
||||||||
return (rowsUpdated == 1); | ||||||||
|
||||||||
} | ||||||||
|
||||||||
Comment on lines
+490
to
+507
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this makes sense but I am actually going to consider this pull request blocked because we have way too many functions that just edit one field right now and it is just getting uglier every time something is added here. And it is really time I clean this up. |
||||||||
public static boolean updateLoyaltyCardStarStatus(SQLiteDatabase database, final int id, final int starStatus) { | ||||||||
ContentValues contentValues = new ContentValues(); | ||||||||
contentValues.put(LoyaltyCardDbIds.STAR_STATUS, starStatus); | ||||||||
|
@@ -687,18 +715,31 @@ public static Cursor getLoyaltyCardCursor(SQLiteDatabase database, String filter | |||||||
|
||||||||
String orderField = getFieldForOrder(order); | ||||||||
|
||||||||
return database.rawQuery("SELECT " + LoyaltyCardDbIds.TABLE + ".* FROM " + LoyaltyCardDbIds.TABLE + | ||||||||
" JOIN " + LoyaltyCardDbFTS.TABLE + | ||||||||
" ON " + LoyaltyCardDbFTS.TABLE + "." + LoyaltyCardDbFTS.ID + " = " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.ID + | ||||||||
(filter.trim().isEmpty() ? " " : " AND " + LoyaltyCardDbFTS.TABLE + " MATCH ? ") + | ||||||||
groupFilter.toString() + | ||||||||
archiveFilterString + | ||||||||
" ORDER BY " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.ARCHIVE_STATUS + " ASC, " + | ||||||||
LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.STAR_STATUS + " DESC, " + | ||||||||
" (CASE WHEN " + LoyaltyCardDbIds.TABLE + "." + orderField + " IS NULL THEN 1 ELSE 0 END), " + | ||||||||
LoyaltyCardDbIds.TABLE + "." + orderField + " COLLATE NOCASE " + getDbDirection(order, direction) + ", " + | ||||||||
LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.STORE + " COLLATE NOCASE ASC " + | ||||||||
limitString, filter.trim().isEmpty() ? null : new String[]{TextUtils.join("* ", filter.split(" ")) + '*'}, null); | ||||||||
if(order != LoyaltyCardOrder.UsageNumber) | ||||||||
return database.rawQuery("SELECT " + LoyaltyCardDbIds.TABLE + ".* FROM " + LoyaltyCardDbIds.TABLE + | ||||||||
" JOIN " + LoyaltyCardDbFTS.TABLE + | ||||||||
" ON " + LoyaltyCardDbFTS.TABLE + "." + LoyaltyCardDbFTS.ID + " = " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.ID + | ||||||||
(filter.trim().isEmpty() ? " " : " AND " + LoyaltyCardDbFTS.TABLE + " MATCH ? ") + | ||||||||
groupFilter.toString() + | ||||||||
archiveFilterString + | ||||||||
" ORDER BY " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.ARCHIVE_STATUS + " ASC, " + | ||||||||
LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.STAR_STATUS + " DESC, " + | ||||||||
" (CASE WHEN " + LoyaltyCardDbIds.TABLE + "." + orderField + " IS NULL THEN 1 ELSE 0 END), " + | ||||||||
LoyaltyCardDbIds.TABLE + "." + orderField + " COLLATE NOCASE " + getDbDirection(order, direction) + ", " + | ||||||||
LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.STORE + " COLLATE NOCASE ASC " + | ||||||||
limitString, filter.trim().isEmpty() ? null : new String[]{TextUtils.join("* ", filter.split(" ")) + '*'}, null); | ||||||||
else | ||||||||
return database.rawQuery("SELECT " + LoyaltyCardDbIds.TABLE + ".* FROM " + LoyaltyCardDbIds.TABLE + | ||||||||
" JOIN " + LoyaltyCardDbFTS.TABLE + | ||||||||
" ON " + LoyaltyCardDbFTS.TABLE + "." + LoyaltyCardDbFTS.ID + " = " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.ID + | ||||||||
(filter.trim().isEmpty() ? " " : " AND " + LoyaltyCardDbFTS.TABLE + " MATCH ? ") + | ||||||||
groupFilter.toString() + | ||||||||
archiveFilterString + | ||||||||
" ORDER BY " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.USAGE_NUMBER + " DESC, "+ | ||||||||
" (CASE WHEN " + LoyaltyCardDbIds.TABLE + "." + orderField + " IS NULL THEN 1 ELSE 0 END), " + | ||||||||
LoyaltyCardDbIds.TABLE + "." + orderField + " COLLATE NOCASE " + getDbDirection(order, direction) + ", " + | ||||||||
LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.STORE + " COLLATE NOCASE ASC " + | ||||||||
limitString, filter.trim().isEmpty() ? null : new String[]{TextUtils.join("* ", filter.split(" ")) + '*'}, null); | ||||||||
Comment on lines
+718
to
+742
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other ordering features just work with |
||||||||
} | ||||||||
|
||||||||
/** | ||||||||
|
@@ -900,6 +941,10 @@ private static String getFieldForOrder(LoyaltyCardOrder order) { | |||||||
return LoyaltyCardDbIds.EXPIRY; | ||||||||
} | ||||||||
|
||||||||
if (order == LoyaltyCardOrder.UsageNumber) { | ||||||||
return LoyaltyCardDbIds.USAGE_NUMBER; | ||||||||
} | ||||||||
|
||||||||
throw new IllegalArgumentException("Unknown order " + order); | ||||||||
} | ||||||||
|
||||||||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -53,6 +53,8 @@ public void onBindViewHolder(GroupListItemViewHolder inputHolder, Cursor inputCu | |||
int groupCardCount = DBHelper.getGroupCardCount(mDatabase, group._id); | ||||
int archivedCardCount = DBHelper.getArchivedCardsCount(mDatabase, group._id); | ||||
|
||||
System.out.println("Try to find 1"); | ||||
|
||||
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary debug statement.
Suggested change
|
||||
Resources resources = mContext.getResources(); | ||||
|
||||
String cardCountText; | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ public class ImportURIHelper { | |
private static final String BARCODE_TYPE = DBHelper.LoyaltyCardDbIds.BARCODE_TYPE; | ||
private static final String HEADER_COLOR = DBHelper.LoyaltyCardDbIds.HEADER_COLOR; | ||
|
||
private static final String USAGE_NUMBER = DBHelper.LoyaltyCardDbIds.USAGE_NUMBER; | ||
|
||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need to add this to ImportURIHelper. I don't think that someone else using a card a lot should affect how often it is considered used in your installation. |
||
private final Context context; | ||
private final String[] hosts = new String[3]; | ||
private final String[] paths = new String[3]; | ||
|
@@ -92,6 +94,7 @@ public LoyaltyCard parse(Uri uri) throws InvalidObjectException { | |
String note = kv.get(NOTE); | ||
String cardId = kv.get(CARD_ID); | ||
String barcodeId = kv.get(BARCODE_ID); | ||
int usage_number = Integer.parseInt(kv.get(USAGE_NUMBER)); | ||
if (store == null || note == null || cardId == null) | ||
throw new InvalidObjectException("Not a valid import URI: " + uri.toString()); | ||
|
||
|
@@ -122,7 +125,7 @@ public LoyaltyCard parse(Uri uri) throws InvalidObjectException { | |
headerColor = Integer.parseInt(unparsedHeaderColor); | ||
} | ||
|
||
return new LoyaltyCard(-1, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, headerColor, 0, Utils.getUnixTime(), 100, 0); | ||
return new LoyaltyCard(-1, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, headerColor, 0, Utils.getUnixTime(), 100, 0, usage_number); | ||
} catch (NullPointerException | NumberFormatException | UnsupportedEncodingException | ArrayIndexOutOfBoundsException ex) { | ||
throw new InvalidObjectException("Not a valid import URI"); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,12 +34,14 @@ public class LoyaltyCard implements Parcelable { | |
public final long lastUsed; | ||
public int zoomLevel; | ||
|
||
public int usage_number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't this be final like the rest? Also, please use camel-case like everywhere else. |
||
|
||
public LoyaltyCard(final int id, final String store, final String note, final Date validFrom, | ||
final Date expiry, final BigDecimal balance, final Currency balanceType, | ||
final String cardId, @Nullable final String barcodeId, | ||
@Nullable final CatimaBarcode barcodeType, | ||
final String cardId, @Nullable final String barcodeId, @Nullable final CatimaBarcode barcodeType, | ||
@Nullable final Integer headerColor, final int starStatus, | ||
final long lastUsed, final int zoomLevel, final int archiveStatus) { | ||
final long lastUsed, final int zoomLevel, final int archiveStatus, | ||
int usage_number) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't this be final like the rest? Also, please use camel-case like everywhere else. |
||
this.id = id; | ||
this.store = store; | ||
this.note = note; | ||
|
@@ -55,6 +57,7 @@ public LoyaltyCard(final int id, final String store, final String note, final Da | |
this.lastUsed = lastUsed; | ||
this.zoomLevel = zoomLevel; | ||
this.archiveStatus = archiveStatus; | ||
this.usage_number = usage_number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use camel-case like everywhere else. |
||
} | ||
|
||
protected LoyaltyCard(Parcel in) { | ||
|
@@ -110,6 +113,7 @@ public static LoyaltyCard toLoyaltyCard(Cursor cursor) { | |
int starred = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.STAR_STATUS)); | ||
long lastUsed = cursor.getLong(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.LAST_USED)); | ||
int zoomLevel = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.ZOOM_LEVEL)); | ||
int usage_number = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.USAGE_NUMBER)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use camel-case like everywhere else. |
||
int archived = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.ARCHIVE_STATUS)); | ||
|
||
int barcodeTypeColumn = cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.BARCODE_TYPE); | ||
|
@@ -142,7 +146,7 @@ public static LoyaltyCard toLoyaltyCard(Cursor cursor) { | |
headerColor = cursor.getInt(headerColorColumn); | ||
} | ||
|
||
return new LoyaltyCard(id, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, headerColor, starred, lastUsed, zoomLevel, archived); | ||
return new LoyaltyCard(id, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId ,barcodeType, headerColor, starred, lastUsed, zoomLevel, archived, usage_number); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use camel-case like everywhere else. |
||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package protect.card_locker; | ||
|
||
import android.Manifest; | ||
import android.annotation.SuppressLint; | ||
import android.app.Activity; | ||
import android.app.DatePickerDialog; | ||
|
@@ -73,7 +72,6 @@ | |
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.annotation.StringRes; | ||
import androidx.appcompat.app.ActionBar; | ||
import androidx.appcompat.app.AlertDialog; | ||
import androidx.appcompat.widget.AppCompatTextView; | ||
import androidx.appcompat.widget.Toolbar; | ||
|
@@ -222,7 +220,8 @@ private static LoyaltyCard updateTempState(LoyaltyCard loyaltyCard, LoyaltyCardF | |
(int) (fieldName == LoyaltyCardField.starStatus ? value : loyaltyCard.starStatus), | ||
0, // Unimportant, always set to null in doSave so the DB updates it to the current timestamp | ||
100, // Unimportant, not updated in doSave, defaults to 100 for new cards | ||
(int) (fieldName == LoyaltyCardField.archiveStatus ? value : loyaltyCard.archiveStatus) | ||
(int) (fieldName == LoyaltyCardField.archiveStatus ? value : loyaltyCard.archiveStatus), | ||
(int) (fieldName == LoyaltyCardField.usage_number ? value : 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use the variable, I think otherwise the usage will be reset to 0 every time you edit the card. Also, please use camel-case like everywhere else. |
||
); | ||
} | ||
|
||
|
@@ -755,7 +754,7 @@ public void onResume() { | |
} | ||
} else { | ||
// New card, use default values | ||
tempLoyaltyCard = new LoyaltyCard(-1, "", "", null, null, new BigDecimal("0"), null, "", null, null, null, 0, Utils.getUnixTime(), 100,0); | ||
tempLoyaltyCard = new LoyaltyCard(-1, "", "", null, null, new BigDecimal("0"), null, "", null, null, null, 0, Utils.getUnixTime(), 100,0, 0); | ||
|
||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ public enum LoyaltyCardField { | |
cardId, | ||
barcodeId, | ||
barcodeType, | ||
usage_number, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use camel-case like everywhere else. And please keep the same order as in the database class (so, below archiveStatus) |
||
headerColor, | ||
starStatus, | ||
archiveStatus | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -308,6 +308,7 @@ private void setCenterGuideline(int zoomLevel) { | |||
|
||||
@Override | ||||
protected void onCreate(Bundle savedInstanceState) { | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary whitespace change.
Suggested change
|
||||
if (savedInstanceState == null) { | ||||
Bundle incomingIntentExtras = getIntent().getExtras(); | ||||
|
||||
|
@@ -428,6 +429,8 @@ public void onStopTrackingTouch(SeekBar seekBar) { | |||
maximizeButton.setOnClickListener(v -> setFullscreen(true)); | ||||
minimizeButton.setOnClickListener(v -> setFullscreen(false)); | ||||
|
||||
DBHelper.updateLoyaltyCardUsageNumber(database, loyaltyCardId); | ||||
|
||||
Comment on lines
+432
to
+433
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to put this either near the top or all the way at the bottom for clarity. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, i don't know where to put this function, i think it going to be null :/ |
||||
editButton = binding.fabEdit; | ||||
editButton.setOnClickListener(v -> { | ||||
Intent intent = new Intent(getApplicationContext(), LoyaltyCardEditActivity.class); | ||||
|
@@ -466,7 +469,10 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom, int | |||
iconImage.setClipBounds(new Rect(left, top, right, bottom)); | ||||
} | ||||
}); | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary whitespace change.
Suggested change
|
||||
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); | ||||
//this.database | ||||
|
||||
Comment on lines
+474
to
+475
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary debug comment.
Suggested change
|
||||
} | ||||
|
||||
private SpannableStringBuilder padSpannableString(SpannableStringBuilder spannableStringBuilder) { | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard | |
private int mLoyaltyCardCount = 0; | ||
protected String mFilter = ""; | ||
protected Object mGroup = null; | ||
protected DBHelper.LoyaltyCardOrder mOrder = DBHelper.LoyaltyCardOrder.Alpha; | ||
protected DBHelper.LoyaltyCardOrder mOrder = DBHelper.LoyaltyCardOrder.UsageNumber; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't change the default sorting style. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
protected DBHelper.LoyaltyCardOrderDirection mOrderDirection = DBHelper.LoyaltyCardOrderDirection.Ascending; | ||
protected int selectedTab = 0; | ||
private RecyclerView mCardList; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd much prefer this to be named
USAGE_COUNT
andusagecount
. To me that is more logical.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)