List of usage examples for android.view View getHandler
public Handler getHandler()
From source file:Main.java
public static void runOnViewThread(View view, Runnable runnable) { if (view.getHandler() == null || view.getHandler().getLooper() == null || view.getHandler().getLooper().getThread() == Thread.currentThread()) { runnable.run();/*ww w.j a v a 2s .co m*/ } else { view.post(runnable); } }
From source file:org.mozilla.gecko.animation.PropertyAnimator.java
private void invalidate(final ElementHolder element, final float delta) { final View view = element.view; // check to see if the view was detached between the check above and this code // getting run on the UI thread. if (view.getHandler() == null) return;//from w w w .j ava 2 s . c om if (element.property == Property.ALPHA) element.proxy.setAlpha(delta); else if (element.property == Property.TRANSLATION_Y) element.proxy.setTranslationY(delta); else if (element.property == Property.TRANSLATION_X) element.proxy.setTranslationX(delta); else if (element.property == Property.SCROLL_Y) element.proxy.scrollTo(element.proxy.getScrollX(), (int) delta); else if (element.property == Property.SCROLL_X) element.proxy.scrollTo((int) delta, element.proxy.getScrollY()); else if (element.property == Property.WIDTH) element.proxy.setWidth((int) delta); else if (element.property == Property.HEIGHT) element.proxy.setHeight((int) delta); }
From source file:com.freshdigitable.udonroad.ffab.IndicatableFFAB.java
public IndicatableFFAB(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final View v = View.inflate(context, R.layout.view_indicatable_ffab, this); indicator = (ActionIndicatorView) v.findViewById(R.id.iffab_indicator); ffab = (FlingableFAB) v.findViewById(R.id.iffab_ffab); ViewCompat.setElevation(indicator, ffab.getCompatElevation()); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IndicatableFFAB, defStyleAttr, R.style.Widget_FFAB_IndicatableFFAB); try {/* w w w.j a v a 2 s . c o m*/ final Drawable fabIcon = a.getDrawable(R.styleable.IndicatableFFAB_fabIcon); ffab.setImageDrawable(fabIcon); final int fabTint = a.getColor(R.styleable.IndicatableFFAB_fabTint, NO_ID); if (fabTint != NO_ID) { ViewCompat.setBackgroundTintList(ffab, ColorStateList.valueOf(fabTint)); } final int indicatorTint = a.getColor(R.styleable.IndicatableFFAB_indicatorTint, 0); indicator.setBackgroundColor(indicatorTint); indicatorMargin = a.getDimensionPixelSize(R.styleable.IndicatableFFAB_marginFabToIndicator, 0); } finally { a.recycle(); } ffab.setOnTouchListener(new OnTouchListener() { private MotionEvent old; @Override public boolean onTouch(View view, MotionEvent motionEvent) { final int action = motionEvent.getAction(); if (action == MotionEvent.ACTION_DOWN) { old = MotionEvent.obtain(motionEvent); onStart(); return false; } final Direction direction = Direction.getDirection(old, motionEvent); if (action == MotionEvent.ACTION_MOVE) { onMoving(direction); } else if (action == MotionEvent.ACTION_UP) { old.recycle(); onFling(view.getHandler()); } return false; } private Direction prevSelected = Direction.UNDEFINED; public void onStart() { indicator.onActionLeave(prevSelected); prevSelected = Direction.UNDEFINED; indicator.setVisibility(View.VISIBLE); } public void onMoving(Direction direction) { if (prevSelected == direction) { return; } indicator.onActionLeave(prevSelected); if (isDirectionEnabled(direction)) { indicator.onActionSelected(direction); } prevSelected = direction; } private boolean isDirectionEnabled(Direction direction) { for (Direction d : enableDirections) { if (d == direction) { return true; } } return false; } public void onFling(Handler handler) { handler.postDelayed(new Runnable() { @Override public void run() { indicator.setVisibility(View.INVISIBLE); } }, 200); } }); if (isInEditMode()) { indicator.setVisibility(VISIBLE); } }
From source file:org.navitproject.navit.Navit.java
@Override public void onResume() { super.onResume(); Log.d("Navit", "OnResume"); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { /* Required to make system bars fully transparent */ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); }//from w w w .j av a 2s . co m //InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // DEBUG // intent_data = "google.navigation:q=Wien Burggasse 27"; // intent_data = "google.navigation:q=48.25676,16.643"; // intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse"; // intent_data = "google.navigation:ll=48.25676,16.643"; if (startup_intent != null) { if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L) { Log.e("Navit", "**2**A " + startup_intent.getAction()); Log.e("Navit", "**2**D " + startup_intent.getDataString()); String navi_scheme = startup_intent.getScheme(); if (navi_scheme != null && navi_scheme.equals("google.navigation")) { parseNavigationURI(startup_intent.getData().getSchemeSpecificPart()); } } else { Log.e("Navit", "timestamp for navigate_to expired! not using data"); } } Log.d(TAG, "onResume"); if (show_soft_keyboard_now_showing) { /* Calling showNativeKeyboard() directly won't work here, we need to use the message queue */ View cf = getCurrentFocus(); if (cf == null) Log.e(TAG, "no view in focus, can't get a handler"); else cf.getHandler().post(new SoftInputRestorer()); } }