Comments (8)
Hello, guys. We couldn't reproduce this issue. If there is some custom behavior you want to achieve, you're welcome to fork this lib and apply any customization you need.
from folding-cell-android.
@oleg-vasiliev
I'm facing this issue too after i've updated from 1.0.1 to 1.2.2, i believe that the problem may be:
I'm my case, i'm calling unfold(true)
and the measureViewAndGetBitmap
calls throw this exception, but they will not be used if i choose to skip animation... so for MY CASE the problem would be solved moving those lines to the else
branch that they will be needed (skip animation false)
Also, i've noticed that calling getParent()
for the folding cell returns null.. and that may be why the measures return 0 and we get the exception
I'm inflating the view this way :
(FoldingCell) inflater.inflate(R.layout.view_order_list_item, parent, false);
and calling the unfold after, i can't change the attachToView
to true
because addView(View, LayoutParams) is not supported in AdapterView
Ah, and if its useful, i'm using a ArrayAdapter
and not a RecyclerView
My temp solution is
if(cell.getParent() != null){
cell.unfold(true);
} else {
//Lay down, try not cry, cry a lot if you need the cell unfolded.
}
from folding-cell-android.
I feel your pain. I have been experiencing this since the beginning of time! This is what I'm trying in onBindViewHolder()
:
switch (itineraryItem.getType()) {
case ItineraryItem.TYPE_TIME:
itineraryItemViewHolder.time_foldingcell.setVisibility(View.VISIBLE);
itineraryItemViewHolder.dist_foldingcell.setVisibility(View.GONE);
if (unfoldedIndexes.contains(position) && !itineraryItemViewHolder.time_foldingcell.isUnfolded()) {
itineraryItemViewHolder.time_foldingcell.unfold(true);
} else if(!unfoldedIndexes.contains(position) && itineraryItemViewHolder.time_foldingcell.isUnfolded()) {
itineraryItemViewHolder.time_foldingcell.fold(true);
}
break;
default:
itineraryItemViewHolder.dist_foldingcell.setVisibility(View.VISIBLE);
itineraryItemViewHolder.time_foldingcell.setVisibility(View.GONE);
if (unfoldedIndexes.contains(position) && !itineraryItemViewHolder.dist_foldingcell.isUnfolded()) {
itineraryItemViewHolder.dist_foldingcell.unfold(true);
} else if(!unfoldedIndexes.contains(position) && itineraryItemViewHolder.dist_foldingcell.isUnfolded()) {
itineraryItemViewHolder.dist_foldingcell.fold(true);
}
break;
}
It always gives me the same error when I use the fold()
or unfold()
method:
java.lang.IllegalArgumentException: width and height must be > 0 at android.graphics.Bitmap.createBitmap(Bitmap.java:969) at android.graphics.Bitmap.createBitmap(Bitmap.java:948) at android.graphics.Bitmap.createBitmap(Bitmap.java:915) at com.ramotion.foldingcell.FoldingCell.measureViewAndGetBitmap(FoldingCell.java:346) at com.ramotion.foldingcell.FoldingCell.unfold(FoldingCell.java:121) at com.ramotion.foldingcell.FoldingCell.toggle(FoldingCell.java:224)
from folding-cell-android.
As you can see - it's open source library and you can suggest your own solution for this issue if no one can help. Exception message can give you initial "where to start" information. So all in your hands.
from folding-cell-android.
I agree @oleg-vasiliev I like this library, wish I did have the time to debug this and make a pull req.
from folding-cell-android.
When I was facing this problem, it was because I was setting the visibility gone on the wrong view.
The visibility gone should be on the cell_content_view. Don't know if anyone have done the same mistake, but maybe it helps someone.
from folding-cell-android.
I forked this project and made my fixes. They didn't work :/ . So i looked more deep to find out why the measures were all 0, i changed my content_layout
visibility from gone
to visible
and the measures worked (also, the exception was gone too), but in the RecyclerView
we need the content to be specifically gone
. I've looked at the project code and this:
Was weird, how the view can be measured if it's visibility
is GONE
?
I did moved the measureViewAndGetBitmap
calls to the else
branch to get rid of the exception, so this part alone was supposed to work because the of the contentView.setVisibility(VISIBLE);
:
But it didn't, contentView.getHeight();
still returns 0.
And that's it, i didn't looked any further into the lib.
But I found a solution for my case, and here it is:
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Model model = items.get(position);
bindModel(model);
if (model.shouldBeUnfolded) {
// Find the content layout
View content = holder.foldingCell.findViewById(R.id.content_layout);
// "marks" the content to be visible.
content.setVisibility(View.VISIBLE);
//"schedule" a fold/unfold AFTER the view HAS measurable height
holder.foldingCell.post(() -> {
holder.foldingCell.unfold(true);
});
}
}
from folding-cell-android.
this happens when you put include into framelayout
<com.ramotion.foldingcell.FoldingCell
android:id="@+id/folding_cell"
folding-cell:backSideColor="#000"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/cell_content_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<include layout="@layout/cell_content_layout" />
</FrameLayout>
<FrameLayout
android:id="@+id/cell_title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/cell_title_layout" />
</FrameLayout>
</com.ramotion.foldingcell.FoldingCell>
</LinearLayout>
remove the frame layout and do this if you are using include
<com.ramotion.foldingcell.FoldingCell xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:folding-cell="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
folding-cell:additionalFlipsCount="2"
folding-cell:animationDuration="1300"
folding-cell:backSideColor="@color/bgBackSideColor"
folding-cell:cameraHeight="30">
<!-- CONTENT (UNFOLDED) LAYOUT (MUST BE AT LEAST 2x times BIGGER than content layout bellow)-->
<include layout="@layout/cell_content_layout" />
<!-- TITLE (FOLDED) LAYOUT (MUST BE AT LEAST 2x times SMALLER than content layout above) -->
<include layout="@layout/cell_title_layout" />
</com.ramotion.foldingcell.FoldingCell>
from folding-cell-android.
Related Issues (20)
- folding cell not working with recyclerview HOT 3
- Folding cell show grey background on fold and unfold HOT 5
- [BuggyViews] with scrolling when animation not completed HOT 2
- Scrolling problems when using ScrollView HOT 1
- Cannot able to genrate List With RecyclerView HOT 5
- Scrolling items in RecyclerView HOT 1
- Could not resolve com.ramotion.foldingcell:folding-cell:1.2.3. HOT 1
- Can I use folding cell in recyclerview. HOT 1
- ListView not behaving well HOT 1
- multiple bugs HOT 4
- Animation slows down if MapView is added in RecyclerView item HOT 2
- android illegal character HOT 1
- Animation flickers on Android 10 HOT 19
- Content view doesn't get updated in unfolded state.
- Single Fold
- problem in toggle HOT 1
- Unfold not working when used in Fragement
- Bug after folding a cell, the layout goes out of bounds
- Flicker at the start and end of animation. HOT 1
- Can't load maven website! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from folding-cell-android.