Search in sources :

Example 1 with MultimediaFragment

use of com.android.incallui.sessiondata.MultimediaFragment in project android_packages_apps_Dialer by LineageOS.

the class AnswerFragment method updateDataFragment.

private void updateDataFragment() {
    if (!isAdded()) {
        return;
    }
    LogUtil.enterBlock("AnswerFragment.updateDataFragment");
    Fragment current = getChildFragmentManager().findFragmentById(R.id.incall_data_container);
    Fragment newFragment = null;
    MultimediaData multimediaData = getSessionData();
    if (multimediaData != null && (!TextUtils.isEmpty(multimediaData.getText()) || (multimediaData.getImageUri() != null) || (multimediaData.getLocation() != null && canShowMap()))) {
        // Need message fragment
        String subject = multimediaData.getText();
        Uri imageUri = multimediaData.getImageUri();
        Location location = multimediaData.getLocation();
        if (!(current instanceof MultimediaFragment) || !Objects.equals(((MultimediaFragment) current).getSubject(), subject) || !Objects.equals(((MultimediaFragment) current).getImageUri(), imageUri) || !Objects.equals(((MultimediaFragment) current).getLocation(), location)) {
            LogUtil.i("AnswerFragment.updateDataFragment", "Replacing multimedia fragment");
            // Needs replacement
            newFragment = MultimediaFragment.newInstance(multimediaData, false, /* isInteractive */
            !primaryInfo.isSpam, /* showAvatar */
            primaryInfo.isSpam);
        }
    } else if (shouldShowAvatar()) {
        // Needs Avatar
        if (!(current instanceof AvatarFragment)) {
            LogUtil.i("AnswerFragment.updateDataFragment", "Replacing avatar fragment");
            // Needs replacement
            newFragment = new AvatarFragment();
        }
    } else {
        // Needs empty
        if (current != null) {
            LogUtil.i("AnswerFragment.updateDataFragment", "Removing current fragment");
            getChildFragmentManager().beginTransaction().remove(current).commitNow();
        }
        contactGridManager.setAvatarImageView(null, 0, false);
    }
    if (newFragment != null) {
        getChildFragmentManager().beginTransaction().replace(R.id.incall_data_container, newFragment).commitNow();
    }
}
Also used : MultimediaData(com.android.dialer.multimedia.MultimediaData) MultimediaFragment(com.android.incallui.sessiondata.MultimediaFragment) MultimediaFragment(com.android.incallui.sessiondata.MultimediaFragment) Fragment(android.support.v4.app.Fragment) Uri(android.net.Uri) Location(android.location.Location)

Aggregations

Location (android.location.Location)1 Uri (android.net.Uri)1 Fragment (android.support.v4.app.Fragment)1 MultimediaData (com.android.dialer.multimedia.MultimediaData)1 MultimediaFragment (com.android.incallui.sessiondata.MultimediaFragment)1