コード例 #1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.listview, container, false);
    mListView = (ListView) root.findViewById(android.R.id.list);

    // Align the track list with the header, in other words,OCD.
    TextView mHeader = (TextView) root.findViewById(R.id.title);
    int eight =
        (int) getActivity().getResources().getDimension(R.dimen.list_separator_padding_left_right);
    mHeader.setPadding(eight, 0, 0, 0);

    // Set the header while in @TracksBrowser
    String header = getActivity().getResources().getString(R.string.track_header);
    int left = getActivity().getResources().getInteger(R.integer.listview_padding_left);
    int right = getActivity().getResources().getInteger(R.integer.listview_padding_right);
    ApolloUtils.listHeader(this, root, header);
    ApolloUtils.setListPadding(this, mListView, left, 0, right, 0);

    // Hide the extra spacing from the Bottom ActionBar in the queue
    // Fragment in @AudioPlayerHolder
    if (getArguments() != null) {
      mPlaylistId = getArguments().getLong(BaseColumns._ID);
      String mimeType = getArguments().getString(MIME_TYPE);
      if (Audio.Playlists.CONTENT_TYPE.equals(mimeType)) {
        switch ((int) mPlaylistId) {
          case (int) PLAYLIST_QUEUE:
            LinearLayout emptyness = (LinearLayout) root.findViewById(R.id.empty_view);
            emptyness.setVisibility(View.GONE);
        }
      }
    }
    return root;
  }
 /** Cycle repeat states */
 private void cycleRepeat() {
   if (MusicUtils.mService == null) {
     return;
   }
   try {
     int mode = MusicUtils.mService.getRepeatMode();
     if (mode == ApolloService.REPEAT_NONE) {
       MusicUtils.mService.setRepeatMode(ApolloService.REPEAT_ALL);
       ApolloUtils.showToast(R.string.repeat_all, mToast, getActivity());
     } else if (mode == ApolloService.REPEAT_ALL) {
       MusicUtils.mService.setRepeatMode(ApolloService.REPEAT_CURRENT);
       if (MusicUtils.mService.getShuffleMode() != ApolloService.SHUFFLE_NONE) {
         MusicUtils.mService.setShuffleMode(ApolloService.SHUFFLE_NONE);
         setShuffleButtonImage();
       }
       ApolloUtils.showToast(R.string.repeat_one, mToast, getActivity());
     } else {
       MusicUtils.mService.setRepeatMode(ApolloService.REPEAT_NONE);
       ApolloUtils.showToast(R.string.repeat_off, mToast, getActivity());
     }
     setRepeatButtonImage();
   } catch (RemoteException ex) {
     ex.printStackTrace();
   }
 }
 /** Set the shuffle mode */
 private void toggleShuffle() {
   if (MusicUtils.mService == null) {
     return;
   }
   try {
     int shuffle = MusicUtils.mService.getShuffleMode();
     if (shuffle == ApolloService.SHUFFLE_NONE) {
       MusicUtils.mService.setShuffleMode(ApolloService.SHUFFLE_NORMAL);
       if (MusicUtils.mService.getRepeatMode() == ApolloService.REPEAT_CURRENT) {
         MusicUtils.mService.setRepeatMode(ApolloService.REPEAT_ALL);
         setRepeatButtonImage();
       }
       ApolloUtils.showToast(R.string.shuffle_on, mToast, getActivity());
     } else if (shuffle == ApolloService.SHUFFLE_NORMAL || shuffle == ApolloService.SHUFFLE_AUTO) {
       MusicUtils.mService.setShuffleMode(ApolloService.SHUFFLE_NONE);
       ApolloUtils.showToast(R.string.shuffle_off, mToast, getActivity());
     }
     setShuffleButtonImage();
   } catch (RemoteException ex) {
     ex.printStackTrace();
   }
 }
コード例 #4
0
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Landscape mode on phone isn't ready
    if (!ApolloUtils.isTablet(this))
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // Scan for music
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    // Layout
    setContentView(R.layout.library_browser);

    // Style the actionbar
    initActionBar();

    // Control Media volume
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // Important!
    initPager();
  }