diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/SCNApp.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/SCNApp.java index e66b130..daf675c 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/SCNApp.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/SCNApp.java @@ -105,15 +105,8 @@ public class SCNApp extends Application implements LifecycleObserver [ ] - test notification channels [ ] - startup time [ ] - periodically get non-ack (option - even when not in-app) -[ ] - expand long content on click [ ] - publish (+ HN post ?) -[ ] - Use for mscom server errrors -[ ] - Use for bfb server errors -[ ] - Use for transmission state -[ ] - Message on connnection lost (seperate process - resend until succ) -[ ] - Message on connnection regained -[ ] - Message on seed-count changed */ \ No newline at end of file diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/MessageAdapter.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/MessageAdapter.java index 9f1128b..4fa74b8 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/MessageAdapter.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/MessageAdapter.java @@ -11,6 +11,12 @@ import com.blackforestbytes.simplecloudnotifier.R; import com.blackforestbytes.simplecloudnotifier.model.CMessage; import com.blackforestbytes.simplecloudnotifier.model.CMessageList; +import java.lang.ref.WeakReference; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.WeakHashMap; + import androidx.annotation.NonNull; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -21,6 +27,8 @@ public class MessageAdapter extends RecyclerView.Adapter private final LinearLayoutManager manLayout; private final RecyclerView viewRecycler; + private WeakHashMap viewHolders = new WeakHashMap<>(); + public MessageAdapter(View noElementsView, LinearLayoutManager layout, RecyclerView recycler) { vNoElements = noElementsView; @@ -45,6 +53,15 @@ public class MessageAdapter extends RecyclerView.Adapter CMessage msg = CMessageList.inst().tryGetFromBack(position); MessagePresenter view = (MessagePresenter) holder; view.setMessage(msg); + + viewHolders.put(view, true); + } + + + @Override + public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) + { + if (holder instanceof MessagePresenter) viewHolders.remove(holder); } @Override @@ -70,7 +87,6 @@ public class MessageAdapter extends RecyclerView.Adapter manLayout.smoothScrollToPosition(viewRecycler, null, 0); } - public void removeItem(int position) { CMessageList.inst().remove(position); @@ -104,7 +120,13 @@ public class MessageAdapter extends RecyclerView.Adapter ivPriority = itemView.findViewById(R.id.ivPriority); viewForeground = itemView.findViewById(R.id.layoutFront); viewBackground = itemView.findViewById(R.id.layoutBack); + itemView.setOnClickListener(this); + tvTimestamp.setOnClickListener(this); + tvTitle.setOnClickListener(this); + tvMessage.setOnClickListener(this); + ivPriority.setOnClickListener(this); + viewForeground.setOnClickListener(this); } void setMessage(CMessage msg) @@ -134,7 +156,16 @@ public class MessageAdapter extends RecyclerView.Adapter @Override public void onClick(View v) { - //SCNApp.showToast(data.Title, Toast.LENGTH_LONG); + for (MessagePresenter holder : MessageAdapter.this.viewHolders.keySet()) + { + if (holder == null) continue; + if (holder == this) continue; + if (holder.tvMessage == null) continue; + if (holder.tvMessage.getMaxLines() == 6) continue; + holder.tvMessage.setMaxLines(6); + } + + tvMessage.setMaxLines(9999); } } } diff --git a/android/app/src/main/res/layout/message_card.xml b/android/app/src/main/res/layout/message_card.xml index a28b409..57b4767 100644 --- a/android/app/src/main/res/layout/message_card.xml +++ b/android/app/src/main/res/layout/message_card.xml @@ -89,8 +89,8 @@ app:layout_constraintRight_toLeftOf="@+id/ivPriority" app:layout_constraintLeft_toLeftOf="parent" android:layout_margin="4sp" - android:ellipsize="none" - android:maxLines="32" + android:ellipsize="end" + android:maxLines="6" android:scrollHorizontally="false" android:text="asdasd asdasd asdasd a" />