本文整理汇总了Java中com.jakewharton.rxbinding.support.v7.widget.RxToolbar类的典型用法代码示例。如果您正苦于以下问题:Java RxToolbar类的具体用法?Java RxToolbar怎么用?Java RxToolbar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RxToolbar类属于com.jakewharton.rxbinding.support.v7.widget包,在下文中一共展示了RxToolbar类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupDefaultUpButton
import com.jakewharton.rxbinding.support.v7.widget.RxToolbar; //导入依赖的package包/类
@SuppressLint("PrivateResource")
protected final Toolbar setupDefaultUpButton() {
Toolbar mainToolbar = (Toolbar) findViewById(R.id.main_toolbar);
mainToolbar.setNavigationIcon(R.drawable.ic_action_back);
RxToolbar.navigationClicks(mainToolbar).subscribe(ignore -> navigateUp());
return mainToolbar;
}
示例2: onCreate
import com.jakewharton.rxbinding.support.v7.widget.RxToolbar; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photo);
// Set up toolbar
Toolbar mainToolbar = setupDefaultUpButton();
mainToolbar.inflateMenu(R.menu.menu_refresh);
RxToolbar.itemClicks(mainToolbar)
.filter(item -> item.getItemId() == R.id.menu_refresh)
.subscribe(item -> showPhoto(true));
showPhoto(false);
}
示例3: onMenuSelection
import com.jakewharton.rxbinding.support.v7.widget.RxToolbar; //导入依赖的package包/类
@Override
public Observable<Integer> onMenuSelection() {
return RxToolbar.itemClicks(toolbar).map(menuItem -> menuItem.getItemId());
}
示例4: onNavHomeClick
import com.jakewharton.rxbinding.support.v7.widget.RxToolbar; //导入依赖的package包/类
@Override
public Observable<Void> onNavHomeClick() {
return RxToolbar.navigationClicks(toolbar);
}
示例5: onCreate
import com.jakewharton.rxbinding.support.v7.widget.RxToolbar; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
shopInfo = new ShopInfo();
applyShopInfo(AppManager.getShopInfo());
shopInfoObservable = NetworkWrapper.get()
.getShopInfo(AppManager.getShopInfo().getId())
.compose(bindToLifecycle());
setInfoObservable = NetworkWrapper.get()
.setShopInfo(AppManager.getShopInfo().getId(), shopInfo)
.compose(bindToLifecycle());
Glide.with(this).load("").placeholder(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_store)
.sizeDp(36).colorRes(R.color.colorAccent).paddingRes(R.dimen.padding_icon)).into(binding.ivUserNameLogo);
Glide.with(this).load("").placeholder(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_local_phone)
.sizeDp(36).colorRes(R.color.colorAccent).paddingRes(R.dimen.padding_icon)).into(binding.ivUserPhoneLogo);
Glide.with(this).load("").placeholder(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_attach_money)
.sizeDp(36).colorRes(R.color.colorAccent).paddingRes(R.dimen.padding_icon)).into(binding.ivUserBasepriceLogo);
Glide.with(this).load("").placeholder(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_description)
.sizeDp(36).colorRes(R.color.colorAccent).paddingRes(R.dimen.padding_icon)).into(binding.ivUserDescriptionLogo);
Glide.with(this).load("").placeholder(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_local_activity)
.sizeDp(36).colorRes(R.color.colorAccent).paddingRes(R.dimen.padding_icon)).into(binding.ivUserActivityLogo);
RxToolbar.itemClicks(getToolbar())
.debounce(500, TimeUnit.MILLISECONDS)
.map(menuItem -> menuItem.getItemId())
.compose(bindToLifecycle())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::onToolbarItemClicked);
Observable.combineLatest(RxTextView.textChanges(binding.tvUserName).skip(1)
, RxTextView.textChanges(binding.tvUserPhone).skip(1)
, RxTextView.textChanges(binding.tvUserBaseprice).skip(1)
, RxTextView.textChanges(binding.tvUserDescription).skip(1)
, RxTextView.textChanges(binding.tvUserActivity).skip(1)
, (name, phone, baseprice, description, activity) -> {
shopInfo.setName(name.toString());
shopInfo.setPhone(phone.toString());
shopInfo.setBasePrice(baseprice.toString());
shopInfo.setDescription(description.toString());
shopInfo.setActivity(activity.toString());
return !TextUtils.isEmpty(name) && !TextUtils.isEmpty(phone)
&& !TextUtils.isEmpty(baseprice)
&& !TextUtils.isEmpty(description);
})
.subscribe(aBoolean -> {
isCheckable = aBoolean;
});
}
示例6: observableUpClicks
import com.jakewharton.rxbinding.support.v7.widget.RxToolbar; //导入依赖的package包/类
@Override
public Observable<Void> observableUpClicks() {
return RxToolbar.navigationClicks(toolbar);
}
示例7: onCreate
import com.jakewharton.rxbinding.support.v7.widget.RxToolbar; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customlist);
// Set up toolbar
Toolbar mainToolbar = setupDefaultUpButton();
mainToolbar.inflateMenu(R.menu.menu_delete);
EditText listNameEdit = (EditText) findViewById(R.id.list_name_edit);
beersList = (RecyclerView) findViewById(R.id.beers_list);
emptyText = (TextView) findViewById(R.id.empty_text);
customListBeersAdapter = new CustomListBeersAdapter();
beersList.setLayoutManager(new LinearLayoutManager(this));
beersList.setAdapter(customListBeersAdapter);
long listId = getIntent().getLongExtra("listId", 0);
if (listId > 0) {
list = database(this).get(CustomList.class, listId);
listNameEdit.setText(list.name);
} else {
// Create and directly save, such that we have an id to bind beers to
list = new CustomList();
rxdb(this).put(list);
}
// Allow deleting the entire list
RxToolbar.itemClicks(mainToolbar).compose(onUi())
.filter(item -> item.getItemId() == R.id.menu_delete).compose(toIo())
.flatMap(event -> Db.deleteCustomList(this, list)).compose(toUi())
.doOnEach(RBLog::rx)
.first().toCompletable()
.subscribe(this::finish, e -> Snackbar.show(this, R.string.error_unexpectederror));
// Directly persist name changes
RxTextView.textChanges(listNameEdit)
.map(name -> {
list.name = name.toString();
return list;
})
.compose(bindToLifecycle())
.subscribe(rxdb(this).put(), e -> RBLog.e("Error persisting the list name", e));
// Directly visualize item changes
Db.getCustomListBeerChanges(this, list._id)
.compose(bindToLifecycle())
.subscribe(
change -> customListBeersAdapter.change(change),
e -> RBLog.e("Error handling a beer list change", e));
// Load current beers list and always have it update the empty view visibility when adding/removing beers
Db.getCustomListBeers(this, list._id)
.toList()
.compose(onIoToUi())
.compose(bindToLifecycle())
.subscribe(
beers -> customListBeersAdapter.init(beers),
e -> Snackbar.show(this, R.string.error_unexpectederror));
RxRecyclerViewAdapter.dataEvents(customListBeersAdapter)
.filter(event -> event.getKind() != RecyclerAdapterDataEvent.Kind.RANGE_CHANGE)
.subscribe(event -> {
emptyText.setVisibility(customListBeersAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
beersList.setVisibility(customListBeersAdapter.getItemCount() == 0 ? View.GONE : View.VISIBLE);
}, e -> RBLog.e("Unexpected error when handling list addition/removal", e));
}
示例8: onCreate
import com.jakewharton.rxbinding.support.v7.widget.RxToolbar; //导入依赖的package包/类
@SuppressLint("PrivateResource")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_beer);
// Set up toolbar
Toolbar mainToolbar = setupDefaultUpButton();
mainToolbar.inflateMenu(R.menu.menu_link);
mainToolbar.inflateMenu(R.menu.menu_refresh);
RxToolbar.itemClicks(mainToolbar).subscribe(item -> {
if (item.getItemId() == R.id.menu_link) {
new ShareHelper(this).shareBeer(beerId, beerName);
} else if (item.getItemId() == R.id.menu_link) {
Animations.fadeFlip(loadingProgress, detailsLayout);
refresh(true);
}
});
ratingsList = (RecyclerView) findViewById(R.id.ratings_list);
loadingProgress = (ProgressBar) findViewById(R.id.loading_progress);
detailsLayout = findViewById(R.id.details_layout);
numbersLayout = findViewById(R.id.numbers_layout);
listAddButton = (CheckableImageButton) findViewById(R.id.list_add_button);
moreLayout = findViewById(R.id.more_layout);
brewerNameText = (TextView) findViewById(R.id.brewer_name_text);
rateButton = (FloatingActionButton) findViewById(R.id.rate_button);
rateButton.setVisibility(View.GONE);
beerId = getIntent().getLongExtra("beerId", 0);
if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_VIEW) && getIntent().getData() != null) {
List<String> segments = getIntent().getData().getPathSegments();
if (segments != null && segments.size() > 1) {
try {
beerId = Integer.parseInt(segments.get(1));
} catch (NumberFormatException e) {
// Not a supported URL; start the url in a browser instead (via missing beerId)
}
}
}
if (beerId == 0) {
startActivity(new Intent(Intent.ACTION_VIEW, getIntent().getData()));
finish();
}
}
示例9: onCreateView
import com.jakewharton.rxbinding.support.v7.widget.RxToolbar; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(
R.layout.activity_car_selection_newcar_fragment, container, false);
ButterKnife.inject(this, view);
// Get the display size in pixels
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
// Set the dropdown width of the spinner to half of the display pixel width.
manufacturerSpinner.setDropDownWidth(width / 2);
modelSpinner.setDropDownWidth(width / 2);
yearSpinner.setDropDownWidth(width / 2);
engineSpinner.setDropDownWidth(width / 2);
toolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
toolbar.inflateMenu(R.menu.menu_logbook_add_fueling);
toolbar.setNavigationOnClickListener(v -> closeThisFragment());
// initially we set the toolbar exp to gone
toolbar.setVisibility(View.GONE);
toolbarExp.setVisibility(View.GONE);
contentView.setVisibility(View.GONE);
downloadView.setVisibility(View.INVISIBLE);
createCarSubscription = RxToolbar.itemClicks(toolbar)
.filter(continueWhenFormIsCorrect())
.map(createCarFromForm())
.filter(continueWhenCarHasCorrectValues())
.map(checkCarAlreadyExist())
.subscribe(new Subscriber<Car>() {
@Override
public void onCompleted() {
LOG.info("onCompleted car");
}
@Override
public void onError(Throwable e) {
LOG.warn(e.getMessage(), e);
}
@Override
public void onNext(Car car) {
LOG.info("car added");
((CarSelectionUiListener) getActivity()).onCarAdded(car);
closeThisFragment();
}
});
dispatchRemoteSensors();
initFocusChangedListener();
initTextWatcher();
return view;
}