Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/src/main/java/com/refresh/pos/domain/DateTimeStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ public static void setLocale(String lang, String reg) {
locale = new Locale(lang, reg);
dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", locale);
}


/**
* Sets current time format.
* @return current time format.
*/
public static String format() {
return dateFormat.format(Calendar.getInstance(locale).getTime());
}

/**
* Sets current time format.
* @param date date of this format.
* @return current time format.
*/
public static String format(String date) {
return dateFormat.format(Calendar.getInstance(locale).getTime());
return dateFormat.format(date);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Product getProduct() {
public Map<String, String> toMap() {
Map<String, String> map = new HashMap<String, String>();
map.put("id", id + "");
map.put("dateAdded", DateTimeStrategy.format(dateAdded));
map.put("dateAdded", DateTimeStrategy.format());
map.put("quantity", quantity + "");
map.put("productName", product.getName());
map.put("cost", unitCost + "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
public class AndroidDatabase extends SQLiteOpenHelper implements Database {

private static final String TAG = "AndroidDatabase";
private static final int DATABASE_VERSION = 1;

/**
Expand Down Expand Up @@ -112,25 +113,23 @@ public List<Object> select(String queryString) {
List<Object> list = new ArrayList<Object>();
Cursor cursor = database.rawQuery(queryString, null);

if (cursor != null) {
if (cursor.moveToFirst()) {
do {
ContentValues content = new ContentValues();
String[] columnNames = cursor.getColumnNames();
for (String columnName : columnNames) {
content.put(columnName, cursor.getString(cursor
.getColumnIndex(columnName)));
}
list.add(content);
} while (cursor.moveToNext());
}
if (cursor != null && cursor.moveToFirst()) {
do {
ContentValues content = new ContentValues();
String[] columnNames = cursor.getColumnNames();
for (String columnName : columnNames) {
content.put(columnName, cursor.getString(cursor
.getColumnIndex(columnName)));
}
list.add(content);
} while (cursor.moveToNext());
}
cursor.close();
database.close();
return list;

} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, e.getMessage(), e);
return null;
}
}
Expand All @@ -144,7 +143,7 @@ public int insert(String tableName, Object content) {
database.close();
return id;
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, e.getMessage(), e);
return -1;
}

Expand All @@ -161,7 +160,7 @@ public boolean update(String tableName, Object content) {
return true;

} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, e.getMessage(), e);
return false;
}
}
Expand All @@ -174,7 +173,7 @@ public boolean delete(String tableName, int id) {
return true;

} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, e.getMessage(), e);
return false;
}
}
Expand All @@ -186,7 +185,7 @@ public boolean execute(String query) {
database.execSQL(query);
return true;
}catch(Exception e){
e.printStackTrace();
Log.e(TAG, e.getMessage(), e);
return false;
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/refresh/pos/techicalservices/Demo.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
public class Demo {

private static final String TAG = "Demo";

/**
* Adds the demo product to inventory.
* @param context The current stage of the application.
Expand All @@ -35,7 +37,7 @@ public static void testProduct(Context context) {
catalog.addProduct(contents[1], contents[0], Double.parseDouble(contents[2]));
}
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public class ProductDetailActivity extends Activity {

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.detail_menu, menu);
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.detail_menu, menu);
return true;
}

Expand Down