mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-26 23:27:55 +03:00
parent
cd90f4dc84
commit
67dce3f20a
1 changed files with 3 additions and 7 deletions
|
@ -36,8 +36,6 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact
|
|||
private final NotesListWidgetData data;
|
||||
private final boolean darkTheme;
|
||||
private NotesDatabase db;
|
||||
private LiveData<List<NoteWithCategory>> noteEntitiesLiveData;
|
||||
private Observer<List<NoteWithCategory>> noteEntitiesObserver = (notes) -> this.noteEntities = notes;
|
||||
private List<NoteWithCategory> noteEntities;
|
||||
|
||||
NoteListWidgetFactory(Context context, Intent intent) {
|
||||
|
@ -53,9 +51,7 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact
|
|||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
if (noteEntitiesLiveData != null) {
|
||||
noteEntitiesLiveData.removeObserver(noteEntitiesObserver);
|
||||
}
|
||||
final LiveData<List<NoteWithCategory>> noteEntitiesLiveData;
|
||||
try {
|
||||
Log.v(TAG, "--- data - " + data);
|
||||
switch (data.getMode()) {
|
||||
|
@ -66,18 +62,18 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact
|
|||
noteEntitiesLiveData = db.getNoteDao().searchFavorites(data.getAccountId(), "%", CategorySortingMethod.SORT_MODIFIED_DESC.getSorder());
|
||||
break;
|
||||
case MODE_DISPLAY_CATEGORY:
|
||||
default:
|
||||
if (data.getCategoryId() != null) {
|
||||
// FIXME
|
||||
noteEntitiesLiveData = db.getNoteDao().searchByCategory(data.getAccountId(), "%", db.getCategoryDao().getCategoryTitleById(data.getCategoryId()), CategorySortingMethod.SORT_MODIFIED_DESC.getSorder());
|
||||
} else {
|
||||
noteEntitiesLiveData = db.getNoteDao().searchUncategorized(data.getAccountId(), "%", CategorySortingMethod.SORT_MODIFIED_DESC.getSorder());
|
||||
}
|
||||
break;
|
||||
}
|
||||
noteEntitiesLiveData.observeForever((notes) -> noteEntities = notes);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
noteEntitiesLiveData.observeForever(noteEntitiesObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue