Skip to content
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

get checked items? #7

Closed
MohsenShafiee opened this issue Mar 22, 2016 · 10 comments
Closed

get checked items? #7

MohsenShafiee opened this issue Mar 22, 2016 · 10 comments

Comments

@MohsenShafiee
Copy link

Hi
how to get the checked items? and their count?
how to mark list items?

thanks...

@davideas
Copy link
Owner

Hello, isFlipped() returns the checked status and also the OnFlippingListener is called when the views flip, but if I understood correctly you want to know how many are marked checked/selected. Well, that is the Adapter implementation.
You need to mark that, a specific position is selected when the flip event occurs.
If you check the dev branch of my other project https://github.com/davideas/FlexibleAdapter/tree/dev I use the ExampleAdapter to know how many are selected, FlipView is just a simple view with some static variable to add more effects, then you need to handle the flip/selection in the adapter implementation.

I hope I answered at your question.

@MohsenShafiee
Copy link
Author

the flexible adapter is great...
but the example app menu is not complete I think...
I cant see any Expandable or swipable adapter
just this:
undo
do you support something like this:
screenshot_2015-07-08-15-00-58

you helped a lot thank you...

@MohsenShafiee
Copy link
Author

another thing!
Flexible adapter stops working on create action mode on android 4.3
on andriod 5.1.1 its ok

@davideas
Copy link
Owner

@TheLoyalCruel, check dev branch and releases, it is everything there, app also should work on 14+.
the swipe is foreseen it works for delete, but to display others views there's more work to do, I have checked that it is possible, but i need time.

@Dreamystify
Copy link

The isFlipped() method is very inaccurate, i'm getting true when I can see it's not flipped at all....

@davideas
Copy link
Owner

@DreamCatcha, in the flip() method, the real flip is run in post (also with a delay if you specify it), therefore if you retrieve the flipped status right after the flip command you will receive false anyway.

There's also a listener that is called after the flipping status is changed, you might check that.
Finally, there's also flipSilently() which is run synchronously along with the call, but without flipping animation.

Maybe, what I can enhance, is to run the real flip synchronously (without post) if delay is 0.

@Dreamystify
Copy link

My use case is I wanted to check if its flipped or not and then use

holder.noteFlipView.flip(isSelected(position));

because if its already false and it is set to false again it still does a slight flip animation, a great addition you could add would be to ignore the flip if the state won't change. I tried:

if(holder.noteFlipView.isFlipped() != isSelected(position)) {
    holder.noteFlipView.flip(isSelected(position));
}

and its here I'm finding it works sometimes and not others, it shouldn't have a issue but does

@Dreamystify
Copy link

Ok I solved it by adding a conditional in the flip method;

final public void flip(final int whichChild, long delay) {
    if (!isEnabled()) {
        if (DEBUG) Log.w(TAG, "Can't flip while view is disabled");
        return;
    }
    if (DEBUG) {
        Log.d(TAG, "Flip! whichChild=" + whichChild + ", previousChild=" + getDisplayedChild() + ", delay=" + delay);
    }
----------
    // This stops a flip if the new value is the same as the old value
    if(whichChild == getDisplayedChild()) {
        return;
    }
----------
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            checked = (whichChild == FRONT_VIEW_INDEX || getDisplayedChild() == FRONT_VIEW_INDEX);//It's tricky!
            setDisplayedChild(whichChild);//start main animation
            animateRearImageIfNeeded();
            mFlippingListener.onFlipped(FlipView.this, checked);
            }
        }, delay);
    }
}

@davideas
Copy link
Owner

@DreamCatcha, I think you are right, I just need to double check if it is coherent with the rest of the code (it should) so I will make a new release.

If you have others remarks I can evaluate them and put it in the same release. Please tell me.

I will take the opportunity to upgrade the project to the new API as well.

@davideas davideas reopened this Nov 28, 2016
@davideas davideas added the bug label Nov 28, 2016
@Dreamystify
Copy link

Its working beautifully for me, nothing else to add at this point ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants