Search in sources :

Example 41 with UiThread

use of android.support.annotation.UiThread in project FastHub by k0shk0sh.

the class AnimHelper method revealPopupWindow.

@UiThread
public static void revealPopupWindow(@NonNull PopupWindow popupWindow, @NonNull View from) {
    Rect rect = ViewHelper.getLayoutPosition(from);
    int x = (int) rect.exactCenterX();
    int y = (int) rect.exactCenterY();
    if (popupWindow.getContentView() != null) {
        View view = popupWindow.getContentView();
        if (view != null) {
            popupWindow.showAsDropDown(from);
            view.post(() -> {
                if (ViewCompat.isAttachedToWindow(view)) {
                    Animator animator = ViewAnimationUtils.createCircularReveal(view, x, y, 0, (float) Math.hypot(rect.width(), rect.height()));
                    animator.setDuration(view.getResources().getInteger(android.R.integer.config_shortAnimTime));
                    animator.start();
                }
            });
        }
    }
}
Also used : Rect(android.graphics.Rect) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) View(android.view.View) UiThread(android.support.annotation.UiThread)

Example 42 with UiThread

use of android.support.annotation.UiThread in project simple-tool-tip by xizzhu.

the class ToolTipView method remove.

/**
 * Removes the tool tip view from the view hierarchy.
 */
@UiThread
public void remove() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
        container.setPivotX(pivotX);
        container.setPivotY(pivotY);
        container.animate().setDuration(ANIMATION_DURATION).alpha(0.0F).scaleX(0.0F).scaleY(0.0F).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                popupWindow.dismiss();
            }
        });
    } else {
        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setDuration(ANIMATION_DURATION);
        animationSet.addAnimation(new AlphaAnimation(1.0F, 0.0F));
        animationSet.addAnimation(new ScaleAnimation(1.0F, 0.0F, 1.0F, 0.0F, pivotX, pivotY));
        animationSet.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
            // do nothing
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                popupWindow.dismiss();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            // do nothing
            }
        });
        container.startAnimation(animationSet);
    }
}
Also used : Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ScaleAnimation(android.view.animation.ScaleAnimation) Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) UiThread(android.support.annotation.UiThread)

Example 43 with UiThread

use of android.support.annotation.UiThread in project Casty by DroidsOnRoids.

the class Casty method addMiniController.

/**
 * Adds the Mini Controller at the bottom of Activity's layout
 * Must be run on UiThread.
 */
@UiThread
public void addMiniController() {
    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
    View rootView = contentView.getChildAt(0);
    LinearLayout linearLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setLayoutParams(linearLayoutParams);
    contentView.removeView(rootView);
    ViewGroup.LayoutParams oldRootParams = rootView.getLayoutParams();
    LinearLayout.LayoutParams rootParams = new LinearLayout.LayoutParams(oldRootParams.width, 0, 1f);
    rootView.setLayoutParams(rootParams);
    linearLayout.addView(rootView);
    activity.getLayoutInflater().inflate(R.layout.mini_controller, linearLayout, true);
    activity.setContentView(linearLayout);
}
Also used : ViewGroup(android.view.ViewGroup) View(android.view.View) LinearLayout(android.widget.LinearLayout) UiThread(android.support.annotation.UiThread)

Example 44 with UiThread

use of android.support.annotation.UiThread in project Conductor by bluelinelabs.

the class Conductor method attachRouter.

/**
 * Conductor will create a {@link Router} that has been initialized for your Activity and containing ViewGroup.
 * If an existing {@link Router} is already associated with this Activity/ViewGroup pair, either in memory
 * or in the savedInstanceState, that router will be used and rebound instead of creating a new one with
 * an empty backstack.
 *
 * @param activity The Activity that will host the {@link Router} being attached.
 * @param container The ViewGroup in which the {@link Router}'s {@link Controller} views will be hosted
 * @param savedInstanceState The savedInstanceState passed into the hosting Activity's onCreate method. Used
 *                           for restoring the Router's state if possible.
 * @return A fully configured {@link Router} instance for use with this Activity/ViewGroup pair.
 */
@NonNull
@UiThread
public static Router attachRouter(@NonNull Activity activity, @NonNull ViewGroup container, @Nullable Bundle savedInstanceState) {
    ThreadUtils.ensureMainThread();
    LifecycleHandler lifecycleHandler = LifecycleHandler.install(activity);
    Router router = lifecycleHandler.getRouter(container, savedInstanceState);
    router.rebindIfNeeded();
    return router;
}
Also used : LifecycleHandler(com.bluelinelabs.conductor.internal.LifecycleHandler) UiThread(android.support.annotation.UiThread) NonNull(android.support.annotation.NonNull)

Example 45 with UiThread

use of android.support.annotation.UiThread in project Conductor by bluelinelabs.

the class Router method replaceTopController.

/**
 * Replaces this Router's top {@link Controller} with a new {@link Controller}
 *
 * @param transaction The transaction detailing what should be pushed, including the {@link Controller},
 *                    and its push and pop {@link ControllerChangeHandler}, and its tag.
 */
@SuppressWarnings("WeakerAccess")
@UiThread
public void replaceTopController(@NonNull RouterTransaction transaction) {
    ThreadUtils.ensureMainThread();
    RouterTransaction topTransaction = backstack.peek();
    if (!backstack.isEmpty()) {
        trackDestroyingController(backstack.pop());
    }
    final ControllerChangeHandler handler = transaction.pushChangeHandler();
    if (topTransaction != null) {
        // noinspection ConstantConditions
        final boolean oldHandlerRemovedViews = topTransaction.pushChangeHandler() == null || topTransaction.pushChangeHandler().removesFromViewOnPush();
        final boolean newHandlerRemovesViews = handler == null || handler.removesFromViewOnPush();
        if (!oldHandlerRemovedViews && newHandlerRemovesViews) {
            for (RouterTransaction visibleTransaction : getVisibleTransactions(backstack.iterator())) {
                performControllerChange(null, visibleTransaction, true, handler);
            }
        }
    }
    pushToBackstack(transaction);
    if (handler != null) {
        handler.setForceRemoveViewOnPush(true);
    }
    performControllerChange(transaction.pushChangeHandler(handler), topTransaction, true);
}
Also used : NoOpControllerChangeHandler(com.bluelinelabs.conductor.internal.NoOpControllerChangeHandler) UiThread(android.support.annotation.UiThread)

Aggregations

UiThread (android.support.annotation.UiThread)48 View (android.view.View)9 ObjectAnimator (android.animation.ObjectAnimator)6 Animator (android.animation.Animator)5 Drawable (android.graphics.drawable.Drawable)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 ArrayList (java.util.ArrayList)5 Intent (android.content.Intent)4 Fragment (android.support.v4.app.Fragment)4 MenuItem (android.view.MenuItem)4 ViewPropertyAnimator (android.view.ViewPropertyAnimator)4 Paint (android.graphics.Paint)3 Rect (android.graphics.Rect)3 DialogFragment (android.support.v4.app.DialogFragment)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 Location (android.location.Location)2 Bundle (android.os.Bundle)2 AlertDialog (android.support.v7.app.AlertDialog)2 RecyclerView (android.support.v7.widget.RecyclerView)2