How do I use AndroidPlot most effizient in Recyler View?

16 views
Skip to first unread message

Franzi

unread,
Feb 8, 2018, 8:29:08 AM2/8/18
to Androidplot


Hello Community,

I got the following Problem,

When using an AndroidPlot XYPlot inside a RecyclerView.

the AndroidPlot like this:

<com.androidplot.xy.XYPlot
android:id="@+id/mPlot"
style="@style/APDefacto.Light"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
androidplot.renderMode="use_background_thread"
android:visibility="visible"
ap:lineLabels="left"
android:minHeight="100dp" />

most important here is renderMode="use_background_thread" which sets that the Plot should be drawn in a background thread.

I have to set the ViewHolder as not RecycleAble

ViewHolder vh = new ViewHolder(v,parentContext);
vh.setIsRecyclable(true);

because the Plot becomes gray when only bind RecyclerView. Reason for this is that there are Problems, recalling the background Thread for drawing an element. By setting the Viewholders as not Recyclable, every time a new Item comes in Focus a new ViewHolder is created. Not really efficient, I but faster than using Plots without Backgroud_Thread. Link to my previous post

Then without Background Thread scrolling is really stagnant and not really beautiful.

Thanks for help,

Franzi




Link to my Post on Stackoverflow

Franzi

unread,
Feb 12, 2018, 10:24:09 AM2/12/18
to Androidplot
Stack Trace when implenting without not Recyclable
 
java.lang.IllegalThreadStateException: Thread already started                                                             
at java.lang.Thread.checkNotStarted(Thread.java:849)                                                                               
at java.lang.Thread.start(Thread.java:1059)                                                                               
at com.androidplot.Plot.onSizeChanged(Plot.java:780)                                                                               
at android.view.View.sizeChange(View.java:16748)                                                                               
at android.view.View.setFrame(View.java:16710)                                                                               
at android.view.View.layout(View.java:16627)                                                                               
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)                                                                      
at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1732)                                                                               
at android.widget.LinearLayout.onLayout(LinearLayout.java:1497)                                                                               
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                               
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)                                                                               
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)                                                                               
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)                                                                               
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                               
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)                                                                               
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)                                                                              
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                               
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)                                                                               
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)                                                                               
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)                                                                               
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                               
at android.support.v7.widget.RecyclerView$LayoutManager.layoutDecoratedWithMargins(RecyclerView.java:8968)                                                                               
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1614)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1516)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:608)                                                                               
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3693)                                                                               
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3410)                                                                               
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3962)                                                                               
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                               
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)                                                                               
at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1732)                                                                               
at android.widget.LinearLayout.onLayout(LinearLayout.java:1497)                                                                               
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                               
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)                                                                               
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)                                                                               
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)                                                                               
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                               
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)                                                                               
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)                                                                               
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                              
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:443)                                                                               
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                               
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)                                                                               
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)                                                                               
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                               
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)                                                                               
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)                                                                               
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)                                                                               
at android.view.View.layout(View.java:16630)                                                                               
at android.view.ViewGroup.layout(ViewGroup.java:5437)                                                                               
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)                                                                               
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)                                                                            
at com.android.internal.policy.PhoneWi
Reply all
Reply to author
Forward
0 new messages