mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-26 23:27:55 +03:00
Minor stuff
This commit is contained in:
parent
8f941964ba
commit
033ae67ef3
3 changed files with 5 additions and 14 deletions
|
@ -22,7 +22,6 @@ import com.nextcloud.android.sso.model.SingleSignOnAccount;
|
|||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import it.niedermann.owncloud.notes.R;
|
||||
|
@ -403,12 +402,10 @@ public class MainViewModel extends AndroidViewModel {
|
|||
return db.getAccountDao().getAccounts();
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public void setCategory(SingleSignOnAccount ssoAccount, long accountId, Long noteId, @NonNull String category) {
|
||||
db.setCategory(ssoAccount, accountId, noteId, category);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public LiveData<NoteWithCategory> moveNoteToAnotherAccount(SingleSignOnAccount ssoAccount, NoteWithCategory note, long newAccountId) {
|
||||
return db.moveNoteToAnotherAccount(ssoAccount, note, newAccountId);
|
||||
}
|
||||
|
@ -418,22 +415,18 @@ public class MainViewModel extends AndroidViewModel {
|
|||
return db.getCategoryDao().getCategory(id);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public LiveData<Void> deleteAccount(@NonNull Account account) {
|
||||
return db.deleteAccount(account);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public void toggleFavoriteAndSync(SingleSignOnAccount ssoAccount, long noteId) {
|
||||
db.toggleFavoriteAndSync(ssoAccount, noteId);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public void deleteNoteAndSync(SingleSignOnAccount ssoAccount, long id) {
|
||||
db.deleteNoteAndSync(ssoAccount, id);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public LiveData<Account> addAccount(@NonNull String url, @NonNull String username, @NonNull String accountName, @NonNull Capabilities capabilities) {
|
||||
return db.addAccount(url, username, accountName, capabilities);
|
||||
}
|
||||
|
@ -443,11 +436,11 @@ public class MainViewModel extends AndroidViewModel {
|
|||
return db.getNoteDao().getNoteWithCategory(accountId, id);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public LiveData<NoteWithCategory> addNoteAndSync(SingleSignOnAccount ssoAccount, long accountId, NoteWithCategory note) {
|
||||
return db.addNoteAndSync(ssoAccount, accountId, note);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public void updateNoteAndSync(SingleSignOnAccount ssoAccount, @NonNull Account localAccount, @NonNull NoteWithCategory oldNote, @Nullable String newContent, @Nullable String newTitle, @Nullable ISyncCallback callback) {
|
||||
db.updateNoteAndSync(ssoAccount, localAccount, oldNote, newContent, newTitle, callback);
|
||||
}
|
||||
|
|
|
@ -261,11 +261,11 @@ public abstract class NotesDatabase extends RoomDatabase {
|
|||
* @param callback When the synchronization is finished, this callback will be invoked (optional).
|
||||
* @return changed {@link Note} if differs from database, otherwise the old {@link Note}.
|
||||
*/
|
||||
@WorkerThread
|
||||
public NoteWithCategory updateNoteAndSync(SingleSignOnAccount ssoAccount, @NonNull Account localAccount, @NonNull NoteWithCategory oldNote, @Nullable String newContent, @Nullable String newTitle, @Nullable ISyncCallback callback) {
|
||||
NoteWithCategory newNote = new NoteWithCategory();
|
||||
final NoteWithCategory newNote;
|
||||
if (newContent == null) {
|
||||
newNote.setNote(new Note(oldNote.getId(), oldNote.getRemoteId(), oldNote.getModified(), oldNote.getTitle(), oldNote.getContent(), oldNote.getFavorite(), oldNote.getETag(), DBStatus.LOCAL_EDITED, localAccount.getId(), oldNote.getExcerpt(), oldNote.getScrollY()));
|
||||
newNote.setCategory(oldNote.getCategory());
|
||||
newNote = new NoteWithCategory(new Note(oldNote.getId(), oldNote.getRemoteId(), oldNote.getModified(), oldNote.getTitle(), oldNote.getContent(), oldNote.getFavorite(), oldNote.getETag(), DBStatus.LOCAL_EDITED, localAccount.getId(), oldNote.getExcerpt(), oldNote.getScrollY()), oldNote.getCategory());
|
||||
} else {
|
||||
final String title;
|
||||
if (newTitle != null) {
|
||||
|
@ -277,8 +277,7 @@ public abstract class NotesDatabase extends RoomDatabase {
|
|||
title = oldNote.getTitle();
|
||||
}
|
||||
}
|
||||
newNote.setNote(new Note(oldNote.getId(), oldNote.getRemoteId(), Calendar.getInstance(), title, newContent, oldNote.getFavorite(), oldNote.getETag(), DBStatus.LOCAL_EDITED, localAccount.getId(), generateNoteExcerpt(newContent, title), oldNote.getScrollY()));
|
||||
newNote.setCategory(oldNote.getCategory());
|
||||
newNote = new NoteWithCategory(new Note(oldNote.getId(), oldNote.getRemoteId(), Calendar.getInstance(), title, newContent, oldNote.getFavorite(), oldNote.getETag(), DBStatus.LOCAL_EDITED, localAccount.getId(), generateNoteExcerpt(newContent, title), oldNote.getScrollY()), oldNote.getCategory());
|
||||
}
|
||||
newNote.getNote().setCategoryId(getOrCreateCategoryIdByTitle(newNote.getAccountId(), newNote.getCategory()));
|
||||
int rows = getNoteDao().updateNote(newNote.getNote());
|
||||
|
|
|
@ -16,7 +16,6 @@ import it.niedermann.owncloud.notes.NotesApplication;
|
|||
import it.niedermann.owncloud.notes.R;
|
||||
import it.niedermann.owncloud.notes.exception.ExceptionHandler;
|
||||
import it.niedermann.owncloud.notes.main.MainActivity;
|
||||
import it.niedermann.owncloud.notes.persistence.entity.Note;
|
||||
import it.niedermann.owncloud.notes.persistence.entity.NoteWithCategory;
|
||||
import it.niedermann.owncloud.notes.persistence.entity.SingleNoteWidgetData;
|
||||
|
||||
|
|
Loading…
Reference in a new issue