expand on click

This commit is contained in:
Mike Schwörer 2018-11-17 03:24:06 +01:00
parent f68d75c226
commit 90f4270b74
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 35 additions and 11 deletions

View File

@ -105,15 +105,8 @@ public class SCNApp extends Application implements LifecycleObserver
[ ] - test notification channels [ ] - test notification channels
[ ] - startup time [ ] - startup time
[ ] - periodically get non-ack (option - even when not in-app) [ ] - periodically get non-ack (option - even when not in-app)
[ ] - expand long content on click
[ ] - publish (+ HN post ?) [ ] - 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
*/ */

View File

@ -11,6 +11,12 @@ import com.blackforestbytes.simplecloudnotifier.R;
import com.blackforestbytes.simplecloudnotifier.model.CMessage; import com.blackforestbytes.simplecloudnotifier.model.CMessage;
import com.blackforestbytes.simplecloudnotifier.model.CMessageList; 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.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -21,6 +27,8 @@ public class MessageAdapter extends RecyclerView.Adapter
private final LinearLayoutManager manLayout; private final LinearLayoutManager manLayout;
private final RecyclerView viewRecycler; private final RecyclerView viewRecycler;
private WeakHashMap<MessagePresenter, Boolean> viewHolders = new WeakHashMap<>();
public MessageAdapter(View noElementsView, LinearLayoutManager layout, RecyclerView recycler) public MessageAdapter(View noElementsView, LinearLayoutManager layout, RecyclerView recycler)
{ {
vNoElements = noElementsView; vNoElements = noElementsView;
@ -45,6 +53,15 @@ public class MessageAdapter extends RecyclerView.Adapter
CMessage msg = CMessageList.inst().tryGetFromBack(position); CMessage msg = CMessageList.inst().tryGetFromBack(position);
MessagePresenter view = (MessagePresenter) holder; MessagePresenter view = (MessagePresenter) holder;
view.setMessage(msg); view.setMessage(msg);
viewHolders.put(view, true);
}
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder)
{
if (holder instanceof MessagePresenter) viewHolders.remove(holder);
} }
@Override @Override
@ -70,7 +87,6 @@ public class MessageAdapter extends RecyclerView.Adapter
manLayout.smoothScrollToPosition(viewRecycler, null, 0); manLayout.smoothScrollToPosition(viewRecycler, null, 0);
} }
public void removeItem(int position) public void removeItem(int position)
{ {
CMessageList.inst().remove(position); CMessageList.inst().remove(position);
@ -104,7 +120,13 @@ public class MessageAdapter extends RecyclerView.Adapter
ivPriority = itemView.findViewById(R.id.ivPriority); ivPriority = itemView.findViewById(R.id.ivPriority);
viewForeground = itemView.findViewById(R.id.layoutFront); viewForeground = itemView.findViewById(R.id.layoutFront);
viewBackground = itemView.findViewById(R.id.layoutBack); viewBackground = itemView.findViewById(R.id.layoutBack);
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
tvTimestamp.setOnClickListener(this);
tvTitle.setOnClickListener(this);
tvMessage.setOnClickListener(this);
ivPriority.setOnClickListener(this);
viewForeground.setOnClickListener(this);
} }
void setMessage(CMessage msg) void setMessage(CMessage msg)
@ -134,7 +156,16 @@ public class MessageAdapter extends RecyclerView.Adapter
@Override @Override
public void onClick(View v) 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);
} }
} }
} }

View File

@ -89,8 +89,8 @@
app:layout_constraintRight_toLeftOf="@+id/ivPriority" app:layout_constraintRight_toLeftOf="@+id/ivPriority"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
android:layout_margin="4sp" android:layout_margin="4sp"
android:ellipsize="none" android:ellipsize="end"
android:maxLines="32" android:maxLines="6"
android:scrollHorizontally="false" android:scrollHorizontally="false"
android:text="asdasd asdasd asdasd a" /> android:text="asdasd asdasd asdasd a" />