forked from mirror/monocles_chat_clean
apply monocles swipe feature
This commit is contained in:
parent
3ca68caaa7
commit
6957dd3b0c
4 changed files with 101 additions and 9 deletions
|
@ -121,6 +121,7 @@ dependencies {
|
|||
implementation 'com.github.Priyansh-Kedia:OpenGraphParser:2.5.6'
|
||||
implementation 'me.xdrop:fuzzywuzzy:1.4.0'
|
||||
implementation 'net.fellbaum:jemoji:1.4.1'
|
||||
implementation "com.daimajia.swipelayout:library:1.2.0@aar"
|
||||
}
|
||||
|
||||
ext {
|
||||
|
|
|
@ -68,6 +68,7 @@ import com.google.common.base.Strings;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.lelloman.identicon.view.GithubIdenticonView;
|
||||
import com.daimajia.swipe.SwipeLayout;
|
||||
|
||||
import io.ipfs.cid.Cid;
|
||||
|
||||
|
@ -1325,9 +1326,64 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
MessageAdapter.this.mOnMessageBoxSwipedListener.onContactPictureClicked(message);
|
||||
}
|
||||
});
|
||||
viewHolder.message_box.setOnTouchListener(swipeDetector);
|
||||
viewHolder.image.setOnTouchListener(swipeDetector);
|
||||
viewHolder.time.setOnTouchListener(swipeDetector);
|
||||
|
||||
|
||||
|
||||
// monocles swipe feature
|
||||
SwipeLayout swipeLayout = view.findViewById(R.id.layout_swipe);
|
||||
|
||||
//set show mode.
|
||||
swipeLayout.setShowMode(SwipeLayout.ShowMode.PullOut);
|
||||
|
||||
//add drag edge.(If the BottomView has 'layout_gravity' attribute, this line is unnecessary)
|
||||
swipeLayout.addDrag(SwipeLayout.DragEdge.Left, view.findViewById(R.id.bottom_wrapper));
|
||||
|
||||
swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
|
||||
@Override
|
||||
public void onClose(SwipeLayout layout) {
|
||||
swipeLayout.refreshDrawableState();
|
||||
swipeLayout.clearAnimation();
|
||||
//when the SurfaceView totally cover the BottomView.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {
|
||||
swipeLayout.setClickToClose(true);
|
||||
//you are swiping.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartOpen(SwipeLayout layout) {
|
||||
swipeLayout.setClickToClose(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(SwipeLayout layout) {
|
||||
swipeLayout.refreshDrawableState();
|
||||
//when the BottomView totally show.
|
||||
if (mOnMessageBoxSwipedListener != null) mOnMessageBoxSwipedListener.onContactPictureClicked(message);
|
||||
swipeLayout.close(true);
|
||||
swipeLayout.setClickToClose(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartClose(SwipeLayout layout) {
|
||||
swipeLayout.close(true);
|
||||
swipeLayout.setClickToClose(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHandRelease(SwipeLayout layout, float xvel, float yvel) {
|
||||
swipeLayout.refreshDrawableState();
|
||||
swipeLayout.close(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Treat touch-up as click so we don't have to touch twice
|
||||
// (touch twice is because it's waiting to see if you double-touch for text selection)
|
||||
|
|
|
@ -1,7 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.daimajia.swipe.SwipeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
app:drag_edge="left"
|
||||
app:show_mode="pull_out"
|
||||
android:id="@+id/layout_swipe"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottom_wrapper"
|
||||
android:layout_width="80sp"
|
||||
android:weightSum="1"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -121,4 +138,4 @@
|
|||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</layout>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
|
|
|
@ -1,6 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<com.daimajia.swipe.SwipeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
app:drag_edge="left"
|
||||
app:show_mode="pull_out"
|
||||
android:id="@+id/layout_swipe"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottom_wrapper"
|
||||
android:layout_width="80sp"
|
||||
android:weightSum="1"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -131,4 +149,4 @@
|
|||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</layout>
|
||||
</com.daimajia.swipe.SwipeLayout>
|
||||
|
|
Loading…
Reference in a new issue