Exemplo n.º 1
0
 @Override
 public boolean onQueryTextSubmit(String newQuery) {
   newQuery = newQuery.trim();
   GameCache newCache =
       new GameCache(newQuery + " Search Result Cache"); // clear cache, new search
   RetrieveSearchResultsTask newTask =
       new RetrieveSearchResultsTask(this, list, newCache, newQuery);
   newTask.execute();
   searchItem.collapseActionView();
   return true;
 }
Exemplo n.º 2
0
  public void updateTask(RetrieveSearchResultsTask task) {
    searchResultsTask = task;
    GamePool.getInstance().setQuery(task.getQuery());
    query = GamePool.getInstance().getQuery();

    GamePool.getInstance().setSearchResultsCache(task.getCache());
    cache = GamePool.getInstance().getSearchCache();

    Log.i(TAG, "Updating data to reflect new search: " + query);
    Log.i(TAG, cache.toString());
  }
Exemplo n.º 3
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    if (mainView == null) {
      Log.i(TAG, "Inflating view...");
      mainView = inflater.inflate(R.layout.activity_search_results_list, container, false);
      list = (ListView) mainView.findViewById(R.id.game_list);

      // LoadMore button
      moreResultsButton = new Button(a);
      moreResultsButton.setText("Load More");
      moreResultsButton.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
              RetrieveAdditionalResultsTask task =
                  new RetrieveAdditionalResultsTask(a, cache, searchResultsTask);
              task.execute();
            }
          });

      // Adding Load More button to listview at bottom
      list.addFooterView(moreResultsButton);

      // Click event for single list row
      list.setOnItemClickListener(
          new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              Log.i(TAG, "onChildClick: position: " + position + " id: " + id);
              Game game = (Game) list.getAdapter().getItem(position);
              GameInfoFragment.setGame(game);
              Fragment gameFragment = new GameInfoFragment();
              FragmentTools.transitionToFragment(a, gameFragment, null);
            }
          });
      searchQuery = (TextView) mainView.findViewById(R.id.search_query);
      searchQuery.setVisibility(View.VISIBLE);

      if (savedInstanceState != null) {
        // restore previous state
        restoreInstanceState(savedInstanceState);
      }

      Log.i(TAG, "Current Query: " + query);

      if (query != null) {
        searchResultsTask = new RetrieveSearchResultsTask(this, list, cache, query);
        searchResultsTask.doPostExecute(TaskResult.TRUE); // set up everything
      }
    }

    return mainView;
  }
Exemplo n.º 4
0
 public GameListAdapter getAdapter() {
   if (searchResultsTask != null) {
     return searchResultsTask.getAdapter();
   }
   return null;
 }