Search in sources :

Example 1 with AccountPainter

use of com.xabber.android.ui.color.AccountPainter in project xabber-android by redsolution.

the class ChatScrollIndicatorAdapter method update.

public void update(ArrayList<AbstractChat> activeChats) {
    final LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    final int size = activeChats.size() + 1;
    linearLayout.removeAllViews();
    for (int i = 0; i < size; i++) {
        View view;
        if (i == 0) {
            view = inflater.inflate(R.layout.chat_scroll_indicator_item_square, linearLayout, false);
        } else {
            view = inflater.inflate(R.layout.chat_scroll_indicator_item_circle, linearLayout, false);
        }
        linearLayout.addView(view);
        final AccountViewHolder accountViewHolder = new AccountViewHolder(view);
        final AccountPainter accountPainter = ColorManager.getInstance().getAccountPainter();
        if (i > 0) {
            final String account = activeChats.get(i - 1).getAccount();
            ((GradientDrawable) accountViewHolder.body.getDrawable()).setColor(accountPainter.getAccountMainColor(account));
            ((GradientDrawable) accountViewHolder.selection.getDrawable()).setColor(accountPainter.getAccountMainColor(account));
        } else {
            accountViewHolder.body.setImageDrawable(new ColorDrawable(accountPainter.getDefaultMainColor()));
            accountViewHolder.selection.setImageDrawable(new ColorDrawable(accountPainter.getDefaultMainColor()));
        }
        view.setTag(accountViewHolder);
    }
}
Also used : AccountPainter(com.xabber.android.ui.color.AccountPainter) ColorDrawable(android.graphics.drawable.ColorDrawable) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) View(android.view.View) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 2 with AccountPainter

use of com.xabber.android.ui.color.AccountPainter in project xabber-android by redsolution.

the class AccountActionButtonsAdapter method onChange.

@Override
public void onChange() {
    for (int index = 0; index < accounts.size(); index++) {
        View view = linearLayout.getChildAt(index);
        final CircleImageView circleImageView = (CircleImageView) view.findViewById(R.id.account_avatar);
        final String account = accounts.get(index);
        circleImageView.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
        FloatingActionButton backgroundActionButton = (FloatingActionButton) view.findViewById(R.id.fab);
        final AccountPainter accountPainter = ColorManager.getInstance().getAccountPainter();
        backgroundActionButton.setColorNormal(accountPainter.getAccountMainColor(account));
        backgroundActionButton.setColorPressed(accountPainter.getAccountDarkColor(account));
        backgroundActionButton.setColorRipple(accountPainter.getAccountRippleColor(account));
        String selectedAccount = AccountManager.getInstance().getSelectedAccount();
        int shadowVisibility;
        if (selectedAccount == null) {
            shadowVisibility = View.GONE;
        } else {
            shadowVisibility = View.VISIBLE;
            if (selectedAccount.equalsIgnoreCase(account)) {
                shadowVisibility = View.GONE;
            }
        }
        view.findViewById(R.id.account_unselected_shadow).setVisibility(shadowVisibility);
        StatusMode statusMode = AccountManager.getInstance().getAccount(account).getDisplayStatusMode();
        int offlineShadowVisibility;
        if (statusMode == StatusMode.connection || statusMode == StatusMode.unavailable) {
            offlineShadowVisibility = View.VISIBLE;
        } else {
            offlineShadowVisibility = View.GONE;
        }
        view.findViewById(R.id.account_offline_shadow).setVisibility(offlineShadowVisibility);
    }
}
Also used : CircleImageView(de.hdodenhof.circleimageview.CircleImageView) AccountPainter(com.xabber.android.ui.color.AccountPainter) StatusMode(com.xabber.android.data.account.StatusMode) FloatingActionButton(com.melnykov.fab.FloatingActionButton) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View)

Aggregations

View (android.view.View)2 AccountPainter (com.xabber.android.ui.color.AccountPainter)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 LayoutInflater (android.view.LayoutInflater)1 ImageView (android.widget.ImageView)1 FloatingActionButton (com.melnykov.fab.FloatingActionButton)1 StatusMode (com.xabber.android.data.account.StatusMode)1 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)1