mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Make card view dismissable with swip
This commit is contained in:
parent
0b965aa5e8
commit
3b5f8a35ab
2 changed files with 32 additions and 4 deletions
|
|
@ -3,6 +3,8 @@ package fr.free.nrw.commons.nearby;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.design.widget.CoordinatorLayout;
|
||||||
|
import android.support.design.widget.SwipeDismissBehavior;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
@ -65,10 +67,36 @@ public class NearbyNoificationCardView extends CardView{
|
||||||
notificationIcon = rootView.findViewById(R.id.nearby_icon);
|
notificationIcon = rootView.findViewById(R.id.nearby_icon);
|
||||||
|
|
||||||
setActionListeners();
|
setActionListeners();
|
||||||
|
|
||||||
Log.d("deneme2",context.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow();
|
||||||
|
// Add swipe and dismiss property
|
||||||
|
SwipeDismissBehavior swipeDismissBehavior = new SwipeDismissBehavior();
|
||||||
|
swipeDismissBehavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY);
|
||||||
|
swipeDismissBehavior.setListener(new SwipeDismissBehavior.OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(View view) {
|
||||||
|
/**
|
||||||
|
* Only dismissing view results a space after dismissed view. Since, we need to
|
||||||
|
* make view invisible at all.
|
||||||
|
*/
|
||||||
|
NearbyNoificationCardView.this.setVisibility(GONE);
|
||||||
|
|
||||||
|
// Save shared preference for nearby card view accordingly
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDragStateChanged(int state) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) this.getLayoutParams();
|
||||||
|
layoutParams.setBehavior(swipeDismissBehavior);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setActionListeners() {
|
private void setActionListeners() {
|
||||||
permissionRequestButton.setOnClickListener(new OnClickListener() {
|
permissionRequestButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<android.support.design.widget.CoordinatorLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
>
|
>
|
||||||
|
|
||||||
</fr.free.nrw.commons.nearby.NearbyNoificationCardView>
|
</fr.free.nrw.commons.nearby.NearbyNoificationCardView>
|
||||||
</RelativeLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue