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();
}
});
}
}
}
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);
}
}
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);
}
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;
}
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);
}
Aggregations