com.jakewharton.rxbinding2.view.RxView Java Examples
The following examples show how to use
com.jakewharton.rxbinding2.view.RxView.
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: VideoViewBinder.java From Interessant with Apache License 2.0 | 6 votes |
@Override protected void onBindViewHolder(@NonNull Holder holder, @NonNull ItemList item) { holder.movieAlbum.setOriginalSize(16, 9); Glide.with(holder.movieAlbum.getContext()) .load(item.data.cover.detail) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .into(holder.movieAlbum); holder.movieDesc.setText(item.data.title); if (item.data.author != null) { holder.tag.setVisibility(View.VISIBLE); holder.tag.setText(item.data.author.name); } else { holder.tag.setVisibility(View.GONE); } RxView.clicks(holder.movieContent).throttleFirst(1000, TimeUnit.MILLISECONDS) .subscribe(aVoid -> { fly(holder.movieAlbum, item); }); }
Example #2
Source File: NotificationFragment.java From JianshuApp with GNU General Public License v3.0 | 6 votes |
private void initView() { mRecycler.setLayoutManager(new LinearLayoutManager(getContext())); mRecycler.setAdapter(new NotificationAdapter()); RxView.clicks(mIvNotificationSetting) .throttleFirst(1, TimeUnit.SECONDS) .observeOn(AndroidSchedulers.mainThread()) .compose(bindToLifecycle()) .subscribe(it -> { SettingNotificationActivity.launch(); }); RxView.clicks(mIvSearch) .throttleFirst(1, TimeUnit.SECONDS) .observeOn(AndroidSchedulers.mainThread()) .compose(bindToLifecycle()) .subscribe(it -> { SearchActivity.launch(); }); }
Example #3
Source File: MediaChannelViewBinder.java From Toutiao with Apache License 2.0 | 6 votes |
@Override protected void onBindViewHolder(@NonNull final ViewHolder holder, @NonNull final MediaChannelBean item) { try { final Context context = holder.itemView.getContext(); String url = item.getAvatar(); ImageLoader.loadCenterCrop(context, url, holder.cv_avatar, R.color.viewBackground); holder.tv_mediaName.setText(item.getName()); holder.tv_descText.setText(item.getDescText()); RxView.clicks(holder.itemView) .throttleFirst(1, TimeUnit.SECONDS) .subscribe(o -> MediaHomeActivity.launch(item.getId())); } catch (Exception e) { ErrorAction.print(e); } }
Example #4
Source File: WendaContentViewBinder.java From Toutiao with Apache License 2.0 | 6 votes |
@Override protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull final WendaContentBean.AnsListBean item) { try { String iv_user_avatar = item.getUser().getAvatar_url(); ImageLoader.loadCenterCrop(holder.itemView.getContext(), iv_user_avatar, holder.iv_user_avatar, R.color.viewBackground); String tv_user_name = item.getUser().getUname(); String tv_like_count = item.getDigg_count() + ""; String tv_abstract = item.getContent_abstract().getText(); holder.tv_user_name.setText(tv_user_name); holder.tv_like_count.setText(tv_like_count); holder.tv_abstract.setText(tv_abstract); RxView.clicks(holder.itemView) .throttleFirst(1, TimeUnit.SECONDS) .subscribe(o -> WendaDetailActivity.launch(item)); } catch (Exception e) { ErrorAction.print(e); } }
Example #5
Source File: WendaArticleTextViewBinder.java From Toutiao with Apache License 2.0 | 6 votes |
@Override protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull final WendaArticleDataBean item) { try { String tv_title = item.getQuestionBean().getTitle(); String tv_answer_count = item.getQuestionBean().getNormal_ans_count() + item.getQuestionBean().getNice_ans_count() + "回答"; String tv_datetime = item.getQuestionBean().getCreate_time() + ""; if (!TextUtils.isEmpty(tv_datetime)) { tv_datetime = TimeUtil.getTimeStampAgo(tv_datetime); } String tv_content = item.getAnswerBean().getAbstractX(); holder.tv_title.setText(tv_title); holder.tv_title.setTextSize(SettingUtil.getInstance().getTextSize()); holder.tv_answer_count.setText(tv_answer_count); holder.tv_time.setText(tv_datetime); holder.tv_content.setText(tv_content); RxView.clicks(holder.itemView) .throttleFirst(1, TimeUnit.SECONDS) .subscribe(o -> WendaContentActivity.launch(item.getQuestionBean().getQid() + "")); } catch (Exception e) { ErrorAction.print(e); } }
Example #6
Source File: MainActivity.java From Readhub with Apache License 2.0 | 6 votes |
@Override protected void initView() { ReadhubAdapter readhubAdapter = new ReadhubAdapter(getSupportFragmentManager()); vpReadHubList.setOffscreenPageLimit(3); vpReadHubList.setAdapter(readhubAdapter); tlReadHubList.setupWithViewPager(vpReadHubList); tlReadHubList.setTabMode(TabLayout.MODE_FIXED); tlReadHubList.setTabsFromPagerAdapter(readhubAdapter); RxView.clicks(ivSetting).subscribe(new Consumer<Object>() { @Override public void accept(Object o) throws Exception { Intent intent = new Intent(mContext, SettingActivity.class); startActivity(intent); } }); }
Example #7
Source File: WelcomeActivity.java From landlord_client with Apache License 2.0 | 6 votes |
private void init() { ivWelcome.setImageResource(R.mipmap.ic_default_bg); addDisposable( Flowable.interval(0, 1, TimeUnit.SECONDS) .map(aLong -> 5 - aLong) .take(6) .observeOn(AndroidSchedulers.mainThread()) .subscribe(aLong -> { tvCountDown.setText(aLong.toString()); if(aLong == 0) redirect(); }), RxView.clicks(llCountDown) .throttleFirst(3, TimeUnit.SECONDS) .subscribe(o -> redirect()) ); }
Example #8
Source File: RegistrationActivity.java From iroha-android with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_registration); SampleApplication.instance.getApplicationComponent().inject(this); registrationPresenter.setView(this); if (registrationPresenter.isRegistered()) { Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish(); } createProgressDialog(); RxView.clicks(binding.registerButton) .subscribe(view -> { showProgressDialog(); registrationPresenter.createAccount(binding.username.getText().toString().trim()); }); }
Example #9
Source File: LoginGuideDialog.java From Protein with Apache License 2.0 | 6 votes |
@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(); }
Example #10
Source File: SceneActivity.java From RxEasyHttp with Apache License 2.0 | 6 votes |
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()); } }); }
Example #11
Source File: TicTacToeView.java From RIBs with Apache License 2.0 | 6 votes |
@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); }
Example #12
Source File: LocationAlarmActivity.java From LocationAware with Apache License 2.0 | 6 votes |
@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()); }
Example #13
Source File: TicTacToeView.java From RIBs with Apache License 2.0 | 6 votes |
@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); }
Example #14
Source File: ActionController.java From science-journal with Apache License 2.0 | 6 votes |
/** * Updates the add note button for {@link TextNoteFragment} and {@link GalleryNoteFragment} when * a recording starts/stops. */ public void attachAddButton(FloatingActionButton button) { recordingStatus .takeUntil(RxView.detaches(button)) .subscribe( status -> { Theme theme = button.getContext().getTheme(); if (status.state.shouldShowStopButton()) { theme = new ContextThemeWrapper( button.getContext(), R.style.RecordingProgressBarColor).getTheme(); } button.setImageDrawable( ResourcesCompat.getDrawable( button.getResources(), R.drawable.ic_send_24dp, theme)); TypedValue iconColor = new TypedValue(); theme.resolveAttribute(R.attr.icon_color, iconColor, true); TypedValue iconBackground = new TypedValue(); theme.resolveAttribute(R.attr.icon_background, iconBackground, true); button.setBackgroundTintList(ColorStateList.valueOf( button.getResources().getColor(iconBackground.resourceId))); button.setRippleColor(button.getResources().getColor(iconColor.resourceId)); }); }
Example #15
Source File: ActionController.java From science-journal with Apache License 2.0 | 6 votes |
/** * Updates the stop recording button for {@link ExperimentDetailsFragment} when a recording * starts/stops. */ public void attachStopButton( ExtendedFloatingActionButton recordButton, FragmentManager fragmentManager) { recordButton.setAllCaps(false); RxView.clicks(recordButton) .flatMapMaybe(click -> recordingStatus.firstElement()) .subscribe( status -> { if (status.isRecording()) { tryStopRecording(recordButton, fragmentManager); } }); recordingStatus .takeUntil(RxView.detaches(recordButton)) .subscribe( status -> { if (status.state.shouldShowStopButton()) { recordButton.setVisibility(View.VISIBLE); } else { recordButton.setVisibility(View.INVISIBLE); } }); }
Example #16
Source File: ActionController.java From science-journal with Apache License 2.0 | 6 votes |
public void attachElapsedTime(MenuItem timingChip, SensorFragment fragment) { TextView elapsedTime = timingChip.getActionView().findViewById(R.id.timing_chip_text); recordingStatus .takeUntil(RxView.detaches(elapsedTime)) .subscribe( status -> { if (status.isRecording()) { timingChip.setVisible(true); } else { timingChip.setVisible(false); } }); ElapsedTimeAxisFormatter formatter = ElapsedTimeAxisFormatter.getInstance(elapsedTime.getContext()); // This clears any old listener as well as setting a new one, so we don't need to worry // about having multiple listeners active. fragment.setRecordingTimeUpdateListener( recordingTime -> elapsedTime.setText(formatter.format(recordingTime, true))); }
Example #17
Source File: TicTacToeView.java From RIBs with Apache License 2.0 | 6 votes |
@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); }
Example #18
Source File: InterestingAdapter.java From Interessant with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(final Holder holder, int position) { final ItemList item = itemList.get(position); if (!item.type.equals(VIDEO_TYPE)) { holder.movieContent.setVisibility(View.GONE); } else { holder.movieAlbum.setOriginalSize(16, 9); Glide.with(holder.movieAlbum.getContext()) .load(item.data.cover.detail) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .into(holder.movieAlbum); holder.movieDesc.setText(item.data.title); if (item.data.author != null) { holder.tag.setVisibility(View.VISIBLE); holder.tag.setText(item.data.author.name); } else { holder.tag.setVisibility(View.GONE); } RxView.clicks(holder.movieContent).throttleFirst(TOUCH_TIME, TimeUnit.MILLISECONDS) .subscribe(aVoid -> fly(holder.movieAlbum, item)); } }
Example #19
Source File: OffGameView.java From RIBs with Apache License 2.0 | 6 votes |
@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); }
Example #20
Source File: TicTacToeView.java From RIBs with Apache License 2.0 | 6 votes |
@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); }
Example #21
Source File: ActionController.java From science-journal with Apache License 2.0 | 5 votes |
/** * Updates the title bar for {@link ActionFragment} when a recording starts/stops. */ public void attachTitleBar(View titleBarView, boolean isTwoPane, OnClickListener listener, boolean hideDuringRecording, int titleResource, int iconResource) { titleBarView .findViewById(R.id.title_bar_close) .setOnClickListener(listener); ((TextView) titleBarView.findViewById(R.id.title_bar_text)) .setText(titleResource); ImageView icon = titleBarView.findViewById(R.id.title_bar_icon); if (isTwoPane) { recordingStatus .takeUntil(RxView.detaches(titleBarView)) .subscribe( status -> { Theme theme = titleBarView.getContext().getTheme(); if (status.state.shouldShowStopButton()) { theme = new ContextThemeWrapper( titleBarView.getContext(), R.style.RecordingProgressBarColor).getTheme(); if (hideDuringRecording) { titleBarView.setVisibility(View.GONE); } } else { titleBarView.setVisibility(View.VISIBLE); } icon.setImageDrawable( ResourcesCompat.getDrawable( titleBarView.getResources(), iconResource, theme)); }); } else { titleBarView.setVisibility(View.GONE); } }
Example #22
Source File: GalleryNoteFragment.java From science-journal with Apache License 2.0 | 5 votes |
private void complainPermissions() { View rootView = getView(); if (rootView != null) { rootView.findViewById(R.id.gallery).setVisibility(View.GONE); rootView.findViewById(R.id.complaint).setVisibility(View.VISIBLE); RxView.clicks(rootView.findViewById(R.id.open_settings)) .subscribe(click -> requestPermission()); } }
Example #23
Source File: ProductDetailsActivity.java From mosby with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_product_detail); ButterKnife.bind(this); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); fabClickObservable = RxView.clicks(fab).share().map(ignored -> true); }
Example #24
Source File: ExperimentDetailsFragment.java From science-journal with Apache License 2.0 | 5 votes |
private void loadLearnMoreIntoHolder(ViewGroup noteHolder, String runId) { LayoutInflater.from(noteHolder.getContext()) .inflate(R.layout.load_more_notes_button, noteHolder); // TODO: Jump straight to the notes section. Button button = (Button) noteHolder.findViewById(R.id.load_more_btn); Context context = button.getContext(); int activeTextColor = button.getCurrentTextColor(); int inactiveColor = context.getResources().getColor(R.color.archived_background_color); AppSingleton.getInstance(context) .getRecorderController(parentReference.get().appAccount) .watchRecordingStatus() .takeUntil(RxView.detaches(button)) .subscribe( status -> { if (status.isRecording()) { button.setTextColor(inactiveColor); } else { button.setTextColor(activeTextColor); } }); button.setOnClickListener( view -> launchRunReviewActivity( noteHolder.getContext(), runId, 0 /* sensor index deprecated */)); }
Example #25
Source File: AutoViewHolder.java From AutoAdapter with Apache License 2.0 | 5 votes |
public final Observable<AutoViewHolder> getViewHolderOnChildClickObservable(@IdRes int viewId) { return RxView.clicks(itemView.findViewById(viewId)) .map(new Function<Object, AutoViewHolder>() { @Override public AutoViewHolder apply(Object o) { return AutoViewHolder.this; } }); }
Example #26
Source File: AutoViewHolder.java From AutoAdapter with Apache License 2.0 | 5 votes |
public Observable<AutoViewHolder> getViewHolderOnChildLongClickObservable(@IdRes int viewId) { return RxView.longClicks(itemView.findViewById(viewId)) .map(new Function<Object, AutoViewHolder>() { @Override public AutoViewHolder apply(Object o) { return AutoViewHolder.this; } }); }
Example #27
Source File: AutoViewHolder.java From AutoAdapter with Apache License 2.0 | 5 votes |
public Observable<AutoViewHolder> getViewHolderOnLongClickObservable() { return RxView.longClicks(itemView).map(new Function<Object, AutoViewHolder>() { @Override public AutoViewHolder apply(Object o) { return AutoViewHolder.this; } }); }
Example #28
Source File: AutoViewHolder.java From AutoAdapter with Apache License 2.0 | 5 votes |
public Observable<AutoViewHolder> getViewHolderOnClickObservable() { return RxView.clicks(itemView).map(new Function<Object, AutoViewHolder>() { @Override public AutoViewHolder apply(Object view) { return AutoViewHolder.this; } }); }
Example #29
Source File: CharactersRecyclerViewAdapter.java From marvel with MIT License | 5 votes |
@Override public void onBindViewHolder(final CharacterViewHolder holder, int position) { final CharacterModel character = characters.get(position); holder.setCharacter(character); RxView.clicks(holder.view) .map(aVoid -> holder.getCharacter()) .subscribe(notify::onNext); }
Example #30
Source File: ViewAdapter.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * view的onLongClick事件绑定 */ @BindingAdapter(value = {"onLongClickCommand"}, requireAll = false) public static void onLongClickCommand(View view, final BindingCommand clickCommand) { RxView.longClicks(view) .subscribe(new Consumer<Object>() { @Override public void accept(Object object) throws Exception { if (clickCommand != null) { clickCommand.execute(); } } }); }