androidx.databinding.ObservableInt Java Examples

The following examples show how to use androidx.databinding.ObservableInt. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseLibraryActivityViewModel.java    From Jockey with Apache License 2.0 6 votes vote down vote up
public BaseLibraryActivityViewModel(Context context, boolean fitSystemWindows) {
    super(context);

    mFitSystemWindows = fitSystemWindows;
    mExpandedHeight = getDimensionPixelSize(R.dimen.miniplayer_height);
    mAnimateSlideInOut = false;

    mMiniplayerHeight = new ObservableInt(0);
    mMiniplayerAlpha = new ObservableFloat(1.0f);
    mNowPlayingToolbarAlpha = new ObservableFloat(0.0f);

    int backgroundColor = getColor(R.color.background);
    mNowPlayingBackground = new ColorDrawable(backgroundColor);

    setPlaybackOngoing(false);

    mMiniplayerHeight.addOnPropertyChangedCallback(new OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(androidx.databinding.Observable sender, int propertyId) {
            notifyPropertyChanged(BR.miniplayerShadowAlpha);
        }
    });
}
 
Example #2
Source File: TrayViewModel.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
public TrayViewModel(@NonNull Application application) {
    super(application);

    isMaxWindows = new MutableLiveData<>(new ObservableBoolean(true));
    shouldBeVisible = new MutableLiveData<>(new ObservableBoolean(true));
    isKeyboardVisible = new MutableLiveData<>(new ObservableBoolean(false));
    downloadsNumber = new MutableLiveData<>(new ObservableInt(0));
    isVisible = new MediatorLiveData<>();
    isVisible.addSource(shouldBeVisible, mIsVisibleObserver);
    isVisible.addSource(isKeyboardVisible, mIsVisibleObserver);
    isVisible.setValue(new ObservableBoolean(false));
}
 
Example #3
Source File: FeatureDetailsViewModel.java    From ground-android with Apache License 2.0 5 votes vote down vote up
@Inject
public FeatureDetailsViewModel() {
  featureTitle = new ObservableField<>();
  featureSubtitle = new ObservableField<>();
  featureSubtitleVisibility = new ObservableInt();
  selectedFeature = BehaviorProcessor.createDefault(Optional.empty());
}
 
Example #4
Source File: AlbumItemViewModel.java    From Jockey with Apache License 2.0 5 votes vote down vote up
private static void defaultColors(Context context, ObservableInt title, ObservableInt artist,
                                  ObservableInt background) {

    Resources res = context.getResources();
    Resources.Theme theme = context.getTheme();

    title.set(ResourcesCompat.getColor(res, R.color.grid_text, theme));
    artist.set(ResourcesCompat.getColor(res, R.color.grid_detail_text, theme));
    background.set(ResourcesCompat.getColor(res, R.color.grid_background_default, theme));
}
 
Example #5
Source File: NowPlayingControllerViewModel.java    From Jockey with Apache License 2.0 5 votes vote down vote up
public NowPlayingControllerViewModel(Context context, FragmentManager fragmentManager,
                                     PlayerController playerController, MusicStore musicStore,
                                     PlaylistStore playlistStore, ThemeStore themeStore) {
    super(context);
    mFragmentManager = fragmentManager;

    mPlayerController = playerController;
    mMusicStore = musicStore;
    mPlaylistStore = playlistStore;
    mThemeStore = themeStore;

    mCurrentPositionObservable = new ObservableInt();
    mSeekbarPosition = new ObservableInt();
}
 
Example #6
Source File: AlbumItemViewModel.java    From Jockey with Apache License 2.0 5 votes vote down vote up
public void setAlbum(Album album) {
    mAlbum = album;

    mArtistImage = new ObservableField<>();
    mTitleTextColor = new ObservableInt();
    mArtistTextColor = new ObservableInt();
    mBackgroundColor = new ObservableInt();

    defaultColors();

    if (mAlbum.getArtUri() != null) {
        int imageSize = mContext.getResources().getDimensionPixelSize(R.dimen.grid_width);

        Glide.with(mContext)
                .load(new File(mAlbum.getArtUri()))
                .placeholder(R.drawable.art_default)
                .error(R.drawable.art_default)
                .listener(new PaletteListener(mTitleTextColor, mArtistTextColor,
                        mBackgroundColor))
                .into(new ObservableTarget(imageSize, mArtistImage));
    } else {
        Drawable fallback = ResourcesCompat.getDrawable(mContext.getResources(),
                R.drawable.art_default, mContext.getTheme());

        mArtistImage.set(fallback);
    }

    notifyChange();
}
 
Example #7
Source File: AlbumItemViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
private void animateColorValue(ObservableInt target, @ColorInt int toColor) {
    ObjectAnimator.ofObject(target, "", new ArgbEvaluator(), target.get(), toColor)
            .setDuration(300)
            .start();
}
 
Example #8
Source File: WindowViewModel.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
@NonNull
public MutableLiveData<ObservableInt> getWidth() {
    return mWidth;
}
 
Example #9
Source File: AlbumItemViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
public PaletteListener(ObservableInt title, ObservableInt artist,
                       ObservableInt background) {
    mTitleTextColor = title;
    mArtistTextColor = artist;
    mBackgroundColor = background;
}
 
Example #10
Source File: AlbumItemViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
public ObservableInt getBackgroundColor() {
    return mBackgroundColor;
}
 
Example #11
Source File: AlbumItemViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
public ObservableInt getArtistTextColor() {
    return mArtistTextColor;
}
 
Example #12
Source File: AlbumItemViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
public ObservableInt getTitleTextColor() {
    return mTitleTextColor;
}
 
Example #13
Source File: NowPlayingControllerViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
public ObservableInt getCurrentPosition() {
    return mCurrentPositionObservable;
}
 
Example #14
Source File: NowPlayingControllerViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
public ObservableInt getSeekBarPosition() {
    return mSeekbarPosition;
}
 
Example #15
Source File: BaseLibraryActivityViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
@Bindable
public ObservableInt getMiniplayerHeight() {
    return mMiniplayerHeight;
}
 
Example #16
Source File: TrayViewModel.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
public MutableLiveData<ObservableInt> getDownloadsNumber() {
    return downloadsNumber;
}
 
Example #17
Source File: TrayViewModel.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
public void setDownloadsNumber(int number) {
    this.downloadsNumber.setValue(new ObservableInt(number));
}
 
Example #18
Source File: WindowViewModel.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
public void setHeight(int height) {
    this.mHeight.setValue(new ObservableInt(height));
}
 
Example #19
Source File: WindowViewModel.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
@NonNull
public MutableLiveData<ObservableInt> getHeight() {
    return mHeight;
}
 
Example #20
Source File: WindowViewModel.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
public void setWidth(int width) {
    this.mWidth.setValue(new ObservableInt(width));
}