diff options
Diffstat (limited to 'app/src/main/java/net/lacolaco')
6 files changed, 11 insertions, 27 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java index c9b14cd5..d68ef3fe 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditCommandActivity.java @@ -125,12 +125,10 @@ public class EditCommandActivity extends Activity { } private void enableAll() { - adapter.setNotifiable(false); for (int i = 0; i < adapter.getCount(); i++) { CheckBoxModel item = adapter.getItem(i); item.setChecked(true); } - adapter.setNotifiable(true); adapter.notifyDataSetChanged(); updateListView(); } @@ -138,9 +136,9 @@ public class EditCommandActivity extends Activity { private void initializeViews() { ListView listView = getListView(); adapter = new UnorderedCustomListAdapter<>(this); - listView.setAdapter(adapter); adapter.addItemsToTop(getCheckBoxItems()); adapter.update(); + listView.setAdapter(adapter); } private void updateListView() { diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java index c4e998f6..ed2c784b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java @@ -141,7 +141,6 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt public void deleteSelectedItems() { SparseBooleanArray checkedItems = getListView().getCheckedItemPositions(); - adapter.setNotifiable(false); for (int i = adapter.getCount() - 1; i > -1; i--) { if (checkedItems.get(i)) { ExtractionWordViewModel vm = adapter.getItem(i); @@ -149,7 +148,6 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt adapter.removeItem(vm); } } - adapter.setNotifiable(true); adapter.notifyDataSetChanged(); updateListView(); } diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java index d1a60fe6..7198a977 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java @@ -133,9 +133,9 @@ public class EditTabActivity extends Activity { private void initializeViews() { ListView listView = getListView(); adapter = new OrderedCustomListAdapter<>(this, Collections.reverseOrder()); - listView.setAdapter(adapter); adapter.addItems(getCheckBoxItems()); adapter.update(); + listView.setAdapter(adapter); } private void putVisibility(int key, boolean value) { diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java index 33c29792..49ac38f9 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditTemplateActivity.java @@ -145,7 +145,6 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem public void deleteSelectedItems() { SparseBooleanArray checkedItems = getListView().getCheckedItemPositions(); - adapter.setNotifiable(false); for (int i = adapter.getCount() - 1; i > -1; i--) { if (checkedItems.get(i)) { Template template = adapter.getItem(i); @@ -153,7 +152,6 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem adapter.removeItem(template); } } - adapter.setNotifiable(true); adapter.notifyDataSetChanged(); updateListView(); } @@ -198,9 +196,9 @@ public class EditTemplateActivity extends Activity implements AdapterView.OnItem private void initializeViews() { ListView listView = getListView(); adapter = new UnorderedCustomListAdapter<>(this); - listView.setAdapter(adapter); adapter.addItemsToBottom(getTemplates()); adapter.update(); + listView.setAdapter(adapter); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setOnItemClickListener(this); listView.setMultiChoiceModeListener(this); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java index 74f110bd..35f44de8 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java @@ -387,7 +387,6 @@ public class UserDetailDialogFragment extends StackableDialogFragment implements int after = adapter.getCount(); int increments = after - before; if (increments > 0) { - adapter.setNotifiable(false); if (addedToTop) { absListView.setSelection(increments + 1); absListView.smoothScrollToPositionFromTop(increments, 0); @@ -395,12 +394,6 @@ public class UserDetailDialogFragment extends StackableDialogFragment implements } else { absListView.smoothScrollToPositionFromTop(before, 0); } - - if (increments == 1) { - adapter.setNotifiable(true); - } - } else { - adapter.setNotifiable(true); } } diff --git a/app/src/main/java/net/lacolaco/smileessence/view/page/CustomListFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/page/CustomListFragment.java index 83d75a6d..012578f4 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/page/CustomListFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/page/CustomListFragment.java @@ -66,12 +66,12 @@ public abstract class CustomListFragment<T extends CustomListAdapter> extends Pa @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { T adapter = getAdapter(); - adapter.setNotifiable(false); - - if (absListView.getFirstVisiblePosition() == 0 && absListView.getChildAt(0) != null && absListView.getChildAt(0).getTop() == 0) { - if (scrollState == SCROLL_STATE_IDLE) { - updateListViewWithNotice(absListView, true); - } + if (scrollState != SCROLL_STATE_TOUCH_SCROLL && + absListView.getFirstVisiblePosition() == 0 && (absListView.getChildAt(0) == null || absListView.getChildAt(0).getTop() == 0)) { + adapter.setNotifiable(true); + updateListViewWithNotice(absListView, true); + } else { + adapter.setNotifiable(false); } } @@ -103,7 +103,6 @@ public abstract class CustomListFragment<T extends CustomListAdapter> extends Pa int after = adapter.getCount(); int increments = after - before; if (increments > 0) { - adapter.setNotifiable(false); Notificator.getInstance().publish(R.string.notice_timeline_new, increments); if (addedToTop) { absListView.setSelection(increments + 1); @@ -113,11 +112,9 @@ public abstract class CustomListFragment<T extends CustomListAdapter> extends Pa absListView.smoothScrollToPositionFromTop(before, 0); } - if (increments == 1) { - adapter.setNotifiable(true); + if (increments > 1) { + adapter.setNotifiable(false); } - } else { - adapter.setNotifiable(true); } } } |