Use item decorator

pull/153/head
M66B 6 years ago
parent 08d5e13ab7
commit 2061d38125

@ -49,11 +49,13 @@ import java.util.Locale;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.Group;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.ListUpdateCallback;
import androidx.recyclerview.widget.RecyclerView;
@ -96,6 +98,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private TextView tvError;
private View vwRipple;
private RecyclerView rvChilds;
private Group grpChilds;
private AdapterFolder childs;
private TwoStateOwner cowner = new TwoStateOwner(owner, "AdapterFolder");
@ -126,12 +129,17 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
tvKeywords = itemView.findViewById(R.id.tvKeywords);
tvError = itemView.findViewById(R.id.tvError);
vwRipple = itemView.findViewById(R.id.vwRipple);
grpChilds = itemView.findViewById(R.id.grpChilds);
rvChilds = itemView.findViewById(R.id.rvChilds);
LinearLayoutManager llm = new LinearLayoutManager(context);
rvChilds.setLayoutManager(llm);
rvChilds.setNestedScrollingEnabled(false);
DividerItemDecoration itemDecorator = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
itemDecorator.setDrawable(context.getDrawable(R.drawable.divider));
rvChilds.addItemDecoration(itemDecorator);
childs = new AdapterFolder(context, owner, properties);
rvChilds.setAdapter(childs);
}
@ -259,12 +267,12 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
cowner.restart();
if (account > 0 && folder.childs > 0) {
if (folder.collapsed) {
rvChilds.setVisibility(View.GONE);
grpChilds.setVisibility(View.GONE);
childs.set(account, folder, level + 1, new ArrayList<TupleFolderEx>());
} else {
DB db = DB.getInstance(context);
cowner.start();
rvChilds.setVisibility(View.VISIBLE);
grpChilds.setVisibility(View.VISIBLE);
childs.set(folder.account, folder, level + 1, properties.getChilds(folder.id));
db.folder().liveFolders(folder.account, folder.id).observe(cowner, new Observer<List<TupleFolderEx>>() {
@Override
@ -277,7 +285,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
});
}
} else {
rvChilds.setVisibility(View.GONE);
grpChilds.setVisibility(View.GONE);
childs.set(account, null, 0, new ArrayList<TupleFolderEx>());
}
}

@ -372,7 +372,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
for (int i = 0; i < group.getChildCount(); i++) {
View child = group.getChildAt(i);
int id = child.getId();
if (id != R.id.tvDay && id != R.id.vSeparatorDay && id != R.id.vSeparator)
if (id != R.id.tvDay && id != R.id.vSeparatorDay)
child.setTranslationX(dx);
}
}

@ -44,6 +44,7 @@ import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -87,6 +88,10 @@ public class FragmentAccounts extends FragmentBase {
LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvAccount.setLayoutManager(llm);
DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
rvAccount.addItemDecoration(itemDecorator);
adapter = new AdapterAccount(getContext(), settings);
rvAccount.setAdapter(adapter);

@ -34,6 +34,7 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -65,6 +66,10 @@ public class FragmentAnswers extends FragmentBase {
LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvAnswer.setLayoutManager(llm);
DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
rvAnswer.addItemDecoration(itemDecorator);
adapter = new AdapterAnswer(getContext(), getViewLifecycleOwner());
rvAnswer.setAdapter(adapter);

@ -49,6 +49,7 @@ import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
@ -132,6 +133,10 @@ public class FragmentFolders extends FragmentBase {
LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvFolder.setLayoutManager(llm);
DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
rvFolder.addItemDecoration(itemDecorator);
adapter = new AdapterFolder(getContext(), getViewLifecycleOwner(), new AdapterFolder.IProperties() {
@Override
public void setChilds(long parent, List<TupleFolderEx> childs) {

@ -36,6 +36,7 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -67,6 +68,10 @@ public class FragmentIdentities extends FragmentBase {
LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvIdentity.setLayoutManager(llm);
DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
rvIdentity.addItemDecoration(itemDecorator);
adapter = new AdapterIdentity(getContext());
rvIdentity.setAdapter(adapter);

@ -90,6 +90,7 @@ import androidx.preference.PreferenceManager;
import androidx.recyclerview.selection.Selection;
import androidx.recyclerview.selection.SelectionTracker;
import androidx.recyclerview.selection.StorageStrategy;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -309,6 +310,10 @@ public class FragmentMessages extends FragmentBase {
LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvMessage.setLayoutManager(llm);
DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
rvMessage.addItemDecoration(itemDecorator);
boolean compact = prefs.getBoolean("compact", false);
int zoom = prefs.getInt("zoom", compact ? 0 : 1);
String sort = prefs.getString("sort", "time");

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?attr/colorSeparator" />
<size android:height="1dp" />
</shape>

@ -175,14 +175,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvError" />
<View
android:id="@+id/vSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/marginBottom" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpSettings"
android:layout_width="0dp"

@ -2,7 +2,8 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:padding="6dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clItem"
@ -15,9 +16,6 @@
android:id="@+id/tvName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:ellipsize="end"
android:maxLines="1"
android:text="Name"
@ -25,15 +23,5 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/vSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvName" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

@ -15,7 +15,7 @@
android:layout_width="6dp"
android:layout_height="0dp"
android:background="@color/colorAccent"
app:layout_constraintBottom_toTopOf="@+id/vSeparator"
app:layout_constraintBottom_toBottomOf="@+id/paddingBottom"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -46,7 +46,7 @@
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:src="@drawable/baseline_expand_less_24"
app:layout_constraintBottom_toTopOf="@+id/vSeparator"
app:layout_constraintBottom_toBottomOf="@+id/paddingBottom"
app:layout_constraintStart_toEndOf="@+id/vwLevel"
app:layout_constraintTop_toTopOf="parent" />
@ -173,11 +173,10 @@
app:layout_constraintTop_toBottomOf="@id/tvKeywords" />
<View
android:id="@+id/vSeparator"
android:id="@+id/paddingBottom"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="6dp"
android:background="?attr/colorSeparator"
android:layout_height="6dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvError" />
@ -186,17 +185,31 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:background="?android:attr/selectableItemBackground"
app:layout_constraintBottom_toTopOf="@id/vSeparator"
app:layout_constraintBottom_toBottomOf="@id/paddingBottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/vSeparatorChilds"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/paddingBottom" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvChilds"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparator" />
app:layout_constraintTop_toBottomOf="@id/vSeparatorChilds" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpChilds"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="vSeparatorChilds,rvChilds" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

@ -149,13 +149,5 @@
android:layout_height="3dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvError" />
<View
android:id="@+id/vSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/marginBottom" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

@ -581,14 +581,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vwBody" />
<View
android:id="@+id/vSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rvImage" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpDay"
android:layout_width="0dp"

@ -573,14 +573,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vwBody" />
<View
android:id="@+id/vSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rvImage" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpDay"
android:layout_width="0dp"

Loading…
Cancel
Save