The problem is : as I'm creating my custom view heriting from View, I don't have any findById so the pattent viewHolder won't be useFull for me :(
And I'm already implemnting it with the view recycling view system. Indeed, in my View I use some Paint elements that I keep in the instance of my view. Le jeudi 28 juin 2012 15:58:53 UTC+2, MagouyaWare a écrit : > > Nope... http://lmgtfy.com/?q=android+viewholder+pattern > > Thanks, > Justin Anderson > MagouyaWare Developer > http://sites.google.com/site/magouyaware > > > On Thu, Jun 28, 2012 at 7:50 AM, jean-francois garreau < > jean.francois.garr...@gmail.com> wrote: > >> You mean : >> >> >> public View getChildView(int groupPosition, int childPosition, boolean >> isLastChild, View convertView, ViewGroup parent) { >> >> >> >> >> ObjectSubViewNew subView = null; >> >> >> if (convertView == null) { >> >> subView = new ObjectSubViewNew(mainContext, kmUnit); >> >> } else { >> >> subView = (ObjectSubViewNew) convertView; >> >> } >> >> .... >> } >> >> >> ? >> >> >> Le jeudi 28 juin 2012 14:27:14 UTC+2, jean-francois garreau a écrit : >> >>> Hi everyone, >>> >>> I have a problem for optimzing my application. More particulary, an >>> ExpandListView. I found the scroll animation pretty slow compare to what I >>> can see on other application. I have done severals optimizations yet but >>> now I'm faced to a lack of idea for have a fluent scroll... >>> >>> What have done : >>> >>> 1. First i start to create CustomView inherting from View >>> 2. I saw that in log I have lots of GC >>> 3. I have use allocationTracket in DDMS in order to see what are the >>> object created who could cause my GC >>> 4. I identify lots of instanciations of String so I've modify my >>> model in order to carry all the string i need in order to avoid new >>> creations of String >>> 5. I also try to write a reusable object corresponding to a drawable >>> instruction in order to skim throught all instruction during the draw >>> method >>> >>> >>> In order to gives you all information for helping me with my code, here >>> is a litle piece of functionnal. >>> >>> My app is an application which gives you the movies showtimes near your >>> position. The expand list show thoses informations : >>> >>> *Name Cinema : [Image]* >>> distance >>> ------------------------------**------------------------------** >>> ------------------------------ >>> *Movie Name 1 :* time >>> passed time 1 | passed time 2 | *nearest time* | >>> futur time 1 | futur time 2 >>> ------------------------------** >>> ------------------------------**------------- >>> *Movie Name 2 :* time >>> passed time 1 | passed time 2 | *nearest time* | >>> futur time 1 | futur time 2 >>> ------------------------------** >>> ------------------------------**------------- >>> >>> >>> etc. >>> >>> As you can see, on each movie I list all showtimes for the cinema and I >>> have a diferent display according to the current time >>> >>> In term of Model Object, I have this structure in my adapter : >>> >>> ArrayList<TheaterBean> theaterList; // The list of my cinema >>> HashMap<String, Movie> mapMovie; // An hashmap which gives me the movie >>> corresponding to an id >>> >>> >>> The problem I'm facing now is that when i look at the log, I still have >>> lots of GC... and when i looked to the allocationTracker i see that : >>> >>> In first position comes android.graphic.Bitmap from method nativeCreate >>> and it's corresponding stack is : >>> >>>> android.graphics.Bitmap nativeCreate Bitmap.java -2 true >>>> android.graphics.Bitmap createBitmap Bitmap.java 477 false >>>> android.view.View buildDrawingCache View.java 6599 false >>>> android.view.View getDrawingCache View.java 6450 false >>>> android.view.ViewGroup drawChild ViewGroup.java 1571 false >>>> android.view.ViewGroup dispatchDraw ViewGroup.java 1373 false >>>> android.widget.AbsListView dispatchDraw AbsListView.java 1545 false >>>> android.widget.ListView dispatchDraw ListView.java 3138 false >>>> android.widget.**ExpandableListView dispatchDraw >>>> ExpandableListView.java 229 false >>>> android.view.View draw View.java 7008 false >>>> android.widget.AbsListView draw AbsListView.java 2669 false >>>> android.view.ViewGroup drawChild ViewGroup.java 1646 false >>>> android.view.ViewGroup dispatchDraw ViewGroup.java 1373 false >>>> android.view.ViewGroup drawChild ViewGroup.java 1644 false >>>> android.view.ViewGroup dispatchDraw ViewGroup.java 1373 false >>>> android.view.ViewGroup drawChild ViewGroup.java 1644 false >>> >>> >>> In second position comes lots of android.widget.**ExpandableListPosition >>> comming from getRecycleCreate the stack is : >>> >>>> android.widget.**ExpandableListPosition getRecycledOrCreate >>>> ExpandableListPosition.java 121 false >>>> android.widget.**ExpandableListPosition obtain >>>> ExpandableListPosition.java 107 false >>>> android.widget.**ExpandableListConnector$**PositionMetadata obtain >>>> ExpandableListConnector.java 988 false >>>> android.widget.**ExpandableListConnector getUnflattenedPos >>>> ExpandableListConnector.java 176 false >>>> android.widget.**ExpandableListConnector getItemViewType >>>> ExpandableListConnector.java 464 false >>>> android.widget.AbsListView$**RecycleBin getScrapView AbsListView.java >>>> 4603 false >>>> android.widget.AbsListView obtainView AbsListView.java 1465 false >>>> android.widget.ListView makeAndAddView ListView.java 1745 false >>>> android.widget.ListView fillDown ListView.java 670 false >>>> android.widget.ListView fillGap ListView.java 641 false >>>> android.widget.AbsListView trackMotionScroll AbsListView.java 3497 >>>> false >>>> android.widget.AbsListView$**FlingRunnable run AbsListView.java 2994 >>>> false >>>> android.os.Handler handleCallback Handler.java 587 false >>>> android.os.Handler dispatchMessage Handler.java 92 false >>>> android.os.Looper loop Looper.java 130 false >>>> android.app.ActivityThread main ActivityThread.java 3835 false >>> >>> >>> After I have lots of java.lang.ref.SoftReference comming from >>> buildDrawingCache, the stack is : >>> >>>> android.view.View buildDrawingCache View.java 6602 false >>>> android.view.View getDrawingCache View.java 6450 false >>>> android.view.ViewGroup drawChild ViewGroup.java 1571 false >>>> android.view.ViewGroup dispatchDraw ViewGroup.java 1373 false >>>> android.widget.AbsListView dispatchDraw AbsListView.java 1545 false >>>> android.widget.ListView dispatchDraw ListView.java 3138 false >>>> android.widget.**ExpandableListView dispatchDraw >>>> ExpandableListView.java 229 false >>>> android.view.View draw View.java 7008 false >>>> android.widget.AbsListView draw AbsListView.java 2669 false >>>> android.view.ViewGroup drawChild ViewGroup.java 1646 false >>>> android.view.ViewGroup dispatchDraw ViewGroup.java 1373 false >>>> android.view.ViewGroup drawChild ViewGroup.java 1644 false >>>> android.view.ViewGroup dispatchDraw ViewGroup.java 1373 false >>>> android.view.ViewGroup drawChild ViewGroup.java 1644 false >>>> android.view.ViewGroup dispatchDraw ViewGroup.java 1373 false >>>> android.view.ViewGroup drawChild ViewGroup.java 1644 false >>> >>> >>> To resume for 512 allocations : >>> >>> - 67 are coming from : android.graphics.Bitmap >>> - 300 are coming from : android.widget.**ExpandableListPosition >>> - 81 are coming from : java.lang.ref.SoftReference AND java.lang.ref. >>> **WeakReference >>> >>> So I have no idea on how to solve my problem... If you have a new device >>> you would probably don't see the lag effect I mention. For my tests I'm >>> using a SGS. But with the emulator we can observe the GCs >>> >>> All the code is available here : >>> >>> https://github.com/binomed/**CineShowTime-Android/blob/** >>> master/Libraries/CineShowTime/**src/com/binomed/showtime/** >>> android/layout/view/**ObjectSubViewNew.java<https://github.com/binomed/CineShowTime-Android/blob/master/Libraries/CineShowTime/src/com/binomed/showtime/android/layout/view/ObjectSubViewNew.java> >>> >>> for the child view >>> https://github.com/binomed/**CineShowTime-Android/blob/** >>> master/Libraries/CineShowTime/**src/com/binomed/showtime/** >>> android/layout/view/**ObjectMasterView.java<https://github.com/binomed/CineShowTime-Android/blob/master/Libraries/CineShowTime/src/com/binomed/showtime/android/layout/view/ObjectMasterView.java> >>> >>> for the group view >>> https://github.com/binomed/**CineShowTime-Android/blob/** >>> master/Libraries/CineShowTime/**src/com/binomed/showtime/** >>> android/adapter/view/**AbstractResultAdapter.java<https://github.com/binomed/CineShowTime-Android/blob/master/Libraries/CineShowTime/src/com/binomed/showtime/android/adapter/view/AbstractResultAdapter.java> >>> >>> for the adpater (It's an utlity class but we find the sames methods as in >>> ExpandableAdapter) >>> >>> the curent version on market only have the optimization of CustomView. : >>> https://play.google.com/**store/apps/details?id=com.** >>> binomed.showtime&feature=**search_result#?t=** >>> W251bGwsMSwyLDEsImNvbS5iaW5vbW**VkLnNob3d0aW1lIl0.<https://play.google.com/store/apps/details?id=com.binomed.showtime&feature=search_result#?t=W251bGwsMSwyLDEsImNvbS5iaW5vbWVkLnNob3d0aW1lIl0.> >>> >>> >>> I'm open to all new idea for making my application faster :) >>> >>> Maybe by not invoking the requestLayout each time I set a movie but each >>> time a scroll is ended ? >>> >>> If you have any question don't hesitate. >>> >>> regards >>> >>> >>> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en