Last active
December 2, 2016 03:04
-
-
Save cattaka/6aee27b0a0e93d0f8f40121551f0b2bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.wantedly.android.namecard_scanner.utils; | |
import android.support.v4.view.OnApplyWindowInsetsListener; | |
import android.support.v4.view.ViewCompat; | |
import android.support.v4.view.WindowInsetsCompat; | |
import android.view.View; | |
import rx.Observable; | |
import rx.subjects.BehaviorSubject; | |
/** | |
* These codes are licensed under CC0. | |
* <p/> | |
* Created by cattaka on 2016/10/13. | |
*/ | |
public class WindowInsetsSubject { | |
private OnApplyWindowInsetsListener mOnApplyWindowInsetsListener = new OnApplyWindowInsetsListener() { | |
@Override | |
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { | |
mBehaviorSubject.onNext(insets); | |
return insets; | |
} | |
}; | |
private BehaviorSubject<WindowInsetsCompat> mBehaviorSubject; | |
public WindowInsetsSubject() { | |
mBehaviorSubject = BehaviorSubject.create(); | |
} | |
public void attachView(View view) { | |
ViewCompat.setOnApplyWindowInsetsListener(view, mOnApplyWindowInsetsListener); | |
} | |
public Observable<WindowInsetsCompat> observable() { | |
return mBehaviorSubject; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment