Merge pull request #38 from TouchInstinct/bindable_vh
changes: add few wrappers for itemView.getResources and ContextCompat…
This commit is contained in:
commit
04f189e482
|
|
@ -19,8 +19,14 @@
|
|||
|
||||
package ru.touchin.roboswag.components.adapters;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
|
|
@ -61,6 +67,57 @@ public class BindableViewHolder extends RecyclerView.ViewHolder implements Lifec
|
|||
return viewById;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string value associated with a particular resource ID. It
|
||||
* will be stripped of any styled text information.
|
||||
*
|
||||
* @param resId The resource id to search for data;
|
||||
* @return String The string data associated with the resource.
|
||||
*/
|
||||
@NonNull
|
||||
public String getString(@StringRes final int resId) {
|
||||
return itemView.getResources().getString(resId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string value associated with a particular resource ID. It
|
||||
* will be stripped of any styled text information.
|
||||
*
|
||||
* @param resId The resource id to search for data;
|
||||
* @param formatArgs The format arguments that will be used for substitution.
|
||||
* @return String The string data associated with the resource.
|
||||
*/
|
||||
@NonNull
|
||||
public String getString(@StringRes final int resId, final Object... formatArgs) {
|
||||
return itemView.getResources().getString(resId, formatArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the color value associated with a particular resource ID.
|
||||
* Starting in {@link android.os.Build.VERSION_CODES#M}, the returned
|
||||
* color will be styled for the specified Context's theme.
|
||||
*
|
||||
* @param resId The resource id to search for data;
|
||||
* @return int A single color value in the form 0xAARRGGBB.
|
||||
*/
|
||||
@ColorInt
|
||||
public int getColor(@ColorRes final int resId) {
|
||||
return ContextCompat.getColor(itemView.getContext(), resId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a drawable object associated with a particular resource ID.
|
||||
* Starting in {@link android.os.Build.VERSION_CODES#LOLLIPOP}, the
|
||||
* returned drawable will be styled for the specified Context's theme.
|
||||
*
|
||||
* @param resId The resource id to search for data;
|
||||
* @return Drawable An object that can be used to draw this resource.
|
||||
*/
|
||||
@NonNull
|
||||
public Drawable getDrawable(@DrawableRes final int resId) {
|
||||
return ContextCompat.getDrawable(itemView.getContext(), resId);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T> Subscription bind(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue