Java Code Examples for org.telegram.ui.Cells.TextCell#setTextAndIcon()

The following examples show how to use org.telegram.ui.Cells.TextCell#setTextAndIcon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContactsAdapter.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder)
{
    switch (holder.getItemViewType())
    {
        case 0:
            UserCell userCell = (UserCell) holder.itemView;
            HashMap<String, ArrayList<TLRPC.TL_contact>> usersSectionsDict = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).usersMutualSectionsDict : ContactsController.getInstance(currentAccount).usersSectionsDict;
            ArrayList<String> sortedUsersSectionsArray = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).sortedUsersMutualSectionsArray : ContactsController.getInstance(currentAccount).sortedUsersSectionsArray;

            ArrayList<TLRPC.TL_contact> arr = usersSectionsDict.get(sortedUsersSectionsArray.get(section - (onlyUsers != 0 && !isAdmin ? 0 : 1)));
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(arr.get(position).user_id);
            userCell.setData(user, null, null, 0);
            if (checkedMap != null)
            {
                userCell.setChecked(checkedMap.indexOfKey(user.id) >= 0, !scrolling);
            }
            if (ignoreUsers != null)
            {
                if (ignoreUsers.indexOfKey(user.id) >= 0)
                {
                    userCell.setAlpha(0.5f);
                }
                else
                {
                    userCell.setAlpha(1.0f);
                }
            }
            break;
        case 1:
            TextCell textCell = (TextCell) holder.itemView;
            if (section == 0)
            {
                if (needPhonebook)
                {
                    textCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite);
                }
                else if (isAdmin)
                {
                    textCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.menu_invite);
                }
                else
                {
                    if (position == 0)
                    {
                        textCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup);
                    }
                    else if (position == 1)
                    {
                        textCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret);
                    }
                    else if (position == 2)
                    {
                        textCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast);
                    }
                }
            }
            else
            {
                ContactsController.Contact contact = ContactsController.getInstance(currentAccount).phoneBookContacts.get(position);
                if (contact.first_name != null && contact.last_name != null)
                {
                    textCell.setText(contact.first_name + " " + contact.last_name);
                }
                else if (contact.first_name != null && contact.last_name == null)
                {
                    textCell.setText(contact.first_name);
                }
                else
                {
                    textCell.setText(contact.last_name);
                }
            }
            break;
    }
}
 
Example 2
Source File: ContactsAdapter.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder)
{
    switch (holder.getItemViewType())
    {
        case 0:
            UserCell userCell = (UserCell) holder.itemView;
            HashMap<String, ArrayList<TLRPC.TL_contact>> usersSectionsDict = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).usersMutualSectionsDict : ContactsController.getInstance(currentAccount).usersSectionsDict;
            ArrayList<String> sortedUsersSectionsArray = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).sortedUsersMutualSectionsArray : ContactsController.getInstance(currentAccount).sortedUsersSectionsArray;

            ArrayList<TLRPC.TL_contact> arr = usersSectionsDict.get(sortedUsersSectionsArray.get(section - (onlyUsers != 0 && !isAdmin ? 0 : 1)));
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(arr.get(position).user_id);
            userCell.setData(user, null, null, 0);
            if (checkedMap != null)
            {
                userCell.setChecked(checkedMap.indexOfKey(user.id) >= 0, !scrolling);
            }
            if (ignoreUsers != null)
            {
                if (ignoreUsers.indexOfKey(user.id) >= 0)
                {
                    userCell.setAlpha(0.5f);
                }
                else
                {
                    userCell.setAlpha(1.0f);
                }
            }
            break;
        case 1:
            TextCell textCell = (TextCell) holder.itemView;
            if (section == 0)
            {
                if (needPhonebook)
                {
                    textCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite);
                }
                else if (isAdmin)
                {
                    textCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.menu_invite);
                }
                else
                {
                    if (position == 0)
                    {
                        textCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup);
                    }
                    else if (position == 1)
                    {
                        textCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret);
                    }
                    else if (position == 2)
                    {
                        textCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast);
                    }
                }
            }
            else
            {
                ContactsController.Contact contact = ContactsController.getInstance(currentAccount).phoneBookContacts.get(position);
                if (contact.first_name != null && contact.last_name != null)
                {
                    textCell.setText(contact.first_name + " " + contact.last_name);
                }
                else if (contact.first_name != null && contact.last_name == null)
                {
                    textCell.setText(contact.first_name);
                }
                else
                {
                    textCell.setText(contact.last_name);
                }
            }
            break;
    }
}
 
Example 3
Source File: ContactsAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) {
    switch (holder.getItemViewType()) {
        case 0:
            UserCell userCell = (UserCell) holder.itemView;
            userCell.setAvatarPadding(sortType == 2 || disableSections ? 6 : 58);
            ArrayList<TLRPC.TL_contact> arr;
            if (sortType == 2) {
                arr = onlineContacts;
            } else {
                HashMap<String, ArrayList<TLRPC.TL_contact>> usersSectionsDict = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).usersMutualSectionsDict : ContactsController.getInstance(currentAccount).usersSectionsDict;
                ArrayList<String> sortedUsersSectionsArray = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).sortedUsersMutualSectionsArray : ContactsController.getInstance(currentAccount).sortedUsersSectionsArray;
                arr = usersSectionsDict.get(sortedUsersSectionsArray.get(section - (onlyUsers != 0 && !isAdmin ? 0 : 1)));
            }
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(arr.get(position).user_id);
            userCell.setData(user, null, null, 0);
            if (checkedMap != null) {
                userCell.setChecked(checkedMap.indexOfKey(user.id) >= 0, !scrolling);
            }
            if (ignoreUsers != null) {
                if (ignoreUsers.indexOfKey(user.id) >= 0) {
                    userCell.setAlpha(0.5f);
                } else {
                    userCell.setAlpha(1.0f);
                }
            }
            break;
        case 1:
            TextCell textCell = (TextCell) holder.itemView;
            if (section == 0) {
                if (needPhonebook) {
                    if (position == 0) {
                        textCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite, false);
                    } else if (position == 1) {
                        textCell.setTextAndIcon(LocaleController.getString("AddPeopleNearby", R.string.AddPeopleNearby), R.drawable.menu_location, false);
                    }
                } else if (isAdmin) {
                    if (isChannel) {
                        textCell.setTextAndIcon(LocaleController.getString("ChannelInviteViaLink", R.string.ChannelInviteViaLink), R.drawable.profile_link, false);
                    } else {
                        textCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.profile_link, false);
                    }
                } else {
                    if (position == 0) {
                        textCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_groups, false);
                    } else if (position == 1) {
                        textCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret, false);
                    } else if (position == 2) {
                        textCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast, false);
                    }
                }
            } else {
                ContactsController.Contact contact = ContactsController.getInstance(currentAccount).phoneBookContacts.get(position);
                if (contact.first_name != null && contact.last_name != null) {
                    textCell.setText(contact.first_name + " " + contact.last_name, false);
                } else if (contact.first_name != null && contact.last_name == null) {
                    textCell.setText(contact.first_name, false);
                } else {
                    textCell.setText(contact.last_name, false);
                }
            }
            break;
        case 2:
            GraySectionCell sectionCell = (GraySectionCell) holder.itemView;
            if (sortType == 0) {
                sectionCell.setText(LocaleController.getString("Contacts", R.string.Contacts));
            } else if (sortType == 1) {
                sectionCell.setText(LocaleController.getString("SortedByName", R.string.SortedByName));
            } else {
                sectionCell.setText(LocaleController.getString("SortedByLastSeen", R.string.SortedByLastSeen));
            }
            break;
    }
}
 
Example 4
Source File: WallpapersListActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0: {
            TextCell textCell = (TextCell) holder.itemView;
            if (position == uploadImageRow) {
                textCell.setTextAndIcon(LocaleController.getString("SelectFromGallery", R.string.SelectFromGallery), R.drawable.profile_photos, true);
            } else if (position == setColorRow) {
                textCell.setTextAndIcon(LocaleController.getString("SetColor", R.string.SetColor), R.drawable.menu_palette, false);
            } else if (position == resetRow) {
                textCell.setText(LocaleController.getString("ResetChatBackgrounds", R.string.ResetChatBackgrounds), false);
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            if (position == resetInfoRow) {
                cell.setText(LocaleController.getString("ResetChatBackgroundsInfo", R.string.ResetChatBackgroundsInfo));
            }
            break;
        }
        case 2: {
            WallpaperCell wallpaperCell = (WallpaperCell) holder.itemView;
            position = (position - wallPaperStartRow) * columnsCount;
            wallpaperCell.setParams(columnsCount, position == 0, position / columnsCount == totalWallpaperRows - 1);
            for (int a = 0; a < columnsCount; a++) {
                int p = position + a;
                Object object = p < wallPapers.size() ? wallPapers.get(p) : null;
                String slugFinal;
                long id;
                if (object instanceof TLRPC.TL_wallPaper) {
                    TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) object;
                    Theme.OverrideWallpaperInfo info = Theme.getActiveTheme().overrideWallpaper;
                    if (selectedBackgroundSlug.equals(wallPaper.slug) && wallPaper.settings != null &&
                            (selectedColor != wallPaper.settings.background_color ||
                            selectedGradientColor != wallPaper.settings.second_background_color ||
                            (selectedGradientColor != 0 && selectedGradientRotation != AndroidUtilities.getWallpaperRotation(wallPaper.settings.rotation, false)) &&
                            (wallPaper.settings.intensity - selectedIntensity) > 0.001f)) {
                        slugFinal = "";
                    } else {
                        slugFinal = selectedBackgroundSlug;
                    }
                    id = wallPaper.id;
                } else {
                    if (object instanceof ColorWallpaper) {
                        ColorWallpaper colorWallpaper = (ColorWallpaper) object;
                        if (colorWallpaper.color != selectedColor || colorWallpaper.gradientColor != selectedGradientColor) {
                            slugFinal = "";
                        } else {
                            slugFinal = selectedBackgroundSlug;
                        }
                    } else {
                        slugFinal = selectedBackgroundSlug;
                    }
                    id = 0;
                }
                wallpaperCell.setWallpaper(currentType, a, object, slugFinal, null, false);
                if (actionBar.isActionModeShowed()) {
                    wallpaperCell.setChecked(a, selectedWallPapers.indexOfKey(id) >= 0, !scrolling);
                } else {
                    wallpaperCell.setChecked(a, false, !scrolling);
                }
            }
            break;
        }
    }
}
 
Example 5
Source File: ContactsAdapter.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) {
    switch (holder.getItemViewType()) {
        case 0:
            UserCell userCell = (UserCell) holder.itemView;
            userCell.setAvatarPadding(sortType == 2 || disableSections ? 6 : 58);
            ArrayList<TLRPC.TL_contact> arr;
            if (sortType == 2) {
                arr = onlineContacts;
            } else {
                HashMap<String, ArrayList<TLRPC.TL_contact>> usersSectionsDict = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).usersMutualSectionsDict : ContactsController.getInstance(currentAccount).usersSectionsDict;
                ArrayList<String> sortedUsersSectionsArray = onlyUsers == 2 ? ContactsController.getInstance(currentAccount).sortedUsersMutualSectionsArray : ContactsController.getInstance(currentAccount).sortedUsersSectionsArray;
                arr = usersSectionsDict.get(sortedUsersSectionsArray.get(section - (onlyUsers != 0 && !isAdmin ? 0 : 1)));
            }
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(arr.get(position).user_id);
            userCell.setData(user, null, null, 0);
            if (checkedMap != null) {
                userCell.setChecked(checkedMap.indexOfKey(user.id) >= 0, !scrolling);
            }
            if (ignoreUsers != null) {
                if (ignoreUsers.indexOfKey(user.id) >= 0) {
                    userCell.setAlpha(0.5f);
                } else {
                    userCell.setAlpha(1.0f);
                }
            }
            break;
        case 1:
            TextCell textCell = (TextCell) holder.itemView;
            if (section == 0) {
                if (needPhonebook) {
                    if (position == 0) {
                        textCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite, false);
                    } else if (position == 1) {
                        textCell.setTextAndIcon(LocaleController.getString("AddPeopleNearby", R.string.AddPeopleNearby), R.drawable.menu_location, false);
                    }
                } else if (isAdmin) {
                    if (isChannel) {
                        textCell.setTextAndIcon(LocaleController.getString("ChannelInviteViaLink", R.string.ChannelInviteViaLink), R.drawable.profile_link, false);
                    } else {
                        textCell.setTextAndIcon(LocaleController.getString("InviteToGroupByLink", R.string.InviteToGroupByLink), R.drawable.profile_link, false);
                    }
                } else {
                    if (position == 0) {
                        textCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_groups, false);
                    } else if (position == 1) {
                        textCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret, false);
                    } else if (position == 2) {
                        textCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast, false);
                    }
                }
            } else {
                ContactsController.Contact contact = ContactsController.getInstance(currentAccount).phoneBookContacts.get(position);
                if (contact.first_name != null && contact.last_name != null) {
                    textCell.setText(contact.first_name + " " + contact.last_name, false);
                } else if (contact.first_name != null && contact.last_name == null) {
                    textCell.setText(contact.first_name, false);
                } else {
                    textCell.setText(contact.last_name, false);
                }
            }
            break;
        case 2:
            GraySectionCell sectionCell = (GraySectionCell) holder.itemView;
            if (sortType == 0) {
                sectionCell.setText(LocaleController.getString("Contacts", R.string.Contacts));
            } else if (sortType == 1) {
                sectionCell.setText(LocaleController.getString("SortedByName", R.string.SortedByName));
            } else {
                sectionCell.setText(LocaleController.getString("SortedByLastSeen", R.string.SortedByLastSeen));
            }
            break;
    }
}
 
Example 6
Source File: WallpapersListActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0: {
            TextCell textCell = (TextCell) holder.itemView;
            if (position == uploadImageRow) {
                textCell.setTextAndIcon(LocaleController.getString("SelectFromGallery", R.string.SelectFromGallery), R.drawable.profile_photos, true);
            } else if (position == setColorRow) {
                textCell.setTextAndIcon(LocaleController.getString("SetColor", R.string.SetColor), R.drawable.menu_palette, false);
            } else if (position == resetRow) {
                textCell.setText(LocaleController.getString("ResetChatBackgrounds", R.string.ResetChatBackgrounds), false);
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            if (position == resetInfoRow) {
                cell.setText(LocaleController.getString("ResetChatBackgroundsInfo", R.string.ResetChatBackgroundsInfo));
            }
            break;
        }
        case 2: {
            WallpaperCell wallpaperCell = (WallpaperCell) holder.itemView;
            position = (position - wallPaperStartRow) * columnsCount;
            wallpaperCell.setParams(columnsCount, position == 0, position / columnsCount == totalWallpaperRows - 1);
            for (int a = 0; a < columnsCount; a++) {
                int p = position + a;
                Object object = p < wallPapers.size() ? wallPapers.get(p) : null;
                String slugFinal;
                long id;
                if (object instanceof TLRPC.TL_wallPaper) {
                    TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) object;
                    Theme.OverrideWallpaperInfo info = Theme.getActiveTheme().overrideWallpaper;
                    if (selectedBackgroundSlug.equals(wallPaper.slug) && wallPaper.settings != null &&
                            (selectedColor != wallPaper.settings.background_color ||
                            selectedGradientColor != wallPaper.settings.second_background_color ||
                            (selectedGradientColor != 0 && selectedGradientRotation != AndroidUtilities.getWallpaperRotation(wallPaper.settings.rotation, false)) &&
                            (wallPaper.settings.intensity - selectedIntensity) > 0.001f)) {
                        slugFinal = "";
                    } else {
                        slugFinal = selectedBackgroundSlug;
                    }
                    id = wallPaper.id;
                } else {
                    if (object instanceof ColorWallpaper) {
                        ColorWallpaper colorWallpaper = (ColorWallpaper) object;
                        if (colorWallpaper.color != selectedColor || colorWallpaper.gradientColor != selectedGradientColor) {
                            slugFinal = "";
                        } else {
                            slugFinal = selectedBackgroundSlug;
                        }
                    } else {
                        slugFinal = selectedBackgroundSlug;
                    }
                    id = 0;
                }
                wallpaperCell.setWallpaper(currentType, a, object, slugFinal, null, false);
                if (actionBar.isActionModeShowed()) {
                    wallpaperCell.setChecked(a, selectedWallPapers.indexOfKey(id) >= 0, !scrolling);
                } else {
                    wallpaperCell.setChecked(a, false, !scrolling);
                }
            }
            break;
        }
    }
}