mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-01-25 07:18:06 -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user