本文整理匯總了Java中com.jakewharton.rxbinding2.view.RxView類的典型用法代碼示例。如果您正苦於以下問題:Java RxView類的具體用法?Java RxView怎麽用?Java RxView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RxView類屬於com.jakewharton.rxbinding2.view包,在下文中一共展示了RxView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onStart
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
@Override protected void onStart() {
super.onStart();
disposeOnStop(RxTextView.textChanges(etEmail)
.debounce(200, TimeUnit.MILLISECONDS)
.map(email -> new CheckEmailAction(email.toString()))
.subscribe(action -> store.dispatch(action)));
disposeOnStop(RxView.clicks(btSignIn)
.map(ignored -> new SubmitAction(
etEmail.getText().toString(),
etPassword.getText().toString()))
.subscribe(action -> store.dispatch(action)));
disposeOnStop(viewModel.idle().subscribe(ignored -> renderIdle()));
disposeOnStop(viewModel.loading().subscribe(ignored -> renderLoading()));
disposeOnStop(viewModel.success().subscribe(ignored -> renderSuccess()));
disposeOnStop(viewModel.error().subscribe(this::renderError));
}
示例2: onViewCreated
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
checkboxbinding =(CheckBox)view.findViewById(R.id.checkboxbinding);
btnrxhandler =(Button)view.findViewById(R.id.btn_rxhandler);
//Using RxBinding view
Disposable buttonSub = RxView.clicks(btnrxhandler)
.subscribe(new Consumer<Object>() {
@Override
public void accept(@NonNull Object o) throws Exception {
// do some work here
get_function_subscription();
}
});
// if Checkbox checked button is enable to click
RxCompoundButton.checkedChanges(checkboxbinding).subscribe(
RxView.enabled(btnrxhandler));
}
示例3: onCreateDialog
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
@NonNull
@Override
@SuppressLint("InflateParams")
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View root = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_login_guide, null);
View loginButton = root.findViewById(R.id.login_button);
RxView.clicks(loginButton)
.throttleFirst(RxUtils.WINDOW_DURATION, RxUtils.TIME_UNIT)
.subscribe(view -> {
dismiss();
startActivity(new Intent(getContext(), AuthActivity.class));
});
builder.setView(root);
return builder.create();
}
示例4: onCreate
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(getResources().getString(R.string.app_name));
setSupportActionBar(toolbar);
}
mAvatarPicker = AvatarPickBuilder.build(this, AVATAR_FILE_PROVIDER_AUTHORITY);
mProfileThumbnail = (ImageView) findViewById(R.id.user_profile_thumbnail);
mProgressBar = (ProgressBar) findViewById(R.id.loading_bar);
RxView
.clicks(mProfileThumbnail)
.throttleFirst(1, TimeUnit.SECONDS, AndroidSchedulers.mainThread())
.subscribe(o -> showPicturePickerMenuDialog());
renderImage("http://cfile25.uf.tistory.com/image/262EA640568FDABE08957B");
}
示例5: onRepeatRquest
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
public void onRepeatRquest(View view) {
//與rxbinding庫結合-從而避免重複請求,1s中內不再重複請求
//RxView.clicks(view).debounce(1,TimeUnit.SECONDS)
RxView.clicks(view).throttleFirst(1, TimeUnit.SECONDS).flatMap(new Function<Object, ObservableSource<ResultBean>>() {
@Override
public ObservableSource<ResultBean> apply(@NonNull Object o) throws Exception {
return EasyHttp.get("http://apis.juhe.cn/mobile/get")
.params("phone", "18688994275")
.params("dtype", "json")
.params("key", "5682c1f44a7f486e40f9720d6c97ffe4")
.execute(new CallClazzProxy<TestApiResult1<ResultBean>, ResultBean>(ResultBean.class) {
});
}
}).subscribe(new BaseSubscriber<ResultBean>() {
@Override
public void onError(ApiException e) {
showToast(e.getMessage());
}
@Override
public void onNext(@NonNull ResultBean resultBean) {
showToast(resultBean.toString());
}
});
}
示例6: showAddCheckPointDialog
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
@Override public void showAddCheckPointDialog() {
LatLng target = mMap.getCameraPosition().target;
AlertDialog.Builder builder = new AlertDialog.Builder(context);
View dialogView =
LayoutInflater.from(context).inflate(R.layout.set_checkpoint_dialog_view, null, false);
((TextView) dialogView.findViewById(R.id.check_point_lat_tv)).setText(
String.valueOf(target.latitude));
((TextView) dialogView.findViewById(R.id.check_point_long_tv)).setText(
String.valueOf(target.longitude));
EditText nameEditText = dialogView.findViewById(R.id.check_point_name_et);
AlertDialog alertDialog = builder.setView(dialogView).show();
RxView.clicks(dialogView.findViewById(R.id.set_checkpoint_done_btn)).subscribe(__ -> {
String enteredText = nameEditText.getText().toString();
if (enteredText.length() >= 4) {
locationPresenter.onSetCheckPoint(enteredText, target.latitude, target.longitude);
alertDialog.dismiss();
} else {
nameEditText.setError("Name should have minimum of 4 characters.");
}
});
RxView.clicks(dialogView.findViewById(R.id.set_checkpoint_cancel_btn))
.subscribe(__ -> alertDialog.dismiss());
}
示例7: setUpLogin
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
private void setUpLogin() {
Disposable disposable = RxView.clicks(loginButton)
.compose(rxActivityResults.composer(getLoginIntent()))
.filter(ActivityResult::isOk)
.map(ActivityResult::getData)
.subscribe(intent -> {
String firstName = intent.getStringExtra(LoginActivity.FIRST_NAME);
String lastName = intent.getStringExtra(LoginActivity.LAST_NAME);
String emailAddress = intent.getStringExtra(LoginActivity.EMAIL_ADDRESS);
String result = getString(R.string.first_name) + ": " + firstName + "\n"
+ getString(R.string.last_name) + ": " + lastName + "\n"
+ getString(R.string.email_address) + ": " + emailAddress + "\n";
loginInfoText.setText(result);
});
disposables.add(disposable);
}
示例8: initViews
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
private void initViews() {
//記得先在application中注冊
//如果您使用Fragment,請使用v4包的Fragment,否則將不會被notified
RxView.clicks(btnNormal)
.throttleFirst(500, TimeUnit.MILLISECONDS)
.subscribe(v -> this.startByNormal());
RxView.clicks(btnRx)
.throttleFirst(500, TimeUnit.MILLISECONDS)
.subscribe(v -> this.startByRxActivityResult());
RxView.clicks(btnCamera)
.throttleFirst(500, TimeUnit.MILLISECONDS)
.map(v -> new Intent(ACTION_IMAGE_CAPTURE))
.flatMap(intent -> RxActivityResult.on(this)
.startIntent(intent))
.map(Result::requestCode)
.subscribe(code -> {
tvResult.setText("requestCode = "+code);
});
}
示例9: onStart
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
@Override
protected void onStart() {
super.onStart();
compositeDisposable.add(RxView.clicks(binding.buttonDebounce)
.observeOn(Schedulers.computation())
.debounce(3, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(v -> binding.textDebounceResult.setText("Debounce Completed")));
compositeDisposable.add(RxView.clicks(binding.buttonSleep)
.observeOn(Schedulers.io())
.map(v -> {
SystemClock.sleep(3000L);
return v;
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(v -> binding.textSleepResult.setText("Sleep Completed")));
}
示例10: squareClicks
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
@Override
public Observable<BoardCoordinate> squareClicks() {
ArrayList<Observable<BoardCoordinate>> observables = new ArrayList<>();
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
final int finalI = i;
final int finalJ = j;
observables.add(
RxView.clicks(imageButtons[i][j])
.map(
new Function<Object, BoardCoordinate>() {
@Override
public BoardCoordinate apply(Object irrelevant) throws Exception {
return new BoardCoordinate(finalI, finalJ);
}
}));
}
}
return Observable.merge(observables);
}
示例11: startGameRequest
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
@Override
public Observable<GameKey> startGameRequest(List<? extends GameKey> gameKeys) {
List<Observable<GameKey>> observables = new ArrayList<>();
for (final GameKey gameKey : gameKeys) {
Button button = (Button) LayoutInflater.from(getContext()).inflate(R.layout.game_button, this, false);
button.setText(gameKey.gameName());
Observable<GameKey> observable = RxView
.clicks(button)
.map(new Function<Object, GameKey>() {
@Override
public GameKey apply(Object o) throws Exception {
return gameKey;
}
});
observables.add(observable);
addView(button);
}
return Observable.merge(observables);
}
示例12: createAccount
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
void createAccount() {
RxView
.clicks(accCreateBtn)
.compose(bindToLifecycle())
.subscribe(event -> {
String password = accPassword.getText().toString();
KeyStore keyStore = CredentialManager.getKeyStore();
Account account = keyStore.newAccount(password);
Toast.makeText(getApplicationContext(), "Create new account... address : " + account.getAddress().getHex(), Toast.LENGTH_SHORT).show();
Log.i(TAG, account.getAddress().getHex());
Log.i(TAG, account.getURL());
getAccountList();
}, err -> Log.e(TAG, err.getLocalizedMessage()));
}
示例13: deleteAccount
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
void deleteAccount() {
RxView
.clicks(delBtn)
.compose(bindToLifecycle())
.subscribe(event -> {
String password = accPassword.getText().toString();
int accNum = Integer.parseInt(delAccNum.getText().toString());
KeyStore keyStore = CredentialManager.getKeyStore();
Account account = keyStore.getAccounts().get(accNum);
Toast.makeText(getApplicationContext(), "Delete account... address : " + account.getAddress(), Toast.LENGTH_SHORT).show();
Log.i(TAG, account.getAddress().getHex());
Log.i(TAG, account.getURL());
keyStore.deleteAccount(account, password);
getAccountList();
}, err -> Log.e(TAG, err.getLocalizedMessage()));
}
示例14: checkBalance
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
void checkBalance() {
RxView
.clicks(accCheckAccBtn)
.compose(bindToLifecycle())
.flatMap(o -> {
int accNum = Integer.parseInt(delAccNum.getText().toString());
KeyStore keyStore = CredentialManager.getKeyStore();
Account account = keyStore.getAccounts().get(accNum);
return TransactionManager.getBalanceAt(account.getAddress());
})
.subscribe(balanceAt -> {
accBalTxt.setText("Balance of account is " + balanceAt);
Toast.makeText(getApplicationContext(), "Balance of account is " + balanceAt, Toast.LENGTH_SHORT).show();
Log.i(TAG, "balanceAt : " + balanceAt);
Log.i(TAG, "sub: run on thread " + Thread.currentThread().getName());
}, err -> Log.e(TAG, err.getLocalizedMessage()));
}
示例15: onBindViewHolder
import com.jakewharton.rxbinding2.view.RxView; //導入依賴的package包/類
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
// if (signinButtonDisposable != null) {
// signinButtonDisposable.dispose();
// }
AccountViewHolder viewHolder = (AccountViewHolder)holder;
viewHolder.bindingAccount(items.get(position));
signinButtonDisposable = RxView.clicks(viewHolder.getSignInButton())
.subscribe(o -> {
Fragment frag = new SignInFragment();
Bundle bundle = new Bundle();
bundle.putSerializable("account", items.get(position));
frag.setArguments(bundle);
observable.onNext(frag);
});
viewHolder.getSignInButton();
}