Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException;
import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException;
import com.nextcloud.android.sso.helper.SingleAccountHelper;
import com.owncloud.android.lib.common.utils.Log_OC;

import java.util.ArrayList;
import java.util.Calendar;
Expand Down Expand Up @@ -141,7 +142,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
requireActivity().invalidateOptionsMenu();
}
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
e.printStackTrace();
Log_OC.e(TAG, e.getLocalizedMessage());
}
});
setHasOptionsMenu(true);
Expand Down Expand Up @@ -240,16 +241,26 @@ public boolean onOptionsItemSelected(MenuItem item) {
repo.updateNoteAndSync(localAccount, originalNote, null, null, null);
}
});
listener.close();

if (listener != null) {
listener.close();
}
return true;
} else if (itemId == R.id.menu_delete) {
repo.deleteNoteAndSync(localAccount, note.getId());
listener.close();

if (listener != null) {
listener.close();
}
return true;
} else if (itemId == R.id.menu_favorite) {
note.setFavorite(!note.getFavorite());
repo.toggleFavoriteAndSync(localAccount, note);
listener.onNoteUpdated(note);

if (listener != null) {
listener.onNoteUpdated(note);
}

prepareFavoriteOption(item);
return true;
} else if (itemId == R.id.menu_category) {
Expand Down Expand Up @@ -288,22 +299,35 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

protected void shareNote() {
if (note == null) {
Log_OC.w(TAG, "Note is null in shareNote");
return;
}

ShareUtil.openShareDialog(requireContext(), note.getTitle(), note.getContent());
}

@CallSuper
protected void onNoteLoaded(Note note) {
if (note == null) {
Log_OC.w(TAG, "Note is null in onNoteLoaded");
return;
}

this.originalScrollY = note.getScrollY();
scrollToY(originalScrollY);
final var scrollView = getScrollView();
if (scrollView != null) {
scrollView.setOnScrollChangeListener((View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) -> {
if (scrollY > 0) {
note.setScrollY(scrollY);
}
onScroll(scrollY, oldScrollY);
});
if (scrollView == null) {
Log_OC.w(TAG, "Scroll view is null, onNoteLoaded");
return;
}

scrollView.setOnScrollChangeListener((View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) -> {
if (scrollY > 0) {
note.setScrollY(scrollY);
}
onScroll(scrollY, oldScrollY);
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,13 @@ class NoteDirectEditFragment : BaseNoteFragment(), Branded {
disposables.add(timeoutDisposable)
}

override fun onNoteLoaded(note: Note) {
override fun onNoteLoaded(note: Note?) {
super.onNoteLoaded(note)
if (note == null) {
Log_OC.w(TAG, "Note is null, onNoteLoaded")
return
}

Log.d(TAG, "onNoteLoaded() called")
val newNoteParam = arguments?.getSerializable(PARAM_NEWNOTE) as Note?
if (newNoteParam != null || note.remoteId == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.owncloud.android.lib.common.utils.Log_OC;

import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.branding.BrandingUtil;
Expand Down Expand Up @@ -182,7 +183,8 @@ public void onResume() {
@Override
protected void onNoteLoaded(Note note) {
super.onNoteLoaded(note);
if (binding == null) {
if (binding == null || note == null) {
Log_OC.w(TAG, "Note is null, onNoteLoaded");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
@Override
protected void onNoteLoaded(Note note) {
super.onNoteLoaded(note);
if (note == null) {
Log_OC.w(TAG, "Note is null, onNoteLoaded");
return;
}

noteLoaded = true;
registerInternalNoteLinkHandler();

Expand Down
Loading