public static int deleteTag(int id) { int deletedId = -1; if (BuildConfig.DEBUG) Log.d( "CoCoin", "Manager: Delete tag: " + "Tag(id = " + id + ", deletedId = " + deletedId + ")"); boolean tagReference = false; for (CoCoinRecord coCoinRecord : RECORDS) { if (coCoinRecord.getTag() == id) { tagReference = true; break; } } if (tagReference) { return DELETE_TAG_ERROR_TAG_REFERENCE; } deletedId = db.deleteTag(id); if (deletedId == -1) { if (BuildConfig.DEBUG) Log.d("CoCoin", "Delete the above tag FAIL!"); return DELETE_TAG_ERROR_DATABASE_ERROR; } else { if (BuildConfig.DEBUG) Log.d("CoCoin", "Delete the above tag SUCCESSFULLY!"); for (Tag tag : TAGS) { if (tag.getId() == deletedId) { TAGS.remove(tag); break; } } TAG_NAMES.remove(id); sortTAGS(); } return deletedId; }
public static List<CoCoinRecord> queryRecordByTag(int tag) { List<CoCoinRecord> list = new LinkedList<>(); for (CoCoinRecord coCoinRecord : RECORDS) { if (coCoinRecord.getTag() == tag) { list.add(coCoinRecord); } } return list; }