当前位置: 首页>>代码示例>>Java>>正文


Java RxAdapterView类代码示例

本文整理汇总了Java中com.jakewharton.rxbinding.widget.RxAdapterView的典型用法代码示例。如果您正苦于以下问题:Java RxAdapterView类的具体用法?Java RxAdapterView怎么用?Java RxAdapterView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RxAdapterView类属于com.jakewharton.rxbinding.widget包,在下文中一共展示了RxAdapterView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initViews

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
private void initViews() {
    mPresenter.bindSearchView(mSearchKeyText);

    final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this.getActivity(),
            R.array.languages, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mLanguageSpinner.setAdapter(adapter);
    RxAdapterView.itemSelections(mLanguageSpinner)
            .subscribe(new Action1<Integer>() {
                @Override
                public void call(Integer position) {
                    mPresenter.setLanguage((String) adapter.getItem(position));
                }
            });

    mAdapter = new RepoListRecyclerAdapter(null);
    mRepoListView.setLayoutManager(new LinearLayoutManager(getContext()));
    mRepoListView.setAdapter(mAdapter);
}
 
开发者ID:pxx11111,项目名称:githubclient,代码行数:20,代码来源:SearchFragment.java

示例2: onViewCreated

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    //Bind Views
    ButterKnife.bind(this, view);

    subscriptions.add(RxAdapterView.itemSelections(mRobotSpinner).debounce(500, TimeUnit.MILLISECONDS).subscribe(onNext -> updateMetricValues()));

    mEvent = rxDbManager.getEventsTable().load(getArguments().getLong(EVENT_ID));
    //Load Robots at Event
    rxDbManager.robotsAtEvent(getArguments().getLong(EVENT_ID))
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .flatMap(robots1 -> {
                this.robots = robots1;
                return Observable.from(robots1);
            })
            .map(robot -> String.format("%d, %s", robot.getTeam_id(), robot.getTeam().getName()))
            .toList()
            .subscribe(onNext -> {
                ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, onNext);
                mRobotSpinner.setAdapter(adapter);
                mRobotSpinner.setSelection(0);
                updateMetricValues();
            }, FirebaseCrash::report);
    super.onViewCreated(view, savedInstanceState);
}
 
开发者ID:frc2052,项目名称:FRC-Krawler,代码行数:27,代码来源:BaseScoutFragment.java

示例3: onAttachedToWindow

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
@Override public void onAttachedToWindow() {
  super.onAttachedToWindow();
  final Spinner spinner = (Spinner) findViewById(R.id.spinner);
  spinner.setAdapter(spinnerAdapter);

  final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
  final WrapLinearLayoutManager layoutManager =
      new WrapLinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  recyclerView.setLayoutManager(layoutManager);
  recyclerView.setAdapter(listAdapter);

  RxAdapterView.itemSelections(spinner).map(new Func1<Integer, String>() {
    @Override public String call(Integer position) {
      return (String) spinner.getItemAtPosition(position);
    }
  }).subscribe(listAdapter);
}
 
开发者ID:xfumihiro,项目名称:DataInspector,代码行数:19,代码来源:StorageUsageDialog.java

示例4: configureResponseSpinner

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
/**
 * Populates a {@code Spinner} with the values of an {@code enum} and binds it to the value set
 * in
 * the mock service.
 */
private <T extends Enum<T>> void configureResponseSpinner(Spinner spinner,
                                                          final Class<T> responseClass) {
    final EnumAdapter<T> adapter = new EnumAdapter<>(getContext(), responseClass);
    spinner.setEnabled(isMockMode);
    spinner.setAdapter(adapter);
    spinner.setSelection(mockGalleryService.getResponse(responseClass).ordinal());

    RxAdapterView.itemSelections(spinner)
            .map(adapter::getItem)
            .filter(item -> item != mockGalleryService.getResponse(responseClass))
            .subscribe(selected -> {
                Timber.d("Setting %s to %s", responseClass.getSimpleName(), selected);
                mockGalleryService.setResponse(responseClass, selected);
                ProcessPhoenix.triggerRebirth(getContext());
            });
}
 
开发者ID:LiveTyping,项目名称:u2020-mvp,代码行数:22,代码来源:DebugView.java

示例5: configureResponseSpinner

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
/**
 * Populates a {@code Spinner} with the values of an {@code enum} and binds it to the value set
 * in
 * the mock service.
 */
private <T extends Enum<T>> void configureResponseSpinner(Spinner spinner,
    final Class<T> responseClass) {
  final EnumAdapter<T> adapter = new EnumAdapter<>(getContext(), responseClass);
  spinner.setEnabled(isMockMode);
  spinner.setAdapter(adapter);
  spinner.setSelection(mockResponseSupplier.get(responseClass).ordinal());

  RxAdapterView.itemSelections(spinner)
      .map(adapter::getItem)
      .filter(item -> item != mockResponseSupplier.get(responseClass))
      .subscribe(selected -> {
        Timber.d("Setting %s to %s", responseClass.getSimpleName(), selected);
        mockResponseSupplier.set(selected);
      });
}
 
开发者ID:JakeWharton,项目名称:u2020,代码行数:21,代码来源:DebugView.java

示例6: onViewCreated

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    listView.setEmptyView(emptyView);
    listView.setAdapter(adapter);

    RxAdapterView.itemClickEvents(listView)
            .observeOn(Schedulers.io())
            .subscribe(event -> {
                boolean newValue = !adapter.getItem(event.position()).complete();
                updateComplete.bind(newValue, event.id());
                db.executeUpdateDelete(updateComplete.table, updateComplete.program);
            });
}
 
开发者ID:geralt-encore,项目名称:Delightful-SQLBrite,代码行数:16,代码来源:ItemsFragment.java

示例7: setupPackets

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
private void setupPackets() {
  final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Packet.asList());
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  packetSelection.setAdapter(adapter);
  lifecycles.addSubscriptionForLife(RxAdapterView
      .itemSelections(packetSelection)
      .distinctUntilChanged()
      .map(Packet::fromSelection)
      .subscribe(this::changePacketSelection, Throwable::printStackTrace));
}
 
开发者ID:swedbank,项目名称:android-banklink,代码行数:11,代码来源:MainActivity.java

示例8: onViewCreated

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    binding.list.setEmptyView(binding.empty);
    binding.list.setAdapter(adapter);
    initItemOnLongClick();

    RxAdapterView.itemClickEvents(binding.list)
            .observeOn(Schedulers.io())
            .subscribe(new Action1<AdapterViewItemClickEvent>() {
                @Override
                public void call(AdapterViewItemClickEvent event) {
                    Timber.i("action on : " + Thread.currentThread().getName());
                    //update
                    ItemsItemViewModel item = adapter.getItem(event.position());
                    boolean complete = !item.isComplete();
                    try {
                        if (model.update(item.getToBuyItem().getId(), complete)) {
                            item.setComplete(complete);
                        } else {
                            Tools.showToastSafty(getContext(), "update fail");
                        }
                    } catch (SQLException e) {
                        Timber.e(e, "getMessage ; " + e.getMessage() + "\ngetSQLState ; " + e.getSQLState() + "\ngetErrorCode ; " + e.getErrorCode());
                        Tools.showToastSafty(getContext(), "fail");
                    }
                }
            });
}
 
开发者ID:andych008,项目名称:ToBuy,代码行数:30,代码来源:ItemsFragment.java

示例9: onCreateView

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
    @Nullable Bundle savedInstanceState) {
  binding = FragmentTrendingBinding.inflate(inflater, container, false);
  binding.trendingToolbar.setNavigationIcon(R.drawable.menu_icon);
  binding.trendingToolbar.setNavigationOnClickListener(
      v -> getMainActivity().getDrawerLayout().openDrawer(GravityCompat.START));

  binding.trendingTimespan.setAdapter(timespanAdapter);

  binding.trendingListView.setLayoutManager(new LinearLayoutManager(getContext()));
  binding.trendingListView.setRefreshListener(this::onRefresh);
  binding.trendingListView.setupMoreListener(
      (overallItemsCount, itemsBeforeMore, maxLastVisiblePosition) -> {
        page += 1;
        timespanSubject.onNext(
            timespanAdapter.getItem(binding.trendingTimespan.getSelectedItemPosition()));
      }, 1);

  binding.trendingTimespan.setSelection(TrendingTimespan.WEEK.ordinal());

  subscriptions.add(RxAdapterView.itemSelections(binding.trendingTimespan)
      .observeOn(mainThread()).subscribe(position -> {
        binding.trendingTimespan.post(() -> {
          onRefresh();
          binding.trendingListView.setRefreshing(true);
        });
      }));

  return binding.getRoot();
}
 
开发者ID:donglua,项目名称:GitHubClient,代码行数:31,代码来源:TrendingFragment.java

示例10: onAttachedToWindow

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
@Override public void onAttachedToWindow() {
  super.onAttachedToWindow();

  File prefsDir = new File("/data/data/" + context.getPackageName() + "/shared_prefs");
  String[] prefs = prefsDir.list();

  Spinner spinner = (Spinner) findViewById(R.id.spinner);
  RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
  final WrapLinearLayoutManager layoutManager =
      new WrapLinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  recyclerView.setLayoutManager(layoutManager);

  if (prefs != null) {
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
        | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
        | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

    for (int i = 0; i < prefs.length; i++) prefs[i] = prefs[i].split("\\.")[0];
    spinnerAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, prefs);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    PreferenceListAdapter listAdapter = new PreferenceListAdapter(context);
    recyclerView.setAdapter(listAdapter);
    spinner.setAdapter(spinnerAdapter);
    RxAdapterView.itemSelections(spinner).map(new Func1<Integer, String>() {
      @Override public String call(Integer position) {
        return spinnerAdapter.getItem(position).split("\\.")[0];
      }
    }).subscribe(listAdapter);
  } else {
    spinner.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_spinner_item,
        new String[] { "No Prefs Found" }));
  }
}
 
开发者ID:xfumihiro,项目名称:DataInspector,代码行数:37,代码来源:PreferenceEditorDialog.java

示例11: setupNetworkSection

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
private void setupNetworkSection() {
  final ApiEndpoints currentEndpoint = ApiEndpoints.from(networkEndpoint.get());
  final EnumAdapter<ApiEndpoints> endpointAdapter =
      new EnumAdapter<>(getContext(), ApiEndpoints.class);
  endpointView.setAdapter(endpointAdapter);
  endpointView.setSelection(currentEndpoint.ordinal());

  RxAdapterView.itemSelections(endpointView)
      .map(endpointAdapter::getItem)
      .filter(item -> item != currentEndpoint)
      .subscribe(selected -> {
        if (selected == ApiEndpoints.CUSTOM) {
          Timber.d("Custom network endpoint selected. Prompting for URL.");
          showCustomEndpointDialog(currentEndpoint.ordinal(), "http://");
        } else {
          setEndpointAndRelaunch(selected.url);
        }
      });

  int currentProxyPosition = networkProxyAddress.isSet() ? ProxyAdapter.PROXY : ProxyAdapter.NONE;
  final ProxyAdapter proxyAdapter = new ProxyAdapter(getContext(), networkProxyAddress);
  networkProxyView.setAdapter(proxyAdapter);
  networkProxyView.setSelection(currentProxyPosition);

  RxAdapterView.itemSelections(networkProxyView)
      .filter(position -> !networkProxyAddress.isSet() || position != ProxyAdapter.PROXY)
      .subscribe(position -> {
        if (position == ProxyAdapter.NONE) {
          // Only clear the proxy and restart if one was previously set.
          if (currentProxyPosition != ProxyAdapter.NONE) {
            Timber.d("Clearing network proxy");
            // TODO: Keep the custom proxy around so you can easily switch back and forth.
            networkProxyAddress.delete();
            // Force a restart to re-initialize the app without a proxy.
            ProcessPhoenix.triggerRebirth(getContext());
          }
        } else if (networkProxyAddress.isSet() && position == ProxyAdapter.PROXY) {
          Timber.d("Ignoring re-selection of network proxy %s", networkProxyAddress.get());
        } else {
          Timber.d("New network proxy selected. Prompting for host.");
          showNewNetworkProxyDialog(proxyAdapter);
        }
      });

  // Only show the endpoint editor when a custom endpoint is in use.
  endpointEditView.setVisibility(currentEndpoint == ApiEndpoints.CUSTOM ? VISIBLE : GONE);
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:48,代码来源:DebugView.java

示例12: setupUserInterfaceSection

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
private void setupUserInterfaceSection() {
  final AnimationSpeedAdapter speedAdapter = new AnimationSpeedAdapter(getContext());
  uiAnimationSpeedView.setAdapter(speedAdapter);
  final int animationSpeedValue = animationSpeed.get();
  uiAnimationSpeedView.setSelection(
      AnimationSpeedAdapter.getPositionForValue(animationSpeedValue));

  RxAdapterView.itemSelections(uiAnimationSpeedView)
      .map(speedAdapter::getItem)
      .filter(item -> item != animationSpeed.get())
      .subscribe(selected -> {
        Timber.d("Setting animation speed to %sx", selected);
        animationSpeed.set(selected);
        applyAnimationSpeed(selected);
      });
  // Ensure the animation speed value is always applied across app restarts.
  post(() -> applyAnimationSpeed(animationSpeedValue));

  boolean gridEnabled = pixelGridEnabled.get();
  uiPixelGridView.setChecked(gridEnabled);
  uiPixelRatioView.setEnabled(gridEnabled);
  uiPixelGridView.setOnCheckedChangeListener((buttonView, isChecked) -> {
    Timber.d("Setting pixel grid overlay enabled to %b", isChecked);
    pixelGridEnabled.set(isChecked);
    uiPixelRatioView.setEnabled(isChecked);
  });

  uiPixelRatioView.setChecked(pixelRatioEnabled.get());
  uiPixelRatioView.setOnCheckedChangeListener((buttonView, isChecked) -> {
    Timber.d("Setting pixel scale overlay enabled to %b", isChecked);
    pixelRatioEnabled.set(isChecked);
  });

  uiScalpelView.setChecked(scalpelEnabled.get());
  uiScalpelWireframeView.setEnabled(scalpelEnabled.get());
  uiScalpelView.setOnCheckedChangeListener((buttonView, isChecked) -> {
    Timber.d("Setting scalpel interaction enabled to %b", isChecked);
    scalpelEnabled.set(isChecked);
    uiScalpelWireframeView.setEnabled(isChecked);
  });

  uiScalpelWireframeView.setChecked(scalpelWireframeEnabled.get());
  uiScalpelWireframeView.setOnCheckedChangeListener((buttonView, isChecked) -> {
    Timber.d("Setting scalpel wireframe enabled to %b", isChecked);
    scalpelWireframeEnabled.set(isChecked);
  });
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:48,代码来源:DebugView.java

示例13: registerSexSpinnerObservable

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
@Override
public Observable<Integer> registerSexSpinnerObservable() {
    return RxAdapterView.itemSelections(sexSpinner);
}
 
开发者ID:matbrandao,项目名称:Saude-no-Mapa,代码行数:5,代码来源:RegisterActivity.java

示例14: registerUfSpinnerObserver

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
@Override
public Observable<Integer> registerUfSpinnerObserver() {
    return RxAdapterView.itemSelections(ufSpinner);
}
 
开发者ID:matbrandao,项目名称:Saude-no-Mapa,代码行数:5,代码来源:EstablishmentFragment.java

示例15: showFilterBottomSheetDialog

import com.jakewharton.rxbinding.widget.RxAdapterView; //导入依赖的package包/类
private void showFilterBottomSheetDialog() {
    mIsFiltered = false;
    BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(mContext);
    View dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_bottom_sheet_filter, null);
    FilterViews bottomViews = new FilterViews();
    ButterKnife.bind(bottomViews, dialogView);

    mCurrentFilterTitle = bottomViews.filterTitle;
    updateCurrentFilterTitle();

    bottomViews.redeAtendimentoSpinner.setAdapter(getRedeAtendimentoAdapter());
    bottomViews.categoriaSpinner.setAdapter(getCategoriaSpinner());

    RxAdapterView.itemSelections(bottomViews.redeAtendimentoSpinner).subscribe(integer -> {
        doFilter(bottomViews);
    });

    RxAdapterView.itemSelections(bottomViews.categoriaSpinner).subscribe(integer -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.vinculoSusCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.atendimentoUrgencialCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.atendimentoAmbulatorialCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.centroCirurgicoCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.obstetraCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.neoNatalCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.dialiseCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    bottomViews.filterButton.setOnClickListener(view -> {
        mIsFiltered = true;
        mInteractor.clearMarkers(mMap);
        showMapPins(mFilteredEstablishmentList);
        mInteractor.animateCameraToAllEstablishments(mMap);
        bottomSheetDialog.dismiss();
    });

    bottomSheetDialog.setContentView(dialogView);
    bottomSheetDialog.getWindow().findViewById(R.id.design_bottom_sheet)
            .setBackgroundResource(R.color.default_dialog_background);

    dialogView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

    BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) dialogView.getParent());
    mBehavior.setPeekHeight((int) (mView.getMapContainerHeight() + 400));

    bottomSheetDialog.setOnDismissListener(dialogInterface -> {
        if (!mIsFiltered) {
            mFilteredEstablishmentList.clear();
            mFilteredEstablishmentList.addAll(mEstablishmentList);
        }
    });

    bottomSheetDialog.show();
}
 
开发者ID:matbrandao,项目名称:Saude-no-Mapa,代码行数:76,代码来源:EstablishmentPresenterImpl.java


注:本文中的com.jakewharton.rxbinding.widget.RxAdapterView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。