Closed MohsenShafiee closed 7 years ago
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.
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: do you support something like this:
you helped a lot thank you...
another thing! Flexible adapter stops working on create action mode on android 4.3 on andriod 5.1.1 its ok
@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.
The isFlipped() method is very inaccurate, i'm getting true when I can see it's not flipped at all....
@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.
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
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);
}
}
@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.
Its working beautifully for me, nothing else to add at this point ;)
Hi how to get the checked items? and their count? how to mark list items?
thanks...