mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-28 03:25:18 +03:00
Create NotesClient in updateAccount when null
This commit is contained in:
parent
a85e93e1fb
commit
99d0bf944e
1 changed files with 19 additions and 15 deletions
|
@ -76,19 +76,6 @@ public class NoteServerSyncHelper {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public void updateAccount(){
|
|
||||||
try {
|
|
||||||
if(notesClient != null) {
|
|
||||||
this.localAccount = dbHelper.getLocalAccountByAccountName(SingleAccountHelper.getCurrentSingleSignOnAccount(appContext).name);
|
|
||||||
notesClient.updateAccount(localAccount.getToken());
|
|
||||||
}
|
|
||||||
Log.v("Notes", "NextcloudRequest account: " + localAccount);
|
|
||||||
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Log.v("Note", "Reinstanziation NotesClient because of SSO acc changed");
|
|
||||||
};
|
|
||||||
|
|
||||||
private final BroadcastReceiver networkReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver networkReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
@ -131,6 +118,23 @@ public class NoteServerSyncHelper {
|
||||||
updateNetworkStatus();
|
updateNetworkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateAccount() {
|
||||||
|
try {
|
||||||
|
this.localAccount = dbHelper.getLocalAccountByAccountName(SingleAccountHelper.getCurrentSingleSignOnAccount(appContext).name);
|
||||||
|
if (notesClient == null) {
|
||||||
|
if(this.localAccount != null) {
|
||||||
|
notesClient = new NotesClient(appContext, localAccount.getToken());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
notesClient.updateAccount(localAccount.getToken());
|
||||||
|
}
|
||||||
|
Log.v("Notes", "NextcloudRequest account: " + localAccount);
|
||||||
|
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
Log.v("Note", "Reinstanziation NotesClient because of SSO acc changed");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
appContext.unregisterReceiver(networkReceiver);
|
appContext.unregisterReceiver(networkReceiver);
|
||||||
|
@ -282,7 +286,7 @@ public class NoteServerSyncHelper {
|
||||||
* Push local changes: for each locally created/edited/deleted Note, use NotesClient in order to push the changed to the server.
|
* Push local changes: for each locally created/edited/deleted Note, use NotesClient in order to push the changed to the server.
|
||||||
*/
|
*/
|
||||||
private void pushLocalChanges() {
|
private void pushLocalChanges() {
|
||||||
if(localAccount == null) {
|
if (localAccount == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.d(getClass().getSimpleName(), "pushLocalChanges()");
|
Log.d(getClass().getSimpleName(), "pushLocalChanges()");
|
||||||
|
@ -331,7 +335,7 @@ public class NoteServerSyncHelper {
|
||||||
* Pull remote Changes: update or create each remote note (if local pendant has no changes) and remove remotely deleted notes.
|
* Pull remote Changes: update or create each remote note (if local pendant has no changes) and remove remotely deleted notes.
|
||||||
*/
|
*/
|
||||||
private LoginStatus pullRemoteChanges() {
|
private LoginStatus pullRemoteChanges() {
|
||||||
if(localAccount == null) {
|
if (localAccount == null) {
|
||||||
return LoginStatus.NO_NETWORK;
|
return LoginStatus.NO_NETWORK;
|
||||||
}
|
}
|
||||||
Log.d(getClass().getSimpleName(), "pullRemoteChanges() for account " + localAccount.getAccountName());
|
Log.d(getClass().getSimpleName(), "pullRemoteChanges() for account " + localAccount.getAccountName());
|
||||||
|
|
Loading…
Reference in a new issue