fixed last element inaccessability and scroll crash
This commit is contained in:
parent
52b0c71eb2
commit
b09b5d4867
|
@ -37,7 +37,7 @@
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</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" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -177,7 +177,6 @@ public class MainActivity extends Activity implements View.ActivityCallback {
|
||||||
SetModel model = new SetModel();
|
SetModel model = new SetModel();
|
||||||
|
|
||||||
view.setPresenter(presenter);
|
view.setPresenter(presenter);
|
||||||
//presenter.setView(view);
|
|
||||||
presenter.setModel(model);
|
presenter.setModel(model);
|
||||||
model.setPresenter(presenter);
|
model.setPresenter(presenter);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class ItemModel implements Model.Item {
|
||||||
public void onEvent(Message event) {
|
public void onEvent(Message event) {
|
||||||
|
|
||||||
switch (event.what) {
|
switch (event.what) {
|
||||||
case Event.SET_ITEMS_LOAD_ERROR : // TODO check
|
case Event.SET_ITEMS_LOAD_ERROR:
|
||||||
if (presenter != null) {
|
if (presenter != null) {
|
||||||
if (packedQty == -1)
|
if (packedQty == -1)
|
||||||
packedQty = presenter.getCurrentSet().getPackedQty();
|
packedQty = presenter.getCurrentSet().getPackedQty();
|
||||||
|
@ -116,17 +116,17 @@ public class ItemModel implements Model.Item {
|
||||||
case Event.ITEM_FROM_SET_DELETED:
|
case Event.ITEM_FROM_SET_DELETED:
|
||||||
executeQuery();
|
executeQuery();
|
||||||
break;
|
break;
|
||||||
case Event.ITEM_DELETED :
|
case Event.ITEM_DELETED:
|
||||||
break;
|
break;
|
||||||
case Event.ITEM_PACKED :
|
case Event.ITEM_PACKED:
|
||||||
executeQuery();
|
executeQuery();
|
||||||
if (getPackedQty() == getActiveItemsCount())
|
if (getPackedQty() == getActiveItemsCount())
|
||||||
NetworkUtil.sendGoogleAnalyticsEvent("SET PACKED", String.format("Set #%d", currentSet));
|
NetworkUtil.sendGoogleAnalyticsEvent("SET PACKED", String.format("Set #%d", currentSet));
|
||||||
break;
|
break;
|
||||||
case Event.ITEM_UNPACKED :
|
case Event.ITEM_UNPACKED:
|
||||||
executeQuery();
|
executeQuery();
|
||||||
break;
|
break;
|
||||||
case Event.ITEM_INSERTED :
|
case Event.ITEM_INSERTED:
|
||||||
break;
|
break;
|
||||||
case Event.SET_RESTORE_COMPLETED:
|
case Event.SET_RESTORE_COMPLETED:
|
||||||
executeQuery();
|
executeQuery();
|
||||||
|
@ -184,7 +184,11 @@ public class ItemModel implements Model.Item {
|
||||||
@Override
|
@Override
|
||||||
public Item getItemByPosition(int position) {
|
public Item getItemByPosition(int position) {
|
||||||
Item ret = null;
|
Item ret = null;
|
||||||
|
try {
|
||||||
ret = itemsCache.get(position);
|
ret = itemsCache.get(position);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,12 +211,28 @@ public class ItemModel implements Model.Item {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeaderId(int position) {
|
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
|
@Override
|
||||||
public int getItemId(int position) {
|
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
|
@Override
|
||||||
|
|
|
@ -153,12 +153,14 @@ public class ItemListPresenter implements Presenter.ItemList {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisibility() {
|
public void setVisibility() {
|
||||||
if (model.getPackedQty() > 0 && model.getPackedQty() == model.getActiveItemsCount()) {
|
/*if (model.getPackedQty() > 0 && model.getPackedQty() == model.getActiveItemsCount()) {
|
||||||
footer.setVisibility(android.view.View.VISIBLE);
|
//showPackedItems();
|
||||||
} else if ( model.getPackedQty() > 0) {
|
} else*/ if (model.getPackedQty() > 0) {
|
||||||
footer.setVisibility(android.view.View.VISIBLE);
|
footer.setVisibility(android.view.View.VISIBLE);
|
||||||
|
adapter.addEmptyToTheEnd();
|
||||||
} else {
|
} else {
|
||||||
footer.setVisibility(android.view.View.GONE);
|
footer.setVisibility(android.view.View.GONE);
|
||||||
|
adapter.removeEmptyFromTheEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class PackedListPresenter extends ItemListPresenter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
try {
|
||||||
if (savedInstanceState != null)
|
if (savedInstanceState != null)
|
||||||
set = (Set) savedInstanceState.getSerializable(BUNDLE_SET_LIST_KEY);
|
set = (Set) savedInstanceState.getSerializable(BUNDLE_SET_LIST_KEY);
|
||||||
else
|
else
|
||||||
|
@ -99,6 +100,11 @@ public class PackedListPresenter extends ItemListPresenter {
|
||||||
}
|
}
|
||||||
NetworkUtil.sendGoogleAnalyticsScreen(TAG);
|
NetworkUtil.sendGoogleAnalyticsScreen(TAG);
|
||||||
return view;
|
return view;
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class AddListAdapter extends RecyclerView.Adapter<AddItemViewHolder> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(AddItemViewHolder holder, int position) {
|
public void onBindViewHolder(AddItemViewHolder holder, int position) {
|
||||||
|
try {
|
||||||
final Item item = presenter.getModel().getItemByPosition(position);
|
final Item item = presenter.getModel().getItemByPosition(position);
|
||||||
holder.name.setText(item.getName());
|
holder.name.setText(item.getName());
|
||||||
holder.category.setText(presenter.getModel().getCategoryById(item.getCategory()).getName());
|
holder.category.setText(presenter.getModel().getCategoryById(item.getCategory()).getName());
|
||||||
|
@ -38,6 +39,10 @@ public class AddListAdapter extends RecyclerView.Adapter<AddItemViewHolder> {
|
||||||
presenter.onAddItemClick(item);
|
presenter.onAddItemClick(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class ItemDetailAdapter extends RecyclerView.Adapter<ItemViewHolder> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
|
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
|
||||||
|
try {
|
||||||
final Item item = presenter.getModel().getCurrentItem();
|
final Item item = presenter.getModel().getCurrentItem();
|
||||||
holder.cb_item.setChecked(item.isPacked());
|
holder.cb_item.setChecked(item.isPacked());
|
||||||
holder.tv_text.setText(item.getName());
|
holder.tv_text.setText(item.getName());
|
||||||
|
@ -60,7 +61,6 @@ public class ItemDetailAdapter extends RecyclerView.Adapter<ItemViewHolder> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
||||||
SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||||
|
|
||||||
|
@ -141,6 +141,10 @@ public class ItemDetailAdapter extends RecyclerView.Adapter<ItemViewHolder> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
menuLayout.addMenu(menu, onClickListener);
|
menuLayout.addMenu(menu, onClickListener);
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
||||||
|
|
||||||
protected Presenter.ItemList presenter;
|
protected Presenter.ItemList presenter;
|
||||||
protected boolean checkAll;
|
protected boolean checkAll;
|
||||||
|
protected int addToCount = 0;
|
||||||
|
|
||||||
public ItemListAdapter(Presenter.ItemList presenter) {
|
public ItemListAdapter(Presenter.ItemList presenter) {
|
||||||
this.presenter = presenter;
|
this.presenter = presenter;
|
||||||
|
@ -41,8 +42,8 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
int res = presenter.getModel().getItemsCount();
|
int ret = presenter.getModel().getItemsCount();
|
||||||
return res;
|
return ret + addToCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,15 +55,17 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
|
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
|
||||||
|
|
||||||
|
try {
|
||||||
final Item item = presenter.getModel().getItemByPosition(position);
|
final Item item = presenter.getModel().getItemByPosition(position);
|
||||||
|
if (item != null) {
|
||||||
|
setVisibility(holder, View.VISIBLE);
|
||||||
holder.cb_item.setChecked(checkAll);
|
holder.cb_item.setChecked(checkAll);
|
||||||
holder.tv_text.setText(item.getName());
|
holder.tv_text.setText(item.getName());
|
||||||
//holder.tv_text.setTypeface(mainFace);
|
|
||||||
if (item.isPendingRemoval()) {
|
if (item.isPendingRemoval()) {
|
||||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||||
holder.cb_item.setVisibility(View.GONE);
|
holder.cb_item.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
holder.cb_item.setVisibility(View.VISIBLE);
|
//holder.cb_item.setVisibility(View.VISIBLE);
|
||||||
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
holder.tv_text.setPaintFlags(holder.tv_text.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +86,7 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final SwipeMenuLayout menuLayout = (SwipeMenuLayout)holder.menu;
|
final SwipeMenuLayout menuLayout = (SwipeMenuLayout) holder.menu;
|
||||||
final SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
final SwipeMenu menu = new SwipeMenu(presenter.getActivityContext());
|
||||||
|
|
||||||
menuLayout.removeAllViews();
|
menuLayout.removeAllViews();
|
||||||
|
@ -149,7 +152,7 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
||||||
// set item background
|
// set item background
|
||||||
deleteItem.setBackground(R.color.colorDeleteBtnBackground);
|
deleteItem.setBackground(R.color.colorDeleteBtnBackground);
|
||||||
// set item width
|
// set item width
|
||||||
deleteItem.setWidth(Util.dp2px(presenter.getActivityContext(),120));
|
deleteItem.setWidth(Util.dp2px(presenter.getActivityContext(), 120));
|
||||||
// set item title
|
// set item title
|
||||||
deleteItem.setTitle(R.string.delete_button);
|
deleteItem.setTitle(R.string.delete_button);
|
||||||
// set item title font size
|
// set item title font size
|
||||||
|
@ -182,7 +185,15 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
||||||
};
|
};
|
||||||
|
|
||||||
menuLayout.addMenu(menu, onClickListener);
|
menuLayout.addMenu(menu, onClickListener);
|
||||||
|
} else {
|
||||||
|
if (presenter.getModel().getPackedQty() > 0) {
|
||||||
|
setVisibility(holder, View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -257,4 +268,22 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
|
||||||
public void setCheckAll(boolean checkAll) {
|
public void setCheckAll(boolean checkAll) {
|
||||||
this.checkAll = 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,9 +22,15 @@ public class PackedListAdapter extends ItemListAdapter {
|
||||||
super(presenter);
|
super(presenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return presenter.getModel().getItemsCount();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
|
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
|
||||||
|
|
||||||
|
try {
|
||||||
final Item item = presenter.getModel().getItemByPosition(position);
|
final Item item = presenter.getModel().getItemByPosition(position);
|
||||||
holder.cb_item.setChecked(checkAll);
|
holder.cb_item.setChecked(checkAll);
|
||||||
holder.tv_text.setText(item.getName());
|
holder.tv_text.setText(item.getName());
|
||||||
|
@ -151,6 +157,10 @@ public class PackedListAdapter extends ItemListAdapter {
|
||||||
};
|
};
|
||||||
|
|
||||||
menuLayout.addMenu(menu, onClickListener);
|
menuLayout.addMenu(menu, onClickListener);
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class SetListAdapter extends RecyclerView.Adapter<SetViewHolder> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final SetViewHolder holder, int position) {
|
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()) {
|
||||||
|
@ -58,8 +58,10 @@ public class SetListAdapter extends RecyclerView.Adapter<SetViewHolder> impleme
|
||||||
});
|
});
|
||||||
holder.applyBackground(presenter.getAppContext(), set.getId());
|
holder.applyBackground(presenter.getAppContext(), set.getId());
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SetViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public SetViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
|
|
@ -78,7 +78,11 @@ public class SwipeMenuItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBackground(int resId) {
|
public void setBackground(int resId) {
|
||||||
|
try {
|
||||||
this.background = mContext.getResources().getDrawable(resId);
|
this.background = mContext.getResources().getDrawable(resId);
|
||||||
|
} catch (Exception ex) { ;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="70dp"
|
android:layout_height="@dimen/item_height"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:id="@+id/item_list_footer"
|
android:id="@+id/item_list_footer"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="70dp"
|
android:layout_height="@dimen/item_height"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:id="@+id/item_list_header"
|
android:id="@+id/item_list_header"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<dimen name="text_item_description">17sp</dimen>
|
<dimen name="text_item_description">17sp</dimen>
|
||||||
|
|
||||||
<dimen name="card_height">150dp</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">2dp</dimen>
|
||||||
<dimen name="card_margin_txt">24dp</dimen>
|
<dimen name="card_margin_txt">24dp</dimen>
|
||||||
<dimen name="card_margin_packed_top">16dp</dimen>
|
<dimen name="card_margin_packed_top">16dp</dimen>
|
||||||
|
|
Loading…
Reference in New Issue