mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-01 14:46:31 +02:00
Prevent crash
This commit is contained in:
@@ -8,9 +8,15 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class DrawerAdapter extends ArrayAdapter<DrawerItem> {
|
||||
private List<DrawerItem> items = new ArrayList<>();
|
||||
|
||||
DrawerAdapter(@NonNull Context context) {
|
||||
super(context, -1);
|
||||
}
|
||||
@@ -39,6 +45,25 @@ public class DrawerAdapter extends ArrayAdapter<DrawerItem> {
|
||||
return row;
|
||||
}
|
||||
|
||||
void set(List<DrawerItem> items) {
|
||||
this.items = items;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public DrawerItem getItem(int position) {
|
||||
if (position < items.size())
|
||||
return items.get(position);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user