搜索hint为多个时随机一个显示
This commit is contained in:
@ -86,6 +86,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@ -645,14 +646,18 @@ public class MainActivity extends BaseFragmentActivity implements
|
||||
@Override
|
||||
public void onResponse(JSONArray response) {
|
||||
if (!isDestroy) {
|
||||
Type listType = new TypeToken<ArrayList<String>>() {
|
||||
}.getType();
|
||||
Type listType = new TypeToken<ArrayList<String>>() {}.getType();
|
||||
Gson gson = new Gson();
|
||||
List<String> searchHintList = gson.fromJson(
|
||||
response.toString(), listType);
|
||||
if (searchHintList != null
|
||||
&& !searchHintList.isEmpty()) {
|
||||
searchHint = searchHintList.get(0);
|
||||
if (searchHintList != null && !searchHintList.isEmpty()) {
|
||||
if (searchHintList.size() == 1) {
|
||||
searchHint = searchHintList.get(0);
|
||||
} else {
|
||||
Random random = new Random(System.currentTimeMillis());
|
||||
int index = random.nextInt(searchHintList.size());
|
||||
searchHint = searchHintList.get(index);
|
||||
}
|
||||
EventBus.getDefault().post(
|
||||
new EBTopState("搜索", searchHintList
|
||||
.get(0)));
|
||||
|
||||
Reference in New Issue
Block a user