diff --git a/app/src/main/java/com/refresh/pos/domain/inventory/ProductCatalog.java b/app/src/main/java/com/refresh/pos/domain/inventory/ProductCatalog.java index a0ab074..95a890e 100644 --- a/app/src/main/java/com/refresh/pos/domain/inventory/ProductCatalog.java +++ b/app/src/main/java/com/refresh/pos/domain/inventory/ProductCatalog.java @@ -41,8 +41,7 @@ public boolean addProduct(String name, String barcode, double salePrice) { * @return true if product edits success ; otherwise false. */ public boolean editProduct(Product product) { - boolean respond = inventoryDao.editProduct(product); - return respond; + return inventoryDao.editProduct(product); } /** diff --git a/app/src/main/java/com/refresh/pos/domain/sale/Register.java b/app/src/main/java/com/refresh/pos/domain/sale/Register.java index c1f6140..17c2e9d 100644 --- a/app/src/main/java/com/refresh/pos/domain/sale/Register.java +++ b/app/src/main/java/com/refresh/pos/domain/sale/Register.java @@ -38,7 +38,8 @@ public static boolean isDaoSet() { } public static Register getInstance() throws NoDaoSetException { - if (instance == null) instance = new Register(); + if (instance == null) + instance = new Register(); return instance; } @@ -90,7 +91,8 @@ public LineItem addItem(Product product, int quantity) { * @return total price of Sale. */ public double getTotal() { - if (currentSale == null) return 0; + if (currentSale == null) + return 0; return currentSale.getTotal(); } @@ -133,7 +135,8 @@ public boolean setCurrentSale(int id) { * @return true if there is a current Sale; otherwise false. */ public boolean hasSale(){ - if(currentSale == null)return false; + if(currentSale == null) + return false; return true; } diff --git a/app/src/main/java/com/refresh/pos/domain/sale/SaleLedger.java b/app/src/main/java/com/refresh/pos/domain/sale/SaleLedger.java index e07bc2d..1de39d6 100644 --- a/app/src/main/java/com/refresh/pos/domain/sale/SaleLedger.java +++ b/app/src/main/java/com/refresh/pos/domain/sale/SaleLedger.java @@ -32,7 +32,8 @@ public static boolean isDaoSet() { } public static SaleLedger getInstance() throws NoDaoSetException { - if (instance == null) instance = new SaleLedger(); + if (instance == null) + instance = new SaleLedger(); return instance; } diff --git a/app/src/main/java/com/refresh/pos/techicalservices/AndroidDatabase.java b/app/src/main/java/com/refresh/pos/techicalservices/AndroidDatabase.java index 5b94154..6badba3 100644 --- a/app/src/main/java/com/refresh/pos/techicalservices/AndroidDatabase.java +++ b/app/src/main/java/com/refresh/pos/techicalservices/AndroidDatabase.java @@ -107,10 +107,11 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { @Override public List select(String queryString) { + Cursor cursor = null; try { SQLiteDatabase database = this.getWritableDatabase(); List list = new ArrayList(); - Cursor cursor = database.rawQuery(queryString, null); + cursor = database.rawQuery(queryString, null); if (cursor != null) { if (cursor.moveToFirst()) { @@ -125,13 +126,16 @@ public List select(String queryString) { } while (cursor.moveToNext()); } } - cursor.close(); database.close(); return list; } catch (Exception e) { e.printStackTrace(); return null; + } finally { + if(cursor != null) { + cursor.close(); + } } } diff --git a/app/src/main/java/com/refresh/pos/techicalservices/Demo.java b/app/src/main/java/com/refresh/pos/techicalservices/Demo.java index fb8b22b..7e315a6 100644 --- a/app/src/main/java/com/refresh/pos/techicalservices/Demo.java +++ b/app/src/main/java/com/refresh/pos/techicalservices/Demo.java @@ -19,6 +19,8 @@ */ public class Demo { + private Demo() {} + /** * Adds the demo product to inventory. * @param context The current stage of the application. diff --git a/app/src/main/java/com/refresh/pos/techicalservices/inventory/InventoryDaoAndroid.java b/app/src/main/java/com/refresh/pos/techicalservices/inventory/InventoryDaoAndroid.java index 2954df9..4cec8b2 100644 --- a/app/src/main/java/com/refresh/pos/techicalservices/inventory/InventoryDaoAndroid.java +++ b/app/src/main/java/com/refresh/pos/techicalservices/inventory/InventoryDaoAndroid.java @@ -79,8 +79,7 @@ public List getAllProduct() { */ private List getAllProduct(String condition) { String queryString = "SELECT * FROM " + DatabaseContents.TABLE_PRODUCT_CATALOG.toString() + condition + " ORDER BY name"; - List list = toProductList(database.select(queryString)); - return list; + return toProductList(database.select(queryString)); } /** @@ -108,7 +107,8 @@ private List getSimilarProductBy(String reference, String value) { @Override public Product getProductByBarcode(String barcode) { List list = getProductBy("barcode", barcode); - if (list.isEmpty()) return null; + if (list.isEmpty()) + return null; return list.get(0); } @@ -167,8 +167,7 @@ public List searchProduct(String search) { */ private List getAllProductLot(String condition) { String queryString = "SELECT * FROM " + DatabaseContents.TABLE_STOCK.toString() + condition; - List list = toProductLotList(database.select(queryString)); - return list; + return toProductLotList(database.select(queryString)); } /** diff --git a/app/src/main/java/com/refresh/pos/techicalservices/sale/SaleDaoAndroid.java b/app/src/main/java/com/refresh/pos/techicalservices/sale/SaleDaoAndroid.java index a9c0ec8..0cef59e 100644 --- a/app/src/main/java/com/refresh/pos/techicalservices/sale/SaleDaoAndroid.java +++ b/app/src/main/java/com/refresh/pos/techicalservices/sale/SaleDaoAndroid.java @@ -62,8 +62,7 @@ public int addLineItem(int saleId, LineItem lineItem) { content.put("product_id", lineItem.getProduct().getId()); content.put("quantity", lineItem.getQuantity()); content.put("unit_price", lineItem.getPriceAtSale()); - int id = database.insert(DatabaseContents.TABLE_SALE_LINEITEM.toString(), content); - return id; + return database.insert(DatabaseContents.TABLE_SALE_LINEITEM.toString(), content); } @Override @@ -86,8 +85,7 @@ public List getAllSale() { public List getAllSaleDuring(Calendar start, Calendar end) { String startBound = DateTimeStrategy.getSQLDateFormat(start); String endBound = DateTimeStrategy.getSQLDateFormat(end); - List list = getAllSale(" WHERE end_time BETWEEN '" + startBound + " 00:00:00' AND '" + endBound + " 23:59:59' AND status = 'ENDED'"); - return list; + return getAllSale(" WHERE end_time BETWEEN '" + startBound + " 00:00:00' AND '" + endBound + " 23:59:59' AND status = 'ENDED'"); } /** diff --git a/app/src/main/java/com/refresh/pos/ui/SplashScreenActivity.java b/app/src/main/java/com/refresh/pos/ui/SplashScreenActivity.java index 326bacc..9fbac0c 100644 --- a/app/src/main/java/com/refresh/pos/ui/SplashScreenActivity.java +++ b/app/src/main/java/com/refresh/pos/ui/SplashScreenActivity.java @@ -112,7 +112,8 @@ public void onClick(View v) { new Handler().postDelayed(new Runnable() { @Override public void run() { - if (!gone) go(); + if (!gone) + go(); } }, SPLASH_TIMEOUT); } diff --git a/app/src/main/java/com/refresh/pos/ui/sale/ReportFragment.java b/app/src/main/java/com/refresh/pos/ui/sale/ReportFragment.java index 70c77e8..46a770f 100644 --- a/app/src/main/java/com/refresh/pos/ui/sale/ReportFragment.java +++ b/app/src/main/java/com/refresh/pos/ui/sale/ReportFragment.java @@ -162,7 +162,7 @@ private void showList(List list) { @Override public void update() { int period = spinner.getSelectedItemPosition(); - List list = null; + List list; Calendar cTime = (Calendar) currentTime.clone(); Calendar eTime = (Calendar) currentTime.clone();