コード例 #1
0
 private void saveListViewVisiblePosition(byte fileType) {
   int firstVisiblePosition = list.getFirstVisiblePosition();
   ConfigurationManager.instance()
       .setInt(
           Constants.BROWSE_PEER_FRAGMENT_LISTVIEW_FIRST_VISIBLE_POSITION + fileType,
           firstVisiblePosition);
 }
コード例 #2
0
 private void restoreListViewScrollPosition() {
   if (adapter != null) {
     int savedListViewVisiblePosition = getSavedListViewVisiblePosition(adapter.getFileType());
     savedListViewVisiblePosition =
         (savedListViewVisiblePosition > 0) ? savedListViewVisiblePosition + 1 : 0;
     list.setSelection(savedListViewVisiblePosition);
   }
 }
コード例 #3
0
  @Override
  protected void initComponents(View v) {
    filesBar = findView(v, R.id.fragment_browse_peer_files_bar);
    filesBar.setOnActionListener(
        new OnActionListener() {
          public void onCheckAll(View v, boolean isChecked) {
            if (adapter != null) {
              if (isChecked) {
                adapter.checkAll();
              } else {
                adapter.clearChecked();
              }
            }
          }

          public void onFilter(View v, String str) {
            if (adapter != null) {
              adapter.getFilter().filter(str);
            }
          }

          @Override
          public void onClear() {
            clearPreviousFilter();
          }
        });

    list = findView(v, R.id.fragment_browse_peer_list);
    list.setOverScrollListener(
        new OverScrollListener() {
          @Override
          public void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
            long now = SystemClock.elapsedRealtime();
            if (scrollY < 0 && clampedY && (now - lastAdapterRefresh) > 5000) {
              refreshSelection();
            }
          }
        });

    initRadioButton(v, R.id.fragment_browse_peer_radio_torrents, Constants.FILE_TYPE_TORRENTS);
    initRadioButton(v, R.id.fragment_browse_peer_radio_documents, Constants.FILE_TYPE_DOCUMENTS);
    initRadioButton(v, R.id.fragment_browse_peer_radio_pictures, Constants.FILE_TYPE_PICTURES);
    initRadioButton(v, R.id.fragment_browse_peer_radio_videos, Constants.FILE_TYPE_VIDEOS);
    initRadioButton(v, R.id.fragment_browse_peer_radio_ringtones, Constants.FILE_TYPE_RINGTONES);
    initRadioButton(v, R.id.fragment_browse_peer_radio_audio, Constants.FILE_TYPE_AUDIO);
  }
コード例 #4
0
  private void updateFiles(Object[] data) {
    if (data == null) {
      LOG.warn("Something wrong, data is null");
      return;
    }

    try {
      byte fileType = (Byte) data[0];

      @SuppressWarnings("unchecked")
      List<FileDescriptor> items = (List<FileDescriptor>) data[1];
      adapter =
          new FileListAdapter(getActivity(), items, fileType) {

            @Override
            protected void onItemChecked(View v, boolean isChecked) {
              if (!isChecked) {
                filesBar.clearCheckAll();
              }
            }

            @Override
            protected void onLocalPlay() {
              if (adapter != null) {
                saveListViewVisiblePosition(adapter.getFileType());
              }
            }
          };
      adapter.setCheckboxesVisibility(true);
      restorePreviouslyChecked();
      restorePreviousFilter();
      list.setAdapter(adapter);

    } catch (Throwable e) {
      LOG.error("Error updating files in list", e);
    }
  }