Compare commits
1 Commits
master
...
tag-last-i
Author | SHA1 | Date |
---|---|---|
Tariel Hlontsi | b09b5d4867 |
|
@ -37,7 +37,7 @@
|
|||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<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">
|
||||
<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">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -177,7 +177,6 @@ public class MainActivity extends Activity implements View.ActivityCallback {
|
|||
SetModel model = new SetModel();
|
||||
|
||||
view.setPresenter(presenter);
|
||||
//presenter.setView(view);
|
||||
presenter.setModel(model);
|
||||
model.setPresenter(presenter);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ItemModel implements Model.Item {
|
|||
public void onEvent(Message event) {
|
||||
|
||||
switch (event.what) {
|
||||
case Event.SET_ITEMS_LOAD_ERROR : // TODO check
|
||||
case Event.SET_ITEMS_LOAD_ERROR:
|
||||
if (presenter != null) {
|
||||
if (packedQty == -1)
|
||||
packedQty = presenter.getCurrentSet().getPackedQty();
|
||||
|
@ -116,17 +116,17 @@ public class ItemModel implements Model.Item {
|
|||
case Event.ITEM_FROM_SET_DELETED:
|
||||
executeQuery();
|
||||
break;
|
||||
case Event.ITEM_DELETED :
|
||||
case Event.ITEM_DELETED:
|
||||
break;
|
||||
case Event.ITEM_PACKED :
|
||||
case Event.ITEM_PACKED:
|
||||
executeQuery();
|
||||
if (getPackedQty() == getActiveItemsCount())
|
||||
NetworkUtil.sendGoogleAnalyticsEvent("SET PACKED", String.format("Set #%d", currentSet));
|
||||
break;
|
||||
case Event.ITEM_UNPACKED :
|
||||
case Event.ITEM_UNPACKED:
|
||||
executeQuery();
|
||||
break;
|
||||
case Event.ITEM_INSERTED :
|
||||
case Event.ITEM_INSERTED:
|
||||
break;
|
||||
case Event.SET_RESTORE_COMPLETED:
|
||||
executeQuery();
|
||||
|
@ -184,7 +184,11 @@ public class ItemModel implements Model.Item {
|
|||
@Override
|
||||
public Item getItemByPosition(int position) {
|
||||
Item ret = null;
|
||||
ret = itemsCache.get(position);
|
||||
try {
|
||||
ret = itemsCache.get(position);
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -207,12 +211,28 @@ public class ItemModel implements Model.Item {
|
|||
|
||||
@Override
|
||||
public int getHeaderId(int position) {
|
||||
return itemsCache.get(position).getCategory();
|
||||
int ret;
|
||||
try {
|
||||
ret = itemsCache.get(position).getCategory();
|
||||
} catch (Exception ex) {
|
||||
try {
|
||||
ret = itemsCache.get(position-1).getCategory();
|
||||
} catch (Exception e) {
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemId(int position) {
|
||||
return itemsCache.get(position).getId();
|
||||
int ret;
|
||||
try {
|
||||
ret = itemsCache.get(position).getId();
|
||||
} catch (Exception ex) {
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -153,12 +153,14 @@ public class ItemListPresenter implements Presenter.ItemList {
|
|||
|
||||
@Override
|
||||
public void setVisibility() {
|
||||
if (model.getPackedQty() > 0 && model.getPackedQty() == model.getActiveItemsCount()) {
|
||||
footer.setVisibility(android.view.View.VISIBLE);
|
||||
} else if ( model.getPackedQty() > 0) {
|
||||
/*if (model.getPackedQty() > 0 && model.getPackedQty() == model.getActiveItemsCount()) {
|
||||
//showPackedItems();
|
||||
} else*/ if (model.getPackedQty() > 0) {
|
||||
footer.setVisibility(android.view.View.VISIBLE);
|
||||
adapter.addEmptyToTheEnd();
|
||||
} else {
|
||||
footer.setVisibility(android.view.View.GONE);
|
||||
adapter.removeEmptyFromTheEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,66 +39,72 @@ public class PackedListPresenter extends ItemListPresenter {
|
|||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
if (savedInstanceState != null)
|
||||
set = (Set) savedInstanceState.getSerializable(BUNDLE_SET_LIST_KEY);
|
||||
else
|
||||
set = getView().getSet();
|
||||
android.view.View view = inflater.inflate(R.layout.fragment_packed_list, container, false);
|
||||
LinearLayoutManager llm = new LinearLayoutManager(getActivityContext());
|
||||
recycler = (RecyclerView) view.findViewById(R.id.items_recycler);
|
||||
recycler.setLayoutManager(llm);
|
||||
recycler.setAdapter(adapter);
|
||||
try {
|
||||
if (savedInstanceState != null)
|
||||
set = (Set) savedInstanceState.getSerializable(BUNDLE_SET_LIST_KEY);
|
||||
else
|
||||
set = getView().getSet();
|
||||
android.view.View view = inflater.inflate(R.layout.fragment_packed_list, container, false);
|
||||
LinearLayoutManager llm = new LinearLayoutManager(getActivityContext());
|
||||
recycler = (RecyclerView) view.findViewById(R.id.items_recycler);
|
||||
recycler.setLayoutManager(llm);
|
||||
recycler.setAdapter(adapter);
|
||||
|
||||
final StickyHeaderDecoration decoration = new StickyHeaderDecoration(adapter);
|
||||
recycler.addItemDecoration(decoration);
|
||||
//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() {
|
||||
decoration.invalidateHeaders();
|
||||
final StickyHeaderDecoration decoration = new StickyHeaderDecoration(adapter);
|
||||
recycler.addItemDecoration(decoration);
|
||||
//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() {
|
||||
decoration.invalidateHeaders();
|
||||
}
|
||||
});
|
||||
recycler.setHasFixedSize(true);
|
||||
model.executeQuery();
|
||||
recycler.scrollToPosition(model.getLastVisiblePosition());
|
||||
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);
|
||||
|
||||
setVisibility();
|
||||
unpackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
model.unpackSet(set.getId());
|
||||
}
|
||||
});
|
||||
|
||||
backToList.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Fragment fragment = (Fragment) getView();
|
||||
if (fragment != null)
|
||||
fragment.getFragmentManager().popBackStack();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Activity activity = (Activity) getActivityContext();
|
||||
if (activity != null) {
|
||||
activity.invalidateOptionsMenu();
|
||||
ActionBar actionBar = activity.getActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.show();
|
||||
actionBar.setTitle(set.getName());
|
||||
actionBar.setDisplayShowHomeEnabled(false);
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayShowCustomEnabled(false);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
recycler.setHasFixedSize(true);
|
||||
model.executeQuery();
|
||||
recycler.scrollToPosition(model.getLastVisiblePosition());
|
||||
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);
|
||||
NetworkUtil.sendGoogleAnalyticsScreen(TAG);
|
||||
return view;
|
||||
|
||||
setVisibility();
|
||||
unpackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
model.unpackSet(set.getId());
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
|
||||
backToList.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Fragment fragment = (Fragment) getView();
|
||||
if (fragment != null)
|
||||
fragment.getFragmentManager().popBackStack();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Activity activity = (Activity) getActivityContext();
|
||||
if (activity != null) {
|
||||
activity.invalidateOptionsMenu();
|
||||
ActionBar actionBar = activity.getActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.show();
|
||||
actionBar.setTitle(set.getName());
|
||||
actionBar.setDisplayShowHomeEnabled(false);
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayShowCustomEnabled(false);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
}
|
||||
NetworkUtil.sendGoogleAnalyticsScreen(TAG);
|
||||
return view;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,16 +28,21 @@ public class AddListAdapter extends RecyclerView.Adapter<AddItemViewHolder> {
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(AddItemViewHolder holder, int position) {
|
||||
final Item item = presenter.getModel().getItemByPosition(position);
|
||||
holder.name.setText(item.getName());
|
||||
holder.category.setText(presenter.getModel().getCategoryById(item.getCategory()).getName());
|
||||
holder.alreadyInList.setVisibility(item.InList ? View.VISIBLE : View.GONE);
|
||||
holder.item.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
presenter.onAddItemClick(item);
|
||||
}
|
||||
});
|
||||
try {
|
||||
final Item item = presenter.getModel().getItemByPosition(position);
|
||||
holder.name.setText(item.getName());
|
||||
holder.category.setText(presenter.getModel().getCategoryById(item.getCategory()).getName());
|
||||
holder.alreadyInList.setVisibility(item.InList ? View.VISIBLE : View.GONE);
|
||||
holder.item.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
presenter.onAddItemClick(item);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,110 +37,114 @@ public class ItemDetailAdapter extends RecyclerView.Adapter<ItemViewHolder> {
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
|
||||
final Item item = presenter.getModel().getCurrentItem();
|
||||
holder.cb_item.setChecked(item.isPacked());
|
||||
holder.tv_text.setText(item.getName());
|
||||
holder.im_info.setVisibility(View.GONE);
|
||||
if (item.isPendingRemoval()) {
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
holder.cb_item.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.cb_item.setVisibility(View.VISIBLE);
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
}
|
||||
|
||||
holder.cb_item.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (holder.cb_item.isChecked()) {
|
||||
pack(item);
|
||||
} else {
|
||||
unpack(item);
|
||||
}
|
||||
try {
|
||||
final Item item = presenter.getModel().getCurrentItem();
|
||||
holder.cb_item.setChecked(item.isPacked());
|
||||
holder.tv_text.setText(item.getName());
|
||||
holder.im_info.setVisibility(View.GONE);
|
||||
if (item.isPendingRemoval()) {
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
holder.cb_item.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.cb_item.setVisibility(View.VISIBLE);
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||
|
||||
menuLayout.removeAllViews();
|
||||
|
||||
// create menu items here
|
||||
if (!item.isPendingRemoval()) {
|
||||
// create "leave at home" item
|
||||
SwipeMenuItem leaveAtHomeItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
leaveAtHomeItem.setId(ItemListAdapter.ID_LEAVE_AT_HOME);
|
||||
// set item background
|
||||
leaveAtHomeItem.setBackground(R.color.colorLeaveAtHomeBtnBackground);
|
||||
// set item width
|
||||
leaveAtHomeItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
leaveAtHomeItem.setTitle(R.string.leave_at_home_button);
|
||||
// set item title font size
|
||||
leaveAtHomeItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
leaveAtHomeItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(leaveAtHomeItem);
|
||||
} else {
|
||||
// create "add to bag" item
|
||||
SwipeMenuItem addToBagItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
addToBagItem.setId(ItemListAdapter.ID_ADD_TO_BAG);
|
||||
// set item background
|
||||
addToBagItem.setBackground(R.color.colorAddToBagBtnBackground);
|
||||
// set item width
|
||||
addToBagItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
addToBagItem.setTitle(R.string.add_to_bag_button);
|
||||
// set item title font size
|
||||
addToBagItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
addToBagItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(addToBagItem);
|
||||
|
||||
// create "return to list" item
|
||||
SwipeMenuItem returnToListItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
returnToListItem.setId(ItemListAdapter.ID_RETURN_TO_LIST);
|
||||
// set item background
|
||||
returnToListItem.setBackground(R.color.colorReturnToListBtnBackground);
|
||||
// set item width
|
||||
returnToListItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
returnToListItem.setTitle(R.string.return_to_list_button);
|
||||
// set item title font size
|
||||
returnToListItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
returnToListItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(returnToListItem);
|
||||
}
|
||||
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case ItemListAdapter.ID_DELETE:
|
||||
// no delete
|
||||
break;
|
||||
case ItemListAdapter.ID_LEAVE_AT_HOME:
|
||||
leave(item);
|
||||
break;
|
||||
case ItemListAdapter.ID_RETURN_TO_LIST:
|
||||
leaveCancel(item);
|
||||
break;
|
||||
case ItemListAdapter.ID_ADD_TO_BAG:
|
||||
holder.cb_item.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (holder.cb_item.isChecked()) {
|
||||
pack(item);
|
||||
break;
|
||||
} else {
|
||||
unpack(item);
|
||||
}
|
||||
}
|
||||
menuLayout.notifyOnMenuItemClick();
|
||||
});
|
||||
|
||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||
|
||||
menuLayout.removeAllViews();
|
||||
|
||||
// create menu items here
|
||||
if (!item.isPendingRemoval()) {
|
||||
// create "leave at home" item
|
||||
SwipeMenuItem leaveAtHomeItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
leaveAtHomeItem.setId(ItemListAdapter.ID_LEAVE_AT_HOME);
|
||||
// set item background
|
||||
leaveAtHomeItem.setBackground(R.color.colorLeaveAtHomeBtnBackground);
|
||||
// set item width
|
||||
leaveAtHomeItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
leaveAtHomeItem.setTitle(R.string.leave_at_home_button);
|
||||
// set item title font size
|
||||
leaveAtHomeItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
leaveAtHomeItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(leaveAtHomeItem);
|
||||
} else {
|
||||
// create "add to bag" item
|
||||
SwipeMenuItem addToBagItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
addToBagItem.setId(ItemListAdapter.ID_ADD_TO_BAG);
|
||||
// set item background
|
||||
addToBagItem.setBackground(R.color.colorAddToBagBtnBackground);
|
||||
// set item width
|
||||
addToBagItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
addToBagItem.setTitle(R.string.add_to_bag_button);
|
||||
// set item title font size
|
||||
addToBagItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
addToBagItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(addToBagItem);
|
||||
|
||||
// create "return to list" item
|
||||
SwipeMenuItem returnToListItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
returnToListItem.setId(ItemListAdapter.ID_RETURN_TO_LIST);
|
||||
// set item background
|
||||
returnToListItem.setBackground(R.color.colorReturnToListBtnBackground);
|
||||
// set item width
|
||||
returnToListItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
returnToListItem.setTitle(R.string.return_to_list_button);
|
||||
// set item title font size
|
||||
returnToListItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
returnToListItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(returnToListItem);
|
||||
}
|
||||
};
|
||||
menuLayout.addMenu(menu, onClickListener);
|
||||
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case ItemListAdapter.ID_DELETE:
|
||||
// no delete
|
||||
break;
|
||||
case ItemListAdapter.ID_LEAVE_AT_HOME:
|
||||
leave(item);
|
||||
break;
|
||||
case ItemListAdapter.ID_RETURN_TO_LIST:
|
||||
leaveCancel(item);
|
||||
break;
|
||||
case ItemListAdapter.ID_ADD_TO_BAG:
|
||||
pack(item);
|
||||
break;
|
||||
}
|
||||
menuLayout.notifyOnMenuItemClick();
|
||||
}
|
||||
};
|
||||
menuLayout.addMenu(menu, onClickListener);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,6 +34,7 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
|||
|
||||
protected Presenter.ItemList presenter;
|
||||
protected boolean checkAll;
|
||||
protected int addToCount = 0;
|
||||
|
||||
public ItemListAdapter(Presenter.ItemList presenter) {
|
||||
this.presenter = presenter;
|
||||
|
@ -41,8 +42,8 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
|||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
int res = presenter.getModel().getItemsCount();
|
||||
return res;
|
||||
int ret = presenter.getModel().getItemsCount();
|
||||
return ret + addToCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,135 +55,145 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
|||
@Override
|
||||
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
|
||||
|
||||
final Item item = presenter.getModel().getItemByPosition(position);
|
||||
holder.cb_item.setChecked(checkAll);
|
||||
holder.tv_text.setText(item.getName());
|
||||
//holder.tv_text.setTypeface(mainFace);
|
||||
if (item.isPendingRemoval()) {
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
holder.cb_item.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.cb_item.setVisibility(View.VISIBLE);
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
}
|
||||
|
||||
holder.cb_item.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (holder.cb_item.isChecked()) {
|
||||
pack(item);
|
||||
try {
|
||||
final Item item = presenter.getModel().getItemByPosition(position);
|
||||
if (item != null) {
|
||||
setVisibility(holder, View.VISIBLE);
|
||||
holder.cb_item.setChecked(checkAll);
|
||||
holder.tv_text.setText(item.getName());
|
||||
if (item.isPendingRemoval()) {
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
holder.cb_item.setVisibility(View.GONE);
|
||||
} else {
|
||||
unpack(item);
|
||||
//holder.cb_item.setVisibility(View.VISIBLE);
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
}
|
||||
|
||||
holder.cb_item.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (holder.cb_item.isChecked()) {
|
||||
pack(item);
|
||||
} else {
|
||||
unpack(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.im_info.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
presenter.showDetails(position);
|
||||
}
|
||||
});
|
||||
|
||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout) holder.menu;
|
||||
final SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||
|
||||
menuLayout.removeAllViews();
|
||||
|
||||
// create menu items here
|
||||
if (!item.isPendingRemoval()) {
|
||||
// create "leave at home" item
|
||||
SwipeMenuItem leaveAtHomeItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
leaveAtHomeItem.setId(ID_LEAVE_AT_HOME);
|
||||
// set item background
|
||||
leaveAtHomeItem.setBackground(R.color.colorLeaveAtHomeBtnBackground);
|
||||
// set item width
|
||||
leaveAtHomeItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
leaveAtHomeItem.setTitle(R.string.leave_at_home_button);
|
||||
// set item title font size
|
||||
leaveAtHomeItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
leaveAtHomeItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(leaveAtHomeItem);
|
||||
} else {
|
||||
// create "add to bag" item
|
||||
SwipeMenuItem addToBagItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
addToBagItem.setId(ID_ADD_TO_BAG);
|
||||
// set item background
|
||||
addToBagItem.setBackground(R.color.colorAddToBagBtnBackground);
|
||||
// set item width
|
||||
addToBagItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
addToBagItem.setTitle(R.string.add_to_bag_button);
|
||||
// set item title font size
|
||||
addToBagItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
addToBagItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(addToBagItem);
|
||||
|
||||
// create "return to list" item
|
||||
SwipeMenuItem returnToListItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
returnToListItem.setId(ID_RETURN_TO_LIST);
|
||||
// set item background
|
||||
returnToListItem.setBackground(R.color.colorReturnToListBtnBackground);
|
||||
// set item width
|
||||
returnToListItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
returnToListItem.setTitle(R.string.return_to_list_button);
|
||||
// set item title font size
|
||||
returnToListItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
returnToListItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(returnToListItem);
|
||||
}
|
||||
|
||||
// create "delete" item
|
||||
SwipeMenuItem deleteItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
deleteItem.setId(ID_DELETE);
|
||||
// set item background
|
||||
deleteItem.setBackground(R.color.colorDeleteBtnBackground);
|
||||
// set item width
|
||||
deleteItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
deleteItem.setTitle(R.string.delete_button);
|
||||
// set item title font size
|
||||
deleteItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
deleteItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(deleteItem);
|
||||
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case ID_DELETE:
|
||||
remove(item);
|
||||
break;
|
||||
case ID_LEAVE_AT_HOME:
|
||||
leave(item);
|
||||
break;
|
||||
case ID_RETURN_TO_LIST:
|
||||
leaveCancel(item);
|
||||
break;
|
||||
case ID_ADD_TO_BAG:
|
||||
pack(item);
|
||||
break;
|
||||
}
|
||||
menuLayout.notifyOnMenuItemClick();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
menuLayout.addMenu(menu, onClickListener);
|
||||
} else {
|
||||
if (presenter.getModel().getPackedQty() > 0) {
|
||||
setVisibility(holder, View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.im_info.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
presenter.showDetails(position);
|
||||
}
|
||||
});
|
||||
|
||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
final SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||
} catch (Exception ex) {
|
||||
|
||||
menuLayout.removeAllViews();
|
||||
|
||||
// create menu items here
|
||||
if (!item.isPendingRemoval()) {
|
||||
// create "leave at home" item
|
||||
SwipeMenuItem leaveAtHomeItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
leaveAtHomeItem.setId(ID_LEAVE_AT_HOME);
|
||||
// set item background
|
||||
leaveAtHomeItem.setBackground(R.color.colorLeaveAtHomeBtnBackground);
|
||||
// set item width
|
||||
leaveAtHomeItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
leaveAtHomeItem.setTitle(R.string.leave_at_home_button);
|
||||
// set item title font size
|
||||
leaveAtHomeItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
leaveAtHomeItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(leaveAtHomeItem);
|
||||
} else {
|
||||
// create "add to bag" item
|
||||
SwipeMenuItem addToBagItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
addToBagItem.setId(ID_ADD_TO_BAG);
|
||||
// set item background
|
||||
addToBagItem.setBackground(R.color.colorAddToBagBtnBackground);
|
||||
// set item width
|
||||
addToBagItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
addToBagItem.setTitle(R.string.add_to_bag_button);
|
||||
// set item title font size
|
||||
addToBagItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
addToBagItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(addToBagItem);
|
||||
|
||||
// create "return to list" item
|
||||
SwipeMenuItem returnToListItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
returnToListItem.setId(ID_RETURN_TO_LIST);
|
||||
// set item background
|
||||
returnToListItem.setBackground(R.color.colorReturnToListBtnBackground);
|
||||
// set item width
|
||||
returnToListItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
returnToListItem.setTitle(R.string.return_to_list_button);
|
||||
// set item title font size
|
||||
returnToListItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
returnToListItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(returnToListItem);
|
||||
}
|
||||
|
||||
// create "delete" item
|
||||
SwipeMenuItem deleteItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
deleteItem.setId(ID_DELETE);
|
||||
// set item background
|
||||
deleteItem.setBackground(R.color.colorDeleteBtnBackground);
|
||||
// set item width
|
||||
deleteItem.setWidth(Util.dp2px(presenter.getActivityContext(),120));
|
||||
// set item title
|
||||
deleteItem.setTitle(R.string.delete_button);
|
||||
// set item title font size
|
||||
deleteItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
deleteItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(deleteItem);
|
||||
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case ID_DELETE:
|
||||
remove(item);
|
||||
break;
|
||||
case ID_LEAVE_AT_HOME:
|
||||
leave(item);
|
||||
break;
|
||||
case ID_RETURN_TO_LIST:
|
||||
leaveCancel(item);
|
||||
break;
|
||||
case ID_ADD_TO_BAG:
|
||||
pack(item);
|
||||
break;
|
||||
}
|
||||
menuLayout.notifyOnMenuItemClick();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
menuLayout.addMenu(menu, onClickListener);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -257,4 +268,22 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
|||
public void setCheckAll(boolean checkAll) {
|
||||
this.checkAll = checkAll;
|
||||
}
|
||||
|
||||
public void addEmptyToTheEnd() {
|
||||
addToCount = 1;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void removeEmptyFromTheEnd() {
|
||||
addToCount = 0;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void setVisibility(ItemViewHolder holder, int visibility) {
|
||||
if (holder != null) {
|
||||
holder.cb_item.setVisibility(visibility);
|
||||
holder.im_info.setVisibility(visibility);
|
||||
holder.menu.setVisibility(visibility);
|
||||
holder.tv_text.setVisibility(visibility);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,135 +22,145 @@ public class PackedListAdapter extends ItemListAdapter {
|
|||
super(presenter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return presenter.getModel().getItemsCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
|
||||
|
||||
final Item item = presenter.getModel().getItemByPosition(position);
|
||||
holder.cb_item.setChecked(checkAll);
|
||||
holder.tv_text.setText(item.getName());
|
||||
if (item.isPendingRemoval()) {
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
holder.cb_item.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.cb_item.setVisibility(View.VISIBLE);
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
}
|
||||
|
||||
holder.cb_item.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (holder.cb_item.isChecked()) {
|
||||
pack(item);
|
||||
} else {
|
||||
unpack(item);
|
||||
}
|
||||
try {
|
||||
final Item item = presenter.getModel().getItemByPosition(position);
|
||||
holder.cb_item.setChecked(checkAll);
|
||||
holder.tv_text.setText(item.getName());
|
||||
if (item.isPendingRemoval()) {
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
holder.cb_item.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.cb_item.setVisibility(View.VISIBLE);
|
||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
}
|
||||
});
|
||||
holder.im_info.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
presenter.showDetails(position);
|
||||
}
|
||||
});
|
||||
|
||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||
|
||||
menuLayout.removeAllViews();
|
||||
|
||||
// create menu items here
|
||||
if (!item.isPendingRemoval()) {
|
||||
// create "leave at home" item
|
||||
SwipeMenuItem leaveAtHomeItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
leaveAtHomeItem.setId(ID_LEAVE_AT_HOME);
|
||||
// set item background
|
||||
leaveAtHomeItem.setBackground(R.color.colorLeaveAtHomeBtnBackground);
|
||||
// set item width
|
||||
leaveAtHomeItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
leaveAtHomeItem.setTitle(R.string.leave_at_home_button);
|
||||
// set item title font size
|
||||
leaveAtHomeItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
leaveAtHomeItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(leaveAtHomeItem);
|
||||
} else {
|
||||
// create "add to bag" item
|
||||
SwipeMenuItem addToBagItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
addToBagItem.setId(ID_ADD_TO_BAG);
|
||||
// set item background
|
||||
addToBagItem.setBackground(R.color.colorAddToBagBtnBackground);
|
||||
// set item width
|
||||
addToBagItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
addToBagItem.setTitle(R.string.add_to_bag_button);
|
||||
// set item title font size
|
||||
addToBagItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
addToBagItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(addToBagItem);
|
||||
|
||||
// create "return to list" item
|
||||
SwipeMenuItem returnToListItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
returnToListItem.setId(ID_RETURN_TO_LIST);
|
||||
// set item background
|
||||
returnToListItem.setBackground(R.color.colorReturnToListBtnBackground);
|
||||
// set item width
|
||||
returnToListItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
returnToListItem.setTitle(R.string.return_to_list_button);
|
||||
// set item title font size
|
||||
returnToListItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
returnToListItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(returnToListItem);
|
||||
}
|
||||
|
||||
// create "delete" item
|
||||
SwipeMenuItem deleteItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
deleteItem.setId(ID_DELETE);
|
||||
// set item background
|
||||
deleteItem.setBackground(R.color.colorDeleteBtnBackground);
|
||||
// set item width
|
||||
deleteItem.setWidth(Util.dp2px(presenter.getActivityContext(),120));
|
||||
// set item title
|
||||
deleteItem.setTitle(R.string.delete_button);
|
||||
// set item title font size
|
||||
deleteItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
deleteItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(deleteItem);
|
||||
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case ID_DELETE:
|
||||
remove(item);
|
||||
break;
|
||||
case ID_LEAVE_AT_HOME:
|
||||
leave(item);
|
||||
break;
|
||||
case ID_RETURN_TO_LIST:
|
||||
unpack(item);
|
||||
break;
|
||||
case ID_ADD_TO_BAG:
|
||||
holder.cb_item.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (holder.cb_item.isChecked()) {
|
||||
pack(item);
|
||||
break;
|
||||
} else {
|
||||
unpack(item);
|
||||
}
|
||||
}
|
||||
menuLayout.notifyOnMenuItemClick();
|
||||
}
|
||||
};
|
||||
});
|
||||
holder.im_info.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
presenter.showDetails(position);
|
||||
}
|
||||
});
|
||||
|
||||
menuLayout.addMenu(menu, onClickListener);
|
||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||
SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||
|
||||
menuLayout.removeAllViews();
|
||||
|
||||
// create menu items here
|
||||
if (!item.isPendingRemoval()) {
|
||||
// create "leave at home" item
|
||||
SwipeMenuItem leaveAtHomeItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
leaveAtHomeItem.setId(ID_LEAVE_AT_HOME);
|
||||
// set item background
|
||||
leaveAtHomeItem.setBackground(R.color.colorLeaveAtHomeBtnBackground);
|
||||
// set item width
|
||||
leaveAtHomeItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
leaveAtHomeItem.setTitle(R.string.leave_at_home_button);
|
||||
// set item title font size
|
||||
leaveAtHomeItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
leaveAtHomeItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(leaveAtHomeItem);
|
||||
} else {
|
||||
// create "add to bag" item
|
||||
SwipeMenuItem addToBagItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
addToBagItem.setId(ID_ADD_TO_BAG);
|
||||
// set item background
|
||||
addToBagItem.setBackground(R.color.colorAddToBagBtnBackground);
|
||||
// set item width
|
||||
addToBagItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
addToBagItem.setTitle(R.string.add_to_bag_button);
|
||||
// set item title font size
|
||||
addToBagItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
addToBagItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(addToBagItem);
|
||||
|
||||
// create "return to list" item
|
||||
SwipeMenuItem returnToListItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
returnToListItem.setId(ID_RETURN_TO_LIST);
|
||||
// set item background
|
||||
returnToListItem.setBackground(R.color.colorReturnToListBtnBackground);
|
||||
// set item width
|
||||
returnToListItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||
// set item title
|
||||
returnToListItem.setTitle(R.string.return_to_list_button);
|
||||
// set item title font size
|
||||
returnToListItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
returnToListItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(returnToListItem);
|
||||
}
|
||||
|
||||
// create "delete" item
|
||||
SwipeMenuItem deleteItem = new SwipeMenuItem(menu.getContext());
|
||||
// set id
|
||||
deleteItem.setId(ID_DELETE);
|
||||
// set item background
|
||||
deleteItem.setBackground(R.color.colorDeleteBtnBackground);
|
||||
// set item width
|
||||
deleteItem.setWidth(Util.dp2px(presenter.getActivityContext(),120));
|
||||
// set item title
|
||||
deleteItem.setTitle(R.string.delete_button);
|
||||
// set item title font size
|
||||
deleteItem.setTitleSize(14);
|
||||
// set item title font color
|
||||
deleteItem.setTitleColor(Color.WHITE);
|
||||
// add to menu
|
||||
menu.addMenuItem(deleteItem);
|
||||
|
||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case ID_DELETE:
|
||||
remove(item);
|
||||
break;
|
||||
case ID_LEAVE_AT_HOME:
|
||||
leave(item);
|
||||
break;
|
||||
case ID_RETURN_TO_LIST:
|
||||
unpack(item);
|
||||
break;
|
||||
case ID_ADD_TO_BAG:
|
||||
pack(item);
|
||||
break;
|
||||
}
|
||||
menuLayout.notifyOnMenuItemClick();
|
||||
}
|
||||
};
|
||||
|
||||
menuLayout.addMenu(menu, onClickListener);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,40 +25,42 @@ public class SetListAdapter extends RecyclerView.Adapter<SetViewHolder> impleme
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(final SetViewHolder holder, int position) {
|
||||
try {
|
||||
final com.hikapro.backpack.model.entities.Set set = presenter.getModel().getSetByPosition(position);
|
||||
|
||||
final com.hikapro.backpack.model.entities.Set set = presenter.getModel().getSetByPosition(position);
|
||||
if (rightBracket == null || rightBracket.isEmpty()) {
|
||||
|
||||
if (rightBracket == null || rightBracket.isEmpty()) {
|
||||
if (presenter.getActivityContext() != null)
|
||||
this.rightBracket = presenter.getActivityContext().getResources().
|
||||
getString(R.string.right_angle_bracket);
|
||||
else
|
||||
this.rightBracket = "";
|
||||
}
|
||||
holder.textView.setText(set.getName() + " " + rightBracket);
|
||||
holder.textView.setTypeface(App.getMainFace());
|
||||
String info = String.format("%s %d / %d",
|
||||
presenter.getActivityContext().getResources().getString(R.string.packed),
|
||||
set.getPackedQty(),
|
||||
set.getActiveQty());
|
||||
holder.setInfo.setText(info);
|
||||
holder.cardView.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(android.view.View v) {
|
||||
presenter.showItemList(set);
|
||||
}
|
||||
});
|
||||
holder.cardView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
presenter.onLongClick(holder);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
holder.applyBackground(presenter.getAppContext(), set.getId());
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
if (presenter.getActivityContext() != null)
|
||||
this.rightBracket = presenter.getActivityContext().getResources().
|
||||
getString(R.string.right_angle_bracket);
|
||||
else
|
||||
this.rightBracket = "";
|
||||
}
|
||||
holder.textView.setText(set.getName() + " " + rightBracket);
|
||||
holder.textView.setTypeface(App.getMainFace());
|
||||
String info = String.format("%s %d / %d",
|
||||
presenter.getActivityContext().getResources().getString(R.string.packed),
|
||||
set.getPackedQty(),
|
||||
set.getActiveQty());
|
||||
holder.setInfo.setText(info);
|
||||
holder.cardView.setOnClickListener(new android.view.View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(android.view.View v) {
|
||||
presenter.showItemList(set);
|
||||
}
|
||||
});
|
||||
holder.cardView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
presenter.onLongClick(holder);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
holder.applyBackground(presenter.getAppContext(), set.getId());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -78,7 +78,11 @@ public class SwipeMenuItem {
|
|||
}
|
||||
|
||||
public void setBackground(int resId) {
|
||||
this.background = mContext.getResources().getDrawable(resId);
|
||||
try {
|
||||
this.background = mContext.getResources().getDrawable(resId);
|
||||
} catch (Exception ex) { ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:layout_height="@dimen/item_height"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/item_list_footer"
|
||||
android:layout_gravity="bottom"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:layout_height="@dimen/item_height"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/item_list_header"
|
||||
android:layout_gravity="top"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<dimen name="text_item_description">17sp</dimen>
|
||||
|
||||
<dimen name="card_height">150dp</dimen>
|
||||
<dimen name="item_height">56dp</dimen>
|
||||
<dimen name="item_height">66dp</dimen>
|
||||
<dimen name="card_margin">2dp</dimen>
|
||||
<dimen name="card_margin_txt">24dp</dimen>
|
||||
<dimen name="card_margin_packed_top">16dp</dimen>
|
||||
|
|
Loading…
Reference in New Issue