// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSource.java
// public class OneTypeItemSource<T> {
// 
//     public int itemViewId = 0;
// 
//     public ObservableArrayList<T> items = new ObservableArrayList<>();
// 
//     public SomethingClicked[] listeners;
// }
// 
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSourceListAdapter.java
// public class OneTypeItemSourceListAdapter extends BaseAdapter {
// 
//     OneTypeItemSource source;
//     LayoutInflater inflater;
//     ObservableList.OnListChangedCallback callback = new ObservableList.OnListChangedCallback() {
//         @Override
//         public void onChanged(ObservableList observableList) {
//             notifyDataSetChanged();
//         }
// 
//         @Override
//         public void onItemRangeChanged(ObservableList observableList, int i, int i1) {
//             notifyDataSetChanged();
//         }
// 
//         @Override
//         public void onItemRangeInserted(ObservableList observableList, int i, int i1) {
//             notifyDataSetChanged();
//         }
// 
//         @Override
//         public void onItemRangeMoved(ObservableList observableList, int i, int i1, int i2) {
//             notifyDataSetChanged();
//         }
// 
//         @Override
//         public void onItemRangeRemoved(ObservableList observableList, int i, int i1) {
//             notifyDataSetChanged();
//         }
//     };
// 
//     public OneTypeItemSourceListAdapter(OneTypeItemSource source, LayoutInflater inflater) {
//         this.source = source;
//         this.inflater = inflater;
//         if(this.source.items != null) {
//             this.source.items.removeOnListChangedCallback(callback);
//             this.source.items.addOnListChangedCallback(callback);
//         }
//     }
// 
//     @Override
//     public int getCount() {
//         return source == null || source.items == null ? 0 : source.items.size();
//     }
// 
//     @Override
//     public Object getItem(int i) {
//         return source == null || source.items == null ? null : source.items.get(i);
//     }
// 
//     @Override
//     public long getItemId(int i) {
//         return i;
//     }
// 
//     @Override
//     public View getView(int i, View view, ViewGroup viewGroup) {
//         ViewDataBinding binding;
//         PositionListeners pl;
//         if(view != null) {
//             binding = (ViewDataBinding) view.getTag(R.id.binding);
//             pl = (PositionListeners) view.getTag(R.id.pl);
//         } else {
//             view = inflater.inflate(source.itemViewId, null);
//             binding = DataBindingUtil.bind(view);
//             view.setTag(R.id.binding, binding);
//             pl = new PositionListeners();
//             pl.listeners = source.listeners;
//             view.setTag(R.id.pl, pl);
//         }
//         binding.setVariable(BR.item, getItem(i));
//         try {
//             pl.position = i;
//             binding.setVariable(BR.pl, pl);
//         } catch (Exception e){}
//         return view;
//     }
// }


import android.databinding.BindingAdapter;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSource;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSourceListAdapter;
package link.anyauto.smartkey.demo.util;



/**
 * Created by discotek on 17-1-24.
 */

public class BindUtil {
    @BindingAdapter("oneTypeSource")
    public static void setOneTypeSource(ListView view, OneTypeItemSource source) {
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSource.java
// public class OneTypeItemSource<T> {
// 
//     public int itemViewId = 0;
// 
//     public ObservableArrayList<T> items = new ObservableArrayList<>();
// 
//     public SomethingClicked[] listeners;
// }
// 
// Path: app/src/main/java/link/anyauto/smartkey/demo/adapter/OneTypeItemSourceListAdapter.java
// public class OneTypeItemSourceListAdapter extends BaseAdapter {
// 
//     OneTypeItemSource source;
//     LayoutInflater inflater;
//     ObservableList.OnListChangedCallback callback = new ObservableList.OnListChangedCallback() {
//         @Override
//         public void onChanged(ObservableList observableList) {
//             notifyDataSetChanged();
//         }
// 
//         @Override
//         public void onItemRangeChanged(ObservableList observableList, int i, int i1) {
//             notifyDataSetChanged();
//         }
// 
//         @Override
//         public void onItemRangeInserted(ObservableList observableList, int i, int i1) {
//             notifyDataSetChanged();
//         }
// 
//         @Override
//         public void onItemRangeMoved(ObservableList observableList, int i, int i1, int i2) {
//             notifyDataSetChanged();
//         }
// 
//         @Override
//         public void onItemRangeRemoved(ObservableList observableList, int i, int i1) {
//             notifyDataSetChanged();
//         }
//     };
// 
//     public OneTypeItemSourceListAdapter(OneTypeItemSource source, LayoutInflater inflater) {
//         this.source = source;
//         this.inflater = inflater;
//         if(this.source.items != null) {
//             this.source.items.removeOnListChangedCallback(callback);
//             this.source.items.addOnListChangedCallback(callback);
//         }
//     }
// 
//     @Override
//     public int getCount() {
//         return source == null || source.items == null ? 0 : source.items.size();
//     }
// 
//     @Override
//     public Object getItem(int i) {
//         return source == null || source.items == null ? null : source.items.get(i);
//     }
// 
//     @Override
//     public long getItemId(int i) {
//         return i;
//     }
// 
//     @Override
//     public View getView(int i, View view, ViewGroup viewGroup) {
//         ViewDataBinding binding;
//         PositionListeners pl;
//         if(view != null) {
//             binding = (ViewDataBinding) view.getTag(R.id.binding);
//             pl = (PositionListeners) view.getTag(R.id.pl);
//         } else {
//             view = inflater.inflate(source.itemViewId, null);
//             binding = DataBindingUtil.bind(view);
//             view.setTag(R.id.binding, binding);
//             pl = new PositionListeners();
//             pl.listeners = source.listeners;
//             view.setTag(R.id.pl, pl);
//         }
//         binding.setVariable(BR.item, getItem(i));
//         try {
//             pl.position = i;
//             binding.setVariable(BR.pl, pl);
//         } catch (Exception e){}
//         return view;
//     }
// }


// Path: app/src/main/java/link/anyauto/smartkey/demo/util/BindUtil.java
import android.databinding.BindingAdapter;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import link.anyauto.smartkey.demo.R;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSource;
import link.anyauto.smartkey.demo.adapter.OneTypeItemSourceListAdapter;

package link.anyauto.smartkey.demo.util;



/**
 * Created by discotek on 17-1-24.
 */

public class BindUtil {
    @BindingAdapter("oneTypeSource")
    public static void setOneTypeSource(ListView view, OneTypeItemSource source) {
        OneTypeItemSourceListAdapter adapter = new OneTypeItemSourceListAdapter(source, LayoutInflater.from(view.getContext()));