package xyz.netfly.ui.main.download;

import bf.c;
import bf.e;
import com.google.android.material.textfield.b;
import i0.o;
import ie.f;
import java.util.ArrayList;
import org.drive_hunter.R;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import v3.a;
import xyz.stream.download.DownloadEvent;
import xyz.stream.download.DownloadFile;
import xyz.stream.download.DownloadManager;
import xyz.stream.download.config.InnerConstant;
import xyz.stream.view.BaseActivity;
import xyz.stream.view.BaseViewModel;
import xyz.stream.view.SpacesItemVerDecoration;
import xyz.stream.view.UiUtils;

/* JADX INFO: loaded from: classes3.dex */
public class DownloadItemActivity extends BaseActivity<BaseViewModel, f> {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final /* synthetic */ int f35598d = 0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final ArrayList f35599b = new ArrayList();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public e f35600c;

    @Override // xyz.stream.view.BaseActivity
    public final a getViewBinding() {
        return f.inflate(getLayoutInflater(), null, false);
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initData() {
        super.initData();
        int intExtra = getIntent().getIntExtra(InnerConstant.Db.f36069id, 0);
        ArrayList arrayList = this.f35599b;
        arrayList.clear();
        ((f) this.binding).f26824d.setVisibility(8);
        for (DownloadFile downloadFile : DownloadManager.getInstance().downloadTaskList) {
            if (downloadFile.getVideoId().intValue() == intExtra) {
                arrayList.add(downloadFile);
            }
        }
        if (arrayList.isEmpty()) {
            ((f) this.binding).f26824d.setVisibility(0);
        } else {
            ((f) this.binding).f26826f.setText(((DownloadFile) arrayList.get(0)).getTitle());
            this.f35600c.notifyDataSetChanged();
        }
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initListener() {
        super.initListener();
        ((f) this.binding).f26822b.setOnClickListener(new b(this, 19));
        this.f35600c.setOnItemListener(new c(this, 1));
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initView() {
        UiUtils.setSvgPicture(((f) this.binding).f26823c, R.drawable.cloud_no_content, Integer.valueOf(R.color.main_color));
        ((f) this.binding).f26825e.addItemDecoration(new SpacesItemVerDecoration(20));
        e eVar = new e(this.f35599b, this);
        this.f35600c = eVar;
        ((f) this.binding).f26825e.setAdapter(eVar);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(DownloadEvent downloadEvent) {
        ArrayList<DownloadFile> arrayList = this.f35599b;
        if (arrayList.isEmpty() || this.f35600c == null || isFinishing() || isDestroyed()) {
            return;
        }
        for (DownloadFile downloadFile : arrayList) {
            if (downloadFile.getId().intValue() == downloadEvent.f36039id) {
                downloadFile.setStatus(Integer.valueOf(downloadEvent.status));
                downloadFile.setProgress(Integer.valueOf(downloadEvent.progress));
                downloadFile.setCurrentBytes(Integer.valueOf(downloadEvent.currentBytes));
                downloadFile.setTotalBytes(Integer.valueOf(downloadEvent.totalBytes));
                runOnUiThread(new o(arrayList.indexOf(downloadFile), 10, this));
                return;
            }
        }
    }
}
