android - Bad Listview Performance on Nexus 4, good on Nexus 7 -
i developing android application @ moment. application has deal large lists alot (thousands of entries, it's playlist).
to add possibility reorder entries, use drag-sort-listview library. additionally, each row has progressbar in it. bar visible on current item (so 1 whole list). however, running huge performance problems on nexus 4 (cm 10.1.2 final), while performance @ nexus 7 (2012, stock). tracked cpu usage while scrolling list fast can (without using fastscroll mechanism. on nexus 7, cpu usage stayed below 30%, on nexus 4 hit 80% , list extremely laggy. logcat output had line
i/choreographer(639): skipped xx frames! application may doing work on main thread.
a few times , ui felt render 1fps.
the problem can't imagine reason this. using viewholder pattern in adapter. because of custom fonts, using font cache.
the getview() method of adapter:
@override public view getview(int position, view convertview, viewgroup arg2) { playlistitem playlistitem = items.get(position); viewholder holder; if (convertview == null) { convertview = inflater.inflate(r.layout.list_item_playlist, null); holder = new viewholder(); holder.tv_artist = (textview) convertview.findviewbyid(r.id.tv_artist); holder.tv_number = (textview) convertview.findviewbyid(r.id.tv_number); holder.tv_number_in_queue = (textview) convertview.findviewbyid(r.id.tv_number_in_queue); holder.tv_title = (textview) convertview.findviewbyid(r.id.tv_title); holder.tv_track_length = (textview) convertview.findviewbyid(r.id.tv_track_length); holder.progressbar = (progressbar) convertview.findviewbyid(r.id.progressbar1); holder.drag_point = (imageview) convertview.findviewbyid(r.id.drag_point); convertview.settag(holder); } else { holder = (viewholder) convertview.gettag(); } //show artist , title holder.tv_artist.settext(playlistitem.getartist()); holder.tv_title.settext(playlistitem.gettitle()); if (queueditems.get(position) != null) holder.tv_number_in_queue.settext("[" + (queueditems.get(position) + 1) + "]"); else holder.tv_number_in_queue.settext(""); //show track length if (playlistitem.getlength() > -1) holder.tv_track_length.settext(playlistitem.getlengthinhours()); else holder.tv_track_length.settext(""); //show index in playlist holder.tv_number.settext(playlistitem.getdisplaynumber()); // show progressbar , set progress if item playing 1 if (playlistitem.getindex() == currentitem) { holder.progressbar.setvisibility(view.visible); if (currenttracklength > 0) { if (holder.progressbar.getmax() != currenttracklength) { holder.progressbar.setmax(currenttracklength); } holder.progressbar.setprogress(currenttrackpos); } else { holder.progressbar.setmax(1); holder.progressbar.setprogress(1); } } else { holder.progressbar.setvisibility(view.invisible); } return convertview; } static class viewholder { textview tv_number; textview tv_title; textview tv_artist; textview tv_track_length; textview tv_number_in_queue; progressbar progressbar; imageview drag_point; }
the layout of single list item:
<relativelayout android:id="@+id/rl_top_container" android:layout_width="match_parent" android:layout_height="@dimen/playlist_fragment_item_height" android:background="?attr/background_playlist_item" > <imageview android:id="@+id/drag_point" android:layout_width="40dp" android:layout_height="match_parent" android:layout_alignparentleft="true" android:paddingleft="10dp" android:paddingright="10dp" android:scaletype="centerinside" android:src="?attr/drag_sort_icon" /> <textview android:id="@+id/tv_number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centervertical="true" android:layout_torightof="@+id/drag_point" android:text="1" android:textappearance="?android:attr/textappearance" android:textcolor="?attr/foreground_text_color_secondary" android:textsize="@dimen/playlist_fragment_title_size" /> <relativelayout android:id="@+id/rl_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centervertical="true" android:layout_marginleft="8dp" android:layout_marginright="8dp" android:layout_torightof="@+id/tv_number" > <textview android:id="@+id/tv_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toleftof="@+id/tv_track_length" android:singleline="true" android:text="title" android:textcolor="?attr/foreground_text_color" android:textsize="@dimen/playlist_fragment_title_size" /> <textview android:id="@+id/tv_artist" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/tv_title" android:layout_toleftof="@+id/tv_number_in_queue" android:singleline="true" android:text="artist" android:textcolor="?attr/foreground_text_color_secondary" android:textsize="@dimen/playlist_fragment_artist_size" /> <textview android:id="@+id/tv_number_in_queue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/tv_artist" android:layout_alignparentend="true" android:padding="3dp" android:textcolor="?attr/foreground_text_color_secondary" android:textsize="@dimen/playlist_fragment_additional_info_size" /> <textview android:id="@+id/tv_track_length" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentend="true" android:layout_alignparenttop="false" android:layout_aligntop="@+id/tv_title" android:padding="3dp" android:textcolor="?attr/foreground_text_color_secondary" android:textsize="@dimen/playlist_fragment_additional_info_size" /> </relativelayout> <progressbar android:id="@+id/progressbar1" style="?android:attr/progressbarstylehorizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_marginbottom="@dimen/playlist_fragment_item_margin_progress_bar" android:visibility="invisible" /> </relativelayout>
the listview:
<com.mobeta.android.dslv.dragsortlistview android:id="@+id/list_playlist" dslv:drag_handle_id="@+id/drag_point" android:layout_width="match_parent" android:layout_height="match_parent" android:fastscrollenabled="true" android:dividerheight="0dp" android:divider="@null" dslv:drag_enabled="true" dslv:collapsed_height="2dp" dslv:drag_scroll_start="0.33" dslv:max_drag_scroll_speed="1.0" dslv:float_alpha="0.6" dslv:slide_shuffle_speed="0.3" dslv:use_default_controller="true"> </com.mobeta.android.dslv.dragsortlistview>
i absolutely ran out of ideas. logcat did show 2 or 3 gc calls while scrolling way, think won't reason.
any idea welcome! thank you.
edit: ok it's getting weird. ran code on htc desire z (aka g2... 800mhz, 512mb ram) android 2.3.5 , sense... here it's smoother on nexus 4?! gong on? cyanogenmod cause misbehaviour? asking, because don't want flash rom because of suspicion.
Comments
Post a Comment