Search in sources :

Example 1 with TextColorCell

use of org.telegram.ui.Cells.TextColorCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class NotificationsCustomSettingsActivity method checkRowsEnabled.

private void checkRowsEnabled() {
    if (!exceptions.isEmpty()) {
        return;
    }
    int count = listView.getChildCount();
    ArrayList<Animator> animators = new ArrayList<>();
    boolean enabled = getNotificationsController().isGlobalNotificationsEnabled(currentType);
    for (int a = 0; a < count; a++) {
        View child = listView.getChildAt(a);
        RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.getChildViewHolder(child);
        switch(holder.getItemViewType()) {
            case 0:
                {
                    HeaderCell headerCell = (HeaderCell) holder.itemView;
                    if (holder.getAdapterPosition() == messageSectionRow) {
                        headerCell.setEnabled(enabled, animators);
                    }
                    break;
                }
            case 1:
                {
                    TextCheckCell textCell = (TextCheckCell) holder.itemView;
                    textCell.setEnabled(enabled, animators);
                    break;
                }
            case 3:
                {
                    TextColorCell textCell = (TextColorCell) holder.itemView;
                    textCell.setEnabled(enabled, animators);
                    break;
                }
            case 5:
                {
                    TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
                    textCell.setEnabled(enabled, animators);
                    break;
                }
        }
    }
    if (!animators.isEmpty()) {
        if (animatorSet != null) {
            animatorSet.cancel();
        }
        animatorSet = new AnimatorSet();
        animatorSet.playTogether(animators);
        animatorSet.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animator) {
                if (animator.equals(animatorSet)) {
                    animatorSet = null;
                }
            }
        });
        animatorSet.setDuration(150);
        animatorSet.start();
    }
}
Also used : TextCheckCell(org.telegram.ui.Cells.TextCheckCell) HeaderCell(org.telegram.ui.Cells.HeaderCell) ArrayList(java.util.ArrayList) AnimatorSet(android.animation.AnimatorSet) RecyclerListView(org.telegram.ui.Components.RecyclerListView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) EmptyTextProgressView(org.telegram.ui.Components.EmptyTextProgressView) TextView(android.widget.TextView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) Animator(android.animation.Animator) TextColorCell(org.telegram.ui.Cells.TextColorCell) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 2 with TextColorCell

use of org.telegram.ui.Cells.TextColorCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class ProfileNotificationsActivity method checkRowsEnabled.

private void checkRowsEnabled() {
    int count = listView.getChildCount();
    ArrayList<Animator> animators = new ArrayList<>();
    for (int a = 0; a < count; a++) {
        View child = listView.getChildAt(a);
        RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.getChildViewHolder(child);
        int type = holder.getItemViewType();
        int position = holder.getAdapterPosition();
        if (position != customRow && position != enableRow && type != 0) {
            switch(type) {
                case 1:
                    {
                        TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
                        textCell.setEnabled(customEnabled && notificationsEnabled, animators);
                        break;
                    }
                case 2:
                    {
                        TextInfoPrivacyCell textCell = (TextInfoPrivacyCell) holder.itemView;
                        textCell.setEnabled(customEnabled && notificationsEnabled, animators);
                        break;
                    }
                case 3:
                    {
                        TextColorCell textCell = (TextColorCell) holder.itemView;
                        textCell.setEnabled(customEnabled && notificationsEnabled, animators);
                        break;
                    }
                case 4:
                    {
                        RadioCell radioCell = (RadioCell) holder.itemView;
                        radioCell.setEnabled(customEnabled && notificationsEnabled, animators);
                        break;
                    }
                case 8:
                    {
                        if (position == previewRow) {
                            TextCheckCell checkCell = (TextCheckCell) holder.itemView;
                            checkCell.setEnabled(customEnabled && notificationsEnabled, animators);
                        }
                        break;
                    }
            }
        }
    }
    if (!animators.isEmpty()) {
        if (animatorSet != null) {
            animatorSet.cancel();
        }
        animatorSet = new AnimatorSet();
        animatorSet.playTogether(animators);
        animatorSet.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animator) {
                if (animator.equals(animatorSet)) {
                    animatorSet = null;
                }
            }
        });
        animatorSet.setDuration(150);
        animatorSet.start();
    }
}
Also used : TextCheckCell(org.telegram.ui.Cells.TextCheckCell) ArrayList(java.util.ArrayList) RadioCell(org.telegram.ui.Cells.RadioCell) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) AnimatorSet(android.animation.AnimatorSet) RecyclerListView(org.telegram.ui.Components.RecyclerListView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) Animator(android.animation.Animator) TextColorCell(org.telegram.ui.Cells.TextColorCell) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Aggregations

Animator (android.animation.Animator)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 AnimatorSet (android.animation.AnimatorSet)2 View (android.view.View)2 TextView (android.widget.TextView)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 ArrayList (java.util.ArrayList)2 TextCheckCell (org.telegram.ui.Cells.TextCheckCell)2 TextColorCell (org.telegram.ui.Cells.TextColorCell)2 TextSettingsCell (org.telegram.ui.Cells.TextSettingsCell)2 RecyclerListView (org.telegram.ui.Components.RecyclerListView)2 HeaderCell (org.telegram.ui.Cells.HeaderCell)1 RadioCell (org.telegram.ui.Cells.RadioCell)1 TextInfoPrivacyCell (org.telegram.ui.Cells.TextInfoPrivacyCell)1 EmptyTextProgressView (org.telegram.ui.Components.EmptyTextProgressView)1