package android.support.design.widget;

import android.animation.ValueAnimator;
import android.os.Build.VERSION;
import android.os.Handler.Callback;
import android.os.Message;
import android.support.design.widget.CoordinatorLayout.d;
import android.support.design.widget.b.3;
import android.support.design.widget.b.5;
import android.support.design.widget.b.6;
import android.support.design.widget.b.7;
import android.support.design.widget.b.a;
import android.support.v4.view.s;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

class b$1 implements Callback {
    b$1() {
    }

    public final boolean handleMessage(Message message) {
        b bVar;
        switch (message.what) {
            case 0:
                bVar = (b) message.obj;
                if (bVar.mM.getParent() == null) {
                    LayoutParams layoutParams = bVar.mM.getLayoutParams();
                    if (layoutParams instanceof d) {
                        d dVar = (d) layoutParams;
                        a aVar = new a(bVar);
                        aVar.rK = n.p(0.1f);
                        aVar.rL = n.p(0.6f);
                        aVar.rI = 0;
                        aVar.rE = new 5(bVar);
                        dVar.a(aVar);
                        dVar.pL = 80;
                    }
                    bVar.mL.addView(bVar.mM);
                }
                bVar.mM.setOnAttachStateChangeListener(new 6(bVar));
                if (!s.as(bVar.mM)) {
                    bVar.mM.setOnLayoutChangeListener(new 7(bVar));
                } else if (bVar.bG()) {
                    bVar.bD();
                } else {
                    bVar.bE();
                }
                return true;
            case 1:
                bVar = (b) message.obj;
                int i = message.arg1;
                if (!bVar.bG() || bVar.mM.getVisibility() != 0) {
                    bVar.bF();
                } else if (VERSION.SDK_INT >= 12) {
                    ValueAnimator valueAnimator = new ValueAnimator();
                    valueAnimator.setIntValues(new int[]{0, bVar.mM.getHeight()});
                    valueAnimator.setInterpolator(a.mg);
                    valueAnimator.setDuration(250);
                    valueAnimator.addListener(new b$2(bVar, i));
                    valueAnimator.addUpdateListener(new 3(bVar));
                    valueAnimator.start();
                } else {
                    Animation loadAnimation = AnimationUtils.loadAnimation(bVar.mM.getContext(), 2131034157);
                    loadAnimation.setInterpolator(a.mg);
                    loadAnimation.setDuration(250);
                    loadAnimation.setAnimationListener(new b$4(bVar, i));
                    bVar.mM.startAnimation(loadAnimation);
                }
                return true;
            default:
                return false;
        }
    }
}
