List of usage examples for android.view View getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:Main.java
public static Rect getLocationInView(View parent, View child) { if (child == null || parent == null) { throw new IllegalArgumentException("parent and child can not be null ."); }// ww w. j a va 2s.co m View decorView = null; Context context = child.getContext(); if (context instanceof Activity) { decorView = ((Activity) context).getWindow().getDecorView(); } Rect result = new Rect(); Rect tmpRect = new Rect(); View tmp = child; if (child == parent) { child.getHitRect(result); return result; } while (tmp != decorView && tmp != parent) { tmp.getHitRect(tmpRect); if (!tmp.getClass().equals(FRAGMENT_CON)) { result.left += tmpRect.left; result.top += tmpRect.top; } tmp = (View) tmp.getParent(); } result.right = result.left + child.getMeasuredWidth(); result.bottom = result.top + child.getMeasuredHeight(); return result; }
From source file:com.aoppp.gatewaymaster.dialogs.DialogUtil.java
/** * ??FragmentView//from ww w .j a v a 2s.c o m * * @param view */ public static void removeDialog(View view) { removeDialog(view.getContext()); ViewUtil.removeSelfFromParent(view); }
From source file:Main.java
public static void showSoftKeyboard(View view) { if (view == null) return;/*from w ww. jav a2 s . c om*/ view.setFocusable(true); view.setFocusableInTouchMode(true); if (!view.isFocused()) view.requestFocus(); InputMethodManager inputMethodManager = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.showSoftInput(view, 0); }
From source file:com.ada.utils.Ui.java
public static void showSoftkeyboard(View view, ResultReceiver resultReceiver) { Configuration config = view.getContext().getResources().getConfiguration(); if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) { InputMethodManager imm = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (resultReceiver != null) { imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT, resultReceiver); } else {/*from www . ja va2s .c om*/ imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); } } }
From source file:com.daycle.daycleapp.custom.swipelistview.itemmanipulation.dragdrop.BitmapUtils.java
/** * Returns a bitmap showing a screenshot of the view passed in. */// w ww .ja v a 2 s. c o m @NonNull static Bitmap getBitmapFromView(@NonNull final View v) { Bitmap bitmap = Bitmap.createBitmap(v.getMeasuredWidth(), v.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint p = new Paint(); p.setColor(ContextCompat.getColor(v.getContext(), R.color.colorAccent)); p.setAlpha(50); //v.setBackgroundColor(ContextCompat.getColor(v.getContext(), android.R.color.transparent)); v.draw(canvas); //canvas.drawCircle((float)(v.getWidth() / 2), (float)(v.getHeight() / 2), 10, p); canvas.drawRect(new Rect(0, 0, v.getWidth(), v.getHeight()), p); return bitmap; }
From source file:Main.java
/** * Applies a fade in animation and set the visibility in * {@link View#VISIBLE}.//from ww w. j av a2 s.c o m * @param view view to animate. */ public static void fadeInView(final View view) { if (view.getVisibility() != View.VISIBLE) { cancelAnimation(view); view.setVisibility(View.VISIBLE); Animation animation = android.view.animation.AnimationUtils.loadAnimation(view.getContext(), android.R.anim.fade_in); animation.setFillEnabled(true); animation.setFillBefore(true); animation.setFillAfter(true); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { view.clearAnimation(); } @Override public void onAnimationRepeat(Animation animation) { } }); view.setAnimation(animation); animation.start(); } }
From source file:com.aoppp.gatewaymaster.dialogs.DialogUtil.java
/** * ?View.//from www. jav a 2 s . c o m * @param view ? */ public static AlertDialogFragment showAlertDialog(View view) { FragmentActivity activity = (FragmentActivity) view.getContext(); AlertDialogFragment newFragment = AlertDialogFragment.newInstance(0, null, null, view, null); FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); newFragment.show(ft, mDialogTag); return newFragment; }
From source file:com.aoppp.gatewaymaster.dialogs.DialogUtil.java
/** * ???dialog View.// w ww . ja v a 2 s.c om * @param icon * @param title ? * @param view ??? */ public static AlertDialogFragment showAlertDialog(int icon, String title, View view) { FragmentActivity activity = (FragmentActivity) view.getContext(); AlertDialogFragment newFragment = AlertDialogFragment.newInstance(icon, title, null, view, null); FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); newFragment.show(ft, mDialogTag); return newFragment; }
From source file:com.aoppp.gatewaymaster.dialogs.DialogUtil.java
/** * ???dialog View./*w w w . j a v a 2s .co m*/ * @param title ? * @param view ??? */ public static AlertDialogFragment showAlertDialog(String title, View view) { FragmentActivity activity = (FragmentActivity) view.getContext(); AlertDialogFragment newFragment = AlertDialogFragment.newInstance(0, title, null, view, null); FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); newFragment.show(ft, mDialogTag); return newFragment; }
From source file:com.flexible.flexibleadapter.utils.DrawableUtils.java
/** * Helper method to set the background depending on the android version * * @param view the view to apply the drawable * @param drawableRes drawable resource id * @since 5.0.0-rc1//w ww . j a va 2 s.c om */ public static void setBackgroundCompat(View view, @DrawableRes int drawableRes) { setBackgroundCompat(view, getDrawableCompat(view.getContext(), drawableRes)); }