user interface - Android fragment optimization -
i trying develop master-child page concept using master-detail flow of android comes execution , design vulnerable critics poor performance. please tell me guidelines increase performance besudes loading bitmaps options ?
the below code fragment
import java.util.arraylist; import java.util.list; import com.aaa.demo.asynctask.resubmitorder; import com.aaa.demo.util.*; import android.os.bundle; import android.content.context; import android.database.cursor; import android.support.v4.app.*; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.baseadapter; import android.widget.gridview; import android.widget.imageview; public class moreactivity extends fragment { private bundle parameter; private filemanager fileman; private salesorderretransmitdbadapter sodbretransmithelper; public class recordadapter extends baseadapter { context context; private list<string> data; recordadapter(list<string> data, context context) { this.data = data; this.context = context; } public int getcount() { return data.size(); } public object getitem(int position) { return data.get(position); } public long getitemid(int position) { return position; } public view getview(final int position, view convertview, viewgroup parent) { view v = convertview; if (v == null) { layoutinflater vi = (layoutinflater) context.getsystemservice(context.layout_inflater_service); v = vi.inflate(r.layout.more_item, null); } final string item = data.get(position); imageview imageview = (imageview) v.findviewbyid(r.id.more_item); imageview.setimagedrawable(fileutil.readimage(context, item + ".png")); imageview.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { if(item.equalsignorecase("more_update")) { ((activityintab) getactivity()).switchtofragment(new updatecontentactivity()); runtime.getruntime().gc(); } else if(item.equalsignorecase("more_building")) { parameter = new bundle(); parameter.putstring("salesid", mainactivity.useridstatic); fragment s = new eordersystembuildlist(); s.setarguments(parameter); ((activityintab) getactivity()).switchtofragment(s); } else if(item.equalsignorecase("more_qc")) { parameter = new bundle(); parameter.putstring("salesid", mainactivity.useridstatic); fragment s = new eorderlist(); s.setarguments(parameter); ((activityintab) getactivity()).switchtofragment(s); } else if(item.equalsignorecase("more_password")) { parameter = new bundle(); parameter.putstring("salesid", mainactivity.useridstatic ); fragment s = new eorderchangepassword(); s.setarguments(parameter); ((activityintab) getactivity()).switchtofragment(s); } else if(item.equalsignorecase("more_logout")) { getactivity().finish(); runtime.getruntime().gc(); } else if(item.equalsignorecase("more_resubmit")) { resubmitorder resubmit = new resubmitorder(getactivity()); resubmit.execute(mainactivity.useridstatic + "|" + mainactivity.isfollowup); } } }); return v; } } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { final view v = inflater.inflate(r.layout.activity_more, container, false); arraylist<string> records = new arraylist<string>(); records.add("more_building"); records.add("more_qc"); records.add("more_password"); records.add("more_logout"); records.add("more_update"); fileman = new filemanager(); int count = fileman.loadrecordrecursivecount("sv_recordings","sales_recording"); log.d("file count " , string.valueof(count)); sodbretransmithelper= new salesorderretransmitdbadapter(getactivity()); sodbretransmithelper.open(); cursor bu = sodbretransmithelper.fetchallunsubmitorder(mainactivity.useridstatic); bu.movetofirst(); int data = bu.getcount(); log.d("data count " , string.valueof(data)); if(count > 0 || data > 0 ){ records.add("more_resubmit"); } bu.close(); sodbretransmithelper.close(); gridview gridview = (gridview) v.findviewbyid(r.id.more_gridview); gridview.setadapter(new recordadapter(records, getactivity())); return v; } }
Comments
Post a Comment