GithubHelp home page GithubHelp logo

swipereveallayout's Introduction

SwipeRevealLayout

A layout that you can swipe/slide to show another layout.

Demo

Overview

Demo all

Drag mode

Drag mode normal:
Demo normal

Drag mode same_level:
Demo same

Features

  • Flexible, easy to use with RecyclerView, ListView or any view that requires view binding.
  • Four drag edges (left, right, top, bottom).
  • Two drag modes:
    • Normal (the secondary view is underneath the main view).
    • Same level (the secondary view sticks to the edge of the main view).
  • Able to open one row at a time.
  • Minimum api level 9.

Usage

Dependencies

dependencies {
    compile 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'
}

Layout file

<com.chauthai.swipereveallayout.SwipeRevealLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:mode="same_level"
        app:dragEdge="left">

        <!-- Your secondary layout here -->
        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />

        <!-- Your main layout here -->
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
            
</com.chauthai.swipereveallayout.SwipeRevealLayout>

app:mode can be normal or same_level

app:dragEdge can be left, right, top or bottom

Use with RecyclerView, ListView, GridView...

In your Adapter class:
public class Adapter extends RecyclerView.Adapter {
  // This object helps you save/restore the open/close state of each view
  private final ViewBinderHelper viewBinderHelper = new ViewBinderHelper();
  
  public Adapter() {
    // uncomment the line below if you want to open only one row at a time
    // viewBinderHelper.setOpenOnlyOne(true);
  }
  
  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {
    // get your data object first.
    YourDataObject dataObject = mDataSet.get(position); 
    
    // Save/restore the open/close state.
    // You need to provide a String id which uniquely defines the data object.
    viewBinderHelper.bind(holder.swipeRevealLayout, dataObject.getId()); 

    // do your regular binding stuff here
  }
}
Optional, to restore/save the open/close state when the device's orientation is changed:
Adapter class:
public class YourAdapter extends RecyclerView.Adapter {
  ...

  public void saveStates(Bundle outState) {
      viewBinderHelper.saveStates(outState);
  }

  public void restoreStates(Bundle inState) {
      viewBinderHelper.restoreStates(inState);
  }  
}
Activity class:
public class YourActivity extends Activity {
  ...
  
  @Override
  protected void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
      if (adapter != null) {
          adapter.saveStates(outState);
      }
  }

  @Override
  protected void onRestoreInstanceState(Bundle savedInstanceState) {
      super.onRestoreInstanceState(savedInstanceState);
      if (adapter != null) {
          adapter.restoreStates(savedInstanceState);
      }
  }
}

Useful Methods/Attributes

app:minDistRequestDisallowParent: The minimum distance (in px or dp) to the closest drag edge that the SwipeRevealLayout will disallow the parent to intercept touch event. It basically means the minimum distance to swipe until a RecyclerView (or something similar) cannot be scrolled.

setSwipeListener(SwipeListener swipeListener): set the listener for the layout. You can use the full interface SwipeListener or a simplified listener class SimpleSwipeListener

open(boolean animation), close(boolean animation): open/close the layout. If animation is set to false, the listener will not be called.

isOpened(), isClosed(): check if the layout is fully opened or closed.

setMinFlingVelocity(int velocity): set the minimum fling velocity (dp/sec) to cause the layout to open/close.

setDragEdge(int edge): Change the edge where the layout can be dragged from.

setLockDrag(boolean lock): If set to true, the user cannot drag/swipe the layout.

viewBinderHelper.lockSwipe(String... id), viewBinderHelper.unlockSwipe(String... id): Lock/unlock layouts which are binded to the binderHelper.

viewBinderHelper.setOpenOnlyOne(boolean openOnlyOne): If openOnlyOne is set to true, you can only open one row at a time.

viewBinderHelper.openLayout(String id): Open a layout. id is the id of the data object which is bind to the layout.

viewBinderHelper.closeLayout(String id): Close a layout. id is the id of the data object which is bind to the layout.

License

 The MIT License (MIT)

 Copyright (c) 2016 Chau Thai

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.

swipereveallayout's People

Contributors

chthai64 avatar geovie avatar nwanvu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swipereveallayout's Issues

Open One at a time

Is it possible to open only one at a time? Eg. if row 1is opened and I now opens row two means , row one should automatically close.

lock swipe just for some rows?

I looked into the documentation but I haven't found much.

I tried to set an empty SwipeListener and I looked if there was a "null" value for the dragEdge property. None of the solutions above worked.

ListView OnItemClickListener not working

if I set the

 listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                  click();
            }
        });

the event is never fired. I tried to put as many items in my row not clickable or focusable.
Is that something that can happen with this library or should I look somewhere else?

setOpenOnlyOne does not work

I am using version 1.4.0 on Android 6.0.1 and the setOpenOnlyOne option doesn't seem to work.

I use Gradle to get the library as follows:

compile 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.0'

Then in my view holder I create the binderhelper and set the setOpenOnlyOne option as follows:

private final ViewBinderHelper viewBinderHelper;
viewBinderHelper = new ViewBinderHelper();
viewBinderHelper.setOpenOnlyOne(true);

I am using a RecyclerView and I can still slide all of the views open.

However

onItemClick in ListView not working...

regarding on #6 , still i cannot make it work pls. help... specially the last part that you mentioned...
"use adapter.setOnItemClickListener() before attaching it to the listview"... sorry i just new on android development.. thanks :)

How to get dragEdge both side

Hi, I want to add buttons both side of list item in listview like accept and reject , But i found dragEdge should be any one how to achieve both side dragEdge .

after scrolling recyclerView, items in list changed there size...

hi
i have one recyclerView with cardview items
inside SwipeRevealLayout ... FrameLayout1 ... have 2 linear (such edit and delete) with layout_height=match_parent ... inside FrameLayout2 have one cardview
i want both card view and framelayout1 have same size...
but framelayout1 before scrolling is wrap_content after scrolling recyclerView both framelayouts have same size :|

now what should i do !?
English is not my mother tongue; please excuse any errors on my part

<com.chauthai.swipereveallayout.SwipeRevealLayout

android:id="@+id/swipe_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="ltr"
app:dragEdge="right"
app:mode="normal">

 <FrameLayout
    android:id="@+id/dsad"
    android:layout_width="@dimen/value_70dp"
    android:layout_height="match_parent"
    android:layout_gravity="center"

    android:gravity="center"
>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="@dimen/value_5dp"
        android:layout_marginTop="@dimen/value_10dp"

        android:orientation="vertical"
        android:weightSum="2">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/delete"
            android:orientation="vertical"

            android:weightSum="2"
        >
            <LinearLayout
                android:id="@+id/address_list_item_edit"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@color/edit"

                android:gravity="center"

                android:orientation="vertical">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:padding="@dimen/value_10dp"

                    android:src="@drawable/ic_create_white_36dp"
                />


            </LinearLayout>

            <LinearLayout
                android:id="@+id/address_list_item_delete"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"

                android:orientation="vertical">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:padding="@dimen/value_10dp"

                    android:src="@drawable/ic_delete_forever_white_36dp"
                />


            </LinearLayout>
        </LinearLayout>


    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    </LinearLayout>

</FrameLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
>

    <android.support.v7.widget.CardView

        android:id="@+id/cardvie2w"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        card_view:cardBackgroundColor="@android:color/white"
        card_view:cardCornerRadius="5dp"
        card_view:cardElevation="4dp"
        card_view:cardUseCompatPadding="true"
        card_view:contentPadding="5dp"
    >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/basket_btn_buy"
            android:orientation="vertical">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="right|center"
                android:gravity="right|center"
                android:orientation="horizontal">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <TextView
                        android:id="@+id/address_list_item_country"
                        fontPath="fonts/sansbold.ttf"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentStart="true"
                        android:layout_centerVertical="true"
                        android:text="@string/hint_country"

                        android:textAppearance="?android:attr/textAppearanceSmall"
                        tools:ignore="MissingPrefix"
                    />
                    <TextView
                        android:id="@+id/address_list_item_title"
                        fontPath="fonts/sansbold.ttf"
                        tools:ignore="MissingPrefix"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_centerVertical="true"
                        android:layout_toEndOf="@+id/address_list_item_country"
                        android:gravity="right"
                        android:text="@string/hint_name"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textColor="@color/adrs_title1"
                       />
                </RelativeLayout>
            </LinearLayout>
            <View
                android:id="@+id/view"
                android:layout_width="wrap_content"
                android:layout_height="1dp"
                android:layout_gravity="center"
                android:background="@android:color/darker_gray"/>

        
            
            </LinearLayout>
          
           
           
           
        </LinearLayout>


    </android.support.v7.widget.CardView>

</FrameLayout>

</com.chauthai.swipereveallayout.SwipeRevealLayout>

SwipeRevealLayout.close will not do anything

After my my onClickListener is called I have the swipeLayout close. However when I call the close method nothing occurs regardless of whether I set animation to true or false

Open the swipe during Notify

Hi,
I used to update my list every half a second since I am updating data through streaming TCP connection.
During notifyDatasetChanged calling, if I try to swipe , it is giving a jerk and closes instead of opening.

Last item of adapter XML not filling parent

Hello, i was testing your library to use it on an app and i found a weird bug.
this is my swipe layout test xml :
<!-- Your secondary layout here --> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginRight="20dp"> <Button android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="EDIT"/> <Button android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="DELETE"/> </LinearLayout>
using RecyclerView.Adapter's typical implementation (https://developer.android.com/training/material/lists-cards.html) , and following your readme guide, on the last item of the adapter's dataset, the buttons show small (wrapped around the text) and don't match or fill the parent ( i've tried both match_parent and fill_parent) , it looks like they're defaulting to wrap_content.

the rest of the interface works correctly, and the rest of items show fine, it's just the last two buttons.

occurred error log

ViewDragHelper: Ignoring pointerId=0 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because ViewDragHelper did not receive all the events in the event stream.

incorrect match_parent height in menu items

I still have an issue with incorrect height of menu item.

compile 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.0'

<com.chauthai.swipereveallayout.SwipeRevealLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:dragEdge="right"
    app:mode="same_level"
    >

    <include
        layout="@layout/layout_action"/>

    <include
        layout="@layout/layout_main"
        />

</com.chauthai.swipereveallayout.SwipeRevealLayout>

layout_action:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:background="@color/blue"
    >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:background="@color/red"
        android:drawablePadding="5dp"
        android:drawableTop="@drawable/ic_close"
        android:gravity="center"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:text="Delete"
        android:textColor="@color/white"
        android:id="@+id/action_delete"
        />

    <View
        android:layout_width="30dp"
        android:layout_height="match_parent"
        android:background="@color/green"
        />
</LinearLayout>

If we make a swipe for the first time without scrolling the recyclerview:
image

if we scroll first (and make this items to be recycled-reused):
image

Improper ListView row while changing orientation from Landscape to Portrait & vice-versa

Hi,

I observed that when you change orientation from Portrait to Landscape the ListView row sticks to the same width giving improper size of ListView row. Also, same is the case with changing orientation from Landscape to Portrait.

I am using

android:configChanges="orientation|keyboardHidden|screenSize"

in AndroidManifest.xml

Please provide the fix!

Thanks!

Swipe item too sensitive, it is hard to do onClick

I use a Recycler view where user can do click, long click and swipe. I don't have any problem with long click and swipe, but when I try to do a click, four out five times, I end up getting a swipe gesture instead a click.

I tried app:minDistRequestDisallowParent=20dp but I do not notice any improvement. Also I tried setMinFlingVelocity without success.

Any idea about what I'm doing wrong?
Thanks.

How can i set drag sensitivity for swipe layout

How can i set drag sensitivity for swipe layout ? In the some devices (as Sony Xperia Z4), too difficult to click children in swipe layout.

I did try this:
mDragHelper = ViewDragHelper.create(this, 1.0f, mDragHelperCallback);
==> mDragHelper = ViewDragHelper.create(this, 0.1f, mDragHelperCallback);
But it still too sensitivity, so difficult to click to children view.

Thanks in advanced.

Delete and other layouts are clickable even before revealing them

Video which shows the bug: https://dl.dropboxusercontent.com/u/19390574/reveal_layouts_clickable_bug.mp4

RecyclerViewHolder where the binding of the layouts is done:

private class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
    private SwipeRevealLayout swipeLayout;
    private View deleteLayout, deactivate_layout;
    private TextView medicineNameTV, medicineDescriptionTV, medicineIntakeDetailsTV;

    public ViewHolder(View itemView) {
      super(itemView);

      swipeLayout = (SwipeRevealLayout) itemView.findViewById(R.id.swipe_layout);
      deleteLayout = itemView.findViewById(R.id.delete_layout);
      deactivate_layout = itemView.findViewById(R.id.deactivate_layout);
      medicineNameTV = (TextView) itemView.findViewById(R.id.medicineNameTV);
      medicineDescriptionTV = (TextView) itemView.findViewById(R.id.medicineDescriptionTV);
      medicineIntakeDetailsTV = (TextView) itemView.findViewById(R.id.medicineIntakeDetailsTV);
    }

    public void bind(Medication medicationItem) {
      deleteLayout.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View v) {
          medicationDAO.delete(medicationsList.get(getAdapterPosition()));
          medicationsList.remove(getAdapterPosition());
          notifyItemRemoved(getAdapterPosition());
        }
      });

      medicineNameTV.setText(WordUtils.capitalizeFully(medicationItem.getName()));
      medicineDescriptionTV.setText(medicationItem.getDescription());
      medicineIntakeDetailsTV.setText(medicationItem.getDosage()
          + " - "
          + medicationItem.getWhen()
          + " - "
          + medicationItem.getFrequency());
    }
  }

XML holding the layout for each of the recyclerview's items:

<?xml version="1.0" encoding="utf-8"?>
<com.chauthai.swipereveallayout.SwipeRevealLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/swipe_layout"
    android:layout_width="match_parent"
    android:layout_height="@dimen/medications_list_row_item_height"
    android:background="@color/white"
    android:clickable="false"
    android:focusable="true"
    app:dragEdge="right"
    app:mode="normal"
    >

  <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:orientation="horizontal"
      >

    <RelativeLayout
        android:id="@+id/deactivate_layout"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@color/camera_gray_color"
        android:gravity="center"
        android:paddingEnd="@dimen/default_margin_1"
        android:paddingStart="@dimen/default_margin_1"
        >

      <ImageView
          android:id="@+id/deactivateImageIV"
          android:layout_width="@dimen/action_items_delete_deactivate_icons"
          android:layout_height="@dimen/action_items_delete_deactivate_icons"
          android:layout_centerInParent="true"
          android:src="@drawable/ic_deactivate_medication"
          />

      <TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/deactivateImageIV"
          android:layout_centerHorizontal="true"
          android:gravity="center"
          android:text="Deactivate"
          android:textColor="@android:color/white"
          />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/delete_layout"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@color/medication_list_delete_action_layout_red"
        android:gravity="center"
        android:paddingEnd="@dimen/default_margin_2"
        android:paddingStart="@dimen/default_margin_2"
        >

      <ImageView
          android:id="@+id/deleteImageIV"
          android:layout_width="@dimen/action_items_delete_deactivate_icons"
          android:layout_height="@dimen/action_items_delete_deactivate_icons"
          android:layout_centerInParent="true"
          android:src="@drawable/ic_delete_medication"
          />

      <TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/deleteImageIV"
          android:layout_centerHorizontal="true"
          android:gravity="center"
          android:text="Delete"
          android:textColor="@android:color/white"
          />
    </RelativeLayout>
  </LinearLayout>

  <RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="@dimen/medications_list_row_item_height"
      android:background="@color/white"
      >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingStart="@dimen/default_margin_2"
        android:paddingTop="@dimen/default_margin_2"
        >

      <TextView
          android:id="@+id/medicineNameTV"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:paddingBottom="@dimen/default_margin_1"
          android:textColor="@android:color/black"
          />

      <TextView
          android:id="@+id/medicineDescriptionTV"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:textColor="@color/medication_list_item_name_gray"
          />

      <TextView
          android:id="@+id/medicineIntakeDetailsTV"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:textColor="@color/medication_list_item_name_gray"
          />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/arrowLayout"
        android:layout_width="@dimen/right_arrow_layout_width"
        android:layout_height="match_parent"
        android:layout_alignParentEnd="true"
        android:background="@color/much_lighter_gray"
        android:gravity="center"
        >

      <ImageView
          android:layout_width="@dimen/far_right_arrow_icon_dimens"
          android:layout_height="@dimen/far_right_arrow_icon_dimens"
          android:src="@drawable/ic_arrow_right_blue"
          />
    </LinearLayout>

    <ImageView
        android:id="@+id/reminderStatusIV"
        android:layout_width="@dimen/reminder_status_icon_dimens"
        android:layout_height="@dimen/reminder_status_icon_dimens"
        android:layout_centerVertical="true"
        android:layout_gravity="end|center_vertical"
        android:layout_marginEnd="@dimen/default_margin_1"
        android:layout_toStartOf="@+id/arrowLayout"
        android:src="@drawable/ic_reminder_active"
        />

  </RelativeLayout>
</com.chauthai.swipereveallayout.SwipeRevealLayout>

Any help with this? Thanks for a cool lib

Less sensitive to user touches

Hello, I'm Natali.

I have some question about swiping item when RecyclerView starts scrolling.
When I starts scrolling list or try to click item pretty often item start dragging .
See small video.
https://drive.google.com/file/d/0B3hDpYmjmuijanZ0bDlvbjZPN2c/view?usp=sharing
May be I should config some option for SwipeRevealLayout to prevent dragging item or do item less sensitive to user touches? Please can you can help me?

Thanks

P.S. And thanks for your good library

Gap issue in rounded layouts

If we choose a rounded view , then there is a gap between swipe and reveal layout.
I guess it could be fixed if we had the option to adjust the swipeable width of the layout so that they both overlap a bit.

how to perform onItemClick in ListView?

Hi, l add setOnClickListener in my adapter for convertView, when l click this item, nothing happen, only delete view get response.the code is:
holder.delete.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
Toast.makeText(mContext, "position: " + position, Toast.LENGTH_SHORT).show();
}
});

convertView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Toast.makeText(mContext, "position: " + position, Toast
                .LENGTH_SHORT).show();
    }
});

and xml is:
<com.chauthai.swipereveallayout.SwipeRevealLayout
android:id="@+id/swipe"
android:background="#F7F4F2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:dragEdge="right"
app:mode="same_level"

<LinearLayout
    android:paddingTop="20dp"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:background="#F7F4F2">

    <ImageView
        android:id="@+id/item_write"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:src="@mipmap/community_detail_comment_btn"/>

    <ImageView
        android:id="@+id/item_praise"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:src="@mipmap/community_detail_nice_btn"/>

    <ImageView
        android:layout_marginRight="15dp"
        android:id="@+id/item_delete"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:src="@mipmap/community_detail_delete_btn"/>
</LinearLayout>


<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:orientation="vertical"
    >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:layout_marginLeft="20dp"
        android:background="@color/common_lineColor"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="10dp"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="22dp">

        <ImageView
            android:id="@+id/comment_item_praise_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@mipmap/community_detail_nice_icon"/>

        <TextView
            android:id="@+id/comment_item_praise_count"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="11dp"
            android:layout_toRightOf="@+id/comment_item_praise_icon"
            android:text="13"
            android:textColor="@color/common_textColor_93"
            android:textSize="14sp"/>

        <TextView
            android:id="@+id/comment_item_username"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginLeft="11dp"
            android:text="God Love"
            android:textColor="@color/common_textColor_93"
            android:textSize="14sp"/>
    </RelativeLayout>

    <TextView
        android:id="@+id/comment_item_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="22dp"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:text="contentcontentcontentcontentcontentcontent"
        android:textColor="#474747"
        android:textSize="17sp"
        />
</LinearLayout>

</com.chauthai.swipereveallayout.SwipeRevealLayout>

Plese help me...

Fast swipe handled by viewpager, not swipereveallayout

Thanks for your good library!

I am doing doing a viewpager and one of the pages are populated with a list of SwipeRevealLayout items.
My problem is that a fast swipe on the SwipeRevealLayout item triggers the viewpager instead.
Is there a way to ensure that it is the SwipeRevealLayout item, that is triggered, also for fast swipe?

layout_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
<android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</RelativeLayout>

context.xml (RevealLayoutItem)

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_gravity="left"
    android:gravity="left"
    android:layout_margin="10dp"
    android:background="@android:color/black"
    android:layout_height="wrap_content"
    android:layout_width="match_parent">

    <com.chauthai.swipereveallayout.SwipeRevealLayout
        android:id="@+id/swipe_layout"
        android:layout_width="match_parent"
        android:layout_height="82dp"
        app:dragEdge="right"
        app:mode="same_level">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="150dp"

                android:background="#00FF00"
                android:orientation="vertical"
                android:showDividers="middle"
                android:layout_margin="40dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="8dp"
                    android:text="Details" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:layout_marginRight="100dp"
                android:background="#ffffff"
                android:orientation="vertical"
                android:showDividers="middle">

                <TextView
                    android:id="@+id/row1_col1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:padding="8dp"
                    android:text="Obligationslån, 5%" />
            </LinearLayout>

        </com.chauthai.swipereveallayout.SwipeRevealLayout>
</LinearLayout>

How to revel two panels?

Is posible swipe left and right, show diferents panels?
Sample:
swipe left panel show (delete action) and swipe right reveal panel (other options)

Can't drill into list item to view detail page

Hi there,

Thank you for the library.

I have followed your example exactly to reveal a delete button on swipe, which works as anticipated. Except that even when the delete button is not in the foreground (i.e: it is under the main layout) and i click on that part of the foreground view, the list item gets deleted. Also, its a recycler view and I am not able to drill into the list item detail page when i click on the list item, it just deletes the item.

I think the delete button's visibility needs to be set to gone and should be made visible onSwipe of the layout.

Please any help at your earliest convenience will be much appreciated.

Click method won't work for any item

Click method won't work for any item in recycler view adapter. Only prints

ViewRoot's Touch Event : ACTION_DOWN
ViewRoot's Touch Event : ACTION_UP

conflict with other libraries?

Hello..
I think there is conflict with google service and support libraries, cause when I just add dependecy of swipereveallayout and ran project it stopped with this error:
"The Google Play services resources were not found. Check your project configuration to ensure that the resources are included."

support version 23.3.0
play-services 8.4.0
what is the solustion?

rows don't adapt on rotation

how can I have the rows to readapt to the new width on rotation? I would like to avoid to handle the rotation event and redraw the whole list.
Is there a way?

thank you

Left and Right Swiping

Is there any option for left and right swiping at same time like this example? If there is how can I achieve that?

problem with notifydatasetchanged() in 4.4.1

Hello! I have a problem in Android 4.4.1 when I use notifydaSetChanged():
elements updating incorrectly. In Android 5+ It's work perfectly.
P.S. trouble in the binderHelper.bind(holder.swipeLayout, String.valueOf(position));
(If I comment out this line, everything will work fine in 4.4.1 (except swipe)
What I did wrong?

   @Override
    public void onBindViewHolder(PointViewHolder holder, int position) {
        binderHelper.bind(holder.swipeLayout, String.valueOf(position));
        if (position == 0) setupFirstItem(position, holder);
        else if (position == points.size() - 1) setupLastItem(position, holder);
        else setupAnotherItem(position, holder);
        holder.tvAddress.setText(DataChecker.getCorrectAddress(points.get(position).getAddress()));
        setupListeners(holder, position);
    }

Swipe and LongClick

I use the lib in a project where list items need to handle

  • swipe right
  • click
  • long-click

The behavior is almost ok, but I still have an issue on usability between the longclick and the swipe events. Actually, if the finger is put on the item to perform a longclick event, this is very often the swipe event that is taken into account.

Are you aware of this behavior ?
I make a try with setMinFlingVelocity, but nothing really changed.

Looking at Gmail app, it seems it runs with a kind of horizontal offset before the swipe event is taken into account. Is there any way to do that with the lib ?

Support of margins for layout revealed by swipe

Thank you for great lib!

I have a proposal. What do you think re inheriting the layout from, say RelativeLayout and handle margins in onLayout like this:

        child.layout(
                left + childParams.leftMargin,
                top + childParams.topMargin,
                right - childParams.rightMargin,
                bottom - childParams.bottomMargin
        );

?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.