package com.ss.android.ugc.aweme.shortvideo.cut.gif;

import X.07U;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.shortvideo.cut.CutMultiVideoViewModel;
import com.ss.android.ugc.aweme.shortvideo.cut.model.VideoSegment;
import java.util.ArrayList;
import java.util.List;

public class Video2GifCutFragment$1 extends Handler {
    public final /* synthetic */ Video2GifCutFragment LIZ;

    static {
        Covode.recordClassIndex(108522);
    }

    public final void handleMessage(Message message) {
        int i;
        super.handleMessage(message);
        if (message.what == 0) {
            CutMultiVideoViewModel cutMultiVideoViewModel = this.LIZ.LJII;
            long longValue = ((Long) message.obj).longValue();
            List<VideoSegment> LJIIIZ = this.LIZ.LJIIIIZZ.LJIIIZ();
            cutMultiVideoViewModel.LIZIZ.setValue(Long.valueOf(longValue));
            int i2 = 0;
            if (cutMultiVideoViewModel.LIZ.getValue() != null) {
                i = ((Integer) ((07U) cutMultiVideoViewModel.LIZ.getValue()).LIZIZ).intValue();
            } else {
                i = 0;
            }
            ArrayList arrayList = new ArrayList();
            for (int i3 = 0; i3 < LJIIIZ.size(); i3++) {
                if (!LJIIIZ.get(i3).LJIIIZ) {
                    arrayList.add(LJIIIZ.get(i3));
                }
            }
            long j = 0;
            int i4 = 0;
            while (true) {
                if (i4 >= arrayList.size()) {
                    break;
                }
                j += ((VideoSegment) arrayList.get(i4)).LIZJ;
                if (j > longValue) {
                    i2 = i4;
                    break;
                }
                i4++;
            }
            if (longValue > 0) {
                cutMultiVideoViewModel.LIZ.setValue(07U.LIZ(Integer.valueOf(i), Integer.valueOf(i2)));
            }
        }
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public Video2GifCutFragment$1(Video2GifCutFragment video2GifCutFragment, Looper looper) {
        super(looper);
        this.LIZ = video2GifCutFragment;
    }
}
