Fixing some bugs
|
@ -37,7 +37,7 @@
|
|||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[{"id":16,"name":"Bug Sprays"},{"id":1,"name":"Clothing"},{"id":8,"name":"Documents"},{"id":11,"name":"Electronics"},{"id":3,"name":"Equipment"},{"id":14,"name":"Furniture"},{"id":7,"name":"Groceries"},{"id":4,"name":"Medicines"},{"id":5,"name":"Personal Care"},{"id":15,"name":"Tools"},{"id":2,"name":"Utensils"}]
|
|
@ -0,0 +1 @@
|
|||
[{"id":4,"item_ids":[212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,254,256,258,259,261,253,257,262,270,275,296,295,297,300,298,308,306,309,310,311,313,318,319,320,321,322,315,323,325,326,327,329,331,333,335,336,337,338,339,340,341,377,348,349,351,352,391,379,353,380,355,381,382,383,358,360,361,362,363,378,384,365,366,367,385,368,386,369,387,371,372,388,374,394,403,395,400,397,398],"name":"Alpine","photo":"","photo_thumb":"","photo_thumbnail":""},{"id":5,"item_ids":[212,213,214,216,217,218,220,221,222,224,225,226,227,228,229,230,231,233,235,236,237,238,239,240,241,242,249,250,243,244,264,251,245,246,247,255,248,256,252,261,253,293,294,299,304,305,309,310,312,317,318,327,328,329,331,333,334,335,336,337,338,343,339,341,342,344,345,346,347,348,353,355,359,362,363,364,368,369,370,374,394,402,400,401,398,258,259,262,275,270,406,223,215,409,232,411,412],"name":"Caravanning","photo":"","photo_thumb":"","photo_thumbnail":""},{"id":8,"item_ids":[212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,228,230,231,232,233,234,235,236,237,238,239,254,256,258,259,260,261,253,257,262,270,275,299,303,305,306,309,310,311,312,314,316,317,321,315,327,328,329,331,332,333,334,335,336,337,338,343,339,340,341,342,344,345,346,377,389,390,348,349,352,379,353,380,383,358,392,362,363,364,378,384,365,366,367,368,386,369,387,370,371,388,373,374,403,395,391,396,400,397,398],"name":"Caving","photo":"","photo_thumb":"","photo_thumbnail":""},{"id":3,"item_ids":[279,282,273,274,288,283,291,289,271,267,268,269,270,266,278,286,277,272,280,281,265,284,285,287,276,290,292],"name":"First-aid kit","photo":"","photo_thumb":"","photo_thumbnail":""},{"id":15,"item_ids":[],"name":"My list","photo":"","photo_thumb":"","photo_thumbnail":""},{"id":2,"item_ids":[212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,238,249,264,254,255,258,259,252,261,253,262,270,275,299,303,304,306,309,310,311,312,316,317,318,327,328,329,331,332,333,334,335,336,337,338,343,339,340,341,342,344,345,346,375,347,348,350,353,359,362,363,364,365,367,368,376,369,370,374,403,395,400,397,398],"name":"Rafting","photo":"","photo_thumb":"","photo_thumbnail":""},{"id":14,"item_ids":[409,217,218,224,225,227,232,234,235,238,254,275,292,295,296,297,421,306,309,310,311,317,318,315,323,327,329,420,332,340,416,427,424,426,425,380,357,417,418,422,419,415,423,374,408,405,404,400,401,428],"name":"Ski / Snowboard","photo":"","photo_thumb":"","photo_thumbnail":""},{"id":1,"item_ids":[212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,254,256,258,259,261,253,262,270,275,296,299,304,330,306,309,310,311,312,316,317,318,320,321,325,326,327,328,329,331,332,333,334,335,336,337,338,343,339,341,342,344,345,346,347,348,349,352,353,354,355,356,360,361,362,363,364,365,367,368,369,370,372,373,374,394,403,395,400,397,398,413],"name":"Summer hiking","photo":"","photo_thumb":"","photo_thumbnail":""},{"id":6,"item_ids":[212,213,214,215,216,217,218,219,220,222,224,225,226,228,231,232,233,235,236,237,238,239,275,299,305,309,310,311,317,318,325,326,327,328,329,332,374,399,400,401,393,398,405,404,340],"name":"Trip","photo":"","photo_thumb":"","photo_thumbnail":""},{"id":10,"item_ids":[223,214,215,409,217,218,219,220,224,225,226,230,234,235,239,264,261,253,270,275,295,297,300,298,308,309,310,311,313,318,320,321,315,324,326,329,332,333,335,336,337,338,339,340,341,331,349,352,353,354,355,356,357,361,362,363,364,365,366,367,368,369,372,374,394,408,395,400,397],"name":"Winter hiking","photo":"","photo_thumb":"","photo_thumbnail":""}]
|
|
@ -2,6 +2,7 @@ package com.hikapro.backpack;
|
|||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
|
||||
/**
|
||||
* Created by tariel on 27/04/16.
|
||||
|
@ -9,14 +10,20 @@ import android.content.Context;
|
|||
public class App extends Application {
|
||||
|
||||
private static Context context;
|
||||
private static Typeface mainFace;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
App.context = getApplicationContext();
|
||||
App.mainFace = Typeface.createFromAsset(App.context.getAssets(), "fonts/Ubuntu-B.ttf");
|
||||
}
|
||||
|
||||
public static Context getAppContext() {
|
||||
return App.context;
|
||||
}
|
||||
|
||||
public static Typeface getMainFace() {
|
||||
return App.mainFace;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,17 @@ public class ItemModel implements Model.Item {
|
|||
break;
|
||||
case Event.ITEM_CATEGORY_LOAD_ERROR :
|
||||
break;
|
||||
case Event.SET_ITEMS_LOAD_COMPLETED :
|
||||
case Event.SET_ITEMS_LIKE_ERROR:
|
||||
if (!itemsCache.isEmpty()) {
|
||||
itemsCache.clear();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
case Event.SET_ITEMS_LOAD_COMPLETED:
|
||||
itemsCache = (List<Item>) event.obj;
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
case Event.SET_ITEMS_LIKE_COMPLETED:
|
||||
itemsCache = (List<Item>) event.obj;
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
|
@ -96,10 +106,7 @@ public class ItemModel implements Model.Item {
|
|||
notifyDataSetChanged();
|
||||
break;
|
||||
case Event.SET_UNPACK_COMPLETED:
|
||||
packedQty = 0;
|
||||
if (presenter != null) {
|
||||
presenter.notifyItemPackStatusChanged();
|
||||
}
|
||||
executeQuery();
|
||||
break;
|
||||
case Event.ITEM_CATEGORY_LOAD_COMPLETED:
|
||||
categoriesCache = (Hashtable<Integer, Category>)event.obj;
|
||||
|
@ -117,10 +124,8 @@ public class ItemModel implements Model.Item {
|
|||
break;
|
||||
case Event.ITEM_INSERTED :
|
||||
break;
|
||||
case Event.SET_RESTORE_COMPLETED :
|
||||
if (presenter != null) {
|
||||
presenter.notifyDataSetChanged();
|
||||
}
|
||||
case Event.SET_RESTORE_COMPLETED:
|
||||
executeQuery();
|
||||
Toast.makeText(App.getAppContext(), "Restore completed", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
|
@ -192,16 +197,11 @@ public class ItemModel implements Model.Item {
|
|||
command.arg1 = presenter.getCurrentSet().getId();
|
||||
dao.executeCommand(command);
|
||||
} else {
|
||||
query = query.toLowerCase();
|
||||
String name;
|
||||
List<Item> newList = new ArrayList<>(20);
|
||||
for (Item item : itemsCache) {
|
||||
name = item.getName().toLowerCase();
|
||||
if (name.contains(query)) {
|
||||
newList.add(item);
|
||||
}
|
||||
}
|
||||
itemsCache = newList;
|
||||
Message command = Message.obtain();
|
||||
command.what = Command.SET_GET_ITEMS_LIKE;
|
||||
command.arg1 = presenter.getCurrentSet().getId();
|
||||
command.obj = query;
|
||||
dao.executeCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,6 @@ public class ItemModel implements Model.Item {
|
|||
//itemsCache.remove(item);
|
||||
}
|
||||
}
|
||||
// TODO use item itself?
|
||||
@Override
|
||||
public void packItem(com.hikapro.backpack.model.entities.Item item) {
|
||||
if (item != null) {
|
||||
|
@ -305,7 +304,11 @@ public class ItemModel implements Model.Item {
|
|||
|
||||
@Override
|
||||
public void unpackSet(int setId) {
|
||||
// nothing
|
||||
Message command;
|
||||
command = Message.obtain();
|
||||
command.what = Command.SET_UNPACK_ITEMS;
|
||||
command.arg1 = setId;
|
||||
dao.executeCommand(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.hikapro.backpack.model;
|
||||
|
||||
import android.os.Message;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import com.hikapro.backpack.App;
|
||||
import com.hikapro.backpack.model.dao.Command;
|
||||
import com.hikapro.backpack.model.dao.Event;
|
||||
import com.hikapro.backpack.model.entities.Category;
|
||||
|
@ -40,6 +42,23 @@ public class PackedModel extends ItemModel {
|
|||
dao.executeCommand(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filter(String query) {
|
||||
|
||||
if (query.isEmpty()) {
|
||||
Message command = Message.obtain();
|
||||
command.what = Command.SET_GET_PACKED_ITEMS;
|
||||
command.arg1 = presenter.getCurrentSet().getId();
|
||||
dao.executeCommand(command);
|
||||
} else {
|
||||
Message command = Message.obtain();
|
||||
command.what = Command.SET_GET_ITEMS_LIKE_PACKED;
|
||||
command.arg1 = presenter.getCurrentSet().getId();
|
||||
command.obj = query;
|
||||
dao.executeCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(Message event) {
|
||||
|
||||
|
@ -61,10 +80,20 @@ public class PackedModel extends ItemModel {
|
|||
break;
|
||||
case Event.ITEM_REMOVAL_CANCEL_ERROR:
|
||||
break;
|
||||
case Event.SET_ITEMS_LIKE_PACKED_ERROR:
|
||||
if (!itemsCache.isEmpty()) {
|
||||
itemsCache.clear();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
case Event.SET_PACKED_LOAD_COMPLETED :
|
||||
itemsCache = (List<Item>) event.obj;
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
case Event.SET_ITEMS_LIKE_PACKED_COMPLETED:
|
||||
itemsCache = (List<Item>) event.obj;
|
||||
notifyDataSetChanged();
|
||||
break;
|
||||
case Event.SET_GET_STAT_COMPLETED:
|
||||
currentSetActiveItemsQty = event.arg1;
|
||||
packedQty = event.arg2;
|
||||
|
@ -86,11 +115,7 @@ public class PackedModel extends ItemModel {
|
|||
notifyDataSetChanged();
|
||||
break;
|
||||
case Event.SET_UNPACK_COMPLETED :
|
||||
packedQty = 0;
|
||||
itemsCache.clear();
|
||||
if (presenter != null) {
|
||||
presenter.notifyItemPackStatusChanged();
|
||||
}
|
||||
executeQuery();
|
||||
break;
|
||||
case Event.ITEM_CATEGORY_LOAD_COMPLETED :
|
||||
categoriesCache = (Hashtable<Integer, Category>)event.obj;
|
||||
|
@ -101,6 +126,10 @@ public class PackedModel extends ItemModel {
|
|||
case Event.ITEM_UNPACKED :
|
||||
executeQuery();
|
||||
break;
|
||||
case Event.SET_RESTORE_COMPLETED:
|
||||
executeQuery();
|
||||
Toast.makeText(App.getAppContext(), "Restore completed", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,13 +156,4 @@ public class PackedModel extends ItemModel {
|
|||
itemsCache.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unpackSet(int setId) {
|
||||
Message command;
|
||||
command = Message.obtain();
|
||||
command.what = Command.SET_UNPACK_ITEMS;
|
||||
command.arg1 = setId;
|
||||
dao.executeCommand(command);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,6 +93,12 @@ public class SetModel implements Model.Set {
|
|||
if (presenter != null)
|
||||
presenter.stopProgress();
|
||||
Toast.makeText(App.getAppContext(), R.string.no_connection, Toast.LENGTH_SHORT).show();
|
||||
Message command = Message.obtain();
|
||||
command.what = Command.SYNC_READ_FROM_FILE;
|
||||
dao.executeCommand(command);
|
||||
command = Message.obtain();
|
||||
command.what = Command.SET_GET_ALL;
|
||||
dao.executeCommand(command);
|
||||
break;
|
||||
case Event.SYNC_FAILED :
|
||||
if (presenter != null)
|
||||
|
|
|
@ -18,6 +18,8 @@ public interface Command {
|
|||
int SET_RESTORE_DEFAULT = 0x69;
|
||||
int SET_GET_STAT = 0x70;
|
||||
int SET_CLEAN_PACKED = 0x71;
|
||||
int SET_GET_ITEMS_LIKE = 0x72;
|
||||
int SET_GET_ITEMS_LIKE_PACKED = 0x73;
|
||||
|
||||
int ITEM_DELETE_FROM_SET = 0x78;
|
||||
int ITEM_INSERT = 0x79;
|
||||
|
@ -37,6 +39,7 @@ public interface Command {
|
|||
|
||||
int SYNC = 0xA0;
|
||||
int SYNC_IF_NOT_EXISTS = 0xA1;
|
||||
int SYNC_READ_FROM_FILE = 0xA2;
|
||||
|
||||
int TEST = 0xC8;
|
||||
|
||||
|
|
|
@ -12,8 +12,11 @@ import android.os.Looper;
|
|||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -26,6 +29,8 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.hikapro.backpack.App;
|
||||
import com.hikapro.backpack.model.Api;
|
||||
import com.hikapro.backpack.model.Model;
|
||||
|
@ -122,26 +127,34 @@ public class DAO {
|
|||
if (command != null) {
|
||||
switch (command.what) {
|
||||
|
||||
case Command.SET_GET_ALL :
|
||||
case Command.SET_GET_ALL:
|
||||
setTask = new SetTask(Command.SET_GET_ALL,
|
||||
Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
threadPool.execute(setTask);
|
||||
break;
|
||||
|
||||
case Command.SET_REORDER :
|
||||
case Command.SET_REORDER:
|
||||
setTask = new SetTask(Command.SET_REORDER,
|
||||
Process.THREAD_PRIORITY_BACKGROUND);
|
||||
setTask.setsToUpdate = (List<Set>) command.obj;
|
||||
threadPool.execute(setTask);
|
||||
break;
|
||||
|
||||
case Command.SET_GET_ITEMS :
|
||||
case Command.SET_GET_ITEMS:
|
||||
setTask = new SetTask(Command.SET_GET_ITEMS,
|
||||
Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
setTask.setId = command.arg1;
|
||||
threadPool.execute(setTask);
|
||||
break;
|
||||
|
||||
case Command.SET_GET_ITEMS_LIKE:
|
||||
setTask = new SetTask(Command.SET_GET_ITEMS_LIKE,
|
||||
Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
setTask.setId = command.arg1;
|
||||
setTask.query = (String) command.obj;
|
||||
threadPool.execute(setTask);
|
||||
break;
|
||||
|
||||
case Command.SET_GET_PACKED_ITEMS :
|
||||
setTask = new SetTask(Command.SET_GET_PACKED_ITEMS,
|
||||
Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
|
@ -149,41 +162,49 @@ public class DAO {
|
|||
threadPool.execute(setTask);
|
||||
break;
|
||||
|
||||
case Command.SET_UNPACK_ITEMS :
|
||||
case Command.SET_GET_ITEMS_LIKE_PACKED:
|
||||
setTask = new SetTask(Command.SET_GET_ITEMS_LIKE_PACKED,
|
||||
Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
setTask.setId = command.arg1;
|
||||
setTask.query = (String) command.obj;
|
||||
threadPool.execute(setTask);
|
||||
break;
|
||||
|
||||
case Command.SET_UNPACK_ITEMS:
|
||||
setTask = new SetTask(Command.SET_UNPACK_ITEMS,
|
||||
Process.THREAD_PRIORITY_DEFAULT);
|
||||
setTask.setId = command.arg1;
|
||||
threadPool.execute(setTask);
|
||||
break;
|
||||
|
||||
case Command.SET_RESTORE_DEFAULT :
|
||||
case Command.SET_RESTORE_DEFAULT:
|
||||
setTask = new SetTask(Command.SET_RESTORE_DEFAULT,
|
||||
Process.THREAD_PRIORITY_DEFAULT);
|
||||
setTask.setId = command.arg1;
|
||||
threadPool.execute(setTask);
|
||||
break;
|
||||
|
||||
case Command.SET_GET_STAT :
|
||||
case Command.SET_GET_STAT:
|
||||
setTask = new SetTask(Command.SET_GET_STAT,
|
||||
Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
setTask.setId = command.arg1;
|
||||
threadPool.execute(setTask);
|
||||
break;
|
||||
|
||||
case Command.SET_CLEAN_PACKED :
|
||||
case Command.SET_CLEAN_PACKED:
|
||||
setTask = new SetTask(Command.SET_CLEAN_PACKED,
|
||||
Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
setTask.setId = command.arg1;
|
||||
threadPool.execute(setTask);
|
||||
break;
|
||||
|
||||
case Command.ITEM_GET_CATEGORIES :
|
||||
case Command.ITEM_GET_CATEGORIES:
|
||||
itemTask = new ItemTask(Command.ITEM_GET_CATEGORIES,
|
||||
Process.THREAD_PRIORITY_MORE_FAVORABLE);
|
||||
threadPool.execute(itemTask);
|
||||
break;
|
||||
|
||||
case Command.ITEM_INSERT :
|
||||
case Command.ITEM_INSERT:
|
||||
itemTask = new ItemTask(Command.ITEM_INSERT,
|
||||
Process.THREAD_PRIORITY_BACKGROUND);
|
||||
itemTask.item = (Item) command.obj;
|
||||
|
@ -199,7 +220,7 @@ public class DAO {
|
|||
threadPool.execute(itemTask);
|
||||
break;
|
||||
|
||||
case Command.ITEM_DELETE_FROM_SET :
|
||||
case Command.ITEM_DELETE_FROM_SET:
|
||||
itemTask = new ItemTask(Command.ITEM_DELETE_FROM_SET,
|
||||
Process.THREAD_PRIORITY_BACKGROUND);
|
||||
itemTask.setId = command.arg1;
|
||||
|
@ -269,12 +290,17 @@ public class DAO {
|
|||
case Command.MY_LIST_CLEAR :
|
||||
break;
|
||||
|
||||
case Command.SYNC :
|
||||
case Command.SYNC:
|
||||
threadPool.execute(new SyncTask(Command.SYNC,
|
||||
Process.THREAD_PRIORITY_BACKGROUND));
|
||||
break;
|
||||
|
||||
case Command.SYNC_IF_NOT_EXISTS :
|
||||
case Command.SYNC_READ_FROM_FILE:
|
||||
threadPool.execute(new SyncTask(Command.SYNC_READ_FROM_FILE,
|
||||
Process.THREAD_PRIORITY_BACKGROUND));
|
||||
break;
|
||||
|
||||
case Command.SYNC_IF_NOT_EXISTS:
|
||||
threadPool.execute(new SyncTask(Command.SYNC_IF_NOT_EXISTS,
|
||||
Process.THREAD_PRIORITY_MORE_FAVORABLE));
|
||||
break;
|
||||
|
@ -436,18 +462,20 @@ public class DAO {
|
|||
}
|
||||
}
|
||||
|
||||
private void insertSetItem(int setId, int itemId, boolean userDefined) {
|
||||
private long insertSetItem(int setId, int itemId, boolean userDefined) {
|
||||
long ret = 0;
|
||||
ContentValues values;
|
||||
SQLiteDatabase db = getWriteDB();
|
||||
try {
|
||||
db.beginTransaction();
|
||||
values = Db.SetItemsTable.toContentValues(setId, itemId, userDefined);
|
||||
db.insert(Db.SetItemsTable.TABLE_NAME, null, values);
|
||||
ret = db.insert(Db.SetItemsTable.TABLE_NAME, null, values);
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
db.close();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// reads
|
||||
|
@ -637,9 +665,11 @@ public class DAO {
|
|||
}
|
||||
} catch (SQLiteException e) {
|
||||
//TODO write to log here
|
||||
ret = null;
|
||||
|
||||
} catch (Exception e) {
|
||||
//TODO write to log here
|
||||
ret = null;
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
|
@ -680,6 +710,61 @@ public class DAO {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private List<Item> readItemsLike(String like, int setId, boolean packed) {
|
||||
List<Item> ret = new ArrayList<>(256);
|
||||
Cursor cursor = null;
|
||||
SQLiteDatabase db = null;
|
||||
Item item;
|
||||
String query = String.format(
|
||||
"SELECT a.%s, a.%s, a.%s, a.%s, a.%s, a.%s, a.%s, a.%s, a.%s, a.%s, %s, %s FROM %s a INNER JOIN %s b ON a.%s = b.%s WHERE b.%s = ? AND a.%s LIKE %s AND b.%s <> 1 AND b.%s %s 1",
|
||||
|
||||
Db.ItemsTable.COLUMN_ID,
|
||||
Db.ItemsTable.COLUMN_NAME,
|
||||
Db.ItemsTable.COLUMN_CATEGORY,
|
||||
Db.ItemsTable.COLUMN_DESCRIPTION,
|
||||
Db.ItemsTable.COLUMN_BUY_URLS,
|
||||
Db.ItemsTable.COLUMN_PHOTO_URL,
|
||||
Db.ItemsTable.COLUMN_PHOTO_THUMB_URL,
|
||||
Db.ItemsTable.COLUMN_PHOTO_LOCAL,
|
||||
Db.ItemsTable.COLUMN_PHOTO_THUMB_LOCAL,
|
||||
Db.ItemsTable.COLUMN_USER_DEFINED,
|
||||
Db.SetItemsTable.COLUMN_PENDING_REMOVAL,
|
||||
Db.SetItemsTable.COLUMN_PACKED,
|
||||
|
||||
Db.ItemsTable.TABLE_NAME,
|
||||
Db.SetItemsTable.TABLE_NAME,
|
||||
Db.ItemsTable.COLUMN_ID,
|
||||
Db.SetItemsTable.COLUMN_ITEM,
|
||||
Db.SetItemsTable.COLUMN_SET,
|
||||
Db.ItemsTable.COLUMN_NAME,
|
||||
'\''+like+'%'+'\'',
|
||||
Db.SetItemsTable.COLUMN_DELETED,
|
||||
Db.SetItemsTable.COLUMN_PACKED,
|
||||
packed ? "=" : "<>");
|
||||
try {
|
||||
db = getReadDB();
|
||||
cursor = db.rawQuery(query, new String[]{String.valueOf(setId)});
|
||||
while (cursor.moveToNext()) {
|
||||
item = Db.ItemsTable.parseCursor(cursor);
|
||||
// if (!packed && item.isPendingRemoval())
|
||||
// continue;
|
||||
ret.add(item);
|
||||
}
|
||||
} catch (SQLiteException e) {
|
||||
//TODO write to log here
|
||||
ret = null;
|
||||
} catch (Exception e) {
|
||||
//TODO write to log here
|
||||
ret = null;
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
if (db != null)
|
||||
db.close();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<Item> readItemsLike(String like, int checkThisSet) {
|
||||
List<Item> ret = new ArrayList<>(256);
|
||||
Cursor cursor = null;
|
||||
|
@ -960,6 +1045,40 @@ public class DAO {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private int updateSetActiveQty(int setId, int updateOn) {
|
||||
int ret = 0;
|
||||
SQLiteDatabase db = null;
|
||||
ContentValues values;
|
||||
Set set;
|
||||
try {
|
||||
db = getWriteDB();
|
||||
db.beginTransaction();
|
||||
set = readSet(db, setId);
|
||||
if (set != null) {
|
||||
values = new ContentValues();
|
||||
|
||||
values.put(Db.SetsTable.COLUMN_ACTIVE_QTY, set.getActiveQty()+updateOn);
|
||||
|
||||
ret += db.update(Db.SetsTable.TABLE_NAME, values, String.format("%s = ?",
|
||||
Db.SetsTable.COLUMN_ID),
|
||||
new String[]{String.valueOf(setId)});
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
} catch (SQLiteException e) {
|
||||
//TODO write to log here
|
||||
ret = -1;
|
||||
} catch (Exception e) {
|
||||
//TODO write to log here
|
||||
ret = -1;
|
||||
} finally {
|
||||
if (db != null) {
|
||||
db.endTransaction();
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int updateSetItemsCleanPacked(int setId) {
|
||||
int ret = 0;
|
||||
SQLiteDatabase db = null;
|
||||
|
@ -1014,9 +1133,11 @@ public class DAO {
|
|||
db.setTransactionSuccessful();
|
||||
} catch (SQLiteException e) {
|
||||
//TODO write to log here
|
||||
ret = -1;
|
||||
|
||||
} catch (Exception e) {
|
||||
//TODO write to log here
|
||||
ret = -1;
|
||||
} finally {
|
||||
if (db != null) {
|
||||
db.endTransaction();
|
||||
|
@ -1065,7 +1186,6 @@ public class DAO {
|
|||
db.setTransactionSuccessful();
|
||||
} catch (SQLiteException e) {
|
||||
//TODO write to log here
|
||||
|
||||
} catch (Exception e) {
|
||||
//TODO write to log here
|
||||
} finally {
|
||||
|
@ -1099,6 +1219,7 @@ public class DAO {
|
|||
if (set != null) {
|
||||
values = new ContentValues();
|
||||
values.put(Db.SetsTable.COLUMN_PACKED_QTY, 0);
|
||||
values.put(Db.SetsTable.COLUMN_ACTIVE_QTY, set.getItems().size());
|
||||
ret += db.update(Db.SetsTable.TABLE_NAME, values, String.format("%s = ?",
|
||||
Db.SetsTable.COLUMN_ID),
|
||||
new String[]{String.valueOf(setId)});
|
||||
|
@ -1109,9 +1230,10 @@ public class DAO {
|
|||
db.setTransactionSuccessful();
|
||||
} catch (SQLiteException e) {
|
||||
//TODO write to log here
|
||||
|
||||
ret = -1;
|
||||
} catch (Exception e) {
|
||||
//TODO write to log here
|
||||
ret = -1;
|
||||
} finally {
|
||||
if (db != null) {
|
||||
db.endTransaction();
|
||||
|
@ -1331,10 +1453,12 @@ public class DAO {
|
|||
|
||||
case Command.ITEM_INSERT :
|
||||
if (insertItem(item) > 0) {
|
||||
insertSetItem(setId, item.getId(), item.isUserDefined());
|
||||
message.what = Event.ITEM_INSERTED;
|
||||
message.arg1 = setId;
|
||||
message.arg2 = item.getId();
|
||||
if (insertSetItem(setId, item.getId(), item.isUserDefined()) > 0) {
|
||||
updateSetActiveQty(setId, 1);
|
||||
message.what = Event.ITEM_INSERTED;
|
||||
message.arg1 = setId;
|
||||
message.arg2 = item.getId();
|
||||
}
|
||||
} else {
|
||||
message.what = Event.ITEM_INSERT_ERROR;
|
||||
}
|
||||
|
@ -1388,6 +1512,7 @@ public class DAO {
|
|||
int currentCommand;
|
||||
int priority;
|
||||
int setId;
|
||||
String query;
|
||||
List<Set> setsToUpdate;
|
||||
List<Item> items;
|
||||
|
||||
|
@ -1404,7 +1529,7 @@ public class DAO {
|
|||
Message message = Message.obtain();
|
||||
switch (currentCommand) {
|
||||
|
||||
case Command.SET_GET_ALL :
|
||||
case Command.SET_GET_ALL:
|
||||
List<Set> sets = readSets();
|
||||
if (sets.isEmpty())
|
||||
message.what = Event.SET_LOAD_ERROR;
|
||||
|
@ -1414,9 +1539,9 @@ public class DAO {
|
|||
}
|
||||
break;
|
||||
|
||||
case Command.SET_GET_ITEMS :
|
||||
case Command.SET_GET_ITEMS:
|
||||
items = readItems(setId, false);
|
||||
if (items.isEmpty())
|
||||
if (items == null)
|
||||
message.what = Event.SET_ITEMS_LOAD_ERROR;
|
||||
else {
|
||||
Collections.sort(items);
|
||||
|
@ -1426,7 +1551,19 @@ public class DAO {
|
|||
}
|
||||
break;
|
||||
|
||||
case Command.SET_REORDER :
|
||||
case Command.SET_GET_ITEMS_LIKE:
|
||||
items = readItemsLike(query, setId, false);
|
||||
if (items == null)
|
||||
message.what = Event.SET_ITEMS_LIKE_ERROR;
|
||||
else {
|
||||
Collections.sort(items);
|
||||
message.what = Event.SET_ITEMS_LIKE_COMPLETED;
|
||||
message.obj = items;
|
||||
message.arg1 = setId;
|
||||
}
|
||||
break;
|
||||
|
||||
case Command.SET_REORDER:
|
||||
message.arg1 = updateSetsOrder(setsToUpdate);
|
||||
if (message.arg1 > 0)
|
||||
message.what = Event.SET_REORDER_COMPLETED;
|
||||
|
@ -1436,7 +1573,7 @@ public class DAO {
|
|||
|
||||
case Command.SET_GET_PACKED_ITEMS :
|
||||
items = readItems(setId, true);
|
||||
if (items.isEmpty())
|
||||
if (items == null)
|
||||
message.what = Event.SET_PACKED_LOAD_ERROR;
|
||||
else {
|
||||
Collections.sort(items);
|
||||
|
@ -1446,6 +1583,18 @@ public class DAO {
|
|||
}
|
||||
break;
|
||||
|
||||
case Command.SET_GET_ITEMS_LIKE_PACKED:
|
||||
items = readItemsLike(query, setId, true);
|
||||
if (items == null)
|
||||
message.what = Event.SET_ITEMS_LIKE_PACKED_ERROR;
|
||||
else {
|
||||
Collections.sort(items);
|
||||
message.what = Event.SET_ITEMS_LIKE_PACKED_COMPLETED;
|
||||
message.obj = items;
|
||||
message.arg1 = setId;
|
||||
}
|
||||
break;
|
||||
|
||||
case Command.SET_UNPACK_ITEMS :
|
||||
message.arg1 = updateSetItemsPacked(setId, false);
|
||||
message.arg2 = setId;
|
||||
|
@ -1524,7 +1673,7 @@ public class DAO {
|
|||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
} else { // for the first time
|
||||
if (!NetworkUtil.isInternetAvailable()) {
|
||||
message.what = Event.SYNC_NO_CONNECTION;
|
||||
} else {
|
||||
|
@ -1553,6 +1702,41 @@ public class DAO {
|
|||
}
|
||||
break;
|
||||
|
||||
case Command.SYNC_READ_FROM_FILE:
|
||||
|
||||
try {
|
||||
String sets = readSetsFromFile();
|
||||
String categories = readCategoriesFromFile();
|
||||
String items = readItemsFromFile();
|
||||
|
||||
if (sets != null && categories != null && items != null) {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<Set>>() {
|
||||
}.getType();
|
||||
List<Set> setsFromJson = gson.fromJson(sets, type);
|
||||
insertSets(setsFromJson);
|
||||
type = new TypeToken<List<Category>>() {
|
||||
}.getType();
|
||||
List<Category> categoriesFromJson = gson.fromJson(categories, type);
|
||||
insertCategories(categoriesFromJson);
|
||||
type = new TypeToken<List<Item>>() {
|
||||
}.getType();
|
||||
List<Item> itemsFromJson = gson.fromJson(items, type);
|
||||
insertItems(itemsFromJson);
|
||||
insertTimestamp(new Timestamp(1456083374));
|
||||
message.what = Event.SYNC_COMPLETED;
|
||||
} else {
|
||||
message.what = Event.SYNC_FAILED;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log.e("Read from file", ex.getMessage());
|
||||
message.what = Event.SYNC_FAILED;
|
||||
} finally {
|
||||
message.arg1 = 200;
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
break;
|
||||
|
||||
case Command.SYNC_IF_NOT_EXISTS:
|
||||
if (logExist()) {
|
||||
message.what = Event.SYNC_COMPLETED;
|
||||
|
@ -1649,5 +1833,48 @@ public class DAO {
|
|||
return bitmap;
|
||||
}
|
||||
|
||||
private String readSetsFromFile() {
|
||||
String sets = null;
|
||||
try {
|
||||
InputStream is = App.getAppContext().getAssets().open("jsons/sets.json");
|
||||
int size = is.available();
|
||||
byte[] buffer = new byte[size];
|
||||
is.read(buffer);
|
||||
is.close();
|
||||
sets = new String(buffer, "UTF-8");
|
||||
} catch (IOException ex) {
|
||||
Log.e("Reading json", ex.getMessage());
|
||||
}
|
||||
return sets;
|
||||
}
|
||||
|
||||
private String readCategoriesFromFile() {
|
||||
String categories = null;
|
||||
try {
|
||||
InputStream is = App.getAppContext().getAssets().open("jsons/item_categories.json");
|
||||
int size = is.available();
|
||||
byte[] buffer = new byte[size];
|
||||
is.read(buffer);
|
||||
is.close();
|
||||
categories = new String(buffer, "UTF-8");
|
||||
} catch (IOException ex) {
|
||||
Log.e("Reading json", ex.getMessage());
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
|
||||
private String readItemsFromFile() {
|
||||
String items = null;
|
||||
try {
|
||||
InputStream is = App.getAppContext().getAssets().open("jsons/items.json");
|
||||
int size = is.available();
|
||||
byte[] buffer = new byte[size];
|
||||
is.read(buffer);
|
||||
is.close();
|
||||
items = new String(buffer, "UTF-8");
|
||||
} catch (IOException ex) {
|
||||
Log.e("Reading json", ex.getMessage());
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,6 @@ package com.hikapro.backpack.model.dao;
|
|||
*/
|
||||
public interface Event {
|
||||
|
||||
int SET_SCOPE_END = 0x13;
|
||||
int ITEM_SCOPE_END = 0x27;
|
||||
int MY_LIST_SCOPE_END = 0x3B;
|
||||
|
||||
int SET_LOAD_ERROR = -0x1;
|
||||
int SET_REORDER_ERROR = -0x2;
|
||||
int SET_ITEMS_LOAD_ERROR = -0x3;
|
||||
|
@ -17,6 +13,8 @@ public interface Event {
|
|||
int SET_RESTORE_ERROR = -0x6;
|
||||
int SET_GET_STAT_ERROR = -0x7;
|
||||
int SET_CLEAN_PACKED_ERROR = -0x8;
|
||||
int SET_ITEMS_LIKE_ERROR = -0x9;
|
||||
int SET_ITEMS_LIKE_PACKED_ERROR = -0xA;
|
||||
|
||||
|
||||
int SET_LOAD_COMPLETED = 0x1;
|
||||
|
@ -27,6 +25,8 @@ public interface Event {
|
|||
int SET_RESTORE_COMPLETED = 0x6;
|
||||
int SET_GET_STAT_COMPLETED = 0x7;
|
||||
int SET_PACKED_CLEANED = 0x8;
|
||||
int SET_ITEMS_LIKE_COMPLETED = 0x9;
|
||||
int SET_ITEMS_LIKE_PACKED_COMPLETED = 0xA;
|
||||
|
||||
int ITEM_FROM_SET_ERROR = -0x14;
|
||||
int ITEM_INSERT_ERROR = -0x15;
|
||||
|
|
|
@ -15,6 +15,10 @@ public class Timestamp {
|
|||
public Timestamp() {
|
||||
}
|
||||
|
||||
public Timestamp(long value) {
|
||||
this.timestamp = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class AddPresenter implements Presenter.Add {
|
|||
recycler.setAdapter(adapter);
|
||||
recycler.setItemAnimator(new DefaultItemAnimator());
|
||||
//recycler.addItemDecoration(new DividerDecoration(getActivityContext()));
|
||||
recycler.addItemDecoration(new DividerDecoration2(getActivityContext(), R.drawable.divider, Util.dp2px(getAppContext(), 16)));
|
||||
recycler.addItemDecoration(new DividerDecoration2(getActivityContext(), R.drawable.divider2, Util.dp2px(getAppContext(), 16)));
|
||||
categoryContainer = (FlowLayout) view.findViewById(R.id.add_item_category_flow);
|
||||
//categoryContainer.setPaddings(Util.dp2px(getAppContext(), 15), Util.dp2px(getAppContext(), 15)); // TODO check here
|
||||
categoryContainerMain = (ViewGroup) view.findViewById(R.id.add_item_category_container);
|
||||
|
|
|
@ -155,7 +155,6 @@ public class ItemListPresenter implements Presenter.ItemList {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private void showPackedItems () {
|
||||
getView().showPackedItems(set);
|
||||
}
|
||||
|
@ -173,6 +172,7 @@ public class ItemListPresenter implements Presenter.ItemList {
|
|||
this.view = new WeakReference<>(view);
|
||||
this.set = getView().getSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModel(Model.Item model) {
|
||||
this.model = model;
|
||||
|
@ -191,6 +191,7 @@ public class ItemListPresenter implements Presenter.ItemList {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getActivityContext() {
|
||||
try {
|
||||
|
|
|
@ -16,7 +16,9 @@ import android.widget.TextView;
|
|||
import com.hikapro.backpack.R;
|
||||
import com.hikapro.backpack.model.entities.Set;
|
||||
import com.hikapro.backpack.presenter.adapters.PackedListAdapter;
|
||||
import com.hikapro.backpack.presenter.adapters.helper.Util;
|
||||
import com.hikapro.backpack.presenter.adapters.helper.items.DividerDecoration;
|
||||
import com.hikapro.backpack.presenter.adapters.helper.items.DividerDecoration2;
|
||||
import com.hikapro.backpack.presenter.adapters.helper.items.ItemSwipeCallback;
|
||||
import com.hikapro.backpack.presenter.adapters.helper.items.StickyHeaderDecoration;
|
||||
|
||||
|
@ -49,7 +51,8 @@ public class PackedListPresenter extends ItemListPresenter {
|
|||
|
||||
final StickyHeaderDecoration decoration = new StickyHeaderDecoration(adapter);
|
||||
recycler.addItemDecoration(decoration);
|
||||
recycler.addItemDecoration(new DividerDecoration(getActivityContext()));
|
||||
//recycler.addItemDecoration(new DividerDecoration(getActivityContext()));
|
||||
recycler.addItemDecoration(new DividerDecoration2(getActivityContext(), R.drawable.divider, Util.dp2px(getAppContext(), 16)));
|
||||
adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
||||
@Override
|
||||
public void onChanged() {
|
||||
|
@ -63,18 +66,7 @@ public class PackedListPresenter extends ItemListPresenter {
|
|||
backToList = (TextView) view.findViewById(R.id.back_to_list);
|
||||
packedCount = (TextView) view.findViewById(R.id.header_packed_count);
|
||||
unpackButton = (Button) view.findViewById(R.id.unpack_button);
|
||||
/*
|
||||
if (model.getPackedQty() == model.getActiveItemsCount()) {
|
||||
backToList.setVisibility(View.INVISIBLE);
|
||||
packedCount.setVisibility(View.INVISIBLE);
|
||||
unpackButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
backToList.setVisibility(View.VISIBLE);
|
||||
packedCount.setVisibility(View.VISIBLE);
|
||||
unpackButton.setVisibility(View.INVISIBLE);
|
||||
|
||||
}
|
||||
*/
|
||||
setVisibility();
|
||||
unpackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.facebook.CallbackManager;
|
||||
import com.facebook.FacebookCallback;
|
||||
|
@ -122,6 +123,13 @@ public class SharePresenter implements Presenter.Share {
|
|||
}
|
||||
}
|
||||
});
|
||||
twitterButton.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(android.view.View v) {
|
||||
Toast.makeText(getActivityContext(), "Not implemented!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.hikapro.backpack.presenter.adapters;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.hikapro.backpack.R;
|
||||
|
@ -61,7 +63,7 @@ public class ItemDetailAdapter extends RecyclerView.Adapter<ItemViewHolder> {
|
|||
});
|
||||
|
||||
|
||||
SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||
|
||||
menuLayout.removeAllViews();
|
||||
|
@ -120,12 +122,9 @@ public class ItemDetailAdapter extends RecyclerView.Adapter<ItemViewHolder> {
|
|||
menu.addMenuItem(returnToListItem);
|
||||
}
|
||||
|
||||
menuLayout.addMenu(menu);
|
||||
|
||||
menuLayout.setMenuItemClickListener(new SwipeMenuLayout.OnMenuItemClickListener() {
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onMenuItemClick(View v) {
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case ItemListAdapter.ID_DELETE:
|
||||
// no delete
|
||||
|
@ -140,8 +139,10 @@ public class ItemDetailAdapter extends RecyclerView.Adapter<ItemViewHolder> {
|
|||
pack(item);
|
||||
break;
|
||||
}
|
||||
menuLayout.notifyOnMenuItemClick();
|
||||
}
|
||||
});
|
||||
};
|
||||
menuLayout.addMenu(menu, onClickListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,9 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.hikapro.backpack.App;
|
||||
import com.hikapro.backpack.R;
|
||||
import com.hikapro.backpack.model.entities.Category;
|
||||
import com.hikapro.backpack.model.entities.Item;
|
||||
|
@ -34,7 +36,6 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
|||
|
||||
protected Presenter.ItemList presenter;
|
||||
protected boolean checkAll;
|
||||
protected Typeface mainFace;
|
||||
|
||||
public ItemListAdapter(Presenter.ItemList presenter) {
|
||||
this.presenter = presenter;
|
||||
|
@ -84,8 +85,8 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
|||
}
|
||||
});
|
||||
|
||||
SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
final SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||
|
||||
menuLayout.removeAllViews();
|
||||
|
||||
|
@ -160,12 +161,9 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
|||
// add to menu
|
||||
menu.addMenuItem(deleteItem);
|
||||
|
||||
menuLayout.addMenu(menu);
|
||||
|
||||
menuLayout.setMenuItemClickListener(new SwipeMenuLayout.OnMenuItemClickListener() {
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onMenuItemClick(View v) {
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case ID_DELETE:
|
||||
remove(item);
|
||||
|
@ -180,9 +178,12 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
|||
pack(item);
|
||||
break;
|
||||
}
|
||||
menuLayout.notifyOnMenuItemClick();
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
menuLayout.addMenu(menu, onClickListener);
|
||||
|
||||
}
|
||||
|
||||
|
@ -229,6 +230,7 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
|||
Category category = presenter.getModel().getCategoryByPosition(position);
|
||||
holder.id = category.getId();
|
||||
holder.title.setText(category.getName());
|
||||
holder.title.setTypeface(App.getMainFace());
|
||||
holder.title.setBackgroundColor(0x2B1E15);
|
||||
}
|
||||
|
||||
|
@ -245,18 +247,13 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
|||
}
|
||||
|
||||
public void pack(Item item) {
|
||||
presenter.getModel().packItem(item);
|
||||
//notifyDataSetChanged(); // TODO check nn
|
||||
/*
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeRemoved(position, getItemCount());
|
||||
*/
|
||||
if (!item.isPacked())
|
||||
presenter.getModel().packItem(item);
|
||||
}
|
||||
|
||||
public void unpack(Item item) {
|
||||
presenter.getModel().unpackItem(item);
|
||||
//notifyItemRemoved(position);
|
||||
//notifyDataSetChanged(); // TODO check nn
|
||||
if (item.isPacked())
|
||||
presenter.getModel().unpackItem(item);
|
||||
}
|
||||
|
||||
public void setCheckAll(boolean checkAll) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public class PackedListAdapter extends ItemListAdapter {
|
|||
}
|
||||
});
|
||||
|
||||
SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||
|
||||
menuLayout.removeAllViews();
|
||||
|
@ -130,12 +130,9 @@ public class PackedListAdapter extends ItemListAdapter {
|
|||
// add to menu
|
||||
menu.addMenuItem(deleteItem);
|
||||
|
||||
menuLayout.addMenu(menu);
|
||||
|
||||
menuLayout.setMenuItemClickListener(new SwipeMenuLayout.OnMenuItemClickListener() {
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onMenuItemClick(View v) {
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case ID_DELETE:
|
||||
remove(item);
|
||||
|
@ -150,8 +147,11 @@ public class PackedListAdapter extends ItemListAdapter {
|
|||
pack(item);
|
||||
break;
|
||||
}
|
||||
menuLayout.notifyOnMenuItemClick();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
menuLayout.addMenu(menu, onClickListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.hikapro.backpack.App;
|
||||
import com.hikapro.backpack.R;
|
||||
import com.hikapro.backpack.presenter.SetListPresenter;
|
||||
import com.hikapro.backpack.presenter.adapters.helper.sets.ItemTouchHelperAdapter;
|
||||
|
@ -18,7 +19,6 @@ public class SetListAdapter extends RecyclerView.Adapter<SetViewHolder> impleme
|
|||
|
||||
private SetListPresenter presenter;
|
||||
private String rightBracket;
|
||||
private Typeface mainFace;
|
||||
|
||||
public SetListAdapter(SetListPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
|
@ -38,13 +38,8 @@ public class SetListAdapter extends RecyclerView.Adapter<SetViewHolder> impleme
|
|||
this.rightBracket = "";
|
||||
}
|
||||
|
||||
if (mainFace == null) {
|
||||
mainFace = Typeface.createFromAsset(presenter.getAppContext().getAssets(),
|
||||
"fonts/Ubuntu-B.ttf");
|
||||
}
|
||||
|
||||
holder.textView.setText(set.getName() + " " + rightBracket);
|
||||
holder.textView.setTypeface(mainFace);
|
||||
holder.textView.setTypeface(App.getMainFace());
|
||||
String info = String.format("%s %d / %d",
|
||||
presenter.getActivityContext().getResources().getString(R.string.packed),
|
||||
set.getPackedQty(),
|
||||
|
|
|
@ -0,0 +1,296 @@
|
|||
package com.hikapro.backpack.presenter.adapters.helper;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.text.Layout.Alignment;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.SparseIntArray;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AutoResizeTextView extends TextView {
|
||||
private interface SizeTester {
|
||||
/**
|
||||
*
|
||||
* @param suggestedSize
|
||||
* Size of text to be tested
|
||||
* @param availableSpace
|
||||
* available space in which text must fit
|
||||
* @return an integer < 0 if after applying {@code suggestedSize} to
|
||||
* text, it takes less space than {@code availableSpace}, > 0
|
||||
* otherwise
|
||||
*/
|
||||
public int onTestSize(int suggestedSize, RectF availableSpace);
|
||||
}
|
||||
|
||||
private RectF mTextRect = new RectF();
|
||||
|
||||
private RectF mAvailableSpaceRect;
|
||||
|
||||
private SparseIntArray mTextCachedSizes;
|
||||
|
||||
private TextPaint mPaint;
|
||||
|
||||
private float mMaxTextSize;
|
||||
|
||||
private float mSpacingMult = 1.0f;
|
||||
|
||||
private float mSpacingAdd = 0.0f;
|
||||
|
||||
private float mMinTextSize = 20;
|
||||
|
||||
private int mWidthLimit;
|
||||
|
||||
private static final int NO_LINE_LIMIT = -1;
|
||||
private int mMaxLines;
|
||||
|
||||
private boolean mEnableSizeCache = true;
|
||||
private boolean mInitiallized;
|
||||
|
||||
public AutoResizeTextView(Context context) {
|
||||
super(context);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public AutoResizeTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public AutoResizeTextView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
mPaint = new TextPaint(getPaint());
|
||||
mMaxTextSize = getTextSize();
|
||||
mAvailableSpaceRect = new RectF();
|
||||
mTextCachedSizes = new SparseIntArray();
|
||||
if (mMaxLines == 0) {
|
||||
// no value was assigned during construction
|
||||
mMaxLines = NO_LINE_LIMIT;
|
||||
}
|
||||
mInitiallized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(final CharSequence text, BufferType type) {
|
||||
super.setText(text, type);
|
||||
adjustTextSize(text.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextSize(float size) {
|
||||
mMaxTextSize = size;
|
||||
mTextCachedSizes.clear();
|
||||
adjustTextSize(getText().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLines(int maxlines) {
|
||||
super.setMaxLines(maxlines);
|
||||
mMaxLines = maxlines;
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
public int getMaxLines() {
|
||||
return mMaxLines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSingleLine() {
|
||||
super.setSingleLine();
|
||||
mMaxLines = 1;
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSingleLine(boolean singleLine) {
|
||||
super.setSingleLine(singleLine);
|
||||
if (singleLine) {
|
||||
mMaxLines = 1;
|
||||
} else {
|
||||
mMaxLines = NO_LINE_LIMIT;
|
||||
}
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLines(int lines) {
|
||||
super.setLines(lines);
|
||||
mMaxLines = lines;
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextSize(int unit, float size) {
|
||||
Context c = getContext();
|
||||
Resources r;
|
||||
|
||||
if (c == null)
|
||||
r = Resources.getSystem();
|
||||
else
|
||||
r = c.getResources();
|
||||
mMaxTextSize = TypedValue.applyDimension(unit, size,
|
||||
r.getDisplayMetrics());
|
||||
mTextCachedSizes.clear();
|
||||
adjustTextSize(getText().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineSpacing(float add, float mult) {
|
||||
super.setLineSpacing(add, mult);
|
||||
mSpacingMult = mult;
|
||||
mSpacingAdd = add;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the lower text size limit and invalidate the view
|
||||
*
|
||||
* @param minTextSize
|
||||
*/
|
||||
public void setMinTextSize(float minTextSize) {
|
||||
mMinTextSize = minTextSize;
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
private void reAdjust() {
|
||||
adjustTextSize(getText().toString());
|
||||
}
|
||||
|
||||
private void adjustTextSize(String string) {
|
||||
if (!mInitiallized) {
|
||||
return;
|
||||
}
|
||||
int startSize = (int) mMinTextSize;
|
||||
int heightLimit = getMeasuredHeight() - getCompoundPaddingBottom()
|
||||
- getCompoundPaddingTop();
|
||||
mWidthLimit = getMeasuredWidth() - getCompoundPaddingLeft()
|
||||
- getCompoundPaddingRight();
|
||||
mAvailableSpaceRect.right = mWidthLimit;
|
||||
mAvailableSpaceRect.bottom = heightLimit;
|
||||
super.setTextSize(
|
||||
TypedValue.COMPLEX_UNIT_PX,
|
||||
efficientTextSizeSearch(startSize, (int) mMaxTextSize,
|
||||
mSizeTester, mAvailableSpaceRect));
|
||||
}
|
||||
|
||||
private final SizeTester mSizeTester = new SizeTester() {
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
@Override
|
||||
public int onTestSize(int suggestedSize, RectF availableSPace) {
|
||||
mPaint.setTextSize(suggestedSize);
|
||||
String text = getText().toString();
|
||||
boolean singleline = getMaxLines() == 1;
|
||||
if (singleline) {
|
||||
mTextRect.bottom = mPaint.getFontSpacing();
|
||||
mTextRect.right = mPaint.measureText(text);
|
||||
} else {
|
||||
StaticLayout layout = new StaticLayout(text, mPaint,
|
||||
mWidthLimit, Alignment.ALIGN_NORMAL, mSpacingMult,
|
||||
mSpacingAdd, true);
|
||||
// return early if we have more lines
|
||||
if (getMaxLines() != NO_LINE_LIMIT
|
||||
&& layout.getLineCount() > getMaxLines()) {
|
||||
return 1;
|
||||
}
|
||||
mTextRect.bottom = layout.getHeight();
|
||||
int maxWidth = -1;
|
||||
for (int i = 0; i < layout.getLineCount(); i++) {
|
||||
if (maxWidth < layout.getLineWidth(i)) {
|
||||
maxWidth = (int) layout.getLineWidth(i);
|
||||
}
|
||||
}
|
||||
mTextRect.right = maxWidth;
|
||||
}
|
||||
|
||||
mTextRect.offsetTo(0, 0);
|
||||
if (availableSPace.contains(mTextRect)) {
|
||||
// may be too small, don't worry we will find the best match
|
||||
return -1;
|
||||
} else {
|
||||
// too big
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Enables or disables size caching, enabling it will improve performance
|
||||
* where you are animating a value inside TextView. This stores the font
|
||||
* size against getText().length() Be careful though while enabling it as 0
|
||||
* takes more space than 1 on some fonts and so on.
|
||||
*
|
||||
* @param enable
|
||||
* enable font size caching
|
||||
*/
|
||||
public void enableSizeCache(boolean enable) {
|
||||
mEnableSizeCache = enable;
|
||||
mTextCachedSizes.clear();
|
||||
adjustTextSize(getText().toString());
|
||||
}
|
||||
|
||||
private int efficientTextSizeSearch(int start, int end,
|
||||
SizeTester sizeTester, RectF availableSpace) {
|
||||
if (!mEnableSizeCache) {
|
||||
return binarySearch(start, end, sizeTester, availableSpace);
|
||||
}
|
||||
String text = getText().toString();
|
||||
int key = text == null ? 0 : text.length();
|
||||
int size = mTextCachedSizes.get(key);
|
||||
if (size != 0) {
|
||||
return size;
|
||||
}
|
||||
size = binarySearch(start, end, sizeTester, availableSpace);
|
||||
mTextCachedSizes.put(key, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
private static int binarySearch(int start, int end, SizeTester sizeTester,
|
||||
RectF availableSpace) {
|
||||
int lastBest = start;
|
||||
int lo = start;
|
||||
int hi = end - 1;
|
||||
int mid = 0;
|
||||
while (lo <= hi) {
|
||||
mid = (lo + hi) >>> 1;
|
||||
int midValCmp = sizeTester.onTestSize(mid, availableSpace);
|
||||
if (midValCmp < 0) {
|
||||
lastBest = lo;
|
||||
lo = mid + 1;
|
||||
} else if (midValCmp > 0) {
|
||||
hi = mid - 1;
|
||||
lastBest = hi;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
// make sure to return last best
|
||||
// this is what should always be returned
|
||||
return lastBest;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTextChanged(final CharSequence text, final int start,
|
||||
final int before, final int after) {
|
||||
super.onTextChanged(text, start, before, after);
|
||||
reAdjust();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int width, int height, int oldwidth,
|
||||
int oldheight) {
|
||||
mTextCachedSizes.clear();
|
||||
super.onSizeChanged(width, height, oldwidth, oldheight);
|
||||
if (width != oldwidth || height != oldheight) {
|
||||
reAdjust();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,7 +40,6 @@ public class SwipableElement extends LinearLayout {
|
|||
private ScrollerCompat mOpenScroller;
|
||||
private ScrollerCompat mCloseScroller;
|
||||
private int mBaseX;
|
||||
private int position;
|
||||
private Interpolator mCloseInterpolator;
|
||||
private Interpolator mOpenInterpolator;
|
||||
|
||||
|
@ -58,6 +57,7 @@ public class SwipableElement extends LinearLayout {
|
|||
mOpenInterpolator = openInterpolator;
|
||||
mContentView = contentView;
|
||||
mMenuView = menuView;
|
||||
menuView.setSwipableElement(this);
|
||||
|
||||
doSomething();
|
||||
}
|
||||
|
|
|
@ -67,12 +67,6 @@ public class SwipableRecycler extends RecyclerView {
|
|||
if (lastTouchedElement != null && lastTouchedElement.isOpen() && lastTouchedElement != buf) {
|
||||
handled = true;
|
||||
}
|
||||
// on click
|
||||
/*
|
||||
if (lastTouchedElement != null && lastTouchedElement.isOpen() && inRangeOfView(lastTouchedElement.getMenuView(), e)) {
|
||||
lastTouchedElement.getMenuView().notifyOnClick(e.getRawX(), e.getRawY());
|
||||
}
|
||||
*/
|
||||
if (lastTouchedElement != null)
|
||||
lastTouchedElement.onSwipe(e);
|
||||
return handled;
|
||||
|
@ -91,13 +85,6 @@ public class SwipableRecycler extends RecyclerView {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
// TODO del
|
||||
case MotionEvent.ACTION_UP:
|
||||
// on click
|
||||
if (lastTouchedElement != null && lastTouchedElement.isOpen() && inRangeOfView(lastTouchedElement.getMenuView(), e)) {
|
||||
lastTouchedElement.getMenuView().notifyOnClick(e.getRawX(), e.getRawY());
|
||||
}
|
||||
return super.onInterceptTouchEvent(e);
|
||||
}
|
||||
return super.onInterceptTouchEvent(e);
|
||||
}
|
||||
|
|
|
@ -17,16 +17,7 @@ import java.util.List;
|
|||
public class SwipeMenuLayout extends LinearLayout {
|
||||
|
||||
private SwipeMenu swipeMenu;
|
||||
|
||||
private OnMenuItemClickListener menuItemClickListener;
|
||||
|
||||
public OnMenuItemClickListener getMenuItemClickListener() {
|
||||
return menuItemClickListener;
|
||||
}
|
||||
|
||||
public void setMenuItemClickListener(OnMenuItemClickListener menuItemClickListener) {
|
||||
this.menuItemClickListener = menuItemClickListener;
|
||||
}
|
||||
private SwipableElement swipableElement;
|
||||
|
||||
public SwipeMenuLayout(Context context) {
|
||||
super(context);
|
||||
|
@ -40,6 +31,11 @@ public class SwipeMenuLayout extends LinearLayout {
|
|||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public void setSwipableElement(SwipableElement swipableElement) {
|
||||
this.swipableElement = swipableElement;
|
||||
}
|
||||
|
||||
// adding menu with items
|
||||
public void addMenu(SwipeMenu menu) {
|
||||
swipeMenu = menu;
|
||||
List<SwipeMenuItem> items = menu.getMenuItems();
|
||||
|
@ -49,7 +45,6 @@ public class SwipeMenuLayout extends LinearLayout {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void addItem(SwipeMenuItem item, int id) {
|
||||
|
||||
LayoutParams params = new LayoutParams(item.getWidth(),LayoutParams.MATCH_PARENT);
|
||||
|
@ -68,6 +63,40 @@ public class SwipeMenuLayout extends LinearLayout {
|
|||
parent.addView(createTitle(item));
|
||||
}
|
||||
}
|
||||
// adding menu with items + listener
|
||||
public void addMenu(SwipeMenu menu, OnClickListener listener) {
|
||||
swipeMenu = menu;
|
||||
List<SwipeMenuItem> items = menu.getMenuItems();
|
||||
int id = 0;
|
||||
for (SwipeMenuItem item : items) {
|
||||
addItem(item, item.getId() == 0 ? ++id : item.getId(), listener);
|
||||
}
|
||||
}
|
||||
|
||||
private void addItem(SwipeMenuItem item, int id, OnClickListener listener) {
|
||||
|
||||
LayoutParams params = new LayoutParams(item.getWidth(),LayoutParams.MATCH_PARENT);
|
||||
LinearLayout parent = new LinearLayout(getContext());
|
||||
parent.setId(id);
|
||||
parent.setGravity(Gravity.CENTER);
|
||||
parent.setOrientation(LinearLayout.VERTICAL);
|
||||
parent.setLayoutParams(params);
|
||||
parent.setBackgroundDrawable(item.getBackground());
|
||||
parent.setOnClickListener(listener);
|
||||
addView(parent);
|
||||
|
||||
if (item.getIcon() != null) {
|
||||
parent.addView(createIcon(item));
|
||||
}
|
||||
if (!TextUtils.isEmpty(item.getTitle())) {
|
||||
parent.addView(createTitle(item));
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyOnMenuItemClick() {
|
||||
if (swipableElement != null && swipableElement.isOpen())
|
||||
swipableElement.smoothCloseMenu();
|
||||
}
|
||||
|
||||
private ImageView createIcon(SwipeMenuItem item) {
|
||||
ImageView iv = new ImageView(getContext());
|
||||
|
@ -83,18 +112,6 @@ public class SwipeMenuLayout extends LinearLayout {
|
|||
tv.setTextColor(item.getTitleColor());
|
||||
return tv;
|
||||
}
|
||||
// should be raw coordinates
|
||||
public void notifyOnClick(float x, float y) {
|
||||
View menuItem = findViewAtPoint(x, y);
|
||||
if (menuItem != null) {
|
||||
if (menuItemClickListener != null)
|
||||
menuItemClickListener.onMenuItemClick(menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnMenuItemClickListener {
|
||||
void onMenuItemClick(View v);
|
||||
}
|
||||
|
||||
private View findViewAtPoint(float x, float y) {
|
||||
View ret = null;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package com.hikapro.backpack.test;
|
||||
|
||||
import android.app.Fragment;
|
||||
|
||||
/**
|
||||
* Created by tariel on 16/07/16.
|
||||
*/
|
||||
public class ScreenSlidePageFrag extends Fragment {
|
||||
}
|
|
@ -113,7 +113,10 @@ public class SetListFragment extends Fragment implements com.hikapro.backpack.vi
|
|||
|
||||
@Override
|
||||
public void showItemList(Set set) {
|
||||
activityCallback.startItemListFragment(set);
|
||||
if (set.getActiveQty() == set.getPackedQty())
|
||||
activityCallback.startPackedListFragment(set);
|
||||
else
|
||||
activityCallback.startItemListFragment(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 260 B |
After Width: | Height: | Size: 579 B |
After Width: | Height: | Size: 119 B |
After Width: | Height: | Size: 176 B |
After Width: | Height: | Size: 579 B |
After Width: | Height: | Size: 162 B |
After Width: | Height: | Size: 275 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 401 B |
After Width: | Height: | Size: 1.9 KiB |
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:drawable="@drawable/ic_check_box_outline_blank_white_24dp"
|
||||
android:state_checked="false"/>
|
||||
<item android:drawable="@drawable/ic_check_box_white_24dp"
|
||||
android:state_checked="true"/>
|
||||
<item android:drawable="@drawable/ic_check_box_outline_blank_white_24dp"/>
|
||||
</selector>
|
|
@ -2,5 +2,5 @@
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<size android:height="2dp" />
|
||||
<solid android:color="#ff992900" />
|
||||
<solid android:color="#FF992900" />
|
||||
</shape>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<size android:height="2dp" />
|
||||
<solid android:color="#FFFFFF" />
|
||||
</shape>
|
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 260 B |
After Width: | Height: | Size: 579 B |
After Width: | Height: | Size: 896 KiB |
|
@ -9,7 +9,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/colorUiMainbackground2">
|
||||
android:background="@color/colorListBackground">
|
||||
|
||||
<com.hikapro.backpack.presenter.adapters.helper.items.swipe2.SwipableRecycler
|
||||
android:id="@+id/items_recycler"
|
||||
|
@ -21,12 +21,12 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="70dp"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/item_list_footer"
|
||||
android:layout_gravity="bottom"
|
||||
android:visibility="gone"
|
||||
android:background="@color/colorFooterbackground">
|
||||
android:background="@color/colorFooterBackground">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -39,6 +39,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:paddingTop="10dp"
|
||||
android:textSize="@dimen/text_footer"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/colorFooterTextGreen"
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.hikapro.backpack.view.fragments.PackedListFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="70dp"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/item_list_header"
|
||||
android:layout_gravity="top"
|
||||
android:gravity="center"
|
||||
android:visibility="visible"
|
||||
android:layout_alignParentTop="true"
|
||||
android:animateLayoutChanges="true"
|
||||
android:background="@color/colorFooterbackground">
|
||||
android:background="@color/colorFooterBackground">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -22,11 +24,11 @@
|
|||
android:textStyle="bold"
|
||||
android:textColor="@color/colorFooterTextWhite"
|
||||
android:id="@+id/header_packed_count"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:paddingTop="10dp"
|
||||
android:textSize="@dimen/text_footer"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/colorFooterTextGreen"
|
||||
|
@ -34,14 +36,15 @@
|
|||
android:id="@+id/back_to_list"/>
|
||||
<Button
|
||||
android:id="@+id/unpack_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="206dp"
|
||||
android:layout_height="50dp"
|
||||
android:text="@string/unpack_button"
|
||||
android:textSize="@dimen/text_action_bar_header"
|
||||
android:textAlignment="center"
|
||||
android:background="@color/colorUnpackBackground"
|
||||
android:layout_marginTop="@dimen/margin_standard"
|
||||
android:layout_marginBottom="@dimen/margin_standard"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -49,17 +52,16 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_below="@id/item_list_header"
|
||||
android:background="@color/colorUiMainbackground2">
|
||||
android:background="@color/colorListBackground">
|
||||
|
||||
<com.hikapro.backpack.presenter.adapters.helper.items.swipe2.SwipableRecycler
|
||||
android:id="@+id/items_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="vertical"/>
|
||||
android:scrollbars="vertical"
|
||||
android:scrollIndicators="none"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
|
@ -16,7 +16,7 @@
|
|||
android:background="@color/colorListBackground"
|
||||
android:textSize="@dimen/text_category_name"
|
||||
android:textStyle="bold"
|
||||
android:textAllCaps="true"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@android:color/white"
|
||||
android:id="@+id/header"
|
||||
tools:context=".MainActivity"/>
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
android:id="@+id/item_checkbox"
|
||||
android:layout_gravity="start|center_vertical"
|
||||
android:padding="@dimen/item_checkbox_padding"
|
||||
android:layout_marginStart="@dimen/margin_standard" />
|
||||
|
||||
android:button="@drawable/checkbox_selector"
|
||||
android:layout_marginStart="@dimen/margin_standard"
|
||||
android:textColor="@color/white"/>
|
||||
<!--
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
@ -27,6 +29,18 @@
|
|||
android:layout_marginEnd="@dimen/margin_standard"
|
||||
android:textSize="@dimen/text_item_name"
|
||||
android:textColor="@color/colorText" />
|
||||
-->
|
||||
<com.hikapro.backpack.presenter.adapters.helper.AutoResizeTextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/item_text"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="@dimen/margin_standard"
|
||||
android:layout_marginEnd="@dimen/margin_standard"
|
||||
android:textSize="@dimen/text_item_name"
|
||||
android:textColor="@color/colorText" />
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -34,6 +48,6 @@
|
|||
android:id="@+id/item_info_button"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:layout_marginEnd="@dimen/margin_standard"
|
||||
android:src="@drawable/ic_info_black_24dp"
|
||||
android:src="@drawable/ic_info_white"
|
||||
android:background="@null" />
|
||||
</LinearLayout>
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:customNS="com.hikapro.backpack"
|
||||
android:id="@+id/sticky_header_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
customNS:paddingY="15dp"
|
||||
customNS:paddingX="15dp" />
|
||||
android:layout_height="wrap_content" />
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 15 KiB |
|
@ -2,8 +2,6 @@
|
|||
<resources>
|
||||
<color name="colorUiMainbackground">#323232</color>
|
||||
<color name="colorUiMainbackground2">#7F7F7F</color>
|
||||
<color name="colorFooterbackground">#33D3D3D3</color>
|
||||
<color name="colorUnpackBtnBackground">#76EE00</color>
|
||||
<color name="colorShareBtnBackground">#76EE00</color>
|
||||
<color name="colorStickyHeaderBackground">#001F3F</color>
|
||||
<color name="colorCategoryBtnBackground">#76EE00</color>
|
||||
|
@ -21,7 +19,7 @@
|
|||
<color name="colorUnpackBackground">#7ED321</color>
|
||||
<color name="colorText">#FFFFFF</color>
|
||||
<color name="colorCategory">#DFDFDF</color>
|
||||
<color name="colorFooterBackground">#76000000</color>
|
||||
<color name="colorFooterBackground">#BF000000</color>
|
||||
<color name="colorSwipeGreenBackground">#436D15</color>
|
||||
<color name="colorSwipeGreyBackground">#555454</color>
|
||||
<color name="colorSwipeRedBackground">#AF00</color>
|
||||
|
|
|
@ -15,14 +15,10 @@
|
|||
<dimen name="text_action_bar_header">14sp</dimen>
|
||||
<dimen name="text_item_header">12sp</dimen>
|
||||
<dimen name="text_item_name">18sp</dimen>
|
||||
<dimen name="text_category_name">12sp</dimen>
|
||||
<dimen name="text_category_name">22sp</dimen>
|
||||
<dimen name="text_item_category">10sp</dimen>
|
||||
<dimen name="text_footer">14sp</dimen>
|
||||
<dimen name="text_category_btn">13sp</dimen>
|
||||
<dimen name="text_action_bar_btn">12sp</dimen>
|
||||
<dimen name="text_item_description">17sp</dimen>
|
||||
|
||||
|
||||
|
||||
|
||||
</resources>
|
|
@ -18,17 +18,24 @@
|
|||
<item name="android:textSize">@dimen/text_action_bar_btn</item>
|
||||
<item name="android:theme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="android:gravity">center</item>
|
||||
|
||||
<item name="android:background">@null</item>
|
||||
|
||||
<!--<item name="android:background">@drawable/ripple</item>-->
|
||||
<!-- <item name="android:background">?android:attr/selectableItemBackground</item> -->
|
||||
<!--
|
||||
<item name="android:background">?attr/selectableItemBackgroundBorderless</item>
|
||||
-->
|
||||
|
||||
</style>
|
||||
|
||||
<style name="BrandedCheckBox" parent="AppTheme">
|
||||
<item name="colorAccent">#aaf000</item>
|
||||
<item name="colorControlNormal">#ffffff</item>
|
||||
</style>
|
||||
|
||||
<style name="ActionBarButtonWhite" parent="@style/ActionBarButton">
|
||||
<item name="android:textColor">@color/white</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="ActionBarButtonOffWhite" parent="@style/ActionBarButton">
|
||||
|
|