Skip to content

Commit

Permalink
Added public method to forcibly move checked items to bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoiosue committed Nov 3, 2020
1 parent d55d1c1 commit cc88c47
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ ImageView getDragHandler () {
}


CheckBox getCheckBox () {
public CheckBox getCheckBox () {
return checkBox;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package it.feio.android.checklistview.models;

import static it.feio.android.checklistview.Settings.CHECKED_ON_TOP_OF_CHECKED;

import android.content.Context;
import android.text.TextWatcher;
import android.view.View;
Expand Down Expand Up @@ -402,6 +404,21 @@ public CheckListViewItem getFocusedItemView () {
}


public void moveCheckedToBottom() {
if (mCheckListView != null) {
int currentSetting = App.getSettings().getMoveCheckedOnBottom();
mCheckListView.setMoveCheckedOnBottom(CHECKED_ON_TOP_OF_CHECKED);
for (int i = 0; i < mCheckListView.getChildCount(); i++) {
CheckListViewItem mCheckListViewItem = mCheckListView.getChildAt(i);
if (!mCheckListViewItem.isHintItem() && mCheckListViewItem.isChecked()) {
mCheckListView.onItemChecked(mCheckListViewItem, true);
}
}
mCheckListView.setMoveCheckedOnBottom(currentSetting);
}
}


public void setOnTextLinkClickListener (TextLinkClickListener textlinkclicklistener) {
mTextLinkClickListener = textlinkclicklistener;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.action_toggle_checklist:
toggleCheckList();
break;

case R.id.action_move_to_bottom:
mChecklistManager.moveCheckedToBottom();
break;
case R.id.settings:
Intent settingsIntent = new Intent(this, SettingsActivity.class);
startActivity(settingsIntent);
Expand Down
16 changes: 11 additions & 5 deletions checklistview_demo/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:id="@+id/action_toggle_checklist"
android:orderInCategory="100"
android:showAsAction="always"
android:title="@string/action_toggle_checklist" />
android:title="@string/action_toggle_checklist"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_move_to_bottom"
android:orderInCategory="150"
android:title="@string/action_move_to_bottom"
app:showAsAction="never" />
<item
android:id="@+id/settings"
android:orderInCategory="200"
android:showAsAction="never"
android:title="@string/settings" />
android:title="@string/settings"
app:showAsAction="never" />

</menu>
1 change: 1 addition & 0 deletions checklistview_demo/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<string name="omninotes_link">market://details?id=it.feio.android.omninotes</string>

<string name="action_toggle_checklist">Convert</string>
<string name="action_move_to_bottom">Move checked to bottom</string>
<string name="template_phrase">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\n Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</string>
<string name="settings">Settings</string>
<string name="settings_lines_separator">Items separator</string>
Expand Down

0 comments on commit cc88c47

Please sign in to comment.