mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-21 20:35:58 +03:00
#101 Option to synchronise notes when opening the app
This commit is contained in:
parent
b9f5182640
commit
6275006b45
1 changed files with 29 additions and 13 deletions
|
@ -64,7 +64,6 @@ public class NotesListViewActivity extends AppCompatActivity implements
|
|||
|
||||
// Display Data
|
||||
db = new NoteSQLiteOpenHelper(this);
|
||||
db.synchronizeWithServer();
|
||||
setListView(db.getNotes());
|
||||
|
||||
// Pull to Refresh
|
||||
|
@ -72,18 +71,7 @@ public class NotesListViewActivity extends AppCompatActivity implements
|
|||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
db.getNoteServerSyncHelper().addCallback(new ICallback() {
|
||||
@Override
|
||||
public void onFinish() {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
adapter.clearSelection();
|
||||
if (mActionMode != null) {
|
||||
mActionMode.finish();
|
||||
}
|
||||
setListView(db.getNotes());
|
||||
}
|
||||
});
|
||||
db.synchronizeWithServer();
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -91,6 +79,34 @@ public class NotesListViewActivity extends AppCompatActivity implements
|
|||
findViewById(R.id.fab_create).setOnClickListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform refresh on every time the activity gets visible
|
||||
*/
|
||||
@Override
|
||||
protected void onResume() {
|
||||
refresh();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a server synchronization and set the RecyclerView
|
||||
*/
|
||||
private void refresh() {
|
||||
swipeRefreshLayout.setRefreshing(true);
|
||||
db.getNoteServerSyncHelper().addCallback(new ICallback() {
|
||||
@Override
|
||||
public void onFinish() {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
adapter.clearSelection();
|
||||
if (mActionMode != null) {
|
||||
mActionMode.finish();
|
||||
}
|
||||
setListView(db.getNotes());
|
||||
}
|
||||
});
|
||||
db.synchronizeWithServer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Click listener for <strong>Floating Action Button</strong>
|
||||
* <p/>
|
||||
|
|
Loading…
Reference in a new issue