mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-16 08:05:34 -04:00
Feat[SimpleAdapter]: Allow resetting the content of the adapter
This commit is contained in:
parent
ff72d5a1c0
commit
ce5ed86515
@ -11,6 +11,7 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -18,12 +19,24 @@ import java.util.List;
|
||||
* @param <T>
|
||||
*/
|
||||
public class SimpleArrayAdapter<T> extends BaseAdapter {
|
||||
|
||||
private final List<T> mObjects;
|
||||
private List<T> mObjects;
|
||||
public SimpleArrayAdapter(List<T> objects) {
|
||||
mObjects = objects;
|
||||
setObjects(objects);
|
||||
}
|
||||
|
||||
public void setObjects(@Nullable List<T> objects) {
|
||||
if(objects == null){
|
||||
if(mObjects != Collections.emptyList()) {
|
||||
mObjects = Collections.emptyList();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
} else {
|
||||
if(objects != mObjects){
|
||||
mObjects = objects;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user