Пример #1
0
 @Override
 public boolean onPrepareOptionsMenu(Menu menu) {
   if (Dian1Application.getInstance().getPlayerEngineInterface() == null
       || Dian1Application.getInstance().getPlayerEngineInterface().getPlaylist() == null) {
     menu.findItem(R.id.player_menu_item).setVisible(false);
   } else {
     menu.findItem(R.id.player_menu_item).setVisible(true);
   }
   return super.onPrepareOptionsMenu(menu);
 }
Пример #2
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);

    mHomeListView = (ListView) findViewById(R.id.HomeListView);
    mGallery = (Gallery) findViewById(R.id.Gallery);
    mProgressBar = (ProgressBar) findViewById(R.id.ProgressBar);
    mFailureBar = (FailureBar) findViewById(R.id.FailureBar);
    mViewFlipper = (ViewFlipper) findViewById(R.id.ViewFlipper);

    mGestureOverlayView = (GestureOverlayView) findViewById(R.id.gestures);
    mGestureOverlayView.addOnGesturePerformedListener(
        Dian1Application.getInstance().getPlayerGestureHandler());

    new NewsTask().execute((Void) null);
  }
Пример #3
0
    @Override
    public Playlist doInBackground(Void... params) {
      JamendoGet2Api server = new JamendoGet2ApiImpl();
      int[] id = null;
      try {
        id = server.getTop100Listened();
        // if loading rss failed and no musics are there - report an error
        if (id == null) {
          publishProgress(new WSError((String) getResources().getText(R.string.top100_fail)));
          return null;
        }
        Album[] albums = server.getAlbumsByTracksId(id);
        Music[] musics =
            server.getTracksByTracksId(id, Dian1Application.getInstance().getStreamEncoding());
        if (albums == null || musics == null) return null;
        Hashtable<Integer, PlaylistEntry> hashtable = new Hashtable<Integer, PlaylistEntry>();
        for (int i = 0; i < musics.length; i++) {
          PlaylistEntry playlistEntry = new PlaylistEntry();
          playlistEntry.setAlbum(albums[i]);
          playlistEntry.setMusic(musics[i]);
          hashtable.put(musics[i].getId(), playlistEntry);
        }

        // creating playlist in the correct order
        Playlist playlist = new Playlist();
        for (int i = 0; i < id.length; i++) {
          playlist.addPlaylistEntry(hashtable.get(id[i]));
        }
        return playlist;
      } catch (JSONException e) {
        e.printStackTrace();
      } catch (WSError e) {
        publishProgress(e);
      }
      return null;
    }