|
|
@ -4,6 +4,8 @@ import android.content.Context; |
|
|
|
import android.widget.ArrayAdapter; |
|
|
|
import android.widget.ArrayAdapter; |
|
|
|
|
|
|
|
|
|
|
|
import com.community.pocket.data.model.GarbageSorting; |
|
|
|
import com.community.pocket.data.model.GarbageSorting; |
|
|
|
|
|
|
|
import com.community.pocket.util.LocaleType; |
|
|
|
|
|
|
|
import com.community.pocket.util.SPUtil; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
@ -15,7 +17,6 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class GarbageSortingAdpter extends ArrayAdapter<String> { |
|
|
|
public class GarbageSortingAdpter extends ArrayAdapter<String> { |
|
|
|
|
|
|
|
|
|
|
|
private List<GarbageSorting> dataList; |
|
|
|
|
|
|
|
private List<String> list = new ArrayList<>(); |
|
|
|
private List<String> list = new ArrayList<>(); |
|
|
|
private Map<String, GarbageSorting> map = new HashMap<>(); |
|
|
|
private Map<String, GarbageSorting> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
@ -26,12 +27,21 @@ public class GarbageSortingAdpter extends ArrayAdapter<String> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void addAll(List<GarbageSorting> dataList) { |
|
|
|
public void addAll(List<GarbageSorting> dataList) { |
|
|
|
this.dataList = dataList; |
|
|
|
|
|
|
|
this.list.clear(); |
|
|
|
this.list.clear(); |
|
|
|
this.map.clear(); |
|
|
|
this.map.clear(); |
|
|
|
for (GarbageSorting garbageSorting : dataList) { |
|
|
|
for (GarbageSorting garbageSorting : dataList) { |
|
|
|
this.list.add(garbageSorting.getName()); |
|
|
|
String name; |
|
|
|
this.map.put(garbageSorting.getName(), garbageSorting); |
|
|
|
if (SPUtil.getInstance(getContext()).getSelectLanguage() == LocaleType.en.getType()) { |
|
|
|
|
|
|
|
name = garbageSorting.getEnglishName(); |
|
|
|
|
|
|
|
if (name == null) { |
|
|
|
|
|
|
|
name = garbageSorting.getName() + "(no english name)"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
name = garbageSorting.getName(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.map.put(name, garbageSorting); |
|
|
|
|
|
|
|
this.list.add(name); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
clear(); |
|
|
|
clear(); |
|
|
|
addAll(this.list); |
|
|
|
addAll(this.list); |
|
|
|