fix: update widget after synchronization

This commit is contained in:
korelstar 2017-09-02 20:58:42 +02:00
parent 15a57f4a7e
commit 7d634e9021
3 changed files with 15 additions and 9 deletions

View file

@ -207,15 +207,7 @@ public class EditNoteActivity extends AppCompatActivity {
data.putExtra(PARAM_NOTE, note);
data.putExtra(PARAM_NOTE_POSITION, notePosition);
setResult(RESULT_OK, data);
updateSingleNoteWidgets();
db.updateSingleNoteWidgets();
finish();
}
public void updateSingleNoteWidgets() {
Intent intent = new Intent(this, SingleNoteWidget.class);
intent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
sendBroadcast(intent);
}
}

View file

@ -2,6 +2,7 @@ package it.niedermann.owncloud.notes.persistence;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
@ -16,6 +17,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import it.niedermann.owncloud.notes.android.activity.SingleNoteWidget;
import it.niedermann.owncloud.notes.model.DBNote;
import it.niedermann.owncloud.notes.model.DBStatus;
import it.niedermann.owncloud.notes.model.CloudNote;
@ -445,4 +447,15 @@ public class NoteSQLiteOpenHelper extends SQLiteOpenHelper {
key_id + " = ? AND " + key_status + " = ?",
new String[]{String.valueOf(id), forceDBStatus.getTitle()});
}
/**
* Update single note widget, if the note data was changed.
* TODO This should be replaced by using the observer pattern
*/
public void updateSingleNoteWidgets() {
Intent intent = new Intent(getContext(), SingleNoteWidget.class);
intent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
getContext().sendBroadcast(intent);
}
}

View file

@ -384,6 +384,7 @@ public class NoteServerSyncHelper {
for (ICallback callback : callbacks) {
callback.onFinish();
}
dbHelper.updateSingleNoteWidgets();
// start next sync if scheduled meanwhile
if(syncScheduled) {
scheduleSync(false);