예제 #1
0
  /**
   * Helper method to update a profile using it's identifier
   *
   * @param newProfile
   */
  @Deprecated
  public void updateProfileByIdentifier(@NonNull IProfile newProfile) {
    if (mAccountHeaderBuilder.mProfiles != null && newProfile.getIdentifier() >= 0) {
      int found = -1;
      for (int i = 0; i < mAccountHeaderBuilder.mProfiles.size(); i++) {
        if (mAccountHeaderBuilder.mProfiles.get(i) instanceof Identifyable) {
          if (mAccountHeaderBuilder.mProfiles.get(i).getIdentifier()
              == newProfile.getIdentifier()) {
            found = i;
            break;
          }
        }
      }

      if (found > -1) {
        mAccountHeaderBuilder.mProfiles.set(found, newProfile);
        mAccountHeaderBuilder.updateHeaderAndList();
      }
    }
  }
예제 #2
0
 /**
  * Selects a profile by its identifier
  *
  * @param identifier
  */
 public void setActiveProfile(int identifier, boolean fireOnProfileChanged) {
   if (mAccountHeaderBuilder.mProfiles != null) {
     for (IProfile profile : mAccountHeaderBuilder.mProfiles) {
       if (profile instanceof Identifyable) {
         if (profile.getIdentifier() == identifier) {
           setActiveProfile(profile, fireOnProfileChanged);
           return;
         }
       }
     }
   }
 }
예제 #3
0
 /**
  * Selects the given profile and sets it to the new active profile
  *
  * @param profile
  */
 public void setActiveProfile(IProfile profile, boolean fireOnProfileChanged) {
   final boolean isCurrentSelectedProfile = mAccountHeaderBuilder.switchProfiles(profile);
   // if the selectionList is shown we should also update the current selected profile in the list
   if (mAccountHeaderBuilder.mDrawer != null && isSelectionListShown()) {
     mAccountHeaderBuilder.mDrawer.setSelection(profile.getIdentifier(), false);
   }
   // fire the event if enabled and a listener is set
   if (fireOnProfileChanged && mAccountHeaderBuilder.mOnAccountHeaderListener != null) {
     mAccountHeaderBuilder.mOnAccountHeaderListener.onProfileChanged(
         null, profile, isCurrentSelectedProfile);
   }
 }