Skip to content

swipeLayout gone when something on swipe view changed #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
IlyaEremin opened this issue Sep 28, 2014 · 40 comments
Open

swipeLayout gone when something on swipe view changed #36

IlyaEremin opened this issue Sep 28, 2014 · 40 comments
Labels

Comments

@IlyaEremin
Copy link

For example: my swipeLayout has textView.
I open my swipe layout with gesture. Click on it. OnClickListener change textview text. After changing text swipeLayout closed :(

@daimajia
Copy link
Owner

Please send me an apk to my mailbox.

@S2V
Copy link

S2V commented Oct 3, 2014

I have the same problem. By clicking I change the text, everything happens for a chain: Adapter - click - static method in the fragment. May be important - I used JazzyListView.

Adapter part

 public void fillValues(int position, View convertView) {
        ClientOrderItem orderItem = items.get(position);
        RobotoTextView count = (RobotoTextView) convertView.findViewById(R.id.count);        
        RobotoTextView countEdit = (RobotoTextView) convertView.findViewById(R.id.count_edit);
        RobotoTextView incrementEdit = (RobotoTextView) convertView.findViewById(R.id.increment_edit);
        RobotoTextView decrementEdit = (RobotoTextView) convertView.findViewById(R.id.decrement_edit);
        ImageView removeEdit = (ImageView) convertView.findViewById(R.id.remove_edit);       
        count.setText(orderItem.getCount()+"");
        countEdit.setText(orderItem.getCount()+"");
        incrementEdit.setTag(new ClientOrderActionTag(ClientOrderActionTag.ClientOrderItemAction.INCREMENT, position));
        incrementEdit.setOnClickListener(this);
        decrementEdit.setTag(new ClientOrderActionTag(ClientOrderActionTag.ClientOrderItemAction.DECREMENT, position));
        decrementEdit.setOnClickListener(this);
        removeEdit.setTag(new ClientOrderActionTag(ClientOrderActionTag.ClientOrderItemAction.REMOVE, position));
        removeEdit.setOnClickListener(this);
    }

OnClick(impl. in adapter class) part

@Override
    public void onClick(View v) {
        ClientOrderActionTag tag = (ClientOrderActionTag)v.getTag();
        if(tag.action == ClientOrderActionTag.ClientOrderItemAction.INCREMENT){
            ClientOrderFragment.incrementCountForItem(tag.position);
        }
        else if(tag.action == ClientOrderActionTag.ClientOrderItemAction.DECREMENT){
            //
        }
        else{
            //
        }
    }

Fragment part

static void incrementCountForItem(int position){
        View itemView = (View) orderList.getChildAt(position - orderList.getFirstVisiblePosition());
        RobotoTextView countView = (RobotoTextView)itemView.findViewById(R.id.count);
        RobotoTextView countEditView = (RobotoTextView)itemView.findViewById(R.id.count_edit);
        int count = Integer.parseInt(countView.getText().toString())+1;
        ClientOrderItem item = orderItems.get(position);
        item.setCount(count);
        countEditView.setText(count+"");
        countView.setText(count+"");
    }

@IlyaEremin
Copy link
Author

Any changes?

@S2V
Copy link

S2V commented Nov 23, 2014

@IlyaEremin Yeap - in 1.1.7 it work as I (We) expected, but swipe adapter class interface changed. I am test it on Lenovo Yoga Tablet 10(4.2.2) and Nexus 10 (4.4). I am sorry for my lousy English. Good job, guys. P.S. I think issue-ticket need close.

@IlyaEremin
Copy link
Author

@S2V I tried 1.1.7 but problem stays.

@IlyaEremin
Copy link
Author

@daimajia hi there!
Eventually I found roots of problem.

Usercase:
When SwipeLayout is opened and when some TextView inside SwipeLayout call setCompoundDrawablesWithIntrinsicBounds then swipe layout closed by itself.

Here is sample project and class with main behaviour and apk file

Note, that not only setCompoundDrawablesWithIntrinsicBounds cause closing SwipeLayout. But now I can not provide more examples.

@daimajia
Copy link
Owner

@IlyaEremin Hey guy, if you are available, please try the latest version, I think this issue has already been fixed in the latest version. :-D The latest version is 1.2.0

@IlyaEremin
Copy link
Author

@daimajia I tried it on latest 1.2.0 version. I added sample apk too.

@daimajia
Copy link
Owner

@IlyaEremin How about on 1.2.0?

@IlyaEremin
Copy link
Author

@daimajia I tried both 1.2.0 and 1.2.0@aar. The result is same :(

@daimajia
Copy link
Owner

@IlyaEremin I mean if it's still buggy when using 1.2.0 library.

@daimajia
Copy link
Owner

@IlyaEremin Ok, I get it. Let's me try your sample project.

@IlyaEremin
Copy link
Author

@daimajia please, tell me when will you investigave this issue )

@sata73
Copy link

sata73 commented May 22, 2015

Hi There, thanks for the great lib but I have the same issue with closing the SwipeLayout automatically.
It happens in both situations, either when updating a textview inside the bottom view and also when updating a textview inside the surface view.
In the bottom view I update the textview with an setOnValueChangedListener() and in the surface view with a handler.

@sata73
Copy link

sata73 commented May 29, 2015

@daimajia Could you kindly help us and tell when you might investigate this issue?

@sata73
Copy link

sata73 commented Jun 11, 2015

@daimajia I hope not to bother but do you need some more information from us for investigating this issue?

@IlyaEremin
Copy link
Author

@sata73 I think he needs more time :)
And I think we can fix this issue ourselves, but I have no time too :)

@daimajia
Copy link
Owner

@sata73 I'm here, sorry for my late, recently just so busy on work... hope you can understand.

@daimajia
Copy link
Owner

When calling setText on TextView it will call requestLayout method to reset parent view. So the SwipeLayout will redraw...

Any idea on this issue? @jpshelley @linfaxin

http://stackoverflow.com/questions/20782916/calling-settext-on-a-textview-calls-requestlayout-which-resets-parent-views-o

@daimajia daimajia added the bug label Jun 11, 2015
@sata73
Copy link

sata73 commented Jun 11, 2015

@daimajia thanks a lot for your reply. Your help and of course your Lib is highly appreciated! Thanks guys!

@zeroarst
Copy link

zeroarst commented Jul 6, 2015

Jump from swipelistview to here but encountering this issue...any updates?

@vavrecan
Copy link

getOpenStatus calculates current state from layout - I suggest store state and then restore it on global layout event - this should fix your problems guys #191

cheers

@REWKyleB
Copy link

Only seems to be an issue on <= 4.4

@IlyaEremin
Copy link
Author

@REWKyleB nope, I observed this bug on 5.0

@sata73
Copy link

sata73 commented Jul 29, 2015

I can confirm that this happens also on 5.x

@benny-jon
Copy link

hi @daimajia , I tried to demo app and every time I slide the view to show the options it closes automatically. Do anyone knows how to get this library working ? Thanks

@cxbiao
Copy link

cxbiao commented Aug 1, 2015

hi @daimajia ,in android studio 1.3 classpath 'com.github.dcendents:android-maven-plugin:1.2' the maven-plugin can't build well. My gradle version is 2.4. I think you can update the library.

@sata73
Copy link

sata73 commented Aug 14, 2015

Thanks for the suggested solution from #191 but to be honest this doesn't seem to me to be a proper solution to restore the layout state every time anything changes.
In my case I have a number picker in the surface layout which updates a textview with a calculated value when number picker is used. So when the user "spins" the picker, restoring the layout every time sounds really hacky to me.

@Drashti-Patel
Copy link

Swipe layout open on drag but it closed itself,it can't remains open for a while.

@jalpesh
Copy link

jalpesh commented Aug 31, 2015

Facing same issue as Drashti, but on specific devices like Acer and Micromax. I noticed the onOpen function gets called tice or thrice, but works fine on almost all other phones. The swipe layout opens and immediately closes.

@sata73
Copy link

sata73 commented Aug 31, 2015

I can confirm that it happens on Sony Xperia devices as well as on the LG Nexus 5

@GaidamakUA
Copy link

Any updates on this?

@sylvia43
Copy link

@GaidamakUA Looks like this is a potential fix: #191

@sylvia43
Copy link

@GaidamakUA Update: You can get that version using Jitpack:

Add this to your root build.gradle:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Then add this to your module dependencies:
compile 'com.github.vavrecan:AndroidSwipeLayout:eaba6c5c69'

Note that it is a few commits behind master.

@briantes
Copy link

Hello. I have the same problem with ConkerTab SX5, but no with other devices. Any solutions?

@GaidamakUA
Copy link

GaidamakUA commented Jun 23, 2016

Top level
@anubiann00b But I have problems adding it.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
...
}
...

And neither of these works

dependencies {
...
    compile 'com.github.vavrecan:AndroidSwipeLayout:eaba6c5c69'
    compile 'com.github.daimajia:AndroidSwipeLayout:be4a2c7c84'
}

@sylvia43
Copy link

@GaidamakUA Just a hunch: you need to add it to your allProjects -> repositories, not your builtscript -> repositories. I'm not totally sure but I think buildscript repositories are just for your gradle build scripts, and your project repositories are for project dependencies.

@zenkhas
Copy link

zenkhas commented Jul 2, 2016

Anyone got a solution? I'm having the same issue. I need to show a progress view in the bottom layout but it gets close when someone clicks.

@ThijsmvSchaik
Copy link

@zenkhas Yes there is an solution.
You have to add a SwipeListener and a GlobalLayoutListener to your SwipeLayout
Add an GlobalLayoutListener to your swipeLayout and keep a variable with the value isOpening>
Example

swipeLayout.addSwipeListener(new SimpleSwipeListener() {
        @Override
        public void onStartOpen(SwipeLayout layout) {
            isOpenSwipeLayout = true;
        }

        @Override
        public void onStartClose(SwipeLayout layout) {
            isOpenSwipeLayout = false;
        }
    });

    swipeGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            if (isOpenSwipeLayout) {
                // Opens the layout without animation
                swipeLayout.open(false);
            }
        }
    };

swipeLayout.getViewTreeObserver().addOnGlobalLayoutListener(swipeGlobalLayoutListener);

@aitbaali
Copy link

aitbaali commented Sep 9, 2016

@daimajia any solution?

saques added a commit to traies/Flysis2 that referenced this issue Nov 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests