mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-01-15 02:18:01 -05:00
Cleanup
This commit is contained in:
@@ -44,7 +44,7 @@ public class CardShortcutConfigure extends AppCompatActivity
|
||||
final ListView cardList = findViewById(R.id.list);
|
||||
cardList.setVisibility(View.VISIBLE);
|
||||
|
||||
Cursor cardCursor = db.getLoyaltyCardCursor("");
|
||||
Cursor cardCursor = db.getLoyaltyCardCursor();
|
||||
|
||||
final LoyaltyCardCursorAdapter adapter = new LoyaltyCardCursorAdapter(this, cardCursor);
|
||||
cardList.setAdapter(adapter);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class CsvDatabaseExporter implements DatabaseExporter
|
||||
DBHelper.LoyaltyCardDbIds.HEADER_TEXT_COLOR,
|
||||
DBHelper.LoyaltyCardDbIds.BARCODE_TYPE);
|
||||
|
||||
Cursor cursor = db.getLoyaltyCardCursor("");
|
||||
Cursor cursor = db.getLoyaltyCardCursor();
|
||||
|
||||
while(cursor.moveToNext())
|
||||
{
|
||||
|
||||
@@ -144,6 +144,18 @@ public class DBHelper extends SQLiteOpenHelper
|
||||
return (rowsDeleted == 1);
|
||||
}
|
||||
|
||||
public Cursor getLoyaltyCardCursor()
|
||||
{
|
||||
// An empty string will match everything
|
||||
return getLoyaltyCardCursor("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cursor to all loyalty cards with the filter text in either the store or note.
|
||||
*
|
||||
* @param filter
|
||||
* @return Cursor
|
||||
*/
|
||||
public Cursor getLoyaltyCardCursor(final String filter)
|
||||
{
|
||||
String actualFilter = String.format("%%%s%%", filter);
|
||||
@@ -160,23 +172,17 @@ public class DBHelper extends SQLiteOpenHelper
|
||||
|
||||
public int getLoyaltyCardCount()
|
||||
{
|
||||
SQLiteDatabase db = getReadableDatabase();
|
||||
Cursor data = db.rawQuery("SELECT Count(*) FROM " + LoyaltyCardDbIds.TABLE, null);
|
||||
|
||||
int numItems = 0;
|
||||
|
||||
if(data.getCount() == 1)
|
||||
{
|
||||
data.moveToFirst();
|
||||
numItems = data.getInt(0);
|
||||
}
|
||||
|
||||
data.close();
|
||||
|
||||
return numItems;
|
||||
// An empty string will match everything
|
||||
return getLoyaltyCardCount("");
|
||||
}
|
||||
|
||||
public int getFilteredLoyaltyCardCount(String filter)
|
||||
/**
|
||||
* Returns the amount of loyalty cards with the filter text in either the store or note.
|
||||
*
|
||||
* @param filter
|
||||
* @return Integer
|
||||
*/
|
||||
public int getLoyaltyCardCount(String filter)
|
||||
{
|
||||
String actualFilter = String.format("%%%s%%", filter);
|
||||
String[] selectionArgs = { actualFilter, actualFilter };
|
||||
|
||||
@@ -95,7 +95,7 @@ public class MainActivity extends AppCompatActivity
|
||||
filter.setVisibility(View.VISIBLE);
|
||||
cardList.setVisibility(View.VISIBLE);
|
||||
helpText.setVisibility(View.GONE);
|
||||
if(db.getFilteredLoyaltyCardCount(filterText) > 0)
|
||||
if(db.getLoyaltyCardCount(filterText) > 0)
|
||||
{
|
||||
noMatchingCardsText.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class DatabaseTest
|
||||
|
||||
assertEquals(CARDS_TO_ADD, db.getLoyaltyCardCount());
|
||||
|
||||
Cursor cursor = db.getLoyaltyCardCursor("");
|
||||
Cursor cursor = db.getLoyaltyCardCursor();
|
||||
assertNotNull(cursor);
|
||||
|
||||
assertEquals(CARDS_TO_ADD, cursor.getCount());
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ImportExportTest
|
||||
*/
|
||||
private void checkLoyaltyCards()
|
||||
{
|
||||
Cursor cursor = db.getLoyaltyCardCursor("");
|
||||
Cursor cursor = db.getLoyaltyCardCursor();
|
||||
int index = 1;
|
||||
|
||||
while(cursor.moveToNext())
|
||||
|
||||
@@ -86,7 +86,7 @@ public class LoyaltyCardCursorAdapterTest
|
||||
db.insertLoyaltyCard("store", "", "cardId", BarcodeFormat.UPC_A.toString(), Color.BLACK, Color.WHITE);
|
||||
LoyaltyCard card = db.getLoyaltyCard(1);
|
||||
|
||||
Cursor cursor = db.getLoyaltyCardCursor("");
|
||||
Cursor cursor = db.getLoyaltyCardCursor();
|
||||
cursor.moveToFirst();
|
||||
|
||||
View view = createView(cursor);
|
||||
@@ -100,7 +100,7 @@ public class LoyaltyCardCursorAdapterTest
|
||||
db.insertLoyaltyCard("store", "note", "cardId", BarcodeFormat.UPC_A.toString(), Color.BLACK, Color.WHITE);
|
||||
LoyaltyCard card = db.getLoyaltyCard(1);
|
||||
|
||||
Cursor cursor = db.getLoyaltyCardCursor("");
|
||||
Cursor cursor = db.getLoyaltyCardCursor();
|
||||
cursor.moveToFirst();
|
||||
|
||||
View view = createView(cursor);
|
||||
@@ -114,7 +114,7 @@ public class LoyaltyCardCursorAdapterTest
|
||||
db.insertLoyaltyCard("store", "note", "cardId", BarcodeFormat.UPC_A.toString(), Color.BLACK, Color.WHITE);
|
||||
LoyaltyCard card = db.getLoyaltyCard(1);
|
||||
|
||||
Cursor cursor = db.getLoyaltyCardCursor("");
|
||||
Cursor cursor = db.getLoyaltyCardCursor();
|
||||
cursor.moveToFirst();
|
||||
|
||||
setFontSizes(1, 2);
|
||||
|
||||
Reference in New Issue
Block a user