本文整理汇总了Java中android.support.design.widget.SwipeDismissBehavior类的典型用法代码示例。如果您正苦于以下问题:Java SwipeDismissBehavior类的具体用法?Java SwipeDismissBehavior怎么用?Java SwipeDismissBehavior使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SwipeDismissBehavior类属于android.support.design.widget包,在下文中一共展示了SwipeDismissBehavior类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setupSwipe
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
private void setupSwipe(ItemTrackedBeaconBinding beaconBinding) {
final SwipeDismissBehavior<CardView> swipe = new SwipeDismissBehavior();
swipe.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY);
swipe.setListener(new SwipeDismissBehavior.OnDismissListener() {
@Override
public void onDismiss(View view) {
Log.d(Constants.TAG, "Swipe +");
}
@Override
public void onDragStateChanged(int state) {
}
});
}
开发者ID:vitas,项目名称:beaconloc,代码行数:17,代码来源:TrackedBeaconAdapter.java
示例2: subscribeActual
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
@Override protected void subscribeActual(Observer<? super View> observer) {
if (!checkMainThread(observer)) {
return;
}
if (!(view.getLayoutParams() instanceof LayoutParams)) {
throw new IllegalArgumentException("The view is not in a Coordinator Layout.");
}
LayoutParams params = (LayoutParams) view.getLayoutParams();
final SwipeDismissBehavior behavior = (SwipeDismissBehavior) params.getBehavior();
if (behavior == null) {
throw new IllegalStateException("There's no behavior set on this view.");
}
Listener listener = new Listener(behavior, observer);
observer.onSubscribe(listener);
behavior.setListener(listener);
}
开发者ID:JakeWharton,项目名称:RxBinding,代码行数:17,代码来源:SwipeDismissBehaviorObservable.java
示例3: dismisses
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
@Test public void dismisses() {
((CoordinatorLayout.LayoutParams) view.getLayoutParams()).setBehavior(
new SwipeDismissBehavior());
RecordingObserver<View> o = new RecordingObserver<>();
RxSwipeDismissBehavior.dismisses(view)
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(o);
o.assertNoMoreEvents(); // No initial value.
onView(withId(1)).perform(swipeRight());
assertEquals(view, o.takeNext());
o.dispose();
onView(withId(1)).perform(swipeRight());
o.assertNoMoreEvents();
}
开发者ID:JakeWharton,项目名称:RxBinding,代码行数:19,代码来源:RxSwipeDismissBehaviorTest.java
示例4: onCreate
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_swipe_behavior);
final SwipeDismissBehavior swipe = new SwipeDismissBehavior();
swipe.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY);
swipe.setListener(new SwipeDismissBehavior.OnDismissListener() {
@Override public void onDismiss(View view) {
Toast.makeText(SwipeBehaviorExampleActivity.this,
"Card swiped !!", Toast.LENGTH_SHORT).show();
}
@Override public void onDragStateChanged(int state) {}
});
CardView cardView = (CardView) findViewById(R.id.swype_card);
LayoutParams coordinatorParams = (LayoutParams) cardView.getLayoutParams();
coordinatorParams.setBehavior(swipe);
}
开发者ID:saulmm,项目名称:CoordinatorExamples,代码行数:22,代码来源:SwipeBehaviorExampleActivity.java
示例5: initBehavior
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
private void initBehavior() {
swipeDismissBehavior = new SwipeDismissBehavior();
swipeDismissBehavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY);
swipeDismissBehavior.setListener(onDismissListener);
CoordinatorLayout.LayoutParams coordinatorParams = (CoordinatorLayout.LayoutParams) findViewById(R.id.textview).getLayoutParams();
coordinatorParams.setBehavior(swipeDismissBehavior);
swipeDismissBehavior.setDragDismissDistance(0.5F);
swipeDismissBehavior.setStartAlphaSwipeDistance(0F);
swipeDismissBehavior.setEndAlphaSwipeDistance(0.5F);
swipeDismissBehavior.setSensitivity(0);
swipeDismissBehavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
}
开发者ID:Pingsh,项目名称:Mix,代码行数:14,代码来源:SwipeDismissBehaviorActivity.java
示例6: CardViewHolder
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
public CardViewHolder(final View itemView) {
super(itemView);
userName = (TextView) itemView.findViewById(R.id.user_name);
userIcon = (ImageView) itemView.findViewById(R.id.user_icon);
image = (ImageView) itemView.findViewById(R.id.image);
card = (CardView) itemView.findViewById(R.id.card);
card.setOnClickListener(this);
// ドラッグして消えるBehaviorを取り付ける。
// スワイプする要素は、親ビューがCoordinatorLayoutである必要がある。
SwipeDismissBehavior behavior = new SwipeDismissBehavior();
behavior.setStartAlphaSwipeDistance(0.1f);
behavior.setEndAlphaSwipeDistance(0.6f);
behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
behavior.setListener(new SwipeDismissBehavior.OnDismissListener() {
@Override
public void onDismiss(View view) {
if (listener != null) {
listener.onCardDismiss(CardViewHolder.this);
}
}
@Override
public void onDragStateChanged(int state) {
if (listener != null) {
listener.onDragStateChanged(CardViewHolder.this, state);
}
}
});
final ViewGroup.LayoutParams cardViewLayoutParams = card.getLayoutParams();
((CoordinatorLayout.LayoutParams) cardViewLayoutParams).setBehavior(behavior);
}
开发者ID:yokmama,项目名称:honki_android2,代码行数:34,代码来源:CardViewHolder.java
示例7: isBeingDragged
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
/**
* @return if the view is being being dragged or settled by {@link SwipeDismissBehavior}.
*/
private boolean isBeingDragged() {
final ViewGroup.LayoutParams lp = mView.getLayoutParams();
if (lp instanceof CoordinatorLayout.LayoutParams) {
final CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) lp;
final CoordinatorLayout.Behavior behavior = layoutParams.getBehavior();
if (behavior instanceof SwipeDismissBehavior) {
return ((SwipeDismissBehavior) behavior).getDragState() != SwipeDismissBehavior.STATE_IDLE;
}
}
return false;
}
开发者ID:polok,项目名称:oversnackbar,代码行数:15,代码来源:OverSnackBar.java
示例8: isBeingDragged
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
/**
* @return if the view is being being dragged or settled by {@link SwipeDismissBehavior}.
*/
private boolean isBeingDragged() {
final ViewGroup.LayoutParams lp = mView.getLayoutParams();
if (lp instanceof CoordinatorLayout.LayoutParams) {
final CoordinatorLayout.LayoutParams cllp = (CoordinatorLayout.LayoutParams) lp;
final CoordinatorLayout.Behavior behavior = cllp.getBehavior();
if (behavior instanceof SwipeDismissBehavior) {
return ((SwipeDismissBehavior) behavior).getDragState()
!= SwipeDismissBehavior.STATE_IDLE;
}
}
return false;
}
开发者ID:isanwenyu,项目名称:TopSnackbar,代码行数:18,代码来源:TopSnackbar.java
示例9: isBeingDragged
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private boolean isBeingDragged() {
final ViewGroup.LayoutParams lp = mView.getLayoutParams();
if (lp instanceof CoordinatorLayout.LayoutParams) {
final CoordinatorLayout.LayoutParams cllp = (CoordinatorLayout.LayoutParams) lp;
final CoordinatorLayout.Behavior behavior = cllp.getBehavior();
if (behavior instanceof SwipeDismissBehavior) {
return ((SwipeDismissBehavior) behavior).getDragState() != SwipeDismissBehavior.STATE_IDLE;
}
}
return false;
}
开发者ID:shenhuanet,项目名称:Account-android,代码行数:13,代码来源:TSnackbar.java
示例10: layoutDependsOn
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
if(dependency instanceof TopCardView) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) dependency.getLayoutParams();
params.setBehavior(swipeDismissBehavior);
swipeDismissBehavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
swipeDismissBehavior.setStartAlphaSwipeDistance(0.1f);
swipeDismissBehavior.setEndAlphaSwipeDistance(0.9f);
swipeDismissBehavior.setDragDismissDistance(0.8f);
return true;
}
return false;
}
开发者ID:IsUncommon,项目名称:Droidcon-India-2015,代码行数:14,代码来源:StepsDemoTopSheetBottomViewsBehavior.java
示例11: Listener
import android.support.design.widget.SwipeDismissBehavior; //导入依赖的package包/类
Listener(SwipeDismissBehavior swipeDismissBehavior, Observer<? super View> observer) {
this.swipeDismissBehavior = swipeDismissBehavior;
this.observer = observer;
}
开发者ID:JakeWharton,项目名称:RxBinding,代码行数:5,代码来源:SwipeDismissBehaviorObservable.java
注:本文中的android.support.design.widget.SwipeDismissBehavior类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论