本文整理汇总了Java中com.jakewharton.rxbinding.widget.RxTextView类的典型用法代码示例。如果您正苦于以下问题:Java RxTextView类的具体用法?Java RxTextView怎么用?Java RxTextView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RxTextView类属于com.jakewharton.rxbinding.widget包,在下文中一共展示了RxTextView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editTextValueOnOk
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@CheckResult
@NonNull
public static Observable<String> editTextValueOnOk(@NonNull RxAlertDialog rxAlertDialog,
@NonNull String initialText,
@IdRes int customEditTextViewId) {
final EditText text = checkNotNull(rxAlertDialog.getCustomView())
.findViewById(customEditTextViewId);
text.setText(initialText);
text.setOnKeyListener((v, keyCode, event) -> {
if (isEnterClicked(event)) {
finishDialog(rxAlertDialog);
}
return false;
});
text.setSelection(text.length());
showSoftInputUntilItsShown(text);
RxTextView.editorActions(text)
.filter(actionId -> actionId == EditorInfo.IME_ACTION_DONE)
.subscribe(actionId1 -> finishDialog(rxAlertDialog));
return rxAlertDialog.observePositiveClick()
.map(aVoid -> text.getText().toString());
}
示例2: bind
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
private void bind(int position) {
Item holder = mItems.get(position);
DisplayableCalculation calculation = mCalculations.get(position);
holder.tviName.setText(calculation.getName());
holder.tviWeight.setText(calculation.getWeight());
holder.eteGrade.setText(calculation.getGrade());
holder.eteGrade.setEnabled(calculation.isEditingEnabled());
int editTextColor = calculation.hasError() ? R.color.red : R.color.secondary_text;
holder.eteGrade.setTextColor(ContextCompat.getColor(mContext,editTextColor));
holder.eteGrade.setSelection(holder.eteGrade.getText().length());
if(mListener!=null){
RxTextView.afterTextChangeEvents(holder.eteGrade)
.map(input -> input.editable().toString())
.debounce(100, TimeUnit.MILLISECONDS)
.subscribe(text -> {
boolean hasChanged = !text.equals(calculation.getGrade());
calculation.setGrade(text);
if(hasChanged)
mListener.onCalculationModified(calculation,position);
});
}
}
示例3: setData
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
public void setData(PackageItem data) {
String strTtime = "";
if(data.getActionDate() != null && !data.getActionDate().isEmpty()){
long timeStamp = DateUtils.strToTimeStamp(data.getActionDate());
strTtime = DateUtils.convertTimeToFormat(timeStamp);
}
if(data.getNickname() != null && !data.getNickname().isEmpty()){
Observable.just("包裹昵称:" + data.getNickname()).subscribe(RxTextView.text(mName));
}else{
Observable.just("运单号:"+data.getCarrierNo()).subscribe(RxTextView.text(mName));
}
if(data.getInventoryStatus() != null){
Observable.just(data.getWarehouseName()).subscribe(RxTextView.text(mWarehouse));
Observable.just("已入库"+" "+strTtime).subscribe(RxTextView.text(mStatus));
}else{
Observable.just(strTtime).subscribe(RxTextView.text(mWarehouse));
Observable.just(data.getInventoryStatus().getStatus()).subscribe(RxTextView.text(mStatus));
}
mSelect.setChecked(data.isChecked());
}
示例4: setData
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
public void setData(Order data) {
String strTtime = "";
if(!data.getOrStatusDate().isEmpty()){
long timeStamp = DateUtils.strToTimeStamp(data.getOrStatusDate());
strTtime = DateUtils.convertTimeToFormat(timeStamp);
}
if(data.getType() == 3){
Observable.just("合箱发货").subscribe(RxTextView.text(mName));
}else {
Observable.just(data.getInventorybasic().get(0).getNickname()).subscribe(RxTextView.text(mName));
}
Observable.just("邮客单号:"+data.getOrderNo()).subscribe(RxTextView.text(mNumber));
Observable.just(strTtime).subscribe(RxTextView.text(mTime));
Observable.just(data.getOrderStatus()).subscribe(RxTextView.text(mStatus));
}
示例5: setData
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
public void setData(WarehouseList data) {
mButton.setOnClickListener(this);
if (!data.getName().isEmpty() && data.getType() == 1){
mImge.setImageResource(R.mipmap.meiguo);
}else if (!data.getName().isEmpty() && data.getType() == 2){
mImge.setImageResource(R.mipmap.deguo);
}else if (!data.getName().isEmpty() && data.getType() == 3){
mImge.setImageResource(R.mipmap.riben);
}else if (!data.getName().isEmpty() && data.getType() == 4){
mImge.setImageResource(R.mipmap.aodaliya);
}
Observable.just(data.getName()).subscribe(RxTextView.text(mName));
Observable.just(data.getValue()).subscribe(RxTextView.text(mVaslue));
}
示例6: setData
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
public void setData(OrderPending data) {
String strTtime = "";
if(!data.getDate().isEmpty()){
long timeStamp = DateUtils.strToTimeStamp(data.getDate());
strTtime = DateUtils.convertTimeToFormat(timeStamp);
}
if(!data.getNickname().isEmpty()){
Observable.just("包裹昵称:" + data.getNickname()).subscribe(RxTextView.text(mName));
}else{
Observable.just("运单号:"+data.getNo()).subscribe(RxTextView.text(mName));
}
Observable.just("").subscribe(RxTextView.text(mGoods));
Observable.just(data.getWarehouseName()).subscribe(RxTextView.text(mTime));
Observable.just(data.getOrderStatus()+" "+strTtime).subscribe(RxTextView.text(mStatus));
}
示例7: onCreateDialog
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
View view = LayoutInflater.from(context).inflate(R.layout.new_item, null);
EditText name = findById(view, android.R.id.input);
Observable.combineLatest(createClicked, RxTextView.textChanges(name),
(ignored, text) -> text.toString())
.observeOn(Schedulers.io())
.subscribe(description -> {
insertTodoItem.bind(getListId(), description);
db.executeInsert(insertTodoItem.table, insertTodoItem.program);
});
return new AlertDialog.Builder(context) //
.setTitle(R.string.new_item)
.setView(view)
.setPositiveButton(R.string.create, (dialog, which) -> createClicked.onNext("clicked"))
.setNegativeButton(R.string.cancel, (dialog, which) -> {})
.create();
}
示例8: onCreateDialog
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
View view = LayoutInflater.from(context).inflate(R.layout.new_list, null);
EditText name = findById(view, android.R.id.input);
Observable.combineLatest(createClicked, RxTextView.textChanges(name),
(ignored, text) -> text.toString())
.observeOn(Schedulers.io())
.subscribe(name1 -> {
insertTodoList.bind(name1);
db.executeInsert(insertTodoList.table, insertTodoList.program);
});
return new AlertDialog.Builder(context) //
.setTitle(R.string.new_list)
.setView(view)
.setPositiveButton(R.string.create, (dialog, which) -> createClicked.onNext("clicked"))
.setNegativeButton(R.string.cancel, (dialog, which) -> {})
.create();
}
示例9: onCreate
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String title = intent.getStringExtra("title");
String id = intent.getStringExtra("order_id");
CommentForm commentForm = new CommentForm();
ActionBar actionBar = getSupportActionBar();
if (!TextUtils.isEmpty(title) && actionBar != null) {
getSupportActionBar().setTitle(title);
}
if (!TextUtils.isEmpty(id))
commentForm.setOrder_id(id);
bind.setComment(commentForm);
RxTextView.textChanges(bind.etComment)
.map(charSequence -> 140 - charSequence.length())
.compose(bindToLifecycle())
.subscribe(integer -> bind.tvAbleCount
.setText(String.format(getString(R.string.commentFormat), integer)));
}
示例10: onCreate
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (AppPreferences.get().getProfile() != null) {
startActivity(new Intent(
GroooLoginActivity.this,
MainActivity.class));
finish();
return;
}
bind.setLoginForm(new AuthUser());
Observable.combineLatest(RxTextView.textChanges(bind.etUsername).skip(1)
, RxTextView.textChanges(bind.etPassword).skip(1)
, (charSequence, charSequence2) -> !TextUtils.isEmpty(charSequence) && !TextUtils.isEmpty(charSequence2))
.compose(bindToLifecycle())
.subscribe(aBoolean -> bind.btnLogin.setEnabled(aBoolean));
}
示例11: onCreate
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SearchDebounceBinding binding = DataBindingUtil.setContentView(this,
R.layout.activity_search_debounce);
adapter = new SearchAdapter(this);
RecyclerViewUtils.setLinearManagerAndAdapter(binding.recyclerView, adapter);
binding.recyclerView.addItemDecoration(DividerItemDecoration.newVertical(this,
R.dimen.list_divider_height, R.color.divider_color));
//[email protected]
//1,避免EditText没改变一次就请求一次.
//2,避免频繁的请求,多个导致结果顺序错乱,最终的结果也就有问题.
// 但是对于第二个问题,也不能彻底的解决. 比如停止输入400毫秒后,
// 那么肯定会开始请求Search接口, 但是用户又会输入新的关键字,
// 这个时候上个请求还没有返回, 新的请求又去请求Search接口.
// 这个时候有可能最后的一个请求返回, 第一个请求最后返回,导致搜索结果不是想要的.
//[email protected]
subscription = RxTextView.textChangeEvents(binding.inputSearch)
.debounce(400, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getSearchObserver());
}
示例12: onCreate
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
ButterKnife.bind(this);
presenter = new SplashActivityPresenter(this,new Validator());
textChangeSubscription = RxTextView.textChangeEvents(etUsername).subscribe(new Action1<TextViewTextChangeEvent>() {
@Override
public void call(TextViewTextChangeEvent textViewTextChangeEvent) {
presenter.username = textViewTextChangeEvent.text().toString();
etUsername.setError(null);
}
});
}
示例13: validateLoginForms
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
public void validateLoginForms(EditText emailEdit, EditText passEdit, OnFormEmitted listener) {
Observable<Boolean> emailObservable = RxTextView.textChanges(emailEdit)
.map(inputText -> inputText.toString().matches("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"))
.skip(1)
.distinctUntilChanged();
Observable<Boolean> passwordObservable = RxTextView.textChanges(passEdit)
.map(inputText -> inputText.toString().length() < 6)
.skip(1)
.distinctUntilChanged();
emailObservable.subscribe(listener::emailOnNext);
passwordObservable.subscribe(listener::passwordOnNext);
Observable.combineLatest(
emailObservable,
passwordObservable,
(emailValid, passValid) -> emailValid && !passValid)
.distinctUntilChanged()
.subscribe(listener::buttonChanged);
}
示例14: validateReactivateForms
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
public void validateReactivateForms(EditText emailEdit, EditText passEdit, OnFormEmitted listener) {
Observable<Boolean> emailObservable = RxTextView.textChanges(emailEdit)
.map(inputText -> inputText.toString().matches("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"))
.skip(1)
.distinctUntilChanged();
Observable<Boolean> passwordObservable = RxTextView.textChanges(passEdit)
.map(inputText -> inputText.toString().length() < 6)
.skip(1)
.distinctUntilChanged();
emailObservable.subscribe(listener::emailOnNext);
passwordObservable.subscribe(listener::passwordOnNext);
Observable.combineLatest(
emailObservable,
passwordObservable,
(emailValid, passValid) -> emailValid && !passValid)
.distinctUntilChanged()
.subscribe(listener::buttonChanged);
}
示例15: onCreateView
import com.jakewharton.rxbinding.widget.RxTextView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.fragment_form_validation_comb_latest,
container,
false);
ButterKnife.bind(this, layout);
emailChangeObservable = RxTextView.textChanges(email).skip(1);
passwordChangeObservable = RxTextView.textChanges(password).skip(1);
numberChangeObservable = RxTextView.textChanges(number).skip(1);
combineLatestEvents();
return layout;
}