Java Code Examples for android.view.ViewGroup#findViewById()
The following examples show how to use
android.view.ViewGroup#findViewById() .
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: WelcomeFragment4.java From OneText_For_Android with GNU Lesser General Public License v3.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_welcome4, container, false); //fb welcome_widget_button = rootView.findViewById(R.id.welcome_widget_button); //懒得写 //懒得写 welcome_widget_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { viewPager2.setCurrentItem(viewPager2.getCurrentItem()+1); } }); return rootView; }
Example 2
Source File: StatusBarUtil.java From Focus with GNU General Public License v3.0 | 6 votes |
/** * 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用) * * @param activity 需要设置的activity * @param drawerLayout DrawerLayout * @param color 状态栏颜色值 */ @Deprecated public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // 生成一个状态栏大小的矩形 ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID); if (fakeStatusBarView != null) { if (fakeStatusBarView.getVisibility() == View.GONE) { fakeStatusBarView.setVisibility(View.VISIBLE); } fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA)); } else { // 添加 statusBarView 到布局中 contentLayout.addView(createStatusBarView(activity, color), 0); } // 内容布局不是 LinearLayout 时,设置padding top if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0); } // 设置属性 setDrawerLayoutProperty(drawerLayout, contentLayout); } }
Example 3
Source File: ColorPreference.java From Noyze with Apache License 2.0 | 6 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater layoutInflater = LayoutInflater.from(getActivity()); mRootView = (ViewGroup) layoutInflater.inflate(R.layout.advanced_color_picker, null); mColorPicker = (ColorPicker) mRootView.findViewById(R.id.color_picker); mSvBar = (SVBar) mRootView.findViewById(R.id.svbar); mOpacityBar = (OpacityBar) mRootView.findViewById(R.id.opacitybar); mColorPicker.addSVBar(mSvBar); hexEdit = (EditText) mRootView.findViewById(R.id.hex); hexApply = (Button) mRootView.findViewById(R.id.apply); hexEdit.setFilters(new InputFilter[] { ALPHANUMERIC }); hexApply.setOnClickListener(hexApplyListener); String hexColor = String.format("%06X", (0xFFFFFF & ColorDialogFragment.getColor(startColor, 255))); hexEdit.setHint(hexColor); mColorPicker.addOpacityBar(mOpacityBar); mColorPicker.setOldCenterColor(startColor); mColorPicker.setShowOldCenterColor(true); return new AlertDialog.Builder(getActivity()) .setView(mRootView) .setNegativeButton(android.R.string.cancel, clickListener) .setPositiveButton(android.R.string.ok, clickListener) .create(); }
Example 4
Source File: FadingActionBarHelperBase.java From FadingActionBar with Apache License 2.0 | 6 votes |
private View createListView(ListView listView) { ViewGroup contentContainer = (ViewGroup) mInflater.inflate(R.layout.fab__listview_container, null); contentContainer.addView(mContentView); mHeaderContainer = (FrameLayout) contentContainer.findViewById(R.id.fab__header_container); initializeGradient(mHeaderContainer); mHeaderContainer.addView(mHeaderView, 0); mMarginView = new FrameLayout(listView.getContext()); mMarginView.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, 0)); listView.addHeaderView(mMarginView, null, false); // Make the background as high as the screen so that it fills regardless of the amount of scroll. mListViewBackgroundView = contentContainer.findViewById(R.id.fab__listview_background); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mListViewBackgroundView.getLayoutParams(); params.height = Utils.getDisplayHeight(listView.getContext()); mListViewBackgroundView.setLayoutParams(params); listView.setOnScrollListener(mOnScrollListener); return contentContainer; }
Example 5
Source File: XStatusBar.java From XFrame with Apache License 2.0 | 6 votes |
/** * 设置状态栏颜色 * * @param activity 需要设置的activity * @param color 状态栏颜色值 * @param statusBarAlpha 状态栏透明度 */ public static void setColor(Activity activity, @ColorInt int color, int statusBarAlpha) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha)); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID); if (fakeStatusBarView != null) { if (fakeStatusBarView.getVisibility() == View.GONE) { fakeStatusBarView.setVisibility(View.VISIBLE); } fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); } else { decorView.addView(createStatusBarView(activity, color, statusBarAlpha)); } setRootView(activity); } }
Example 6
Source File: Focus2AndroidTest.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override protected void setUp() throws Exception { super.setUp(); mFocusFinder = FocusFinder.getInstance(); // inflate the layout final Context context = getContext(); final LayoutInflater inflater = LayoutInflater.from(context); mRoot = (ViewGroup) inflater.inflate(R.layout.focus_2, null); // manually measure it, and lay it out mRoot.measure(500, 500); mRoot.layout(0, 0, 500, 500); mLeftButton = (Button) mRoot.findViewById(R.id.leftButton); mCenterButton = (Button) mRoot.findViewById(R.id.centerButton); mRightButton = (Button) mRoot.findViewById(R.id.rightButton); }
Example 7
Source File: TabularContextMenuUi.java From 365browser with Apache License 2.0 | 5 votes |
private void displayImageHeader( ViewGroup baseLayout, ContextMenuParams params, Resources resources) { mHeaderImageView = (ImageView) baseLayout.findViewById(R.id.context_header_image); TextView headerTextView = (TextView) baseLayout.findViewById(R.id.context_header_text); // We'd prefer the header text is the title text instead of the link text for images. String headerText = params.getTitleText(); if (!TextUtils.isEmpty(headerText)) { headerTextView.setText(headerText); } setBackgroundForImageView(mHeaderImageView, resources); }
Example 8
Source File: SettingsActivity.java From input-samples with Apache License 2.0 | 5 votes |
private void setupSettingsSwitch(int containerId, int labelId, int switchId, boolean checked, CompoundButton.OnCheckedChangeListener checkedChangeListener) { ViewGroup container = findViewById(containerId); String switchLabel = ((TextView) container.findViewById(labelId)).getText().toString(); final Switch switchView = container.findViewById(switchId); switchView.setContentDescription(switchLabel); switchView.setChecked(checked); container.setOnClickListener((view) -> switchView.performClick()); switchView.setOnCheckedChangeListener(checkedChangeListener); }
Example 9
Source File: StatusBarUtils.java From tysq-android with GNU General Public License v3.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.KITKAT) private static void clearPreviousSetting(Activity activity) { ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID); if (fakeStatusBarView != null) { decorView.removeView(fakeStatusBarView); ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0); rootView.setPadding(0, 0, 0, 0); } }
Example 10
Source File: EasySwipeManager.java From EasySwipeLayout with MIT License | 5 votes |
@Override public void onActivityPaused(Activity activity) { if (activity.isFinishing()) { if (activity instanceof IgnoreMakeEasy) return; View view = activity.getWindow().getDecorView(); if (view instanceof ViewGroup) { ViewGroup decor = (ViewGroup) view; EasySwipeLayout layout = decor.findViewById(R.id.sl_swipe_gesture_layout); if (layout != null) { layout.reset(); } } } }
Example 11
Source File: PostViewActivity.java From quill with MIT License | 5 votes |
public PostImageLayoutManager(ViewGroup rootLayout) { mRootLayout = rootLayout; mPostImageView = (ImageView) rootLayout.findViewById(R.id.post_image); mPostImagePlaceholderView = (ImageView) rootLayout.findViewById(R.id.post_image_placeholder); mPostImageHintTextView = (TextView) rootLayout.findViewById(R.id.post_image_hint); mPostImageProgressBar = (ProgressBar) rootLayout.findViewById(R.id.post_image_loading); }
Example 12
Source File: ValidationMessageBubble.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
private static void updateTextViews(ViewGroup root, String mainText, String subText) { ((TextView) root.findViewById(R.id.main_text)).setText(mainText); final TextView subTextView = (TextView) root.findViewById(R.id.sub_text); if (!TextUtils.isEmpty(subText)) { subTextView.setText(subText); } else { ((ViewGroup) subTextView.getParent()).removeView(subTextView); } }
Example 13
Source File: WebappActivity.java From 365browser with Apache License 2.0 | 4 votes |
protected void initializeSplashScreenWidgets(int backgroundColor, Bitmap splashImage) { Bitmap displayIcon = splashImage == null ? mWebappInfo.icon() : splashImage; int minimiumSizeThreshold = getResources().getDimensionPixelSize( R.dimen.webapp_splash_image_size_minimum); int bigThreshold = getResources().getDimensionPixelSize( R.dimen.webapp_splash_image_size_threshold); // Inflate the correct layout for the image. int layoutId; if (displayIcon == null || displayIcon.getWidth() < minimiumSizeThreshold || (displayIcon == mWebappInfo.icon() && mWebappInfo.isIconGenerated())) { mWebappUma.recordSplashscreenIconType(WebappUma.SPLASHSCREEN_ICON_TYPE_NONE); layoutId = R.layout.webapp_splash_screen_no_icon; } else { // The size of the splash screen image determines which layout to use. boolean isUsingSmallSplashImage = displayIcon.getWidth() <= bigThreshold || displayIcon.getHeight() <= bigThreshold; if (isUsingSmallSplashImage) { layoutId = R.layout.webapp_splash_screen_small; } else { layoutId = R.layout.webapp_splash_screen_large; } // Record stats about the splash screen. int splashScreenIconType; if (splashImage == null) { splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_FALLBACK; } else if (isUsingSmallSplashImage) { splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM_SMALL; } else { splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM; } mWebappUma.recordSplashscreenIconType(splashScreenIconType); mWebappUma.recordSplashscreenIconSize( Math.round(displayIcon.getWidth() / getResources().getDisplayMetrics().density)); } ViewGroup subLayout = (ViewGroup) LayoutInflater.from(WebappActivity.this) .inflate(layoutId, mSplashScreen, true); // Set up the elements of the splash screen. TextView appNameView = (TextView) subLayout.findViewById( R.id.webapp_splash_screen_name); ImageView splashIconView = (ImageView) subLayout.findViewById( R.id.webapp_splash_screen_icon); appNameView.setText(mWebappInfo.name()); if (splashIconView != null) splashIconView.setImageBitmap(displayIcon); if (ColorUtils.shouldUseLightForegroundOnBackground(backgroundColor)) { appNameView.setTextColor(ApiCompatibilityUtils.getColor(getResources(), R.color.webapp_splash_title_light)); } }
Example 14
Source File: ExpandableListItemAdapter.java From ListViewAnimations with Apache License 2.0 | 4 votes |
@Override @NonNull public View getView(final int position, @Nullable final View convertView, @NonNull final ViewGroup parent) { ViewGroup view = (ViewGroup) convertView; ViewHolder viewHolder; if (view == null) { view = createView(parent); viewHolder = new ViewHolder(); viewHolder.titleParent = (ViewGroup) view.findViewById(mTitleParentResId); viewHolder.contentParent = (ViewGroup) view.findViewById(mContentParentResId); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } View titleView = getTitleView(position, viewHolder.titleView, viewHolder.titleParent); if (!titleView.equals(viewHolder.titleView)) { viewHolder.titleParent.removeAllViews(); viewHolder.titleParent.addView(titleView); if (mActionViewResId == 0) { view.setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } else { view.findViewById(mActionViewResId).setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent)); } } viewHolder.titleView = titleView; View contentView = getContentView(position, viewHolder.contentView, viewHolder.contentParent); if (!contentView.equals(viewHolder.contentView)) { viewHolder.contentParent.removeAllViews(); viewHolder.contentParent.addView(contentView); } viewHolder.contentView = contentView; viewHolder.contentParent.setVisibility(mExpandedIds.contains(getItemId(position)) ? View.VISIBLE : View.GONE); viewHolder.contentParent.setTag(getItemId(position)); LayoutParams layoutParams = viewHolder.contentParent.getLayoutParams(); layoutParams.height = LayoutParams.WRAP_CONTENT; viewHolder.contentParent.setLayoutParams(layoutParams); return view; }
Example 15
Source File: ScoreAdapter.java From android-topeka with Apache License 2.0 | 4 votes |
public ViewHolder(ViewGroup scorecardItem) { mQuizView = (TextView) scorecardItem.findViewById(R.id.quiz); mAnswerView = (TextView) scorecardItem.findViewById(R.id.answer); mSolvedState = (ImageView) scorecardItem.findViewById(R.id.solved_state); }
Example 16
Source File: DatePickerCalendarDelegate.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public DatePickerCalendarDelegate(DatePicker delegator, Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(delegator, context); final Locale locale = mCurrentLocale; mCurrentDate = Calendar.getInstance(locale); mTempDate = Calendar.getInstance(locale); mMinDate = Calendar.getInstance(locale); mMaxDate = Calendar.getInstance(locale); mMinDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1); mMaxDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31); final Resources res = mDelegator.getResources(); final TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.DatePicker, defStyleAttr, defStyleRes); final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE); final int layoutResourceId = a.getResourceId( R.styleable.DatePicker_internalLayout, R.layout.date_picker_material); // Set up and attach container. mContainer = (ViewGroup) inflater.inflate(layoutResourceId, mDelegator, false); mContainer.setSaveFromParentEnabled(false); mDelegator.addView(mContainer); // Set up header views. final ViewGroup header = mContainer.findViewById(R.id.date_picker_header); mHeaderYear = header.findViewById(R.id.date_picker_header_year); mHeaderYear.setOnClickListener(mOnHeaderClickListener); mHeaderMonthDay = header.findViewById(R.id.date_picker_header_date); mHeaderMonthDay.setOnClickListener(mOnHeaderClickListener); // For the sake of backwards compatibility, attempt to extract the text // color from the header month text appearance. If it's set, we'll let // that override the "real" header text color. ColorStateList headerTextColor = null; @SuppressWarnings("deprecation") final int monthHeaderTextAppearance = a.getResourceId( R.styleable.DatePicker_headerMonthTextAppearance, 0); if (monthHeaderTextAppearance != 0) { final TypedArray textAppearance = mContext.obtainStyledAttributes(null, ATTRS_TEXT_COLOR, 0, monthHeaderTextAppearance); final ColorStateList legacyHeaderTextColor = textAppearance.getColorStateList(0); headerTextColor = applyLegacyColorFixes(legacyHeaderTextColor); textAppearance.recycle(); } if (headerTextColor == null) { headerTextColor = a.getColorStateList(R.styleable.DatePicker_headerTextColor); } if (headerTextColor != null) { mHeaderYear.setTextColor(headerTextColor); mHeaderMonthDay.setTextColor(headerTextColor); } // Set up header background, if available. if (a.hasValueOrEmpty(R.styleable.DatePicker_headerBackground)) { header.setBackground(a.getDrawable(R.styleable.DatePicker_headerBackground)); } a.recycle(); // Set up picker container. mAnimator = mContainer.findViewById(R.id.animator); // Set up day picker view. mDayPickerView = mAnimator.findViewById(R.id.date_picker_day_picker); mDayPickerView.setFirstDayOfWeek(mFirstDayOfWeek); mDayPickerView.setMinDate(mMinDate.getTimeInMillis()); mDayPickerView.setMaxDate(mMaxDate.getTimeInMillis()); mDayPickerView.setDate(mCurrentDate.getTimeInMillis()); mDayPickerView.setOnDaySelectedListener(mOnDaySelectedListener); // Set up year picker view. mYearPickerView = mAnimator.findViewById(R.id.date_picker_year_picker); mYearPickerView.setRange(mMinDate, mMaxDate); mYearPickerView.setYear(mCurrentDate.get(Calendar.YEAR)); mYearPickerView.setOnYearSelectedListener(mOnYearSelectedListener); // Set up content descriptions. mSelectDay = res.getString(R.string.select_day); mSelectYear = res.getString(R.string.select_year); // Initialize for current locale. This also initializes the date, so no // need to call onDateChanged. onLocaleChanged(mCurrentLocale); setCurrentView(VIEW_MONTH_DAY); }
Example 17
Source File: ITagsFragment.java From itag with GNU General Public License v3.0 | 4 votes |
private void updateState(@NonNull ViewGroup rootView, @NonNull String id, @NonNull BLEConnectionState state) { Activity activity = getActivity(); if (activity == null) return; // int statusDrawableId; int statusTextId; if (ble.state() == BLEState.OK) { switch (state) { case connected: statusDrawableId = R.drawable.bt; statusTextId = R.string.bt; break; case connecting: case disconnecting: ITagInterface itag = ITag.store.byId(id); if (itag != null && itag.isAlertDisconnected()) { statusDrawableId = R.drawable.bt_connecting; statusTextId = R.string.bt_lost; } else { statusDrawableId = R.drawable.bt_setup; if (state == BLEConnectionState.connecting) statusTextId = R.string.bt_connecting; else statusTextId = R.string.bt_disconnecting; } break; case writting: case reading: statusDrawableId = R.drawable.bt_call; statusTextId = R.string.bt_call; break; case disconnected: default: statusDrawableId = R.drawable.bt_disabled; statusTextId = R.string.bt_disabled; } } else { statusDrawableId = R.drawable.bt_disabled; statusTextId = R.string.bt_disabled; } final ImageView imgStatus = rootView.findViewById(R.id.bt_status); imgStatus.setImageResource(statusDrawableId); final TextView textStatus = rootView.findViewById(R.id.text_status); textStatus.setText(statusTextId); }
Example 18
Source File: HighLight.java From Highlight with Apache License 2.0 | 4 votes |
public HighLight addHighLight(int viewId, int decorLayoutId, OnPosCallback onPosCallback, LightShape lightShape) { ViewGroup parent = (ViewGroup) mAnchor; View view = parent.findViewById(viewId); addHighLight(view, decorLayoutId, onPosCallback, lightShape); return this; }
Example 19
Source File: BlackberryVolumePanel.java From Noyze with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.KITKAT) @Override public void onCreate() { super.onCreate(); Context context = getContext(); transition = TransitionCompat.get(); LayoutInflater inflater = LayoutInflater.from(context); root = (ViewGroup) inflater.inflate(R.layout.bb_volume_adjust, null); seekBar = (ProgressBar) root.findViewById(android.R.id.progress); icon = (ImageView) root.findViewById(R.id.stream_icon); divider = root.findViewById(R.id.divider); streamName = (TextView) root.findViewById(R.id.streamName); mediaContainer = (ViewGroup) root.findViewById(R.id.media_container); albumArtContainer = (ViewGroup) root.findViewById(R.id.album_art_container); albumArt = (ImageView) root.findViewById(R.id.album_art); albumArt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openMusic(); } }); artist = (TextView) root.findViewById(R.id.track_artist); song = (TextView) root.findViewById(R.id.track_song); musicPanel = (ViewGroup) root.findViewById(R.id.music_panel); attachPlaybackListeners(root, new MediaButtonClickListener()); playPause = (ImageButton) root.findViewById(R.id.media_play_pause); mBtnNext = (ImageButton) root.findViewById(R.id.media_next); mBtnPrev = (ImageButton) root.findViewById(R.id.media_previous); setEnableMarquee(true); // Make sure we don't seek! seekBar.setOnTouchListener(noTouchListener); // Launch settings if the stream icon is clicked. icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (view.getId() == R.id.stream_icon) { hide(); Intent volumeSettings = new Intent(Settings.ACTION_SOUND_SETTINGS); startActivity(volumeSettings); } } }); transition.beginDelayedTransition((ViewGroup) root.findViewById(R.id.slider_group)); mLayout = root; }
Example 20
Source File: DirectorySheet.java From Aria2App with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreateBody(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent, @NonNull SetupPayload payload) { inflater.inflate(R.layout.sheet_dir, parent, true); currentDir = payload.dir; final DownloadWithUpdate download = payload.download; SuperTextView indexes = parent.findViewById(R.id.dirSheet_indexes); indexes.setHtml(R.string.indexes, CommonUtils.join(currentDir.indexes, ", ")); SuperTextView path = parent.findViewById(R.id.dirSheet_path); path.setHtml(R.string.path, download.update().dir + currentDir.path); length = parent.findViewById(R.id.dirSheet_length); selected = parent.findViewById(R.id.dirSheet_selected); completedLength = parent.findViewById(R.id.dirSheet_completedLength); update(currentDir); if (download.update().canDeselectFiles()) { selected.setEnabled(true); selected.setOnCheckedChangeListener((buttonView, isChecked) -> download.changeSelection(currentDir.indexes.toArray(new Integer[0]), isChecked, new AbstractClient.OnResult<Download.ChangeSelectionResult>() { @Override public void onResult(@NonNull Download.ChangeSelectionResult result) { if (!isAdded()) return; Toaster toaster = Toaster.build(); toaster.extra(result); switch (result) { case EMPTY: toaster.message(R.string.cannotDeselectAllFiles); break; case SELECTED: toaster.message(R.string.fileSelected); break; case DESELECTED: toaster.message(R.string.fileDeselected); break; default: toaster.message(R.string.failedAction); break; } dismissAllowingStateLoss(); DialogUtils.showToast(getContext(), toaster); } @Override public void onException(@NonNull Exception ex) { if (!isAdded()) return; dismissAllowingStateLoss(); Log.e(TAG, "Failed changing selection.", ex); DialogUtils.showToast(getContext(), Toaster.build().message(R.string.failedFileChangeSelection)); } })); } else { selected.setEnabled(false); } isLoading(false); }