Search in sources :

Example 26 with TransitionInflater

use of android.transition.TransitionInflater in project android_frameworks_base by crdroidandroid.

the class Fragment method loadTransition.

private static Transition loadTransition(Context context, TypedArray typedArray, Transition currentValue, Transition defaultValue, int id) {
    if (currentValue != defaultValue) {
        return currentValue;
    }
    int transitionId = typedArray.getResourceId(id, 0);
    Transition transition = defaultValue;
    if (transitionId != 0 && transitionId != com.android.internal.R.transition.no_transition) {
        TransitionInflater inflater = TransitionInflater.from(context);
        transition = inflater.inflateTransition(transitionId);
        if (transition instanceof TransitionSet && ((TransitionSet) transition).getTransitionCount() == 0) {
            transition = null;
        }
    }
    return transition;
}
Also used : TransitionSet(android.transition.TransitionSet) Transition(android.transition.Transition) TransitionInflater(android.transition.TransitionInflater)

Example 27 with TransitionInflater

use of android.transition.TransitionInflater in project android_frameworks_base by crdroidandroid.

the class ResourceLoadingTest method sendMessage.

public void sendMessage(View view) {
    if (mTransitionManager == null) {
        try {
            TransitionInflater inflater = TransitionInflater.from(this);
            mTransitionManager = inflater.inflateTransitionManager(R.transition.my_transition_mgr, mSceneRoot);
            Scene loadedScene = new Scene(mSceneRoot);
            System.out.println("loadedScene = " + loadedScene);
            Transition loadedTransition = inflater.inflateTransition(R.transition.my_transition);
            System.out.println("loadedTransition = " + loadedTransition);
        } catch (Exception e) {
            System.out.println("Problem loading scene resource: " + e);
        }
    }
    if (mCurrentScene == RESULTS_SCREEN) {
        Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
        mTransitionManager.transitionTo(scene);
        mCurrentScene = SEARCH_SCREEN;
    } else {
        Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
        mTransitionManager.transitionTo(scene);
        mCurrentScene = RESULTS_SCREEN;
    }
}
Also used : Transition(android.transition.Transition) TransitionInflater(android.transition.TransitionInflater) Scene(android.transition.Scene)

Example 28 with TransitionInflater

use of android.transition.TransitionInflater in project platform_frameworks_base by android.

the class ResourceLoadingTest method sendMessage.

public void sendMessage(View view) {
    if (mTransitionManager == null) {
        try {
            TransitionInflater inflater = TransitionInflater.from(this);
            mTransitionManager = inflater.inflateTransitionManager(R.transition.my_transition_mgr, mSceneRoot);
            Scene loadedScene = new Scene(mSceneRoot);
            System.out.println("loadedScene = " + loadedScene);
            Transition loadedTransition = inflater.inflateTransition(R.transition.my_transition);
            System.out.println("loadedTransition = " + loadedTransition);
        } catch (Exception e) {
            System.out.println("Problem loading scene resource: " + e);
        }
    }
    if (mCurrentScene == RESULTS_SCREEN) {
        Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.search_screen, this);
        mTransitionManager.transitionTo(scene);
        mCurrentScene = SEARCH_SCREEN;
    } else {
        Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.results_screen, this);
        mTransitionManager.transitionTo(scene);
        mCurrentScene = RESULTS_SCREEN;
    }
}
Also used : Transition(android.transition.Transition) TransitionInflater(android.transition.TransitionInflater) Scene(android.transition.Scene)

Example 29 with TransitionInflater

use of android.transition.TransitionInflater in project Signal-Android by WhisperSystems.

the class AvatarPreviewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState, boolean ready) {
    super.onCreate(savedInstanceState, ready);
    setTheme(R.style.TextSecure_MediaPreview);
    setContentView(R.layout.contact_photo_preview_activity);
    if (Build.VERSION.SDK_INT >= 21) {
        postponeEnterTransition();
        TransitionInflater inflater = TransitionInflater.from(this);
        getWindow().setSharedElementEnterTransition(inflater.inflateTransition(R.transition.full_screen_avatar_image_enter_transition_set));
        getWindow().setSharedElementReturnTransition(inflater.inflateTransition(R.transition.full_screen_avatar_image_return_transition_set));
    }
    Toolbar toolbar = findViewById(R.id.toolbar);
    EmojiTextView title = findViewById(R.id.title);
    ImageView avatar = findViewById(R.id.avatar);
    setSupportActionBar(toolbar);
    requireSupportActionBar().setDisplayHomeAsUpEnabled(true);
    requireSupportActionBar().setDisplayShowTitleEnabled(false);
    Context context = getApplicationContext();
    RecipientId recipientId = RecipientId.from(getIntent().getStringExtra(RECIPIENT_ID_EXTRA));
    Recipient.live(recipientId).observe(this, recipient -> {
        ContactPhoto contactPhoto = recipient.isSelf() ? new ProfileContactPhoto(recipient, recipient.getProfileAvatar()) : recipient.getContactPhoto();
        FallbackContactPhoto fallbackPhoto = recipient.isSelf() ? new ResourceContactPhoto(R.drawable.ic_profile_outline_40, R.drawable.ic_profile_outline_20, R.drawable.ic_person_large) : recipient.getFallbackContactPhoto();
        Resources resources = this.getResources();
        GlideApp.with(this).asBitmap().load(contactPhoto).fallback(fallbackPhoto.asCallCard(this)).error(fallbackPhoto.asCallCard(this)).diskCacheStrategy(DiskCacheStrategy.ALL).addListener(new RequestListener<Bitmap>() {

            @Override
            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
                Log.w(TAG, "Unable to load avatar, or avatar removed, closing");
                finish();
                return false;
            }

            @Override
            public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
                return false;
            }
        }).into(new CustomTarget<Bitmap>() {

            @Override
            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                avatar.setImageDrawable(RoundedBitmapDrawableFactory.create(resources, resource));
                if (Build.VERSION.SDK_INT >= 21) {
                    startPostponedEnterTransition();
                }
            }

            @Override
            public void onLoadCleared(@Nullable Drawable placeholder) {
            }
        });
        title.setText(recipient.getDisplayName(context));
    });
    FullscreenHelper fullscreenHelper = new FullscreenHelper(this);
    findViewById(android.R.id.content).setOnClickListener(v -> fullscreenHelper.toggleUiVisibility());
    fullscreenHelper.configureToolbarSpacer(findViewById(R.id.toolbar_cutout_spacer));
    fullscreenHelper.showAndHideWithSystemUI(getWindow(), findViewById(R.id.toolbar_layout));
}
Also used : Context(android.content.Context) ProfileContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) TransitionInflater(android.transition.TransitionInflater) ContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ContactPhoto) ProfileContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto) FallbackContactPhoto(org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto) ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) DataSource(com.bumptech.glide.load.DataSource) FallbackContactPhoto(org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto) CustomTarget(com.bumptech.glide.request.target.CustomTarget) Target(com.bumptech.glide.request.target.Target) Bitmap(android.graphics.Bitmap) ResourceContactPhoto(org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto) EmojiTextView(org.thoughtcrime.securesms.components.emoji.EmojiTextView) ImageView(android.widget.ImageView) Resources(android.content.res.Resources) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(androidx.annotation.Nullable) FullscreenHelper(org.thoughtcrime.securesms.util.FullscreenHelper) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

TransitionInflater (android.transition.TransitionInflater)29 Transition (android.transition.Transition)19 TransitionSet (android.transition.TransitionSet)15 TextView (android.widget.TextView)9 ImageView (android.widget.ImageView)6 TransitionManager (android.transition.TransitionManager)5 View (android.view.View)5 MenuView (com.android.internal.view.menu.MenuView)5 DecorContentParent (com.android.internal.widget.DecorContentParent)5 Scene (android.transition.Scene)4 Context (android.content.Context)1 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 Drawable (android.graphics.drawable.Drawable)1 Nullable (androidx.annotation.Nullable)1 Toolbar (androidx.appcompat.widget.Toolbar)1 DataSource (com.bumptech.glide.load.DataSource)1 GlideException (com.bumptech.glide.load.engine.GlideException)1 RequestListener (com.bumptech.glide.request.RequestListener)1 CustomTarget (com.bumptech.glide.request.target.CustomTarget)1