| 1 | package tw.nekomimi.nekogram; |
| 2 | |
| 3 | import android.annotation.SuppressLint; |
| 4 | import android.content.Context; |
| 5 | import android.content.Intent; |
| 6 | import android.net.Uri; |
| 7 | import android.os.Build; |
| 8 | import android.os.Bundle; |
| 9 | import android.text.TextUtils; |
| 10 | import android.view.Gravity; |
| 11 | import android.view.View; |
| 12 | import android.view.ViewGroup; |
| 13 | import android.widget.FrameLayout; |
| 14 | import android.widget.Toast; |
| 15 | |
| 16 | import androidx.core.content.FileProvider; |
| 17 | import androidx.recyclerview.widget.LinearLayoutManager; |
| 18 | import androidx.recyclerview.widget.RecyclerView; |
| 19 | |
| 20 | import com.google.gson.Gson; |
| 21 | |
| 22 | import org.telegram.messenger.AndroidUtilities; |
| 23 | import org.telegram.messenger.BuildConfig; |
| 24 | import org.telegram.messenger.ContactsController; |
| 25 | import org.telegram.messenger.FileLoader; |
| 26 | import org.telegram.messenger.FileLog; |
| 27 | import org.telegram.messenger.LocaleController; |
| 28 | import org.telegram.messenger.MessageObject; |
| 29 | import org.telegram.messenger.R; |
| 30 | import org.telegram.tgnet.TLRPC; |
| 31 | import org.telegram.ui.ActionBar.ActionBar; |
| 32 | import org.telegram.ui.ActionBar.BaseFragment; |
| 33 | import org.telegram.ui.ActionBar.Theme; |
| 34 | import org.telegram.ui.ActionBar.ThemeDescription; |
| 35 | import org.telegram.ui.Cells.EmptyCell; |
| 36 | import org.telegram.ui.Cells.HeaderCell; |
| 37 | import org.telegram.ui.Cells.NotificationsCheckCell; |
| 38 | import org.telegram.ui.Cells.ShadowSectionCell; |
| 39 | import org.telegram.ui.Cells.TextCheckCell; |
| 40 | import org.telegram.ui.Cells.TextDetailSettingsCell; |
| 41 | import org.telegram.ui.Cells.TextSettingsCell; |
| 42 | import org.telegram.ui.Components.LayoutHelper; |
| 43 | import org.telegram.ui.Components.RecyclerListView; |
| 44 | import org.telegram.ui.ProfileActivity; |
| 45 | |
| 46 | import java.io.File; |
| 47 | import java.util.Date; |
| 48 | |
| 49 | public class MessageDetailsActivity extends BaseFragment { |
| 50 | |
| 51 | private RecyclerListView listView; |
| 52 | private ListAdapter listAdapter; |
| 53 | |
| 54 | private MessageObject messageObject; |
| 55 | private TLRPC.Chat fromChat; |
| 56 | private TLRPC.User fromUser; |
| 57 | private String filePath; |
| 58 | private String fileName; |
| 59 | |
| 60 | private int rowCount; |
| 61 | |
| 62 | private int idRow; |
| 63 | private int messageRow; |
| 64 | private int captionRow; |
| 65 | private int groupRow; |
| 66 | private int channelRow; |
| 67 | private int fromRow; |
| 68 | private int botRow; |
| 69 | private int dateRow; |
| 70 | private int editedRow; |
| 71 | private int forwardRow; |
| 72 | private int fileNameRow; |
| 73 | private int filePathRow; |
| 74 | private int fileSizeRow; |
| 75 | private int dcRow; |
| 76 | private int emptyRow; |
| 77 | private int exportRow; |
| 78 | private int endRow; |
| 79 | |
| 80 | public MessageDetailsActivity(MessageObject messageObject) { |
| 81 | this.messageObject = messageObject; |
| 82 | if (messageObject.messageOwner.to_id != null && messageObject.messageOwner.to_id.channel_id != 0) { |
| 83 | fromChat = getMessagesController().getChat(messageObject.messageOwner.to_id.channel_id); |
| 84 | } else if (messageObject.messageOwner.to_id != null && messageObject.messageOwner.to_id.chat_id != 0) { |
| 85 | fromChat = getMessagesController().getChat(messageObject.messageOwner.to_id.chat_id); |
| 86 | } |
| 87 | if (messageObject.messageOwner.from_id != 0) { |
| 88 | fromUser = getMessagesController().getUser(messageObject.messageOwner.from_id); |
| 89 | } |
| 90 | filePath = messageObject.messageOwner.attachPath; |
| 91 | if (!TextUtils.isEmpty(filePath)) { |
| 92 | File temp = new File(filePath); |
| 93 | if (!temp.exists()) { |
| 94 | filePath = null; |
| 95 | } |
| 96 | } |
| 97 | if (TextUtils.isEmpty(filePath)) { |
| 98 | filePath = FileLoader.getPathToMessage(messageObject.messageOwner).toString(); |
| 99 | File temp = new File(filePath); |
| 100 | if (!temp.exists()) { |
| 101 | filePath = null; |
| 102 | } |
| 103 | } |
| 104 | if (TextUtils.isEmpty(filePath)) { |
| 105 | filePath = FileLoader.getPathToAttach(messageObject.getDocument(), true).toString(); |
| 106 | File temp = new File(filePath); |
| 107 | if (!temp.isFile()) { |
| 108 | filePath = null; |
| 109 | } |
| 110 | } |
| 111 | if (messageObject.messageOwner.media != null && messageObject.messageOwner.media.document != null) { |
| 112 | if (TextUtils.isEmpty(messageObject.messageOwner.media.document.file_name)) { |
| 113 | for (int a = 0; a < messageObject.messageOwner.media.document.attributes.size(); a++) { |
| 114 | if (messageObject.messageOwner.media.document.attributes.get(a) instanceof TLRPC.TL_documentAttributeFilename) { |
| 115 | fileName = messageObject.messageOwner.media.document.attributes.get(a).file_name; |
| 116 | } |
| 117 | } |
| 118 | } else { |
| 119 | fileName = messageObject.messageOwner.media.document.file_name; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | } |
| 124 | |
| 125 | @Override |
| 126 | public boolean onFragmentCreate() { |
| 127 | super.onFragmentCreate(); |
| 128 | |
| 129 | updateRows(); |
| 130 | |
| 131 | return true; |
| 132 | } |
| 133 | |
| 134 | @SuppressLint({"NewApi", "RtlHardcoded"}) |
| 135 | @Override |
| 136 | public View createView(Context context) { |
| 137 | actionBar.setBackButtonImage(R.drawable.ic_ab_back); |
| 138 | actionBar.setTitle(LocaleController.getString("MessageDetails", R.string.MessageDetails)); |
| 139 | |
| 140 | if (AndroidUtilities.isTablet()) { |
| 141 | actionBar.setOccupyStatusBar(false); |
| 142 | } |
| 143 | actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { |
| 144 | @Override |
| 145 | public void onItemClick(int id) { |
| 146 | if (id == -1) { |
| 147 | finishFragment(); |
| 148 | } |
| 149 | } |
| 150 | }); |
| 151 | |
| 152 | listAdapter = new ListAdapter(context); |
| 153 | |
| 154 | fragmentView = new FrameLayout(context); |
| 155 | fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray)); |
| 156 | FrameLayout frameLayout = (FrameLayout) fragmentView; |
| 157 | |
| 158 | listView = new RecyclerListView(context); |
| 159 | listView.setVerticalScrollBarEnabled(false); |
| 160 | listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) { |
| 161 | @Override |
| 162 | public boolean supportsPredictiveItemAnimations() { |
| 163 | return false; |
| 164 | } |
| 165 | }); |
| 166 | listView.setGlowColor(Theme.getColor(Theme.key_avatar_backgroundActionBarBlue)); |
| 167 | listView.setAdapter(listAdapter); |
| 168 | listView.setItemAnimator(null); |
| 169 | listView.setLayoutAnimation(null); |
| 170 | frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); |
| 171 | listView.setOnItemClickListener((view, position, x, y) -> { |
| 172 | if (position == exportRow) { |
| 173 | Gson gson = new Gson(); |
| 174 | try { |
| 175 | AndroidUtilities.addToClipboard(gson.toJson(messageObject.messageOwner)); |
| 176 | Toast.makeText(getParentActivity(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show(); |
| 177 | } catch (Exception e) { |
| 178 | FileLog.e(e); |
| 179 | } |
| 180 | } else if (position != endRow && position != emptyRow) { |
| 181 | TextDetailSettingsCell textCell = (TextDetailSettingsCell) view; |
| 182 | try { |
| 183 | AndroidUtilities.addToClipboard(textCell.getValueTextView().getText()); |
| 184 | Toast.makeText(getParentActivity(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show(); |
| 185 | } catch (Exception e) { |
| 186 | FileLog.e(e); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | }); |
| 191 | listView.setOnItemLongClickListener((view, position) -> { |
| 192 | if (position == filePathRow) { |
| 193 | AndroidUtilities.runOnUIThread(() -> { |
| 194 | Intent intent = new Intent(Intent.ACTION_SEND); |
| 195 | intent.setType("application/octet-stream"); |
| 196 | if (Build.VERSION.SDK_INT >= 24) { |
| 197 | try { |
| 198 | intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", new File(filePath))); |
| 199 | intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| 200 | } catch (Exception ignore) { |
| 201 | intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filePath))); |
| 202 | } |
| 203 | } else { |
| 204 | intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filePath))); |
| 205 | } |
| 206 | startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareFile", R.string.ShareFile)), 500); |
| 207 | }); |
| 208 | } else if (position == channelRow || position == groupRow) { |
| 209 | if (fromChat != null) { |
| 210 | Bundle args = new Bundle(); |
| 211 | args.putInt("chat_id", fromChat.id); |
| 212 | ProfileActivity fragment = new ProfileActivity(args); |
| 213 | presentFragment(fragment); |
| 214 | } |
| 215 | } else if (position == fromRow) { |
| 216 | if (fromUser != null) { |
| 217 | Bundle args = new Bundle(); |
| 218 | args.putInt("user_id", fromUser.id); |
| 219 | ProfileActivity fragment = new ProfileActivity(args); |
| 220 | presentFragment(fragment); |
| 221 | } |
| 222 | } else { |
| 223 | return false; |
| 224 | } |
| 225 | return true; |
| 226 | }); |
| 227 | return fragmentView; |
| 228 | } |
| 229 | |
| 230 | @Override |
| 231 | public void onResume() { |
| 232 | super.onResume(); |
| 233 | if (listAdapter != null) { |
| 234 | listAdapter.notifyDataSetChanged(); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | private void updateRows() { |
| 239 | rowCount = 0; |
| 240 | idRow = rowCount++; |
| 241 | messageRow = TextUtils.isEmpty(messageObject.messageText) ? -1 : rowCount++; |
| 242 | captionRow = TextUtils.isEmpty(messageObject.caption) ? -1 : rowCount++; |
| 243 | groupRow = fromChat != null && !fromChat.broadcast ? rowCount++ : -1; |
| 244 | channelRow = fromChat != null && fromChat.broadcast ? rowCount++ : -1; |
| 245 | fromRow = fromUser != null || messageObject.messageOwner.post_author != null ? rowCount++ : -1; |
| 246 | botRow = fromUser != null && fromUser.bot ? rowCount++ : -1; |
| 247 | dateRow = messageObject.messageOwner.date != 0 ? rowCount++ : -1; |
| 248 | editedRow = messageObject.messageOwner.edit_date != 0 ? rowCount++ : -1; |
| 249 | forwardRow = messageObject.isForwarded() ? rowCount++ : -1; |
| 250 | fileNameRow = TextUtils.isEmpty(fileName) ? -1 : rowCount++; |
| 251 | filePathRow = TextUtils.isEmpty(filePath) ? -1 : rowCount++; |
| 252 | fileSizeRow = messageObject.getSize() != 0 ? rowCount++ : -1; |
| 253 | if (messageObject.messageOwner.media != null && ( |
| 254 | (messageObject.messageOwner.media.photo != null && messageObject.messageOwner.media.photo.dc_id > 0) || |
| 255 | (messageObject.messageOwner.media.document != null && messageObject.messageOwner.media.document.dc_id > 0) |
| 256 | )) { |
| 257 | dcRow = rowCount++; |
| 258 | } else { |
| 259 | dcRow = -1; |
| 260 | } |
| 261 | emptyRow = rowCount++; |
| 262 | exportRow = rowCount++; |
| 263 | endRow = rowCount++; |
| 264 | if (listAdapter != null) { |
| 265 | listAdapter.notifyDataSetChanged(); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | @Override |
| 270 | public ThemeDescription[] getThemeDescriptions() { |
| 271 | return new ThemeDescription[]{ |
| 272 | new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{EmptyCell.class, TextSettingsCell.class, TextCheckCell.class, HeaderCell.class, TextDetailSettingsCell.class, NotificationsCheckCell.class}, null, null, null, Theme.key_windowBackgroundWhite), |
| 273 | new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray), |
| 274 | |
| 275 | new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue), |
| 276 | new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_avatar_backgroundActionBarBlue), |
| 277 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_avatar_actionBarIconBlue), |
| 278 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle), |
| 279 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_avatar_actionBarSelectorBlue), |
| 280 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, null, Theme.key_actionBarDefaultSubmenuBackground), |
| 281 | new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, null, Theme.key_actionBarDefaultSubmenuItem), |
| 282 | |
| 283 | new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector), |
| 284 | |
| 285 | new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider), |
| 286 | |
| 287 | new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow), |
| 288 | |
| 289 | new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 290 | new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteValueText), |
| 291 | |
| 292 | new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), |
| 293 | new ThemeDescription(listView, 0, new Class[]{TextDetailSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), |
| 294 | }; |
| 295 | } |
| 296 | |
| 297 | private class ListAdapter extends RecyclerListView.SelectionAdapter { |
| 298 | |
| 299 | private Context mContext; |
| 300 | |
| 301 | public ListAdapter(Context context) { |
| 302 | mContext = context; |
| 303 | } |
| 304 | |
| 305 | @Override |
| 306 | public int getItemCount() { |
| 307 | return rowCount; |
| 308 | } |
| 309 | |
| 310 | @Override |
| 311 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { |
| 312 | switch (holder.getItemViewType()) { |
| 313 | case 1: { |
| 314 | break; |
| 315 | } |
| 316 | case 2: { |
| 317 | TextDetailSettingsCell textCell = (TextDetailSettingsCell) holder.itemView; |
| 318 | textCell.setMultilineDetail(true); |
| 319 | boolean divider = position + 1 != emptyRow; |
| 320 | if (position == idRow) { |
| 321 | textCell.setTextAndValue("ID", String.valueOf(messageObject.messageOwner.id), divider); |
| 322 | } else if (position == messageRow) { |
| 323 | textCell.setTextWithEmojiAnd21Value("Message", messageObject.messageText, divider); |
| 324 | } else if (position == captionRow) { |
| 325 | textCell.setTextWithEmojiAnd21Value("Caption", messageObject.caption, divider); |
| 326 | } else if (position == channelRow || position == groupRow) { |
| 327 | StringBuilder builder = new StringBuilder(); |
| 328 | builder.append(fromChat.title); |
| 329 | builder.append("\n"); |
| 330 | if (!TextUtils.isEmpty(fromChat.username)) { |
| 331 | builder.append("@"); |
| 332 | builder.append(fromChat.username); |
| 333 | builder.append("\n"); |
| 334 | } |
| 335 | builder.append(fromChat.id); |
| 336 | textCell.setTextWithEmojiAnd21Value(position == channelRow ? "Channel" : "Group", builder.toString(), divider); |
| 337 | } else if (position == fromRow) { |
| 338 | StringBuilder builder = new StringBuilder(); |
| 339 | if (fromUser != null) { |
| 340 | builder.append(ContactsController.formatName(fromUser.first_name, fromUser.last_name)); |
| 341 | builder.append("\n"); |
| 342 | if (!TextUtils.isEmpty(fromUser.username)) { |
| 343 | builder.append("@"); |
| 344 | builder.append(fromUser.username); |
| 345 | builder.append("\n"); |
| 346 | } |
| 347 | builder.append(fromUser.id); |
| 348 | } else { |
| 349 | builder.append(messageObject.messageOwner.post_author); |
| 350 | } |
| 351 | textCell.setTextWithEmojiAnd21Value("From", builder.toString(), divider); |
| 352 | } else if (position == botRow) { |
| 353 | textCell.setTextWithEmojiAnd21Value("Bot", "Yes", divider); |
| 354 | } else if (position == dateRow) { |
| 355 | long date = (long) messageObject.messageOwner.date * 1000; |
| 356 | textCell.setTextWithEmojiAnd21Value("Date", LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))), divider); |
| 357 | } else if (position == editedRow) { |
| 358 | long date = (long) messageObject.messageOwner.date * 1000; |
| 359 | textCell.setTextWithEmojiAnd21Value("Edited", LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))), divider); |
| 360 | } else if (position == forwardRow) { |
| 361 | StringBuilder builder = new StringBuilder(); |
| 362 | if (messageObject.messageOwner.fwd_from.channel_id != 0) { |
| 363 | TLRPC.Chat chat = getMessagesController().getChat(messageObject.messageOwner.fwd_from.channel_id); |
| 364 | builder.append(chat.title); |
| 365 | builder.append("\n"); |
| 366 | if (!TextUtils.isEmpty(chat.username)) { |
| 367 | builder.append("@"); |
| 368 | builder.append(chat.username); |
| 369 | builder.append("\n"); |
| 370 | } |
| 371 | builder.append(chat.id); |
| 372 | } else if (messageObject.messageOwner.fwd_from.from_id != 0) { |
| 373 | TLRPC.User user = getMessagesController().getUser(messageObject.messageOwner.fwd_from.from_id); |
| 374 | builder.append(ContactsController.formatName(user.first_name, user.last_name)); |
| 375 | builder.append("\n"); |
| 376 | if (!TextUtils.isEmpty(user.username)) { |
| 377 | builder.append("@"); |
| 378 | builder.append(user.username); |
| 379 | builder.append("\n"); |
| 380 | } |
| 381 | builder.append(user.id); |
| 382 | } else if (!TextUtils.isEmpty(messageObject.messageOwner.fwd_from.from_name)) { |
| 383 | builder.append(messageObject.messageOwner.fwd_from.from_name); |
| 384 | } |
| 385 | textCell.setTextWithEmojiAnd21Value("Forward from", builder.toString(), divider); |
| 386 | } else if (position == fileNameRow) { |
| 387 | textCell.setTextWithEmojiAnd21Value("File name", fileName, divider); |
| 388 | } else if (position == filePathRow) { |
| 389 | textCell.setTextWithEmojiAnd21Value("File path", filePath, divider); |
| 390 | } else if (position == fileSizeRow) { |
| 391 | textCell.setTextWithEmojiAnd21Value("File size", AndroidUtilities.formatFileSize(messageObject.getSize()), divider); |
| 392 | } else if (position == dcRow) { |
| 393 | if (messageObject.messageOwner.media.photo != null && messageObject.messageOwner.media.photo.dc_id > 0) { |
| 394 | textCell.setTextWithEmojiAnd21Value("DC", String.valueOf(messageObject.messageOwner.media.photo.dc_id), divider); |
| 395 | } else if (messageObject.messageOwner.media.document != null && messageObject.messageOwner.media.document.dc_id > 0) { |
| 396 | textCell.setTextWithEmojiAnd21Value("DC", String.valueOf(messageObject.messageOwner.media.document.dc_id), divider); |
| 397 | } |
| 398 | } |
| 399 | break; |
| 400 | } |
| 401 | case 3: { |
| 402 | TextSettingsCell textCell = (TextSettingsCell) holder.itemView; |
| 403 | if (position == exportRow) { |
| 404 | textCell.setText(LocaleController.getString("ExportAsJson", R.string.ExportAsJson), false); |
| 405 | textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText)); |
| 406 | } |
| 407 | break; |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | @Override |
| 413 | public boolean isEnabled(RecyclerView.ViewHolder holder) { |
| 414 | int position = holder.getAdapterPosition(); |
| 415 | return position != endRow && position != emptyRow; |
| 416 | } |
| 417 | |
| 418 | @Override |
| 419 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
| 420 | View view = null; |
| 421 | switch (viewType) { |
| 422 | case 1: |
| 423 | view = new ShadowSectionCell(mContext); |
| 424 | break; |
| 425 | case 2: |
| 426 | view = new TextDetailSettingsCell(mContext); |
| 427 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 428 | break; |
| 429 | case 3: |
| 430 | view = new TextSettingsCell(mContext); |
| 431 | view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); |
| 432 | break; |
| 433 | } |
| 434 | //noinspection ConstantConditions |
| 435 | view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT)); |
| 436 | return new RecyclerListView.Holder(view); |
| 437 | } |
| 438 | |
| 439 | @Override |
| 440 | public int getItemViewType(int position) { |
| 441 | if (position == endRow || position == emptyRow) { |
| 442 | return 1; |
| 443 | } else if (position == exportRow) { |
| 444 | return 3; |
| 445 | } else { |
| 446 | return 2; |
| 447 | } |
| 448 | } |
| 449 | } |
| 450 | } |
| 451 | |