@Test(expected = IllegalArgumentException.class) public void testSetFormattedDurationNegative() { BindingAdapters.setFormattedDuration( new TextView(RuntimeEnvironment.application), -1); }
@BindingAdapter("formattedDuration") public static void setFormattedDuration( @NonNull final TextView textView, final long seconds) { if (seconds < 0) { throw new IllegalArgumentException("Seconds must be a positive value"); } final int secondsInHour = 3600; final int secondsInMinute = 60; final String time; if (seconds >= secondsInHour) { time = String.format(Locale.US, "%d:%02d:%02d", seconds / secondsInHour, (seconds % secondsInHour) / secondsInMinute, seconds % secondsInMinute); } else { time = String.format(Locale.US, "%d:%02d", (seconds % secondsInHour) / secondsInMinute, seconds % secondsInMinute); } textView.setText(time); }
BindingAdapters { @BindingAdapter("formattedDuration") public static void setFormattedDuration( @NonNull final TextView textView, final long seconds) { if (seconds < 0) { throw new IllegalArgumentException("Seconds must be a positive value"); } final int secondsInHour = 3600; final int secondsInMinute = 60; final String time; if (seconds >= secondsInHour) { time = String.format(Locale.US, "%d:%02d:%02d", seconds / secondsInHour, (seconds % secondsInHour) / secondsInMinute, seconds % secondsInMinute); } else { time = String.format(Locale.US, "%d:%02d", (seconds % secondsInHour) / secondsInMinute, seconds % secondsInMinute); } textView.setText(time); } }
BindingAdapters { @BindingAdapter("formattedDuration") public static void setFormattedDuration( @NonNull final TextView textView, final long seconds) { if (seconds < 0) { throw new IllegalArgumentException("Seconds must be a positive value"); } final int secondsInHour = 3600; final int secondsInMinute = 60; final String time; if (seconds >= secondsInHour) { time = String.format(Locale.US, "%d:%02d:%02d", seconds / secondsInHour, (seconds % secondsInHour) / secondsInMinute, seconds % secondsInMinute); } else { time = String.format(Locale.US, "%d:%02d", (seconds % secondsInHour) / secondsInMinute, seconds % secondsInMinute); } textView.setText(time); } private  BindingAdapters(); }
BindingAdapters { @BindingAdapter("formattedDuration") public static void setFormattedDuration( @NonNull final TextView textView, final long seconds) { if (seconds < 0) { throw new IllegalArgumentException("Seconds must be a positive value"); } final int secondsInHour = 3600; final int secondsInMinute = 60; final String time; if (seconds >= secondsInHour) { time = String.format(Locale.US, "%d:%02d:%02d", seconds / secondsInHour, (seconds % secondsInHour) / secondsInMinute, seconds % secondsInMinute); } else { time = String.format(Locale.US, "%d:%02d", (seconds % secondsInHour) / secondsInMinute, seconds % secondsInMinute); } textView.setText(time); } private  BindingAdapters(); @NonNull static DataBindingComponent glideBindingComponent(
            @NonNull final RequestManager requestManager); @BindingAdapter("formattedDuration") static void setFormattedDuration(
            @NonNull final TextView textView,
            final long seconds); @BindingAdapter("recyclerAdapter") static void setRecyclerAdapter(
            @NonNull final RecyclerView recyclerView,
            @Nullable final RecyclerView.Adapter<?> adapter); @BindingAdapter({"drawableTop", "tintAttr"}) static void setDrawableTopTintedFromAttr(
            @NonNull final TextView textView,
            @Nullable Drawable top,
            @AttrRes final int tintAttr); @BindingAdapter({"srcRes", "tintAttr"}) static void setSrcResTintedFromAttr(
            @NonNull final ImageView imageView,
            @DrawableRes final int res,
            @AttrRes final int tintAttr); @BindingAdapter({"src", "tintAttr"}) static void setSrcTintedFromAttr(
            @NonNull final ImageView imageView,
            @Nullable Drawable src,
            @AttrRes final int tintAttr); @BindingAdapter({"src", "tintNormal", "useActivatedSrcTint"}) static void setUseActivatedSrcTint(
            @NonNull final ImageView imageView,
            @Nullable final Drawable src,
            @ColorInt final int tintNormal,
            final boolean useActivatedSrcTint); @BindingAdapter("activated") static void setActivated(@NonNull final View view, final boolean activated); @BindingAdapter("srcRes") static void setImageResource(
            @NonNull final ImageView imageView,
            @DrawableRes final int src); @BindingAdapter("colorFilter") static void setColorFiler(
            @NonNull final ImageView imageView,
            @ColorInt final int color); }
BindingAdapters { @BindingAdapter("formattedDuration") public static void setFormattedDuration( @NonNull final TextView textView, final long seconds) { if (seconds < 0) { throw new IllegalArgumentException("Seconds must be a positive value"); } final int secondsInHour = 3600; final int secondsInMinute = 60; final String time; if (seconds >= secondsInHour) { time = String.format(Locale.US, "%d:%02d:%02d", seconds / secondsInHour, (seconds % secondsInHour) / secondsInMinute, seconds % secondsInMinute); } else { time = String.format(Locale.US, "%d:%02d", (seconds % secondsInHour) / secondsInMinute, seconds % secondsInMinute); } textView.setText(time); } private  BindingAdapters(); @NonNull static DataBindingComponent glideBindingComponent(
            @NonNull final RequestManager requestManager); @BindingAdapter("formattedDuration") static void setFormattedDuration(
            @NonNull final TextView textView,
            final long seconds); @BindingAdapter("recyclerAdapter") static void setRecyclerAdapter(
            @NonNull final RecyclerView recyclerView,
            @Nullable final RecyclerView.Adapter<?> adapter); @BindingAdapter({"drawableTop", "tintAttr"}) static void setDrawableTopTintedFromAttr(
            @NonNull final TextView textView,
            @Nullable Drawable top,
            @AttrRes final int tintAttr); @BindingAdapter({"srcRes", "tintAttr"}) static void setSrcResTintedFromAttr(
            @NonNull final ImageView imageView,
            @DrawableRes final int res,
            @AttrRes final int tintAttr); @BindingAdapter({"src", "tintAttr"}) static void setSrcTintedFromAttr(
            @NonNull final ImageView imageView,
            @Nullable Drawable src,
            @AttrRes final int tintAttr); @BindingAdapter({"src", "tintNormal", "useActivatedSrcTint"}) static void setUseActivatedSrcTint(
            @NonNull final ImageView imageView,
            @Nullable final Drawable src,
            @ColorInt final int tintNormal,
            final boolean useActivatedSrcTint); @BindingAdapter("activated") static void setActivated(@NonNull final View view, final boolean activated); @BindingAdapter("srcRes") static void setImageResource(
            @NonNull final ImageView imageView,
            @DrawableRes final int src); @BindingAdapter("colorFilter") static void setColorFiler(
            @NonNull final ImageView imageView,
            @ColorInt final int color);  }