package zaihuishou.com.expandablerecyclerview;

import android.animation.ObjectAnimator;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.zaihuishou.expandablerecycleradapter.viewholder.AbstractExpandableAdapterItem;


public class CompanyItem extends AbstractExpandableAdapterItem {

    private TextView mName;
    private ImageView mArrow;

    @Override
    public int getLayoutResId() {
        return R.layout.item_company;
    }

    @Override
    public void onBindViews(View root) {
        /**
         * control item expand and unexpand
         */
        root.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                doExpandOrUnexpand();
            }
        });
        mName = (TextView) root.findViewById(R.id.tv_name);
        mArrow = (ImageView) root.findViewById(R.id.iv_arrow);
    }

    @Override
    public void onExpansionToggled(boolean expanded) {
        float start, target;
        if (expanded) {
            start = 0f;
            target = 90f;
        } else {
            start = 90f;
            target = 0f;
        }
        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mArrow, View.ROTATION, start, target);
        objectAnimator.setDuration(300);
        objectAnimator.start();
    }

    @Override
    public void onSetViews() {
        mArrow.setImageResource(0);
        mArrow.setImageResource(R.mipmap.arrow_down);
    }

    @Override
    public void onUpdateViews(Object model, int position) {
        super.onUpdateViews(model, position);
        onSetViews();
        onExpansionToggled(getExpandableListItem().isExpanded());
        Company company = (Company) model;
        mName.setText(company.name);
        if (position == 0) {
        }
    }


}

@@ -168,24 +168,53 @@
 et.TextView;
+%0Aimport android.widget.Toast;
 %0A%0Aimport com
@@ -418,16 +418,46 @@
  mArrow;
+%0A    private Company mCompany;
 %0A%0A    @O
@@ -585,16 +585,22 @@
 ndViews(
+final 
 View roo
@@ -796,24 +796,24 @@
 iew view) %7B%0A
-
             
@@ -834,24 +834,134 @@
 Unexpand();%0A
+                Toast.makeText(root.getContext(), %22click company%EF%BC%9A%22 +mCompany.name,Toast.LENGTH_SHORT).show();%0A
             
@@ -1897,17 +1897,10 @@
     
+m
 C
-ompany c
 ompa
@@ -1943,17 +1943,18 @@
 setText(
-c
+mC
 ompany.n
@@ -1963,47 +1963,8 @@
 e);%0A
-        if (position == 0) %7B%0A        %7D%0A
     

add click toast to show item name