Java Code Examples for org.telegram.ui.Cells.HeaderCell#setText()

The following examples show how to use org.telegram.ui.Cells.HeaderCell#setText() . 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: ChatAttachAlertDocumentLayout.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (sortByName) {
                headerCell.setText(LocaleController.getString("RecentFilesAZ", R.string.RecentFilesAZ));
            } else {
                headerCell.setText(LocaleController.getString("RecentFiles", R.string.RecentFiles));
            }
            break;
        case 1:
            ListItem item = getItem(position);
            SharedDocumentCell documentCell = (SharedDocumentCell) holder.itemView;
            if (item.icon != 0) {
                documentCell.setTextAndValueAndTypeAndThumb(item.title, item.subtitle, null, null, item.icon, position != items.size() - 1);
            } else {
                String type = item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4));
                documentCell.setTextAndValueAndTypeAndThumb(item.title, item.subtitle, type, item.thumb, 0, false);
            }
            if (item.file != null) {
                documentCell.setChecked(selectedFiles.containsKey(item.file.toString()), !scrolling);
            } else {
                documentCell.setChecked(false, !scrolling);
            }
            break;
    }
}
 
Example 2
Source File: CacheControlActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == databaseRow) {
                textCell.setTextAndValue(LocaleController.getString("ClearLocalDatabase", R.string.ClearLocalDatabase), AndroidUtilities.formatFileSize(databaseSize), false);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == databaseInfoRow) {
                privacyCell.setText(LocaleController.getString("LocalDatabaseInfo", R.string.LocalDatabaseInfo));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == cacheInfoRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == keepMediaInfoRow) {
                privacyCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("KeepMediaInfo", R.string.KeepMediaInfo)));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            StroageUsageView stroageUsageView = (StroageUsageView) holder.itemView;
            stroageUsageView.setStorageUsage(calculating, databaseSize, totalSize, totalDeviceFreeSize, totalDeviceSize);
            break;
        case 3:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == keepMediaHeaderRow) {
                headerCell.setText(LocaleController.getString("KeepMedia", R.string.KeepMedia));
            } else if (position == deviseStorageHeaderRow) {
                headerCell.setText(LocaleController.getString("DeviceStorage", R.string.DeviceStorage));
            }
            break;
    }
}
 
Example 3
Source File: StatisticActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
    int type = getItemViewType(position);
    if (type >= 0 && type <= 4) {
        ChartViewData data;
        if (growCell == position) {
            data = growthData;
        } else if (folowersCell == position) {
            data = followersData;
        } else if (interactionsCell == position) {
            data = interactionsData;
        } else if (viewsBySourceCell == position) {
            data = viewsBySourceData;
        } else if (newFollowersBySourceCell == position) {
            data = newFollowersBySourceData;
        } else if (ivInteractionsCell == position) {
            data = ivInteractionsData;
        } else if (topHourseCell == position) {
            data = topHoursData;
        } else if (notificationsCell == position) {
            data = notificationsData;
        } else {
            data = languagesData;
        }
        ((ChartCell) holder.itemView).updateData(data, false);
    } else if (type == 9) {
        int i = position - recentPostsStartRow;
        ((StatisticPostInfoCell) holder.itemView).setData(recentPostsLoaded.get(i));
    } else if (type == 13) {
        HeaderCell headerCell = (HeaderCell) holder.itemView;
        if (position == overviewHeaderCell) {
            headerCell.setText(LocaleController.getString("StatisticOverview", R.string.StatisticOverview));
        } else {
            headerCell.setText(LocaleController.getString("RecentPosts", R.string.RecentPosts));
        }
    } else if (type == 14) {
        OverviewCell overviewCell = (OverviewCell) holder.itemView;
        overviewCell.setData(overviewData);
    }
}
 
Example 4
Source File: StatisticActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
    int type = getItemViewType(position);
    if (type >= 0 && type <= 4) {
        ChartViewData data;
        if (growCell == position) {
            data = growthData;
        } else if (folowersCell == position) {
            data = followersData;
        } else if (interactionsCell == position) {
            data = interactionsData;
        } else if (viewsBySourceCell == position) {
            data = viewsBySourceData;
        } else if (newFollowersBySourceCell == position) {
            data = newFollowersBySourceData;
        } else if (ivInteractionsCell == position) {
            data = ivInteractionsData;
        } else if (topHourseCell == position) {
            data = topHoursData;
        } else if (notificationsCell == position) {
            data = notificationsData;
        } else {
            data = languagesData;
        }
        ((ChartCell) holder.itemView).updateData(data, false);
    } else if (type == 9) {
        int i = position - recentPostsStartRow;
        ((StatisticPostInfoCell) holder.itemView).setData(recentPostsLoaded.get(i));
    } else if (type == 13) {
        HeaderCell headerCell = (HeaderCell) holder.itemView;
        if (position == overviewHeaderCell) {
            headerCell.setText(LocaleController.getString("StatisticOverview", R.string.StatisticOverview));
        } else {
            headerCell.setText(LocaleController.getString("RecentPosts", R.string.RecentPosts));
        }
    } else if (type == 14) {
        OverviewCell overviewCell = (OverviewCell) holder.itemView;
        overviewCell.setData(overviewData);
    }
}
 
Example 5
Source File: CacheControlActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == databaseRow) {
                textCell.setTextAndValue(LocaleController.getString("ClearLocalDatabase", R.string.ClearLocalDatabase), AndroidUtilities.formatFileSize(databaseSize), false);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == databaseInfoRow) {
                privacyCell.setText(LocaleController.getString("LocalDatabaseInfo", R.string.LocalDatabaseInfo));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == cacheInfoRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == keepMediaInfoRow) {
                privacyCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("KeepMediaInfo", R.string.KeepMediaInfo)));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            StroageUsageView stroageUsageView = (StroageUsageView) holder.itemView;
            stroageUsageView.setStorageUsage(calculating, databaseSize, totalSize, totalDeviceFreeSize, totalDeviceSize);
            break;
        case 3:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == keepMediaHeaderRow) {
                headerCell.setText(LocaleController.getString("KeepMedia", R.string.KeepMedia));
            } else if (position == deviseStorageHeaderRow) {
                headerCell.setText(LocaleController.getString("DeviceStorage", R.string.DeviceStorage));
            }
            break;
    }
}
 
Example 6
Source File: ChatAttachAlertDocumentLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (sortByName) {
                headerCell.setText(LocaleController.getString("RecentFilesAZ", R.string.RecentFilesAZ));
            } else {
                headerCell.setText(LocaleController.getString("RecentFiles", R.string.RecentFiles));
            }
            break;
        case 1:
            ListItem item = getItem(position);
            SharedDocumentCell documentCell = (SharedDocumentCell) holder.itemView;
            if (item.icon != 0) {
                documentCell.setTextAndValueAndTypeAndThumb(item.title, item.subtitle, null, null, item.icon, position != items.size() - 1);
            } else {
                String type = item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4));
                documentCell.setTextAndValueAndTypeAndThumb(item.title, item.subtitle, type, item.thumb, 0, false);
            }
            if (item.file != null) {
                documentCell.setChecked(selectedFiles.containsKey(item.file.toString()), !scrolling);
            } else {
                documentCell.setChecked(false, !scrolling);
            }
            break;
    }
}
 
Example 7
Source File: DataUsageActivity.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: {
            if (position == resetSection2Row) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        }
        case 1: {
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == resetRow) {
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText2);
                textCell.setText(LocaleController.getString("ResetStatistics", R.string.ResetStatistics), false);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
            } else {
                int type;
                textCell.setTag(Theme.key_windowBackgroundWhiteBlackText);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
                if (position == callsSentRow || position == callsReceivedRow || position == callsBytesSentRow || position == callsBytesReceivedRow) {
                    type = StatsController.TYPE_CALLS;
                } else if (position == messagesSentRow || position == messagesReceivedRow || position == messagesBytesSentRow || position == messagesBytesReceivedRow) {
                    type = StatsController.TYPE_MESSAGES;
                } else if (position == photosSentRow || position == photosReceivedRow || position == photosBytesSentRow || position == photosBytesReceivedRow) {
                    type = StatsController.TYPE_PHOTOS;
                } else if (position == audiosSentRow || position == audiosReceivedRow || position == audiosBytesSentRow || position == audiosBytesReceivedRow) {
                    type = StatsController.TYPE_AUDIOS;
                } else if (position == videosSentRow || position == videosReceivedRow || position == videosBytesSentRow || position == videosBytesReceivedRow) {
                    type = StatsController.TYPE_VIDEOS;
                } else if (position == filesSentRow || position == filesReceivedRow || position == filesBytesSentRow || position == filesBytesReceivedRow) {
                    type = StatsController.TYPE_FILES;
                } else {
                    type = StatsController.TYPE_TOTAL;
                }
                if (position == callsSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("OutgoingCalls", R.string.OutgoingCalls), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == callsReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("IncomingCalls", R.string.IncomingCalls), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == callsTotalTimeRow) {
                    String time = AndroidUtilities.formatShortDuration(StatsController.getInstance(currentAccount).getCallsTotalTime(currentType));
                    textCell.setTextAndValue(LocaleController.getString("CallsTotalTime", R.string.CallsTotalTime), time, false);
                } else if (position == messagesSentRow || position == photosSentRow || position == videosSentRow || position == audiosSentRow || position == filesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountSent", R.string.CountSent), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == messagesReceivedRow || position == photosReceivedRow || position == videosReceivedRow || position == audiosReceivedRow || position == filesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountReceived", R.string.CountReceived), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == messagesBytesSentRow || position == photosBytesSentRow || position == videosBytesSentRow || position == audiosBytesSentRow || position == filesBytesSentRow || position == callsBytesSentRow || position == totalBytesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesSent", R.string.BytesSent), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getSentBytesCount(currentType, type)), true);
                } else if (position == messagesBytesReceivedRow || position == photosBytesReceivedRow || position == videosBytesReceivedRow || position == audiosBytesReceivedRow || position == filesBytesReceivedRow || position == callsBytesReceivedRow || position == totalBytesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesReceived", R.string.BytesReceived), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getReceivedBytesCount(currentType, type)), position == callsBytesReceivedRow);
                }
            }
            break;
        }
        case 2: {
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == totalSectionRow) {
                headerCell.setText(LocaleController.getString("TotalDataUsage", R.string.TotalDataUsage));
            } else if (position == callsSectionRow) {
                headerCell.setText(LocaleController.getString("CallsDataUsage", R.string.CallsDataUsage));
            } else if (position == filesSectionRow) {
                headerCell.setText(LocaleController.getString("FilesDataUsage", R.string.FilesDataUsage));
            } else if (position == audiosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache));
            } else if (position == videosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache));
            } else if (position == photosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache));
            } else if (position == messagesSectionRow) {
                headerCell.setText(LocaleController.getString("MessagesDataUsage", R.string.MessagesDataUsage));
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            cell.setText(LocaleController.formatString("NetworkUsageSince", R.string.NetworkUsageSince, LocaleController.getInstance().formatterStats.format(StatsController.getInstance(currentAccount).getResetStatsDate(currentType))));
            break;
        }
        default:
            break;
    }
}
 
Example 8
Source File: SessionsActivity.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:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == terminateAllSessionsRow) {
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText2);
                if (currentType == 0) {
                    textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false);
                } else {
                    textCell.setText(LocaleController.getString("TerminateAllWebSessions", R.string.TerminateAllWebSessions), false);
                }
            } else if (position == qrCodeRow) {
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
                textCell.setTag(Theme.key_windowBackgroundWhiteBlueText4);
                textCell.setText(LocaleController.getString("AuthAnotherClient", R.string.AuthAnotherClient), !sessions.isEmpty());
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == terminateAllSessionsDetailRow) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("ClearOtherSessionsHelp", R.string.ClearOtherSessionsHelp));
                } else {
                    privacyCell.setText(LocaleController.getString("ClearOtherWebSessionsHelp", R.string.ClearOtherWebSessionsHelp));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == otherSessionsTerminateDetail) {
                if (currentType == 0) {
                    if (sessions.isEmpty()) {
                        privacyCell.setText("");
                    } else {
                        privacyCell.setText(LocaleController.getString("TerminateSessionInfo", R.string.TerminateSessionInfo));
                    }
                } else {
                    privacyCell.setText(LocaleController.getString("TerminateWebSessionInfo", R.string.TerminateWebSessionInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == passwordSessionsDetailRow) {
                privacyCell.setText(LocaleController.getString("LoginAttemptsInfo", R.string.LoginAttemptsInfo));
                if (otherSessionsTerminateDetail == -1) {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
                } else {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
                }
            }
            break;
        case 2:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == currentSessionSectionRow) {
                headerCell.setText(LocaleController.getString("CurrentSession", R.string.CurrentSession));
            } else if (position == otherSessionsSectionRow) {
                if (currentType == 0) {
                    headerCell.setText(LocaleController.getString("OtherSessions", R.string.OtherSessions));
                } else {
                    headerCell.setText(LocaleController.getString("OtherWebSessions", R.string.OtherWebSessions));
                }
            } else if (position == passwordSessionsSectionRow) {
                headerCell.setText(LocaleController.getString("LoginAttempts", R.string.LoginAttempts));
            }
            break;
        case 3:
            ViewGroup.LayoutParams layoutParams = emptyLayout.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.height = Math.max(AndroidUtilities.dp(220), AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(128 + (qrCodeRow == -1 ? 0 : 30)) - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0));
                emptyLayout.setLayoutParams(layoutParams);
            }
            break;
        default:
            SessionCell sessionCell = (SessionCell) holder.itemView;
            if (position == currentSessionRow) {
                sessionCell.setSession(currentSession, !sessions.isEmpty() || !passwordSessions.isEmpty() || qrCodeRow != -1);
            } else if (position >= otherSessionsStartRow && position < otherSessionsEndRow) {
                sessionCell.setSession(sessions.get(position - otherSessionsStartRow), position != otherSessionsEndRow - 1);
            } else if (position >= passwordSessionsStartRow && position < passwordSessionsEndRow) {
                sessionCell.setSession(passwordSessions.get(position - passwordSessionsStartRow), position != passwordSessionsEndRow - 1);
            }
            break;
    }
}
 
Example 9
Source File: DataUsageActivity.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: {
            if (position == resetSection2Row) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        }
        case 1: {
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == resetRow) {
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText2);
                textCell.setText(LocaleController.getString("ResetStatistics", R.string.ResetStatistics), false);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
            } else {
                int type;
                textCell.setTag(Theme.key_windowBackgroundWhiteBlackText);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
                if (position == callsSentRow || position == callsReceivedRow || position == callsBytesSentRow || position == callsBytesReceivedRow) {
                    type = StatsController.TYPE_CALLS;
                } else if (position == messagesSentRow || position == messagesReceivedRow || position == messagesBytesSentRow || position == messagesBytesReceivedRow) {
                    type = StatsController.TYPE_MESSAGES;
                } else if (position == photosSentRow || position == photosReceivedRow || position == photosBytesSentRow || position == photosBytesReceivedRow) {
                    type = StatsController.TYPE_PHOTOS;
                } else if (position == audiosSentRow || position == audiosReceivedRow || position == audiosBytesSentRow || position == audiosBytesReceivedRow) {
                    type = StatsController.TYPE_AUDIOS;
                } else if (position == videosSentRow || position == videosReceivedRow || position == videosBytesSentRow || position == videosBytesReceivedRow) {
                    type = StatsController.TYPE_VIDEOS;
                } else if (position == filesSentRow || position == filesReceivedRow || position == filesBytesSentRow || position == filesBytesReceivedRow) {
                    type = StatsController.TYPE_FILES;
                } else {
                    type = StatsController.TYPE_TOTAL;
                }
                if (position == callsSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("OutgoingCalls", R.string.OutgoingCalls), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == callsReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("IncomingCalls", R.string.IncomingCalls), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == callsTotalTimeRow) {
                    String time = AndroidUtilities.formatShortDuration(StatsController.getInstance(currentAccount).getCallsTotalTime(currentType));
                    textCell.setTextAndValue(LocaleController.getString("CallsTotalTime", R.string.CallsTotalTime), time, false);
                } else if (position == messagesSentRow || position == photosSentRow || position == videosSentRow || position == audiosSentRow || position == filesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountSent", R.string.CountSent), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == messagesReceivedRow || position == photosReceivedRow || position == videosReceivedRow || position == audiosReceivedRow || position == filesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountReceived", R.string.CountReceived), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == messagesBytesSentRow || position == photosBytesSentRow || position == videosBytesSentRow || position == audiosBytesSentRow || position == filesBytesSentRow || position == callsBytesSentRow || position == totalBytesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesSent", R.string.BytesSent), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getSentBytesCount(currentType, type)), true);
                } else if (position == messagesBytesReceivedRow || position == photosBytesReceivedRow || position == videosBytesReceivedRow || position == audiosBytesReceivedRow || position == filesBytesReceivedRow || position == callsBytesReceivedRow || position == totalBytesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesReceived", R.string.BytesReceived), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getReceivedBytesCount(currentType, type)), position == callsBytesReceivedRow);
                }
            }
            break;
        }
        case 2: {
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == totalSectionRow) {
                headerCell.setText(LocaleController.getString("TotalDataUsage", R.string.TotalDataUsage));
            } else if (position == callsSectionRow) {
                headerCell.setText(LocaleController.getString("CallsDataUsage", R.string.CallsDataUsage));
            } else if (position == filesSectionRow) {
                headerCell.setText(LocaleController.getString("FilesDataUsage", R.string.FilesDataUsage));
            } else if (position == audiosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache));
            } else if (position == videosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache));
            } else if (position == photosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache));
            } else if (position == messagesSectionRow) {
                headerCell.setText(LocaleController.getString("MessagesDataUsage", R.string.MessagesDataUsage));
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            cell.setText(LocaleController.formatString("NetworkUsageSince", R.string.NetworkUsageSince, LocaleController.getInstance().formatterStats.format(StatsController.getInstance(currentAccount).getResetStatsDate(currentType))));
            break;
        }
        default:
            break;
    }
}
 
Example 10
Source File: PrivacyUsersActivity.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:
            ManageChatUserCell userCell = (ManageChatUserCell) holder.itemView;
            int uid;
            if (currentType == TYPE_BLOCKED) {
                uid = getMessagesController().blockedUsers.keyAt(position - usersStartRow);
            } else {
                uid = uidArray.get(position - usersStartRow);
            }
            userCell.setTag(uid);
            if (uid > 0) {
                TLRPC.User user = getMessagesController().getUser(uid);
                if (user != null) {
                    String number;
                    if (user.bot) {
                        number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1);
                    } else if (user.phone != null && user.phone.length() != 0) {
                        number = PhoneFormat.getInstance().format("+" + user.phone);
                    } else {
                        number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
                    }
                    userCell.setData(user, null, number, position != usersEndRow - 1);
                }
            } else {
                TLRPC.Chat chat = getMessagesController().getChat(-uid);
                if (chat != null) {
                    String subtitle;
                    if (chat.participants_count != 0) {
                        subtitle = LocaleController.formatPluralString("Members", chat.participants_count);
                    } else if (chat.has_geo) {
                        subtitle = LocaleController.getString("MegaLocation", R.string.MegaLocation);
                    } else if (TextUtils.isEmpty(chat.username)) {
                        subtitle = LocaleController.getString("MegaPrivate", R.string.MegaPrivate);
                    } else {
                        subtitle = LocaleController.getString("MegaPublic", R.string.MegaPublic);
                    }
                    userCell.setData(chat, null, subtitle, position != usersEndRow - 1);
                }
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == blockUserDetailRow) {
                if (currentType == TYPE_BLOCKED) {
                    privacyCell.setText(LocaleController.getString("BlockedUsersInfo", R.string.BlockedUsersInfo));
                } else {
                    privacyCell.setText(null);
                }
                if (usersStartRow == -1) {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
                } else {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
                }
            } else if (position == usersDetailRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            ManageChatTextCell actionCell = (ManageChatTextCell) holder.itemView;
            actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
            if (currentType == TYPE_BLOCKED) {
                actionCell.setText(LocaleController.getString("BlockUser", R.string.BlockUser), null, R.drawable.actions_addmember2, false);
            } else {
                actionCell.setText(LocaleController.getString("PrivacyAddAnException", R.string.PrivacyAddAnException), null, R.drawable.actions_addmember2, false);
            }
            break;
        case 3:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == usersHeaderRow) {
                if (currentType == TYPE_BLOCKED) {
                    headerCell.setText(LocaleController.formatPluralString("BlockedUsersCount", getMessagesController().totalBlockedCount));
                } else {
                    headerCell.setText(LocaleController.getString("PrivacyExceptions", R.string.PrivacyExceptions));
                }
            }
            break;
    }
}
 
Example 11
Source File: SessionsActivity.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:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == terminateAllSessionsRow) {
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText2);
                if (currentType == 0) {
                    textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false);
                } else {
                    textCell.setText(LocaleController.getString("TerminateAllWebSessions", R.string.TerminateAllWebSessions), false);
                }
            } else if (position == qrCodeRow) {
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
                textCell.setTag(Theme.key_windowBackgroundWhiteBlueText4);
                textCell.setText(LocaleController.getString("AuthAnotherClient", R.string.AuthAnotherClient), !sessions.isEmpty());
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == terminateAllSessionsDetailRow) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("ClearOtherSessionsHelp", R.string.ClearOtherSessionsHelp));
                } else {
                    privacyCell.setText(LocaleController.getString("ClearOtherWebSessionsHelp", R.string.ClearOtherWebSessionsHelp));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == otherSessionsTerminateDetail) {
                if (currentType == 0) {
                    if (sessions.isEmpty()) {
                        privacyCell.setText("");
                    } else {
                        privacyCell.setText(LocaleController.getString("TerminateSessionInfo", R.string.TerminateSessionInfo));
                    }
                } else {
                    privacyCell.setText(LocaleController.getString("TerminateWebSessionInfo", R.string.TerminateWebSessionInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == passwordSessionsDetailRow) {
                privacyCell.setText(LocaleController.getString("LoginAttemptsInfo", R.string.LoginAttemptsInfo));
                if (otherSessionsTerminateDetail == -1) {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
                } else {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
                }
            }
            break;
        case 2:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == currentSessionSectionRow) {
                headerCell.setText(LocaleController.getString("CurrentSession", R.string.CurrentSession));
            } else if (position == otherSessionsSectionRow) {
                if (currentType == 0) {
                    headerCell.setText(LocaleController.getString("OtherSessions", R.string.OtherSessions));
                } else {
                    headerCell.setText(LocaleController.getString("OtherWebSessions", R.string.OtherWebSessions));
                }
            } else if (position == passwordSessionsSectionRow) {
                headerCell.setText(LocaleController.getString("LoginAttempts", R.string.LoginAttempts));
            }
            break;
        case 3:
            ViewGroup.LayoutParams layoutParams = emptyLayout.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.height = Math.max(AndroidUtilities.dp(220), AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(128 + (qrCodeRow == -1 ? 0 : 30)) - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0));
                emptyLayout.setLayoutParams(layoutParams);
            }
            break;
        default:
            SessionCell sessionCell = (SessionCell) holder.itemView;
            if (position == currentSessionRow) {
                sessionCell.setSession(currentSession, !sessions.isEmpty() || !passwordSessions.isEmpty() || qrCodeRow != -1);
            } else if (position >= otherSessionsStartRow && position < otherSessionsEndRow) {
                sessionCell.setSession(sessions.get(position - otherSessionsStartRow), position != otherSessionsEndRow - 1);
            } else if (position >= passwordSessionsStartRow && position < passwordSessionsEndRow) {
                sessionCell.setSession(passwordSessions.get(position - passwordSessionsStartRow), position != passwordSessionsEndRow - 1);
            }
            break;
    }
}
 
Example 12
Source File: DataAutoDownloadActivity.java    From TelePlus-Android 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:
        {
            if (position == mobileSection2Row || position == wifiSection2Row)
            {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            else
            {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        }
        case 1:
        {
            TextCheckBoxCell textCell = (TextCheckBoxCell) holder.itemView;
            if (position == mContactsRow || position == wContactsRow || position == rContactsRow)
            {
                textCell.setTextAndCheck(LocaleController.getString("AutodownloadContacts", R.string.AutodownloadContacts), (getMaskForRow(position) & currentType) != 0, true);
            }
            else if (position == mPrivateRow || position == wPrivateRow || position == rPrivateRow)
            {
                textCell.setTextAndCheck(LocaleController.getString("AutodownloadPrivateChats", R.string.AutodownloadPrivateChats), (getMaskForRow(position) & currentType) != 0, true);
            }
            else if (position == mChannelsRow || position == wChannelsRow || position == rChannelsRow)
            {
                textCell.setTextAndCheck(LocaleController.getString("AutodownloadChannels", R.string.AutodownloadChannels), (getMaskForRow(position) & currentType) != 0, mSizeRow != -1);
            }
            else if (position == mGroupRow || position == wGroupRow || position == rGroupRow)
            {
                textCell.setTextAndCheck(LocaleController.getString("AutodownloadGroupChats", R.string.AutodownloadGroupChats), (getMaskForRow(position) & currentType) != 0, true);
            }
            break;
        }
        case 2:
        {
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == mobileSectionRow)
            {
                headerCell.setText(LocaleController.getString("WhenUsingMobileData", R.string.WhenUsingMobileData));
            }
            else if (position == wifiSectionRow)
            {
                headerCell.setText(LocaleController.getString("WhenConnectedOnWiFi", R.string.WhenConnectedOnWiFi));
            }
            else if (position == roamingSectionRow)
            {
                headerCell.setText(LocaleController.getString("WhenRoaming", R.string.WhenRoaming));
            }
            break;
        }
        case 3:
        {
            MaxFileSizeCell cell = (MaxFileSizeCell) holder.itemView;
            if (position == mSizeRow)
            {
                cell.setSize(mobileMaxSize, maxSize);
                cell.setTag(0);
            }
            else if (position == wSizeRow)
            {
                cell.setSize(wifiMaxSize, maxSize);
                cell.setTag(1);
            }
            else if (position == rSizeRow)
            {
                cell.setSize(roamingMaxSize, maxSize);
                cell.setTag(2);
            }
            break;
        }
    }
}
 
Example 13
Source File: PrivacyUsersActivity.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:
            ManageChatUserCell userCell = (ManageChatUserCell) holder.itemView;
            int uid;
            if (currentType == TYPE_BLOCKED) {
                uid = getMessagesController().blockedUsers.keyAt(position - usersStartRow);
            } else {
                uid = uidArray.get(position - usersStartRow);
            }
            userCell.setTag(uid);
            if (uid > 0) {
                TLRPC.User user = getMessagesController().getUser(uid);
                if (user != null) {
                    String number;
                    if (user.bot) {
                        number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1);
                    } else if (user.phone != null && user.phone.length() != 0) {
                        number = PhoneFormat.getInstance().format("+" + user.phone);
                    } else {
                        number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
                    }
                    userCell.setData(user, null, number, position != usersEndRow - 1);
                }
            } else {
                TLRPC.Chat chat = getMessagesController().getChat(-uid);
                if (chat != null) {
                    String subtitle;
                    if (chat.participants_count != 0) {
                        subtitle = LocaleController.formatPluralString("Members", chat.participants_count);
                    } else if (chat.has_geo) {
                        subtitle = LocaleController.getString("MegaLocation", R.string.MegaLocation);
                    } else if (TextUtils.isEmpty(chat.username)) {
                        subtitle = LocaleController.getString("MegaPrivate", R.string.MegaPrivate);
                    } else {
                        subtitle = LocaleController.getString("MegaPublic", R.string.MegaPublic);
                    }
                    userCell.setData(chat, null, subtitle, position != usersEndRow - 1);
                }
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == blockUserDetailRow) {
                if (currentType == TYPE_BLOCKED) {
                    privacyCell.setText(LocaleController.getString("BlockedUsersInfo", R.string.BlockedUsersInfo));
                } else {
                    privacyCell.setText(null);
                }
                if (usersStartRow == -1) {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
                } else {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
                }
            } else if (position == usersDetailRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            ManageChatTextCell actionCell = (ManageChatTextCell) holder.itemView;
            actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
            if (currentType == TYPE_BLOCKED) {
                actionCell.setText(LocaleController.getString("BlockUser", R.string.BlockUser), null, R.drawable.actions_addmember2, false);
            } else {
                actionCell.setText(LocaleController.getString("PrivacyAddAnException", R.string.PrivacyAddAnException), null, R.drawable.actions_addmember2, false);
            }
            break;
        case 3:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == usersHeaderRow) {
                if (currentType == TYPE_BLOCKED) {
                    headerCell.setText(LocaleController.formatPluralString("BlockedUsersCount", getMessagesController().totalBlockedCount));
                } else {
                    headerCell.setText(LocaleController.getString("PrivacyExceptions", R.string.PrivacyExceptions));
                }
            }
            break;
    }
}
 
Example 14
Source File: SessionsActivity.java    From TelePlus-Android 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:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == terminateAllSessionsRow) {
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
                if (currentType == 0) {
                    textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false);
                } else {
                    textCell.setText(LocaleController.getString("TerminateAllWebSessions", R.string.TerminateAllWebSessions), false);
                }
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == terminateAllSessionsDetailRow) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("ClearOtherSessionsHelp", R.string.ClearOtherSessionsHelp));
                } else {
                    privacyCell.setText(LocaleController.getString("ClearOtherWebSessionsHelp", R.string.ClearOtherWebSessionsHelp));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == otherSessionsTerminateDetail) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("TerminateSessionInfo", R.string.TerminateSessionInfo));
                } else {
                    privacyCell.setText(LocaleController.getString("TerminateWebSessionInfo", R.string.TerminateWebSessionInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == currentSessionSectionRow) {
                headerCell.setText(LocaleController.getString("CurrentSession", R.string.CurrentSession));
            } else if (position == otherSessionsSectionRow) {
                if (currentType == 0) {
                    headerCell.setText(LocaleController.getString("OtherSessions", R.string.OtherSessions));
                } else {
                    headerCell.setText(LocaleController.getString("OtherWebSessions", R.string.OtherWebSessions));
                }
            }
            break;
        case 3:
            ViewGroup.LayoutParams layoutParams = emptyLayout.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.height = Math.max(AndroidUtilities.dp(220), AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(128) - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0));
                emptyLayout.setLayoutParams(layoutParams);
            }
            break;
        default:
            SessionCell sessionCell = (SessionCell) holder.itemView;
            if (position == currentSessionRow) {
                sessionCell.setSession(currentSession, !sessions.isEmpty());
            } else {
                sessionCell.setSession(sessions.get(position - otherSessionsStartRow), position != otherSessionsEndRow - 1);
            }
            break;
    }
}
 
Example 15
Source File: DataUsageActivity.java    From TelePlus-Android 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: {
            if (position == resetSection2Row) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        }
        case 1: {
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == resetRow) {
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText2);
                textCell.setText(LocaleController.getString("ResetStatistics", R.string.ResetStatistics), false);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
            } else {
                int type;
                textCell.setTag(Theme.key_windowBackgroundWhiteBlackText);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
                if (position == callsSentRow || position == callsReceivedRow || position == callsBytesSentRow || position == callsBytesReceivedRow) {
                    type = StatsController.TYPE_CALLS;
                } else if (position == messagesSentRow || position == messagesReceivedRow || position == messagesBytesSentRow || position == messagesBytesReceivedRow) {
                    type = StatsController.TYPE_MESSAGES;
                } else if (position == photosSentRow || position == photosReceivedRow || position == photosBytesSentRow || position == photosBytesReceivedRow) {
                    type = StatsController.TYPE_PHOTOS;
                } else if (position == audiosSentRow || position == audiosReceivedRow || position == audiosBytesSentRow || position == audiosBytesReceivedRow) {
                    type = StatsController.TYPE_AUDIOS;
                } else if (position == videosSentRow || position == videosReceivedRow || position == videosBytesSentRow || position == videosBytesReceivedRow) {
                    type = StatsController.TYPE_VIDEOS;
                } else if (position == filesSentRow || position == filesReceivedRow || position == filesBytesSentRow || position == filesBytesReceivedRow) {
                    type = StatsController.TYPE_FILES;
                } else {
                    type = StatsController.TYPE_TOTAL;
                }
                if (position == callsSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("OutgoingCalls", R.string.OutgoingCalls), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == callsReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("IncomingCalls", R.string.IncomingCalls), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == callsTotalTimeRow) {
                    int total = StatsController.getInstance(currentAccount).getCallsTotalTime(currentType);
                    int hours = total / 3600;
                    total -= hours * 3600;
                    int minutes = total / 60;
                    total -= minutes * 60;
                    String time;
                    if (hours != 0) {
                        time = String.format("%d:%02d:%02d", hours, minutes, total);
                    } else {
                        time = String.format("%d:%02d", minutes, total);
                    }
                    textCell.setTextAndValue(LocaleController.getString("CallsTotalTime", R.string.CallsTotalTime), time, false);
                } else if (position == messagesSentRow || position == photosSentRow || position == videosSentRow || position == audiosSentRow || position == filesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountSent", R.string.CountSent), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == messagesReceivedRow || position == photosReceivedRow || position == videosReceivedRow || position == audiosReceivedRow || position == filesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountReceived", R.string.CountReceived), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == messagesBytesSentRow || position == photosBytesSentRow || position == videosBytesSentRow || position == audiosBytesSentRow || position == filesBytesSentRow || position == callsBytesSentRow || position == totalBytesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesSent", R.string.BytesSent), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getSentBytesCount(currentType, type)), true);
                } else if (position == messagesBytesReceivedRow || position == photosBytesReceivedRow || position == videosBytesReceivedRow || position == audiosBytesReceivedRow || position == filesBytesReceivedRow || position == callsBytesReceivedRow || position == totalBytesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesReceived", R.string.BytesReceived), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getReceivedBytesCount(currentType, type)), position != totalBytesReceivedRow);
                }
            }
            break;
        }
        case 2: {
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == totalSectionRow) {
                headerCell.setText(LocaleController.getString("TotalDataUsage", R.string.TotalDataUsage));
            } else if (position == callsSectionRow) {
                headerCell.setText(LocaleController.getString("CallsDataUsage", R.string.CallsDataUsage));
            } else if (position == filesSectionRow) {
                headerCell.setText(LocaleController.getString("FilesDataUsage", R.string.FilesDataUsage));
            } else if (position == audiosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache));
            } else if (position == videosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache));
            } else if (position == photosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache));
            } else if (position == messagesSectionRow) {
                headerCell.setText(LocaleController.getString("MessagesDataUsage", R.string.MessagesDataUsage));
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            cell.setText(LocaleController.formatString("NetworkUsageSince", R.string.NetworkUsageSince, LocaleController.getInstance().formatterStats.format(StatsController.getInstance(currentAccount).getResetStatsDate(currentType))));
            break;
        }
        default:
            break;
    }
}
 
Example 16
Source File: DataAutoDownloadActivity.java    From TelePlus-Android 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:
        {
            if (position == mobileSection2Row || position == wifiSection2Row)
            {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            else
            {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        }
        case 1:
        {
            TextCheckBoxCell textCell = (TextCheckBoxCell) holder.itemView;
            if (position == mContactsRow || position == wContactsRow || position == rContactsRow)
            {
                textCell.setTextAndCheck(LocaleController.getString("AutodownloadContacts", R.string.AutodownloadContacts), (getMaskForRow(position) & currentType) != 0, true);
            }
            else if (position == mPrivateRow || position == wPrivateRow || position == rPrivateRow)
            {
                textCell.setTextAndCheck(LocaleController.getString("AutodownloadPrivateChats", R.string.AutodownloadPrivateChats), (getMaskForRow(position) & currentType) != 0, true);
            }
            else if (position == mChannelsRow || position == wChannelsRow || position == rChannelsRow)
            {
                textCell.setTextAndCheck(LocaleController.getString("AutodownloadChannels", R.string.AutodownloadChannels), (getMaskForRow(position) & currentType) != 0, mSizeRow != -1);
            }
            else if (position == mGroupRow || position == wGroupRow || position == rGroupRow)
            {
                textCell.setTextAndCheck(LocaleController.getString("AutodownloadGroupChats", R.string.AutodownloadGroupChats), (getMaskForRow(position) & currentType) != 0, true);
            }
            break;
        }
        case 2:
        {
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == mobileSectionRow)
            {
                headerCell.setText(LocaleController.getString("WhenUsingMobileData", R.string.WhenUsingMobileData));
            }
            else if (position == wifiSectionRow)
            {
                headerCell.setText(LocaleController.getString("WhenConnectedOnWiFi", R.string.WhenConnectedOnWiFi));
            }
            else if (position == roamingSectionRow)
            {
                headerCell.setText(LocaleController.getString("WhenRoaming", R.string.WhenRoaming));
            }
            break;
        }
        case 3:
        {
            MaxFileSizeCell cell = (MaxFileSizeCell) holder.itemView;
            if (position == mSizeRow)
            {
                cell.setSize(mobileMaxSize, maxSize);
                cell.setTag(0);
            }
            else if (position == wSizeRow)
            {
                cell.setSize(wifiMaxSize, maxSize);
                cell.setTag(1);
            }
            else if (position == rSizeRow)
            {
                cell.setSize(roamingMaxSize, maxSize);
                cell.setTag(2);
            }
            break;
        }
    }
}
 
Example 17
Source File: SessionsActivity.java    From TelePlus-Android 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:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == terminateAllSessionsRow) {
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
                if (currentType == 0) {
                    textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false);
                } else {
                    textCell.setText(LocaleController.getString("TerminateAllWebSessions", R.string.TerminateAllWebSessions), false);
                }
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == terminateAllSessionsDetailRow) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("ClearOtherSessionsHelp", R.string.ClearOtherSessionsHelp));
                } else {
                    privacyCell.setText(LocaleController.getString("ClearOtherWebSessionsHelp", R.string.ClearOtherWebSessionsHelp));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == otherSessionsTerminateDetail) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("TerminateSessionInfo", R.string.TerminateSessionInfo));
                } else {
                    privacyCell.setText(LocaleController.getString("TerminateWebSessionInfo", R.string.TerminateWebSessionInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == currentSessionSectionRow) {
                headerCell.setText(LocaleController.getString("CurrentSession", R.string.CurrentSession));
            } else if (position == otherSessionsSectionRow) {
                if (currentType == 0) {
                    headerCell.setText(LocaleController.getString("OtherSessions", R.string.OtherSessions));
                } else {
                    headerCell.setText(LocaleController.getString("OtherWebSessions", R.string.OtherWebSessions));
                }
            }
            break;
        case 3:
            ViewGroup.LayoutParams layoutParams = emptyLayout.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.height = Math.max(AndroidUtilities.dp(220), AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(128) - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0));
                emptyLayout.setLayoutParams(layoutParams);
            }
            break;
        default:
            SessionCell sessionCell = (SessionCell) holder.itemView;
            if (position == currentSessionRow) {
                sessionCell.setSession(currentSession, !sessions.isEmpty());
            } else {
                sessionCell.setSession(sessions.get(position - otherSessionsStartRow), position != otherSessionsEndRow - 1);
            }
            break;
    }
}
 
Example 18
Source File: DataUsageActivity.java    From TelePlus-Android 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: {
            if (position == resetSection2Row) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        }
        case 1: {
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == resetRow) {
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText2);
                textCell.setText(LocaleController.getString("ResetStatistics", R.string.ResetStatistics), false);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
            } else {
                int type;
                textCell.setTag(Theme.key_windowBackgroundWhiteBlackText);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
                if (position == callsSentRow || position == callsReceivedRow || position == callsBytesSentRow || position == callsBytesReceivedRow) {
                    type = StatsController.TYPE_CALLS;
                } else if (position == messagesSentRow || position == messagesReceivedRow || position == messagesBytesSentRow || position == messagesBytesReceivedRow) {
                    type = StatsController.TYPE_MESSAGES;
                } else if (position == photosSentRow || position == photosReceivedRow || position == photosBytesSentRow || position == photosBytesReceivedRow) {
                    type = StatsController.TYPE_PHOTOS;
                } else if (position == audiosSentRow || position == audiosReceivedRow || position == audiosBytesSentRow || position == audiosBytesReceivedRow) {
                    type = StatsController.TYPE_AUDIOS;
                } else if (position == videosSentRow || position == videosReceivedRow || position == videosBytesSentRow || position == videosBytesReceivedRow) {
                    type = StatsController.TYPE_VIDEOS;
                } else if (position == filesSentRow || position == filesReceivedRow || position == filesBytesSentRow || position == filesBytesReceivedRow) {
                    type = StatsController.TYPE_FILES;
                } else {
                    type = StatsController.TYPE_TOTAL;
                }
                if (position == callsSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("OutgoingCalls", R.string.OutgoingCalls), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == callsReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("IncomingCalls", R.string.IncomingCalls), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == callsTotalTimeRow) {
                    int total = StatsController.getInstance(currentAccount).getCallsTotalTime(currentType);
                    int hours = total / 3600;
                    total -= hours * 3600;
                    int minutes = total / 60;
                    total -= minutes * 60;
                    String time;
                    if (hours != 0) {
                        time = String.format("%d:%02d:%02d", hours, minutes, total);
                    } else {
                        time = String.format("%d:%02d", minutes, total);
                    }
                    textCell.setTextAndValue(LocaleController.getString("CallsTotalTime", R.string.CallsTotalTime), time, false);
                } else if (position == messagesSentRow || position == photosSentRow || position == videosSentRow || position == audiosSentRow || position == filesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountSent", R.string.CountSent), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == messagesReceivedRow || position == photosReceivedRow || position == videosReceivedRow || position == audiosReceivedRow || position == filesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountReceived", R.string.CountReceived), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == messagesBytesSentRow || position == photosBytesSentRow || position == videosBytesSentRow || position == audiosBytesSentRow || position == filesBytesSentRow || position == callsBytesSentRow || position == totalBytesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesSent", R.string.BytesSent), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getSentBytesCount(currentType, type)), true);
                } else if (position == messagesBytesReceivedRow || position == photosBytesReceivedRow || position == videosBytesReceivedRow || position == audiosBytesReceivedRow || position == filesBytesReceivedRow || position == callsBytesReceivedRow || position == totalBytesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesReceived", R.string.BytesReceived), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getReceivedBytesCount(currentType, type)), position != totalBytesReceivedRow);
                }
            }
            break;
        }
        case 2: {
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == totalSectionRow) {
                headerCell.setText(LocaleController.getString("TotalDataUsage", R.string.TotalDataUsage));
            } else if (position == callsSectionRow) {
                headerCell.setText(LocaleController.getString("CallsDataUsage", R.string.CallsDataUsage));
            } else if (position == filesSectionRow) {
                headerCell.setText(LocaleController.getString("FilesDataUsage", R.string.FilesDataUsage));
            } else if (position == audiosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache));
            } else if (position == videosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache));
            } else if (position == photosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache));
            } else if (position == messagesSectionRow) {
                headerCell.setText(LocaleController.getString("MessagesDataUsage", R.string.MessagesDataUsage));
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            cell.setText(LocaleController.formatString("NetworkUsageSince", R.string.NetworkUsageSince, LocaleController.getInstance().formatterStats.format(StatsController.getInstance(currentAccount).getResetStatsDate(currentType))));
            break;
        }
        default:
            break;
    }
}