title: Loading text in recycler view with card view is too slow
body: <p>I have a problem with the recycler view and card view. I'm using asynctask to get info from API, and for now I'm getting only a name - which means, I display in my card view only a text view. however, when I'm loading the list, it is awfully slow. in the log cat I can see that the app is getting the data pretty fast, but it takes a lot of time to show it in the recycler view.</p>
  
  <p>I'm adding few samples - from the adapter of the recycler view and the fragment that holds the recycler view in. maybe I did something wrong in the adapter.</p>
  
  <p>Thank you for your help!</p>
  
  <p>Adapter:</p>
  
  <pre><code>public class PlacesListAdapter extends RecyclerView.Adapter&lt;PlacesListAdapter.ListViewHolder&gt;{
  ArrayList&lt;PlaceItem&gt; items;
  Context context;
  
  public PlacesListAdapter(Context context,ArrayList&lt;PlaceItem&gt; placeItems){
      this.context = context;
      this.items = placeItems;
  }
  
  public void swap(ArrayList&lt;PlaceItem&gt; places){
      items.clear();
      items.addAll(places);
      notifyDataSetChanged();
  }
  
  @Override
  public ListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View v = LayoutInflater.from(context).inflate(R.layout.card_view, parent, false);
      return new ListViewHolder(v);
  }
  
  @Override
  public void onBindViewHolder(ListViewHolder holder, int position) {
      PlaceItem item = items.get(position);
      holder.bindData(item);
  }
  
  @Override
  public int getItemCount() {
      return items.size();
  }
  
  public class ListViewHolder extends RecyclerView.ViewHolder{
      TextView title;
      PlaceItem placeItem;
      public ListViewHolder(View itemView) {
          super(itemView);
          title = (TextView) itemView.findViewById(R.id.txtTitlePlace);
      }
  
      public void bindData(PlaceItem item){
          this.placeItem = item;
          title.setText(placeItem.getTitle());
      }
    }
  }
  </code></pre>
  
  <p>Fragment:</p>
  
  <pre><code>public class FragmentListPlaces extends Fragment implements  View.OnClickListener {
  
  ArrayList&lt;PlaceItem&gt; placeItems;
  PlacesListAdapter adapter;
  RecyclerView list;
  EditText editName;
  
  public FragmentListPlaces() {
      // Required empty public constructor
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      View v = inflater.inflate(R.layout.fragment_list_places, container, false);
      editName = (EditText) v.findViewById(R.id.editPlaceName);
      v.findViewById(R.id.btnGetLocations).setOnClickListener(this);
      v.findViewById(R.id.btnSearchByText).setOnClickListener(this);
      placeItems = new ArrayList&lt;&gt;();
      placeItems.add(new PlaceItem("Example"));
      adapter = new PlacesListAdapter(getContext(), placeItems);
      list = (RecyclerView) v.findViewById(R.id.placesList);
      list.setLayoutManager(new LinearLayoutManager(getContext()));
      list.setAdapter(adapter);
      return v;
  }
  
  @Override
  public void onClick(View v) {
      switch (v.getId()){
          case R.id.btnGetLocations:
              GetUserLocation location = new GetUserLocation();
              location.getLocation(getActivity());
              adapter.swap(placeItems);
              break;
          case R.id.btnSearchByText:
              // this is the method loading data with user input
              String getNameFromUser = editName.getText().toString();
              searchPlaceByText(getNameFromUser);
              adapter.swap(placeItems);
              break;
      }
  }
  
  public void searchPlaceByText(String place){
      // instantiate the asynctask here
      LocationDetailsByText locationDetailsByText = new LocationDetailsByText(placeItems);
      locationDetailsByText.execute("http://api.v3.factual.com/t/places-il?q=" + place + "&amp;KEY=AFvDryDJmPkkgXohbpFdqkRQelT9w0HKtyEqXy3G");
  }
  </code></pre>
  
  <p>Loading of data from the web:</p>
  
  <pre><code>public class LocationDetailsByText extends AsyncTask&lt;String, Void, String&gt; {
  
  ArrayList&lt;PlaceItem&gt; placeItems = new ArrayList&lt;&gt;();
  
  public LocationDetailsByText(ArrayList&lt;PlaceItem&gt; places){
      this.placeItems = places;
  }
  @Override
  protected String doInBackground(String... params) {
      StringBuilder result = new StringBuilder();
      BufferedReader reader;
      HttpURLConnection connection = null;
      URL url;
  
      String query = (params[0]);
      try {
          url = new URL(query);
          connection = (HttpURLConnection)url.openConnection();
  
          if(connection.getResponseCode() != 200){
              return "Error!";
          }
  
          reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  
          String line = "";
          while((line = reader.readLine())!= null){
              result.append(line);
          }
      } catch (MalformedURLException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }finally {
          connection.disconnect();
      }
      return result.toString();
  }
  
  @Override
  protected void onPostExecute(String s) {
      PlaceItem placeItem;
      try {
          JSONObject root = new JSONObject(s);
          JSONObject response = root.getJSONObject("response");
          JSONArray data = response.getJSONArray("data");
  
          for(int i = 0; i &lt; data.length(); i++){
              JSONObject getData = data.getJSONObject(i);
              String title = getData.getString("name");
              placeItem = new PlaceItem(title);
              placeItems.add(placeItem);
          }
      } catch (JSONException e) {
          e.printStackTrace();
      }
  }
  </code></pre>