Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SOUZOUxMERCARI-A Story of Cute Birds and Oldman

jsugai
November 24, 2017
590

SOUZOUxMERCARI-A Story of Cute Birds and Oldman

jsugai

November 24, 2017
Tweet

Transcript

  1. var/val/collection public class SearchListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private val List<SearchKeyWord>

    dataSet = new ArrayList<>(); public SearchListAdapter(SearchListener listener) { this.listener = listener; } //... @Override public int getItemCount() { return dataSet.size(); } public void setDataSet(List<SearchKeyWord> dataSet) { this.dataSet = dataSet; notifyDataSetChanged(); }
  2. var/val/collection public class SearchListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private val List<SearchKeyWord>

    dataSet = new ArrayList<SearchKeyWord>() //େࣄͳͱ͜Ζ͚ͩ public void setDataSet(List<SearchKeyWord> dataSet) { this.dataSet.clear() this.dataSet.addAll(dataSet) notifyDataSetChanged(); } // Kotlin ͩͱ immutable ʹͨ͘͠ͳͬͪΌ͏
  3. var/val/collection private val List<SearchKeyWord> dataSet = new ArrayList<SearchKeyWord>() //େࣄͳͱ͜Ζ͚ͩ public

    void setDataSet(List<SearchKeyWord> dataSet) { this.dataSet.clear() this.dataSet.addAll(dataSet) notifyDataSetChanged(); } •clear() -> addAll() ͷྲྀΕ͸ GC ίετతʹͲ͏ͳͷ? •addAll() Ͱ௥Ճ͢Δࡍͷཁૉ͕ڊେͳ instance ΍ڊେͳ heap ΁ͷࢀরΛอ࣋͢Δߏ଄ͩͱ
 clear() -> adAll() ͚ͩͰ GC ͕૸ΔՄೳੑ͸? •ཁૉͷίϐʔΛ࡞Δ heap ίετ/ϑοτϓϦϯτ͸ॲཧશମͰແࢹͰ͖Δ΄Ͳখ͍͞?