package com.example.todocloud.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.todocloud.R;

import java.util.List;

public class ListAdapter extends BaseAdapter {

  private List<com.example.todocloud.data.List> listItems;

  public ListAdapter(List<com.example.todocloud.data.List> listItems) {
    this.listItems = listItems;
  }

  @Override
  public int getCount() {
    return listItems.size();
  }

  @Override
  public Object getItem(int position) {
    return listItems.get(position);
  }

  @Override
  public long getItemId(int position) {
    return listItems.get(position).get_id();
  }

  public String getItemListOnlineId(int position) {
    return listItems.get(position).getListOnlineId();
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    final com.example.todocloud.data.List listItem = listItems.get(position);
    LayoutInflater inflater = (LayoutInflater) parent.getContext().
        getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = inflater.inflate(R.layout.list_item, null);
    TextView tvTitle = (TextView) convertView.findViewById(R.id.tvTitle);
    tvTitle.setText(listItem.getTitle());
    return convertView;
  }

  /**
   * Törli az adapterből a megadott List-et .
   * @param list A törlendő List.
   */
  public void deleteList(com.example.todocloud.data.List list) {
    if (listItems.contains(list)) {
      listItems.remove(list);
    }
  }

  /**
   * Frissíti az adapter tartalmát a megadott adatokkal.
   * @param listItems A megadott List-ek.
   */
  public void update(List<com.example.todocloud.data.List> listItems) {
    this.listItems.clear();
    this.listItems.addAll(listItems);
  }

}

@@ -383,20 +383,16 @@
 st%3E list
-Item
 s;%0A%0A  pu
@@ -442,36 +442,32 @@
 .data.List%3E list
-Item
 s) %7B%0A    this.li
@@ -472,20 +472,16 @@
 list
-Item
 s = list
 Item
@@ -476,20 +476,16 @@
 s = list
-Item
 s;%0A  %7D%0A%0A
@@ -537,20 +537,16 @@
 urn list
-Item
 s.size()
@@ -611,36 +611,32 @@
 %0A    return list
-Item
 s.get(position);
@@ -701,94 +701,57 @@
     
-return listItems.get(position).get_id();%0A  %7D%0A%0A  public String getItemListOnlineId(int 
+com.example.todocloud.data.List list = lists.get(
 posi
@@ -747,34 +747,33 @@
 ts.get(position)
- %7B
+;
 %0A    return list
@@ -776,42 +776,14 @@
 list
-Items.get(position).getListOnlineI
+.get_i
 d();
@@ -882,14 +882,8 @@
     
-final 
 com.
@@ -918,23 +918,15 @@
 list
-Item
  = list
-Item
 s.ge
@@ -957,17 +957,23 @@
 nflater 
-i
+layoutI
 nflater 
@@ -1015,17 +1015,8 @@
 t().
-%0A        
 getS
@@ -1028,16 +1028,25 @@
 Service(
+%0A        
 Context.
@@ -1068,16 +1068,21 @@
 _SERVICE
+%0A    
 );%0A    c
@@ -1094,17 +1094,23 @@
 tView = 
-i
+layoutI
 nflater.
@@ -1242,20 +1242,16 @@
 ext(list
-Item
 .getTitl
@@ -1256,16 +1256,17 @@
 tle());%0A
+%0A
     retu
@@ -1290,353 +1290,8 @@
  %7D%0A%0A
-  /**%0A   * T%C3%B6rli az adapterb%C5%91l a megadott List-et .%0A   * @param list A t%C3%B6rlend%C5%91 List.%0A   */%0A  public void deleteList(com.example.todocloud.data.List list) %7B%0A    if (listItems.contains(list)) %7B%0A      listItems.remove(list);%0A    %7D%0A  %7D%0A%0A  /**%0A   * Friss%C3%ADti az adapter tartalm%C3%A1t a megadott adatokkal.%0A   * @param listItems A megadott List-ek.%0A   */%0A
   pu
@@ -1349,20 +1349,16 @@
 st%3E list
-Item
 s) %7B%0A   
@@ -1367,20 +1367,16 @@
 his.list
-Item
 s.clear(
@@ -1391,20 +1391,16 @@
 his.list
-Item
 s.addAll
@@ -1404,20 +1404,16 @@
 All(list
-Item
 s);%0A  %7D%0A

Simplify ListAdapter class