mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-25 14:26:13 +03:00
Merge pull request #59 from HeaDBanGer84/RecyclerView
Creating a new Note creates the note two times Deleting a Note via long-click selects another Note after Deletion
This commit is contained in:
commit
bac2e86d88
7 changed files with 38 additions and 7 deletions
|
@ -67,7 +67,6 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/debug" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/debugAndroidTest" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.support.v7.app.ActionBar;
|
|||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.EditText;
|
||||
|
||||
import java.util.Timer;
|
||||
|
@ -23,6 +24,7 @@ public class EditNoteActivity extends AppCompatActivity {
|
|||
private EditText content = null;
|
||||
private Note note = null;
|
||||
private Timer timer = new Timer();
|
||||
private ActionBar actionBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
|
@ -34,6 +36,12 @@ public class EditNoteActivity extends AppCompatActivity {
|
|||
content.setEnabled(false);
|
||||
content.setText(note.getContent());
|
||||
content.setEnabled(true);
|
||||
actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle(note.getTitle());
|
||||
actionBar.setSubtitle(getString(R.string.action_edit_editing));
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
content.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||
|
@ -76,6 +84,22 @@ public class EditNoteActivity extends AppCompatActivity {
|
|||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
content.setEnabled(false);
|
||||
saveData();
|
||||
Intent data = new Intent();
|
||||
data.setAction(Intent.ACTION_VIEW);
|
||||
data.putExtra(NoteActivity.EDIT_NOTE, note);
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void saveData() {
|
||||
ActionBar ab = getSupportActionBar();
|
||||
if (ab != null) {
|
||||
|
|
|
@ -168,7 +168,7 @@ public class NotesListViewActivity extends AppCompatActivity implements
|
|||
itemList.add(currentNote);
|
||||
}
|
||||
|
||||
adapter = new ItemAdapter(getApplicationContext(), itemList);
|
||||
adapter = new ItemAdapter(itemList);
|
||||
ItemAdapter.setNoteClickListener(this);
|
||||
listView = (RecyclerView) findViewById(R.id.list_view);
|
||||
listView.setAdapter(adapter);
|
||||
|
@ -223,9 +223,12 @@ public class NotesListViewActivity extends AppCompatActivity implements
|
|||
if (requestCode == create_note_cmd) {
|
||||
// Make sure the request was successful
|
||||
if (resultCode == RESULT_OK) {
|
||||
Note createdNote = (Note) data.getExtras().getSerializable(
|
||||
//not need because of db.synchronisation in createActivity
|
||||
|
||||
/*Note createdNote = (Note) data.getExtras().getSerializable(
|
||||
CREATED_NOTE);
|
||||
adapter.add(createdNote);
|
||||
adapter.add(createdNote);*/
|
||||
setListView(db.getNotes());
|
||||
}
|
||||
} else if (requestCode == show_single_note_cmd) {
|
||||
if (resultCode == RESULT_OK || resultCode == RESULT_FIRST_USER) {
|
||||
|
@ -340,9 +343,12 @@ public class NotesListViewActivity extends AppCompatActivity implements
|
|||
for (Integer i : selection) {
|
||||
Note note = (Note) adapter.getItem(i);
|
||||
db.deleteNoteAndSync(note.getId());
|
||||
adapter.remove(note);
|
||||
// Not needed because of dbsync
|
||||
//adapter.remove(note);
|
||||
}
|
||||
mode.finish(); // Action picked, so close the CAB
|
||||
//after delete selection has to be cleared
|
||||
setListView(db.getNotes());
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -65,7 +65,7 @@ public class SelectSingleNoteActivity extends AppCompatActivity implements Adapt
|
|||
private void setListView(List<Note> noteList) {
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
itemList.addAll(noteList);
|
||||
adapter = new ItemAdapter(getApplicationContext(), itemList);
|
||||
adapter = new ItemAdapter(itemList);
|
||||
listView = (RecyclerView) findViewById(R.id.select_single_note_list_view);
|
||||
listView.setAdapter(adapter);
|
||||
listView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|||
private static NoteClickListener noteClickListener;
|
||||
private List<Item> itemList = null;
|
||||
private List<Integer> selected = null;
|
||||
public ItemAdapter(Context context, List<Item> itemList) {
|
||||
public ItemAdapter(List<Item> itemList) {
|
||||
//super(context, android.R.layout.simple_list_item_1, itemList);
|
||||
super();
|
||||
this.itemList = itemList;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<string name="action_settings">Einstellungen</string>
|
||||
<string name="action_create_save">Speichern</string>
|
||||
<string name="action_create_cancel">Abbrechen</string>
|
||||
<string name="action_edit_editing">Bearbeiten</string>
|
||||
<string name="action_edit_save">Speichern</string>
|
||||
<string name="action_edit_saving">Speichern…</string>
|
||||
<string name="action_edit_saved">Gespeichert</string>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<string name="action_settings">Settings</string>
|
||||
<string name="action_create_save">Save</string>
|
||||
<string name="action_create_cancel">Cancel</string>
|
||||
<string name="action_edit_editing">Edit</string>
|
||||
<string name="action_edit_save">Save</string>
|
||||
<string name="action_edit_saving">Saving…</string>
|
||||
<string name="action_edit_saved">Saved</string>
|
||||
|
|
Loading…
Reference in a new issue