Exemple #1
0
 public void updateDrawerHeader() {
   if (Util.isOffline(this)) {
     drawerServerName.setText(R.string.select_album_offline);
     drawerUserName.setText("");
     drawerUserAvatar.setVisibility(View.GONE);
     drawerHeader.setClickable(false);
     drawerHeaderToggle.setVisibility(View.GONE);
   } else {
     drawerServerName.setText(Util.getServerName(this));
     drawerUserName.setText(UserUtil.getCurrentUsername(this));
     drawerUserAvatar.setVisibility(View.VISIBLE);
     getImageLoader().loadAvatar(this, drawerUserAvatar, UserUtil.getCurrentUsername(this));
     drawerHeader.setClickable(true);
     drawerHeaderToggle.setVisibility(View.VISIBLE);
   }
 }
  @Override
  public void onCreateContextMenu(
      Menu menu,
      MenuInflater menuInflater,
      UpdateView<Serializable> updateView,
      Serializable item) {
    if (item instanceof PodcastChannel) {
      PodcastChannel channel = (PodcastChannel) item;
      if (!Util.isOffline(context) && UserUtil.canPodcast()) {
        menuInflater.inflate(R.menu.select_podcasts_context, menu);

        if (SyncUtil.isSyncedPodcast(context, channel.getId())) {
          menu.removeItem(R.id.podcast_menu_sync);
        } else {
          menu.removeItem(R.id.podcast_menu_stop_sync);
        }
      } else {
        menuInflater.inflate(R.menu.select_podcasts_context_offline, menu);
      }
    } else {
      onCreateContextMenuSupport(menu, menuInflater, updateView, item);
    }

    recreateContextMenu(menu);
  }
Exemple #3
0
 public void setActiveServer(int instance) {
   if (Util.getActiveServer(this) != instance) {
     final DownloadService service = getDownloadService();
     if (service != null) {
       new SilentBackgroundTask<Void>(this) {
         @Override
         protected Void doInBackground() throws Throwable {
           service.clearIncomplete();
           return null;
         }
       }.execute();
     }
     Util.setActiveServer(this, instance);
     invalidate();
     UserUtil.refreshCurrentUser(this, false, true);
     updateDrawerHeader();
   }
 }
Exemple #4
0
  public void toggleOffline() {
    boolean isOffline = Util.isOffline(this);
    Util.setOffline(this, !isOffline);
    invalidate();
    DownloadService service = getDownloadService();
    if (service != null) {
      service.setOnline(isOffline);
    }

    // Coming back online
    if (isOffline) {
      int scrobblesCount = Util.offlineScrobblesCount(this);
      int starsCount = Util.offlineStarsCount(this);
      if (scrobblesCount > 0 || starsCount > 0) {
        showOfflineSyncDialog(scrobblesCount, starsCount);
      }
    }

    UserUtil.seedCurrentUser(this);
    this.updateDrawerHeader();
  }
 @Override
 public int getOptionsMenu() {
   return (UserUtil.canPodcast() && !Util.isOffline(context))
       ? R.menu.select_podcasts
       : R.menu.abstract_top_menu;
 }