mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-27 09:46:50 +03:00
parent
9da687f847
commit
23a535bf35
2 changed files with 25 additions and 8 deletions
|
@ -148,7 +148,7 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
|
|||
private ICallback syncCallBack = new ICallback() {
|
||||
@Override
|
||||
public void onFinish() {
|
||||
adapter.clearSelection();
|
||||
adapter.clearSelection(listView);
|
||||
if (mActionMode != null) {
|
||||
mActionMode.finish();
|
||||
}
|
||||
|
@ -973,14 +973,13 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
|
|||
AccountChooserDialogFragment.newInstance().show(getFragmentManager(), NotesListViewActivity.class.getCanonicalName());
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
adapter.clearSelection();
|
||||
adapter.clearSelection(listView);
|
||||
mActionMode = null;
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -988,14 +987,21 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
|
|||
|
||||
@Override
|
||||
public void onAccountChosen(LocalAccount account) {
|
||||
List<Integer> selection = adapter.getSelected();
|
||||
List<Integer> selection = new ArrayList<>(adapter.getSelected());
|
||||
|
||||
adapter.deselect(0);
|
||||
for (Integer i : selection) {
|
||||
DBNote note = (DBNote) adapter.getItem(i);
|
||||
db.moveNoteToAnotherAccount(note.getAccountId(),db.getNote(note.getAccountId(), note.getId()), account.getId());
|
||||
RecyclerView.ViewHolder viewHolder = listView.findViewHolderForAdapterPosition(i);
|
||||
if(viewHolder != null) {
|
||||
viewHolder.itemView.setSelected(false);
|
||||
} else {
|
||||
Log.w(TAG, "Could not found viewholder to remove selection");
|
||||
}
|
||||
}
|
||||
|
||||
mActionMode.finish(); // Act// ion picked, so close the CAB
|
||||
//after delete selection has to be cleared
|
||||
mActionMode.finish();
|
||||
searchView.setIconified(true);
|
||||
refreshLists();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package it.niedermann.owncloud.notes.model;
|
||||
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -21,6 +22,8 @@ import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
|
|||
|
||||
public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private static final String TAG = ItemAdapter.class.getCanonicalName();
|
||||
|
||||
private static final int section_type = 0;
|
||||
private static final int note_type = 1;
|
||||
private final NoteClickListener noteClickListener;
|
||||
|
@ -105,7 +108,15 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|||
return !selected.contains(position) && selected.add(position);
|
||||
}
|
||||
|
||||
public void clearSelection() {
|
||||
public void clearSelection(RecyclerView recyclerView) {
|
||||
for (Integer i : getSelected()) {
|
||||
RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(i);
|
||||
if(viewHolder != null) {
|
||||
viewHolder.itemView.setSelected(false);
|
||||
} else {
|
||||
Log.w(TAG, "Could not found viewholder to remove selection");
|
||||
}
|
||||
}
|
||||
selected.clear();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue