コード例 #1
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
  /**
   * Add a new profile at a specific position to the list
   *
   * @param profile
   * @param position
   */
  public void addProfile(@NonNull IProfile profile, int position) {
    if (mAccountHeaderBuilder.mProfiles == null) {
      mAccountHeaderBuilder.mProfiles = new ArrayList<>();
    }
    mAccountHeaderBuilder.mProfiles.add(position, IdDistributor.checkId(profile));

    mAccountHeaderBuilder.updateHeaderAndList();
  }
コード例 #2
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
  /** Clear the header */
  public void clear() {
    mAccountHeaderBuilder.mProfiles = null;

    // calculate the profiles to set
    mAccountHeaderBuilder.calculateProfiles();

    // process and build the profiles
    mAccountHeaderBuilder.buildProfiles();
  }
コード例 #3
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
  /**
   * Add new profiles to the existing list of profiles
   *
   * @param profiles
   */
  public void addProfiles(@NonNull IProfile... profiles) {
    if (mAccountHeaderBuilder.mProfiles == null) {
      mAccountHeaderBuilder.mProfiles = new ArrayList<>();
    }

    Collections.addAll(mAccountHeaderBuilder.mProfiles, IdDistributor.checkIds(profiles));

    mAccountHeaderBuilder.updateHeaderAndList();
  }
コード例 #4
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
 /**
  * add the values to the bundle for saveInstanceState
  *
  * @param savedInstanceState
  * @return
  */
 public Bundle saveInstanceState(Bundle savedInstanceState) {
   if (savedInstanceState != null) {
     savedInstanceState.putInt(
         BUNDLE_SELECTION_HEADER, mAccountHeaderBuilder.getCurrentSelection());
   }
   return savedInstanceState;
 }
コード例 #5
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
  /**
   * try to remove the given profile
   *
   * @param profile
   */
  public void removeProfile(@NonNull IProfile profile) {
    if (mAccountHeaderBuilder.mProfiles != null) {
      mAccountHeaderBuilder.mProfiles.remove(profile);
    }

    mAccountHeaderBuilder.updateHeaderAndList();
  }
コード例 #6
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
  /**
   * remove a profile from the given position
   *
   * @param position
   */
  public void removeProfile(int position) {
    if (mAccountHeaderBuilder.mProfiles != null
        && mAccountHeaderBuilder.mProfiles.size() > position) {
      mAccountHeaderBuilder.mProfiles.remove(position);
    }

    mAccountHeaderBuilder.updateHeaderAndList();
  }
コード例 #7
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
 /**
  * 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);
   }
 }
コード例 #8
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
  /**
   * 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();
      }
    }
  }
コード例 #9
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
 /**
  * Toggle the selection list (show or hide it)
  *
  * @param ctx
  */
 public void toggleSelectionList(Context ctx) {
   mAccountHeaderBuilder.toggleSelectionList(ctx);
 }
コード例 #10
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
 /**
  * Set the drawer for the AccountHeader so we can use it for the select
  *
  * @param drawer
  */
 public void setDrawer(Drawer drawer) {
   mAccountHeaderBuilder.mDrawer = drawer;
 }
コード例 #11
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
 /**
  * Set a new list of profiles for the header
  *
  * @param profiles
  */
 public void setProfiles(ArrayList<IProfile> profiles) {
   mAccountHeaderBuilder.mProfiles = IdDistributor.checkIds(profiles);
   mAccountHeaderBuilder.updateHeaderAndList();
 }
コード例 #12
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
 /**
  * set this to define the second line in the selection area if there is no profile note this will
  * block any values from profiles!
  *
  * @param selectionSecondLine
  */
 public void setSelectionSecondLine(String selectionSecondLine) {
   mAccountHeaderBuilder.mSelectionSecondLine = selectionSecondLine;
   mAccountHeaderBuilder.updateHeaderAndList();
 }
コード例 #13
0
ファイル: AccountHeader.java プロジェクト: ccc920123/Android
 /**
  * set this to false if you want to hide the second line of the selection box in the header
  * (second line would be the e-mail)
  *
  * @param selectionSecondLineShown
  */
 public void setSelectionSecondLineShown(boolean selectionSecondLineShown) {
   mAccountHeaderBuilder.mSelectionSecondLineShown = selectionSecondLineShown;
   mAccountHeaderBuilder.updateHeaderAndList();
 }