Small improvement

This commit is contained in:
M66B 2019-04-28 20:21:13 +02:00
parent 47ed25f135
commit 259be35c00
1 changed files with 5 additions and 4 deletions

View File

@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.List;
public class DrawerAdapter extends ArrayAdapter<DrawerItem> {
private boolean collapsed = false;
private boolean collapsed;
private List<DrawerItem> items = new ArrayList<>();
DrawerAdapter(@NonNull Context context, boolean collapsed) {
@ -26,7 +26,10 @@ public class DrawerAdapter extends ArrayAdapter<DrawerItem> {
@NonNull
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
DrawerItem item = getItem(position);
View row = LayoutInflater.from(getContext()).inflate(item.getLayout(), null);
View row = item.isCollapsible() && collapsed
? new View(getContext())
: LayoutInflater.from(getContext()).inflate(item.getLayout(), null);
ImageView iv = row.findViewById(R.id.ivItem);
TextView tv = row.findViewById(R.id.tvItem);
@ -48,8 +51,6 @@ public class DrawerAdapter extends ArrayAdapter<DrawerItem> {
if (expander != null)
expander.setImageLevel(collapsed ? 1 /* more */ : 0 /* less */);
row.setVisibility(item.isCollapsible() && collapsed ? View.GONE : View.VISIBLE);
return row;
}