Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java
new file mode 100644
index 00000000..6f840fb1
--- /dev/null
+++ b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java
@@ -0,0 +1,55 @@
+package it.niedermann.owncloud.notes.model;
+
+import android.content.Context;
+import android.graphics.Typeface;
+import android.text.TextUtils;
+import android.util.TypedValue;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.Px;
+
+import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemGridBinding;
+
+import static android.view.View.GONE;
+import static android.view.View.INVISIBLE;
+import static android.view.View.VISIBLE;
+import static it.niedermann.owncloud.notes.util.NoteUtil.EXCERPT_LINE_SEPARATOR;
+
+public class NoteViewGridHolder extends NoteViewHolder {
+ @NonNull
+ private final ItemNotesListNoteItemGridBinding binding;
+
+ public NoteViewGridHolder(@NonNull ItemNotesListNoteItemGridBinding binding, @NonNull NoteClickListener noteClickListener, boolean monospace, @Px float fontSize) {
+ super(binding.getRoot(), noteClickListener);
+ this.binding = binding;
+
+ binding.noteTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * 1.1f);
+ binding.noteExcerpt.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize * .8f);
+ if (monospace) {
+ binding.noteTitle.setTypeface(Typeface.MONOSPACE);
+ binding.noteExcerpt.setTypeface(Typeface.MONOSPACE);
+ }
+ }
+
+ public void showSwipe(boolean left) {
+ throw new UnsupportedOperationException(NoteViewGridHolder.class.getSimpleName() + " does not support swiping");
+ }
+
+ public void bind(@NonNull DBNote note, boolean showCategory, int mainColor, int textColor, @Nullable CharSequence searchQuery) {
+ super.bind(note, showCategory, mainColor, textColor, searchQuery);
+ @NonNull final Context context = itemView.getContext();
+ bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), mainColor);
+ binding.noteStatus.setVisibility(DBStatus.VOID.equals(note.getStatus()) ? INVISIBLE : VISIBLE);
+ bindFavorite(binding.noteFavorite, note.isFavorite());
+ bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor);
+ bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt().replace(EXCERPT_LINE_SEPARATOR, "\n"), mainColor);
+ binding.noteExcerpt.setVisibility(TextUtils.isEmpty(note.getExcerpt()) ? GONE : VISIBLE);
+ }
+
+ @Nullable
+ public View getNoteSwipeable() {
+ return null;
+ }
+} \ No newline at end of file