예제 #1
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    if (getListAdapter() == mHistoryAdapter) {
      String selection = ((TextView) v.findViewById(android.R.id.text1)).getText().toString();
      mSearchText.setText(selection);
      mSearchText.setSelection(selection.length());
      mSearchText.requestFocus();
    } else if (getListAdapter() == mResultAdapter) {
      // add search text to the database (history)
      MediaDatabase db = MediaDatabase.getInstance(this);
      db.addSearchhistoryItem(mSearchText.getText().toString());

      // open media in the player
      Media item = (Media) getListAdapter().getItem(position - 1);
      if (item.getType() == Media.TYPE_VIDEO) {
        VideoPlayerActivity.start(this, item.getLocation());
      } else {
        ArrayList<String> arr = new ArrayList<String>();
        for (int i = 0; i < getListAdapter().getCount(); i++) {
          Media audioItem = (Media) getListAdapter().getItem(i);
          if (audioItem.getType() == Media.TYPE_AUDIO) arr.add(audioItem.getLocation());
        }
        AudioServiceController.getInstance().load(arr, arr.indexOf(item.getLocation()));
        AudioPlayerActivity.start(this);
      }
      super.onListItemClick(l, v, position, id);
    }
  };
예제 #2
0
  /** Handle onClick form menu buttons */
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    // Handle item selection
    switch (item.getItemId()) {
        // Sort by name
      case R.id.search_clear_history:
        MediaDatabase db = MediaDatabase.getInstance(this);
        db.clearSearchhistory();
        if (mHistoryAdapter == getListAdapter()) showSearchHistory();
    }
    return super.onOptionsItemSelected(item);
  }
예제 #3
0
  private void showSearchHistory() {

    // Add header to the history
    String headerText = getString(R.string.history);
    showListHeader(headerText);

    MediaDatabase db = MediaDatabase.getInstance(this);
    mHistoryAdapter.clear();
    ArrayList<String> history = db.getSearchhistory(20);
    for (String s : history) mHistoryAdapter.add(s);
    mHistoryAdapter.notifyDataSetChanged();
    setListAdapter(mHistoryAdapter);
  }
예제 #4
0
  @Override
  public void onResume() {
    super.onResume();
    if ((getActivity() instanceof MainActivity)) mMainActivity = (MainActivity) getActivity();
    mMediaLibrary.setBrowser(this);
    mMediaLibrary.addUpdateHandler(mHandler);
    final boolean refresh = mVideoAdapter.isEmpty();
    if (refresh) updateList();
    else {
      mViewNomedia.setVisibility(View.GONE);
      focusHelper(false);
    }
    // Get & set times
    HashMap<String, Long> times = MediaDatabase.getInstance().getVideoTimes();
    mVideoAdapter.setTimes(times);
    mGridView.setSelection(mGVFirstVisiblePos);
    updateViewMode();
    if (mGroup == null && refresh) mAnimator.animate();

    /* Start the thumbnailer */
    if (mThumbnailer != null) mThumbnailer.start(this);
  }