List of usage examples for android.view View getResources
public Resources getResources()
From source file:com.jet.sweettips.snackbar.SweetSnackbar.java
/** * Make a SweetSnackbar to display a message. * * <p>Snackbar will try and find a parent view to hold SweetSnackbar's view from the value given * to {@code view}. SweetSnackbar will walk up the view tree trying to find a suitable parent, * which is defined as a {@link CoordinatorLayout} or the window decor's content view, * whichever comes first.//ww w.java 2s. c o m * * <p>Having a {@link CoordinatorLayout} in your view hierarchy allows SweetSnackbar to enable * certain features, such as swipe-to-dismiss and automatically moving of widgets like * {@link FloatingActionButton}. * * @param view The view to find a parent from. * @param resId The resource id of the string resource to use. Can be formatted text. * @param duration How long to display the message. Either {@link #LENGTH_SHORT} or {@link * #LENGTH_LONG} */ @NonNull public static SweetSnackbar make(@NonNull View view, @StringRes int resId, @Duration int duration) { return make(view, view.getResources().getText(resId), duration); }
From source file:android.support.designox.widget.Snackbar.java
/** * Make a Snackbar to display a message. * <p/>/* ww w .j a v a 2 s. c om*/ * <p>Snackbar will try and find a parent view to hold Snackbar's view from the value given * to {@code view}. Snackbar will walk up the view tree trying to find a suitable parent, * which is defined as a {@link CoordinatorLayout} or the window decor's content view, * whichever comes first. * <p/> * <p>Having a {@link CoordinatorLayout} in your view hierarchy allows Snackbar to enable * certain features, such as swipe-to-dismiss and automatically moving of widgets like * {@link FloatingActionButton}. * * @param view The view to find a parent from. * @param resId The resource id of the string resource to use. Can be formatted text. * @param duration How long to display the message. Either {@link #LENGTH_SHORT} or {@link * #LENGTH_LONG} */ @NonNull public static Snackbar make(@NonNull View view, @StringRes int resId, @Duration int duration) { return make(view, view.getResources().getText(resId), duration); }
From source file:nu.yona.app.utils.AppUtils.java
public static boolean checkKeyboardOpen(View view) { int defaultKeyboardDp = 100; Rect r = new Rect(); view.getWindowVisibleDisplayFrame(r); int estimatedKeyboardHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, defaultKeyboardDp, view.getResources().getDisplayMetrics()); view.getWindowVisibleDisplayFrame(r); int heightDiff = view.getRootView().getHeight() - (r.bottom - r.top); return heightDiff > estimatedKeyboardHeight; }
From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java
public static Drawable getDrawableByName(View view, String name) { Resources resources = view.getResources(); return resources.getDrawable(resources.getIdentifier(name, "drawable", view.getContext().getPackageName())); }
From source file:com.jekyll.wu.widget.FreeSnackBar.java
/** * Make a FreeSnackBar to display a message. * <p>/*w ww . j a v a 2 s . c om*/ * <p>FreeSnackBar will try and find a parent view to hold FreeSnackBar's view from the value given * to {@code view}. FreeSnackBar will walk up the view tree trying to find a suitable parent, * which is defined as a {@link CoordinatorLayout} or the window decor's content view, * whichever comes first. * <p> * <p>Having a {@link CoordinatorLayout} in your view hierarchy allows FreeSnackBar to enable * certain features, such as swipe-to-dismiss and automatically moving of widgets like * {@link FloatingActionButton}. * * @param view The view to find a parent from. * @param resId The resource id of the string resource to use. Can be formatted text. * @param duration How long to display the message. Either {@link #LENGTH_SHORT} or {@link * #LENGTH_LONG} */ @NonNull public static FreeSnackBar make(@NonNull View view, @StringRes int resId, @Duration int duration) { return make(view, view.getResources().getText(resId), duration); }
From source file:com.jekyll.wu.widget.FreeSnackBar.java
@NonNull public static FreeSnackBar make(@NonNull View view, @StringRes int resId, @Gravity int gravity, @Duration int duration) { return make(view, view.getResources().getText(resId), gravity, duration); }
From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java
public static int parseColor(View view, String text) { if (text.startsWith("@color/")) { Resources resources = view.getResources(); return resources.getColor(resources.getIdentifier(text.substring("@color/".length()), "color", view.getContext().getPackageName())); }//w w w . j a va 2 s . com if (text.length() == 4 && text.startsWith("#")) { text = "#" + text.charAt(1) + text.charAt(1) + text.charAt(2) + text.charAt(2) + text.charAt(3) + text.charAt(3); } return Color.parseColor(text); }
From source file:com.github.topbottomsnackbar.TBSnackbar.java
/** * Make a TBSnackbar to display a message. *Having a {@link CoordinatorLayout} in your view hierarchy allows TBSnackbar to enable * certain features, such as swipe-to-dismiss and automatically moving of widgets like * * * @param view The view to find a parent from. * @param resId The resource id of the string resource to use. Can be formatted text. * @param duration How long to display the message. Either {@link #LENGTH_SHORT} or {@link * #LENGTH_LONG}/*from w w w .j a v a 2 s .co m*/ */ @NonNull public static TBSnackbar make(@NonNull View view, @StringRes int resId, @Duration int duration, @Style int style) { return make(view, view.getResources().getText(resId), duration, style); }
From source file:com.box.myview.MyTopSnackBar.TSnackbar.java
/** * Make a TSnackbar to display a message. * <p/>// w w w. ja va2 s .c o m * <p>TSnackbar will try and find a parent view to hold TSnackbar's view from the value given * to {@code view}. TSnackbar will walk up the view tree trying to find a suitable parent, * which is defined as a {@link CoordinatorLayout} or the window decor's content view, * whichever comes first. * <p/> * <p>Having a {@link CoordinatorLayout} in your view hierarchy allows TSnackbar to enable * certain features, such as swipe-to-dismiss and automatically moving of widgets like * {@link FloatingActionButton}. * * @param view The view to find a parent from. * @param resId The resource id of the string resource to use. Can be formatted text. * @param duration How long to display the message. Either {@link #LENGTH_SHORT} or {@link * #LENGTH_LONG} */ @NonNull public static TSnackbar make(@NonNull View view, @StringRes int resId, @Duration int duration) { return make(view, view.getResources().getText(resId), duration); }
From source file:com.example.d062654.faciliman._1f_FacilityLogin.java
@Override public void onClick(View v) { final View view = v; if (v.getResources().getResourceName(v.getId()).substring(30).contentEquals("id/fac_login")) { Call<ResponseBody> call = Connection.getApiInterface().getLogin(facusername.getText().toString(), facpassword.getText().toString()); call.enqueue(new Callback<ResponseBody>() { @Override/*from w w w.j a va2 s .co m*/ public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { if (response.isSuccessful()) { // Do awesome stuff Toast.makeText(ll.getContext(), view.getResources().getResourceName(view.getId()), Toast.LENGTH_SHORT).show(); FragmentTransaction transaction = fragact.getSupportFragmentManager().beginTransaction(); _2f_FacilityView newFragment = new _2f_FacilityView(); newFragment.username = facusername.getText().toString(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack so the user can navigate back transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); } else if (response.code() == 401) { // Handle unauthorized } else { // Handle other responses } } @Override public void onFailure(Call<ResponseBody> call, Throwable t) { // Log error here since request failed Log.e(TAG, t.toString()); } }); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack so the user can navigate back //transaction.replace(R.id.fragment_container, newFragment); //transaction.addToBackStack(null); // Commit the transaction //transaction.commit(); } }