Example #1
0
 public void loadKeys(List<String> keys) {
   adapter.setData(keys);
   if (keys == null) {
     final File target =
         App.getFile(App.getInstance().getJsonFileCacheRootDir() + File.separator + "saerch_keys");
     Log.i("target.getAbsolutePath()", "target.getAbsolutePath()" + target.getAbsolutePath());
     try {
       String json = App.getFileContext(target);
       Log.e("test", json);
       org.json.JSONArray jsonArray = new JSONObject(json).getJSONArray("data");
       int lenght = jsonArray.length();
       keys = new ArrayList<String>();
       for (int i = 0; i < lenght; i++) {
         keys.add(jsonArray.getString(i));
       }
       adapter.setData(keys);
     } catch (Exception e) {
     }
   }
 }
Example #2
0
 protected void initViews(View fragmentView) {
   textView.setVisibility(View.GONE);
   if (getArguments() != null && getArguments().getInt(SearchActivity.TAG_NONE) > 1) {
     String text = getArguments().getString(SearchActivity.TAG_KEY);
     textView.setText(getString(R.string.search_none, text));
     textView.setVisibility(View.VISIBLE);
   }
   adapter = new SearchKeysAdapter();
   recyclerView.setAdapter(adapter);
   GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), COUNT_COLUMS);
   gridLayoutManager.setSpanSizeLookup(adapter.getSpanSizeLookup());
   recyclerView.setLayoutManager(gridLayoutManager);
   loadHistory();
 }
Example #3
0
 /** 加载搜索历史 */
 private void loadHistory() {
   String history = spu.getHistory();
   if (!TextUtils.isEmpty(history)) {
     adapter.setHistory(Arrays.asList(history.split(SearchActivity.SPLIT)));
   }
 }
Example #4
0
 public void onEventMainThread(HistoryClearEvent event) {
   adapter.setHistory(new ArrayList<String>());
 }