Java Code Examples for androidx.databinding.DataBindingUtil#inflate()

The following examples show how to use androidx.databinding.DataBindingUtil#inflate() . 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: ViewSubjectsFragment.java    From edx-app-android with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    binding = DataBindingUtil.inflate(inflater, R.layout.fragment_view_subjects, container, false);

    initSubjectsGrid();
    initSubjectsSearch();

    if (savedInstanceState != null) {
        searchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
        if (!TextUtils.isEmpty(searchQuery)) {
            performSearch(searchQuery);
        }
    }

    analyticsRegistry.trackScreenView(Analytics.Screens.ALL_SUBJECTS);

    return binding.getRoot();
}
 
Example 2
Source File: ImageRow.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public ImageHolder onCreate(@NonNull ViewGroup parent, int count, ObservableField<String> imageSelector, String sectionRendering) {

        FormImageBinding binding = DataBindingUtil.inflate(inflater, R.layout.form_image, parent, false);

        Integer height = null;
        Integer parentHeight = parent.getHeight();
        if (sectionRendering != null && sectionRendering.equals(ProgramStageSectionRenderingType.SEQUENTIAL.name())) {
            height = parentHeight / (count > 2 ? 3 : count);
        } else if (sectionRendering != null && sectionRendering.equals(ProgramStageSectionRenderingType.MATRIX.name())) {
            height = parentHeight / (count / 2 + 1);
        }

        View rootView = binding.getRoot();
        if (height != null) {
            ViewGroup.LayoutParams layoutParams = rootView.getLayoutParams();
            layoutParams.height = height;
            rootView.setLayoutParams(layoutParams);
        }

        return new ImageHolder(binding, processor, imageSelector);
    }
 
Example 3
Source File: SettingsFooter.java    From FirefoxReality with Mozilla Public License 2.0 6 votes vote down vote up
private void initialize(@NonNull Context aContext, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    LayoutInflater inflater = LayoutInflater.from(aContext);

    // Inflate this data binding layout
    mBinding = DataBindingUtil.inflate(inflater, R.layout.options_footer, this, true);

    TypedArray attributes = aContext.obtainStyledAttributes(attrs, R.styleable.SettingsFooter, defStyleAttr, defStyleRes);
    String buttonText = attributes.getString(R.styleable.SettingsFooter_buttonText);
    String description = attributes.getString(R.styleable.SettingsFooter_description);

    if (buttonText != null) {
        mBinding.resetButton.setButtonText(buttonText);
    }

    if (description != null) {
        mBinding.resetButton.setDescription(description);
    }
    attributes.recycle();
}
 
Example 4
Source File: ControllerOptionsView.java    From FirefoxReality with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected void updateUI() {
    super.updateUI();

    LayoutInflater inflater = LayoutInflater.from(getContext());

    // Inflate this data binding layout
    mBinding = DataBindingUtil.inflate(inflater, R.layout.options_controller, this, true);

    mScrollbar = mBinding.scrollbar;

    // Header
    mBinding.headerLayout.setBackClickListener(view -> onDismiss());

    // Footer
    mBinding.footerLayout.setFooterButtonClickListener(v -> resetOptions());

    int color = SettingsStore.getInstance(getContext()).getPointerColor();
    mBinding.pointerColorRadio.setOnCheckedChangeListener(mPointerColorListener);
    setPointerColor(mBinding.pointerColorRadio.getIdForValue(color), false);

    int scrollDirection = SettingsStore.getInstance(getContext()).getScrollDirection();
    mBinding.scrollDirectionRadio.setOnCheckedChangeListener(mScrollDirectionListener);
    setScrollDirection(mBinding.scrollDirectionRadio.getIdForValue(scrollDirection), false);
}
 
Example 5
Source File: SimpleBlurFragment.java    From Dali with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    FragmentSimpleBlurBinding binding = DataBindingUtil.inflate(inflater, R.layout.fragment_simple_blur, container, false);

    Dali dali = Dali.create(getActivity());

    final ImageView iv = binding.image;
    BlurBuilder.JobDescription jobDescription1 = dali.load(R.drawable.test_img1).placeholder(R.drawable.test_img1).blurRadius(12).colorFilter(Color.parseColor("#ff00529c")).concurrent().into(iv);
    binding.subtitle1.setText(jobDescription1.builderDescription);

    final ImageView iv2 = binding.image2;
    BlurBuilder.JobDescription jobDescription2 = dali.load(R.drawable.test_img1).placeholder(R.drawable.test_img1).blurRadius(12).brightness(0).concurrent().into(iv2);
    binding.subtitle2.setText(jobDescription2.builderDescription);

    final ImageView iv3 = binding.image3;
    BlurBuilder.JobDescription jobDescription3 = dali.load(R.drawable.test_img1).placeholder(R.drawable.test_img1).blurRadius(12).downScale(1).colorFilter(Color.parseColor("#ffccdceb")).concurrent().reScale().into(iv3);
    binding.subtitle3.setText(jobDescription3.builderDescription);

    final ImageView iv4 = binding.image4;
    BlurBuilder.JobDescription jobDescription4 = dali.load(R.drawable.test_img1).placeholder(R.drawable.test_img1).blurRadius(8).downScale(4).brightness(-40).concurrent().reScale().into(iv4);
    binding.subtitle4.setText(jobDescription4.builderDescription);

    return binding.getRoot();
}
 
Example 6
Source File: JiraFragment.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    FragmentJiraBinding binding = DataBindingUtil.inflate(inflater, R.layout.fragment_jira, container, false);
    jiraViewModel = ViewModelProviders.of(this).get(JiraViewModel.class);
    jiraViewModel.init(new PreferenceProviderImpl(context.getApplicationContext()));

    jiraViewModel.issueListResponse().observe(this, response -> {
        if (response.isSuccessful() && response.body() != null) {
            List<JiraIssue> issueList = new ArrayList<>();
            try {
                JiraIssueListResponse jiraIssueListRes = new Gson().fromJson(response.body().string(), JiraIssueListResponse.class);
                issueList = jiraIssueListRes.getIssues();
            } catch (IOException e) {
                e.printStackTrace();
            }
            adapter.addItems(issueList);
        } else
            displayMessage(response.message());
    });

    jiraViewModel.issueMessage().observe(this, message -> {
        if (!isEmpty(message))
            displayMessage(message);
    });

    binding.setJiraViewModel(jiraViewModel);
    binding.sendReportButton.setEnabled(NetworkUtils.isOnline(context));
    binding.issueRecycler.setAdapter(adapter);
    binding.issueRecycler.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));

    return binding.getRoot();
}
 
Example 7
Source File: HistoryAdapter.java    From Pixiv-Shaft with MIT License 5 votes vote down vote up
@Override
public ViewHolder<RecyViewHistoryBinding> getNormalItem(ViewGroup parent) {
    return new SpringHolder(
            DataBindingUtil.inflate(
                    LayoutInflater.from(mContext),
                    mLayoutID,
                    parent,
                    false
            )
    );
}
 
Example 8
Source File: DownloadsAdapter.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    DownloadItemBinding binding = DataBindingUtil
            .inflate(LayoutInflater.from(parent.getContext()), R.layout.download_item,
                    parent, false);
    binding.setCallback(mDownloadItemCallback);
    binding.setIsHovered(false);
    binding.setIsNarrow(mIsNarrowLayout);

    return new DownloadItemViewHolder(binding);
}
 
Example 9
Source File: ReservedValueAdapter.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NonNull
@Override
public ReservedValueViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
    ItemReservedValueBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_reserved_value, viewGroup, false);
    return new ReservedValueViewHolder(binding, presenter);
}
 
Example 10
Source File: TeiProgramListAdapter.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NonNull
@Override
public TeiProgramListEnrollmentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    ViewDataBinding binding;

    switch (viewType) {
        case TeiProgramListItem.TeiProgramListItemViewType.ALL_PROGRAMS_DASHBOARD:
            binding = DataBindingUtil.inflate(inflater, R.layout.item_tei_all_programs_dashboard_title, parent, false);
            break;
        case TeiProgramListItem.TeiProgramListItemViewType.FIRST_TITLE:
            binding = DataBindingUtil.inflate(inflater, R.layout.item_tei_programs_active_title, parent, false);
            break;
        case TeiProgramListItem.TeiProgramListItemViewType.ACTIVE_ENROLLMENT:
            binding = DataBindingUtil.inflate(inflater, R.layout.item_tei_programs_enrollment, parent, false);
            break;
        case TeiProgramListItem.TeiProgramListItemViewType.PROGRAM:
            binding = DataBindingUtil.inflate(inflater, R.layout.item_tei_programs_programs, parent, false);
            break;
        case TeiProgramListItem.TeiProgramListItemViewType.SECOND_TITLE:
            binding = DataBindingUtil.inflate(inflater, R.layout.item_tei_programs_inactive_title, parent, false);
            break;
        case TeiProgramListItem.TeiProgramListItemViewType.INACTIVE_ENROLLMENT:
            binding = DataBindingUtil.inflate(inflater, R.layout.item_tei_programs_enrollment_inactive, parent, false);
            break;
        case TeiProgramListItem.TeiProgramListItemViewType.THIRD_TITLE:
            binding = DataBindingUtil.inflate(inflater, R.layout.item_tei_programs_to_enroll_title, parent, false);
            break;
        case TeiProgramListItem.TeiProgramListItemViewType.PROGRAMS_TO_ENROLL:
            binding = DataBindingUtil.inflate(inflater, R.layout.item_tei_programs_programs, parent, false);
            break;
        default:
            binding = DataBindingUtil.inflate(inflater, R.layout.item_tei_programs_enrollment, parent, false);
            break;
    }

    return new TeiProgramListEnrollmentViewHolder(binding);
}
 
Example 11
Source File: ThreadAdapter.java    From lttrs-android with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public AbstractThreadItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    if (viewType == ITEM_VIEW_TYPE) {
        return new ThreadItemViewHolder(DataBindingUtil.inflate(inflater, R.layout.email_item, parent, false));
    } else {
        return new ThreadHeaderViewHolder(DataBindingUtil.inflate(inflater, R.layout.email_header, parent, false));
    }

}
 
Example 12
Source File: FieldViewFactory.java    From ground-android with Apache License 2.0 5 votes vote down vote up
/**
 * Inflates the view, generates a new view model and binds to the {@link ViewDataBinding}.
 *
 * @param fieldType Type of the field
 * @param root Parent layout
 * @return {@link ViewDataBinding}
 */
ViewDataBinding addFieldView(Field.Type fieldType, LinearLayout root) {
  ViewDataBinding binding =
      DataBindingUtil.inflate(fragment.getLayoutInflater(), getLayoutId(fieldType), root, true);
  binding.setLifecycleOwner(fragment);
  binding.setVariable(BR.viewModel, viewModelFactory.create(getViewModelClass(fieldType)));
  assignGeneratedId(binding.getRoot());
  return binding;
}
 
Example 13
Source File: LottieViewCreator.java    From LottieBottomNav with MIT License 5 votes vote down vote up
@NonNull
static LottieMenuItemBinding from(@NonNull ViewGroup parent,
                                  @NonNull MenuItem menuItem,
                                  boolean  isSelected,
                                  @NonNull Config config) {

    LayoutInflater inflater = LayoutInflater.from(parent.getContext());

    LottieMenuItemBinding binder = DataBindingUtil.inflate(inflater, R.layout.lottie_menu_item, parent, false);

    binder.lmiMenuText.setTypeface(menuItem.fontItem.getTypeface());

    binder.lmiMenuText.setText(menuItem.fontItem.getSpannableTitle());
    binder.lmiMenuText.setTextSize(TypedValue.COMPLEX_UNIT_SP, isSelected ? menuItem.fontItem.getSelectedTextSize()
            : menuItem.fontItem.getUnselectedTextSize());
    binder.lmiMenuText.setTextColor(isSelected ? menuItem.fontItem.getTextSelectedColor() :
            menuItem.fontItem.getTextUnselectedColor());

    setLottieView(binder.lmiMenuItem, menuItem, isSelected);

    ViewGroup.LayoutParams params = binder.lmiMenuItem.getLayoutParams();
    params.width = isSelected ? config.getSelectedMenuWidth() : config.getUnselectedMenuWidth();
    params.height = isSelected ? config.getSelectedMenuHeight() : config.getUnselectedMenuHeight();
    binder.lmiMenuItem.setLayoutParams(params);

    if(!config.isShowTextOnUnselected()) {
        binder.lmiMenuText.setVisibility(isSelected ? View.VISIBLE : View.INVISIBLE);
    }

    return binder;
}
 
Example 14
Source File: AbstractQueryFragment.java    From lttrs-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    final AbstractQueryViewModel viewModel = getQueryViewModel();
    this.binding = DataBindingUtil.inflate(inflater, R.layout.fragment_thread_list, container, false);

    setupAdapter(viewModel.getImportant());
    setupSelectionTracker(savedInstanceState);
    observeThreadOverviewItems(viewModel.getThreadOverviewItems());

    binding.setViewModel(viewModel);
    binding.setLifecycleOwner(getViewLifecycleOwner());
    binding.compose.setOnClickListener((v) -> {
        startActivity(new Intent(requireActivity(), ComposeActivity.class));
    });
    if (showComposeButton() && actionMode == null) {
        binding.compose.show();
    }

    binding.swipeToRefresh.setColorSchemeResources(R.color.colorAccent);
    binding.swipeToRefresh.setProgressBackgroundColorSchemeColor(
            ContextCompat.getColor(requireContext(), R.color.colorSurface)
    );

    //TODO: do we want to get rid of flicker on changes
    //((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);

    viewModel.isRunningPagingRequest().observe(getViewLifecycleOwner(), threadOverviewAdapter::setLoading);

    viewModel.getEmailModificationWorkInfo().observe(getViewLifecycleOwner(), this::emailModification);

    final QueryItemTouchHelper queryItemTouchHelper = new QueryItemTouchHelper();

    queryItemTouchHelper.setOnQueryItemSwipeListener(this);

    new ItemTouchHelper(queryItemTouchHelper).attachToRecyclerView(binding.threadList);

    return binding.getRoot();
}
 
Example 15
Source File: CoinDetailFragment.java    From CloudReader with Apache License 2.0 4 votes vote down vote up
private void initRefreshView() {
    headerBinding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.header_coin_detail, (ViewGroup) bindingView.xrvWan.getParent(), false);
    RefreshHelper.initLinear(bindingView.xrvWan, true, 1);
    bindingView.srlWan.setColorSchemeColors(CommonUtils.getColor(R.color.colorTheme));
    mAdapter = new CoinAdapter(activity, false);
    bindingView.xrvWan.setAdapter(mAdapter);
    bindingView.xrvWan.addHeaderView(headerBinding.getRoot());
    headerBinding.tvHeaderCoin.setVisibility(View.INVISIBLE);
    bindingView.srlWan.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            bindingView.xrvWan.postDelayed(new Runnable() {
                @Override
                public void run() {
                    viewModel.setPage(1);
                    getCoinLog();
                }
            }, 150);
        }
    });
    bindingView.xrvWan.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {
        @Override
        public void onLoadMore() {
            if (!bindingView.srlWan.isRefreshing()) {
                int page = viewModel.getPage();
                viewModel.setPage(++page);
                getCoinLog();
            } else {
                bindingView.xrvWan.loadMoreComplete();
            }
        }
    });
    UserUtil.getUserInfo(new OnUserInfoListener() {
        @Override
        public void onSuccess(User user) {
            if (user != null) {
                headerBinding.tvHeaderCoin.setText(String.valueOf(user.getCoinCount()));
            }
        }
    });
}
 
Example 16
Source File: BulkDownloadFragment.java    From edx-app-android with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    binding = DataBindingUtil.inflate(inflater, R.layout.row_bulk_download, container, false);
    return binding.getRoot();
}
 
Example 17
Source File: WebViewProgramInfoFragment.java    From edx-app-android with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    binding = DataBindingUtil.inflate(inflater, R.layout.fragment_webview, container, false);
    return binding.getRoot();
}
 
Example 18
Source File: DisplayOptionsView.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
@Override
protected void updateUI() {
    super.updateUI();

    LayoutInflater inflater = LayoutInflater.from(getContext());

    // Inflate this data binding layout
    mBinding = DataBindingUtil.inflate(inflater, R.layout.options_display, this, true);

    mScrollbar = mBinding.scrollbar;

    // Header
    mBinding.headerLayout.setBackClickListener(view -> onDismiss());

    // Footer
    mBinding.footerLayout.setFooterButtonClickListener(mResetListener);

    // Options
    mBinding.curvedDisplaySwitch.setOnCheckedChangeListener(mCurvedDisplayListener);
    setCurvedDisplay(SettingsStore.getInstance(getContext()).getCylinderDensity() > 0.0f, false);

    int uaMode = SettingsStore.getInstance(getContext()).getUaMode();
    mBinding.uaRadio.setOnCheckedChangeListener(mUaModeListener);
    setUaMode(mBinding.uaRadio.getIdForValue(uaMode), false);

    int msaaLevel = SettingsStore.getInstance(getContext()).getMSAALevel();
    mBinding.msaaRadio.setOnCheckedChangeListener(mMSSAChangeListener);
    setMSAAMode(mBinding.msaaRadio.getIdForValue(msaaLevel), false);

    mBinding.autoplaySwitch.setOnCheckedChangeListener(mAutoplayListener);
    setAutoplay(SettingsStore.getInstance(getContext()).isAutoplayEnabled(), false);

    mDefaultHomepageUrl = getContext().getString(R.string.homepage_url);

    mBinding.homepageEdit.setHint1(getContext().getString(R.string.homepage_hint, getContext().getString(R.string.app_name)));
    mBinding.homepageEdit.setDefaultFirstValue(mDefaultHomepageUrl);
    mBinding.homepageEdit.setFirstText(SettingsStore.getInstance(getContext()).getHomepage());
    mBinding.homepageEdit.setOnClickListener(mHomepageListener);
    setHomepage(SettingsStore.getInstance(getContext()).getHomepage());

    mBinding.densityEdit.setHint1(String.valueOf(SettingsStore.DISPLAY_DENSITY_DEFAULT));
    mBinding.densityEdit.setDefaultFirstValue(String.valueOf(SettingsStore.DISPLAY_DENSITY_DEFAULT));
    mBinding.densityEdit.setFirstText(Float.toString(SettingsStore.getInstance(getContext()).getDisplayDensity()));
    mBinding.densityEdit.setOnClickListener(mDensityListener);
    setDisplayDensity(SettingsStore.getInstance(getContext()).getDisplayDensity());

    mBinding.dpiEdit.setHint1(String.valueOf(SettingsStore.DISPLAY_DPI_DEFAULT));
    mBinding.dpiEdit.setDefaultFirstValue(String.valueOf(SettingsStore.DISPLAY_DPI_DEFAULT));
    mBinding.dpiEdit.setFirstText(Integer.toString(SettingsStore.getInstance(getContext()).getDisplayDpi()));
    mBinding.dpiEdit.setOnClickListener(mDpiListener);
    setDisplayDpi(SettingsStore.getInstance(getContext()).getDisplayDpi());
}
 
Example 19
Source File: VideoController.java    From AerialDream with GNU General Public License v3.0 4 votes vote down vote up
public VideoController(Context context) {
    LayoutInflater inflater = LayoutInflater.from(context);
    binding = DataBindingUtil.inflate(inflater, R.layout.aerial_dream, null, false);

    // Apply preferences
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    // Backwards compatibility
    String cache = prefs.getBoolean("cache", false) ? "-1" : "0";
    prefs.edit().remove("cache").apply();

    boolean showClock = prefs.getBoolean("show_clock", true);
    boolean showLocation = prefs.getBoolean("show_location", true);
    boolean showProgress = prefs.getBoolean("show_progress", false);
    int cacheSize = 0;//Integer.valueOf(prefs.getString("cache_size", cache));

    source_apple_2015 = prefs.getString("source_apple_2015", "all");
    source_apple_2017 = prefs.getString("source_apple_2017", "1080_sdr");
    source_apple_2018 = prefs.getString("source_apple_2018", "1080_sdr");
    source_apple_2019 = prefs.getString("source_apple_2019", "1080_sdr");

    binding.setShowLocation(showLocation);
    binding.setShowClock(showClock);
    binding.setShowProgress(showProgress);
    binding.setCacheSize(cacheSize);

    binding.videoView0.setController(binding.videoView0.videoView);
    binding.videoView1.setController(binding.videoView1.videoView);

    binding.videoView0.videoView.setOnPlayerListener(this);
    binding.videoView1.videoView.setOnPlayerListener(this);

    new VideoInteractor(
            context,
            !source_apple_2015.equals("disabled"),
            !source_apple_2017.equals("disabled"),
            !source_apple_2018.equals("disabled"),
            !source_apple_2019.equals("disabled"),
            this
    ).fetchVideos();
}
 
Example 20
Source File: BlockContactDialog.java    From Pix-Art-Messenger with GNU General Public License v3.0 4 votes vote down vote up
public static void show(final XmppActivity xmppActivity, final Blockable blockable) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(xmppActivity);
    final boolean isBlocked = blockable.isBlocked();
    builder.setNegativeButton(R.string.cancel, null);
    DialogBlockContactBinding binding = DataBindingUtil.inflate(xmppActivity.getLayoutInflater(), R.layout.dialog_block_contact, null, false);
    final boolean reporting = blockable.getAccount().getXmppConnection().getFeatures().spamReporting();
    binding.reportSpam.setVisibility(!isBlocked && reporting ? View.VISIBLE : View.GONE);
    builder.setView(binding.getRoot());

    final String value;
    @StringRes int res;
    if (blockable.getJid().isFullJid()) {
        builder.setTitle(isBlocked ? R.string.action_unblock_participant : R.string.action_block_participant);
        value = blockable.getJid().toEscapedString();
        res = isBlocked ? R.string.unblock_contact_text : R.string.block_contact_text;
    } else if (blockable.getJid().getLocal() == null || blockable.getAccount().isBlocked(blockable.getJid().getDomain())) {
        builder.setTitle(isBlocked ? R.string.action_unblock_domain : R.string.action_block_domain);
        value =blockable.getJid().getDomain().toEscapedString();
        res = isBlocked ? R.string.unblock_domain_text : R.string.block_domain_text;
    } else {
        int resBlockAction = blockable instanceof Conversation && ((Conversation) blockable).isWithStranger() ? R.string.block_stranger : R.string.action_block_contact;
        builder.setTitle(isBlocked ? R.string.action_unblock_contact : resBlockAction);
        value = blockable.getJid().asBareJid().toEscapedString();
        res = isBlocked ? R.string.unblock_contact_text : R.string.block_contact_text;
    }
    binding.text.setText(JidDialog.style(xmppActivity, res, value));
    builder.setPositiveButton(isBlocked ? R.string.unblock : R.string.block, (dialog, which) -> {
        if (isBlocked) {
            xmppActivity.xmppConnectionService.sendUnblockRequest(blockable);
        } else {
            boolean toastShown = false;
            if (xmppActivity.xmppConnectionService.sendBlockRequest(blockable, binding.reportSpam.isChecked())) {
                ToastCompat.makeText(xmppActivity, R.string.corresponding_conversations_closed, Toast.LENGTH_SHORT).show();
                toastShown = true;
            }
            if (xmppActivity instanceof ContactDetailsActivity) {
                if (!toastShown) {
                    ToastCompat.makeText(xmppActivity, R.string.contact_blocked_past_tense, Toast.LENGTH_SHORT).show();
                }
                xmppActivity.finish();
            }
        }
    });
    builder.create().show();
}