package com.tencent.mm.plugin.music.ui;

import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;

public class MusicSeekBar extends FrameLayout {
    private Context context;
    boolean isLoading;
    private TextView oPd;
    private TextView oPe;
    private SeekBar oPf;
    ValueAnimator oPg;
    boolean oPh;
    c oPi;
    Drawable oPj;
    private a oPk;

    public MusicSeekBar(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public MusicSeekBar(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        AppMethodBeat.i(105127);
        this.oPh = false;
        this.isLoading = false;
        this.context = context;
        View inflate = LayoutInflater.from(this.context).inflate(2130970275, this);
        this.oPd = (TextView) inflate.findViewById(2131826269);
        this.oPe = (TextView) inflate.findViewById(2131824710);
        this.oPf = (SeekBar) inflate.findViewById(2131826270);
        this.oPd.setText("00:00");
        this.oPe.setText("--:--");
        this.oPi = new c(getResources().getDrawable(2130839641));
        this.oPj = getResources().getDrawable(2130839643);
        AppMethodBeat.o(105127);
    }

    public void setOnSeekBarChange(a aVar) {
        this.oPk = aVar;
    }

    public final void jA(boolean z) {
        AppMethodBeat.i(105128);
        if (this.oPg == null) {
            this.oPg = ValueAnimator.ofFloat(new float[]{0.0f, 360.0f});
            this.oPg.setTarget(this.oPf);
            this.oPg.setRepeatCount(100);
            this.oPg.setDuration(5000);
            this.oPg.setInterpolator(new LinearInterpolator());
            this.oPg.addUpdateListener(new 1(this));
        }
        this.isLoading = z;
        if (z) {
            this.oPg.start();
            AppMethodBeat.o(105128);
            return;
        }
        this.oPg.cancel();
        this.oPf.setThumb(this.oPj);
        AppMethodBeat.o(105128);
    }

    public void setColor(int i) {
        AppMethodBeat.i(105129);
        this.oPd.setTextColor(i);
        this.oPe.setTextColor(i);
        this.oPf.getProgressDrawable().setColorFilter(i, Mode.MULTIPLY);
        this.oPf.getThumb().setColorFilter(i, Mode.MULTIPLY);
        this.oPj.setColorFilter(i, Mode.MULTIPLY);
        this.oPi.setColorFilter(i, Mode.MULTIPLY);
        this.oPf.setOnSeekBarChangeListener(new 2(this));
        AppMethodBeat.o(105129);
    }

    public void setProgress(int i) {
        AppMethodBeat.i(105130);
        if (this.isLoading || this.oPh) {
            AppMethodBeat.o(105130);
            return;
        }
        this.oPd.setText(zW(i));
        this.oPf.setProgress(i);
        AppMethodBeat.o(105130);
    }

    public void setMaxProgress(int i) {
        AppMethodBeat.i(105131);
        this.oPe.setText(zW(i));
        this.oPf.setMax(i);
        AppMethodBeat.o(105131);
    }

    private static String zW(int i) {
        AppMethodBeat.i(105132);
        StringBuilder stringBuilder = new StringBuilder();
        long j = (long) (i / 60000);
        long floor = (long) Math.floor((double) (((long) (i % 60000)) / 1000));
        if (j < 10) {
            stringBuilder.append("0");
        }
        stringBuilder.append(j + ":");
        if (floor < 10) {
            stringBuilder.append("0");
        }
        stringBuilder.append(floor);
        String stringBuilder2 = stringBuilder.toString();
        AppMethodBeat.o(105132);
        return stringBuilder2;
    }
}
