导航菜单

页面标题

页面副标题

Top浏览器 v4.6.16 - BookChapterActivity.java 源代码

正在查看: Top浏览器 v4.6.16 应用的 BookChapterActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.pocket.topbrowser.reader.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModel;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import c.f.a.a.a.g.d;
import c.f.a.a.a.i.e;
import c.o.a.b.c;
import c.t.a.d.n;
import c.t.a.w.r0;
import c.t.c.o.u.h;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.pocket.common.base.BaseViewModelActivity;
import com.pocket.common.db.read.Book;
import com.pocket.common.db.read.BookChapter;
import com.pocket.common.view.fastscrollrecylerview.FastScrollRecyclerView;
import com.pocket.common.view.fastscrollrecylerview.UpLinearLayoutManager;
import com.pocket.topbrowser.reader.R$attr;
import com.pocket.topbrowser.reader.R$color;
import com.pocket.topbrowser.reader.R$id;
import com.pocket.topbrowser.reader.R$layout;
import com.pocket.topbrowser.reader.activity.BookChapterActivity;
import d.b.a.b.o;
import h.b0.d.g;
import h.b0.d.l;
import h.b0.d.m;
import h.u;
import java.util.List;
import java.util.concurrent.TimeUnit;

public final class BookChapterActivity extends BaseViewModelActivity {
    public static final a a = new a(null);
    public int b;

    public UpLinearLayoutManager f1785c;

    public BookChapterAdapter f1786d;

    public BookChapter2ViewModel f1787e;

    public boolean f1788f;

    public boolean f1789g;

    public final class BookChapterAdapter extends BaseQuickAdapter<BookChapter, BaseViewHolder> implements e {
        public int D;
        public final BookChapterActivity E;

        public BookChapterAdapter(BookChapterActivity bookChapterActivity) {
            super(R$layout.reader_book_chapter_activity_item, (List) null, 2, (g) null);
            l.f(bookChapterActivity, "this$0");
            this.E = bookChapterActivity;
        }

        public void r(BaseViewHolder baseViewHolder, BookChapter bookChapter) {
            l.f(baseViewHolder, "holder");
            l.f(bookChapter, "item");
            int i2 = R$id.tv_name;
            baseViewHolder.setText(i2, bookChapter.getTitle());
            if (this.E.b == bookChapter.getIndex()) {
                baseViewHolder.setTextColor(i2, r0.a.b(R$color.c_0c82fd));
            } else {
                baseViewHolder.setTextColor(i2, w0());
            }
        }

        public final int w0() {
            if (this.D == 0) {
                this.D = r0.a.b(c.t.a.u.a.a.a().b(y(), R$attr.yaTextPrimary));
            }
            return this.D;
        }
    }

    public static final class a {
        public a() {
        }

        public a(g gVar) {
            this();
        }
    }

    public static final class b extends m implements h.b0.c.l<String, u> {
        public b() {
            super(1);
        }

        public final void a(String str) {
            l.f(str, "it");
            BookChapterAdapter bookChapterAdapter = BookChapterActivity.this.f1786d;
            if (bookChapterAdapter == null) {
                l.u("adapter");
                bookChapterAdapter = null;
            }
            FrameLayout D = bookChapterAdapter.D();
            TextView textView = D != null ? (TextView) D.findViewById(R$id.tv_tip) : null;
            if (textView == null) {
                return;
            }
            textView.setText(str);
        }

        @Override
        public u invoke(String str) {
            a(str);
            return u.a;
        }
    }

    public static final void D(BookChapterActivity bookChapterActivity) {
        l.f(bookChapterActivity, "this$0");
        BookChapter2ViewModel bookChapter2ViewModel = bookChapterActivity.f1787e;
        if (bookChapter2ViewModel == null) {
            l.u("viewModel");
            bookChapter2ViewModel = null;
        }
        bookChapter2ViewModel.t();
    }

    public static final void E(BookChapterActivity bookChapterActivity, BaseQuickAdapter baseQuickAdapter, View view, int i2) {
        l.f(bookChapterActivity, "this$0");
        l.f(baseQuickAdapter, "$noName_0");
        l.f(view, "$noName_1");
        BookChapterAdapter bookChapterAdapter = null;
        if (bookChapterActivity.f1788f) {
            Intent intent = new Intent();
            BookChapterAdapter bookChapterAdapter2 = bookChapterActivity.f1786d;
            if (bookChapterAdapter2 == null) {
                l.u("adapter");
            } else {
                bookChapterAdapter = bookChapterAdapter2;
            }
            intent.putExtra("index", ((BookChapter) bookChapterAdapter.z().get(i2)).getIndex());
            u uVar = u.a;
            bookChapterActivity.setResult(-1, intent);
        } else {
            h hVar = h.a;
            BookChapterAdapter bookChapterAdapter3 = bookChapterActivity.f1786d;
            if (bookChapterAdapter3 == null) {
                l.u("adapter");
                bookChapterAdapter3 = null;
            }
            hVar.Q(((BookChapter) bookChapterAdapter3.z().get(i2)).getIndex());
            hVar.R(0);
            hVar.L();
            Intent intent2 = new Intent();
            BookChapterAdapter bookChapterAdapter4 = bookChapterActivity.f1786d;
            if (bookChapterAdapter4 == null) {
                l.u("adapter");
            } else {
                bookChapterAdapter = bookChapterAdapter4;
            }
            intent2.putExtra("book_url", ((BookChapter) bookChapterAdapter.z().get(i2)).getBookUrl());
            u uVar2 = u.a;
            bookChapterActivity.setResult(-1, intent2);
        }
        bookChapterActivity.finish();
    }

    public static final void F(BookChapterActivity bookChapterActivity, List list) {
        l.f(bookChapterActivity, "this$0");
        LinearLayoutManager linearLayoutManager = null;
        if (list.isEmpty()) {
            BookChapterAdapter bookChapterAdapter = bookChapterActivity.f1786d;
            if (bookChapterAdapter == null) {
                l.u("adapter");
                bookChapterAdapter = null;
            }
            bookChapterAdapter.L().q(true);
        } else {
            BookChapterAdapter bookChapterAdapter2 = bookChapterActivity.f1786d;
            if (bookChapterAdapter2 == null) {
                l.u("adapter");
                bookChapterAdapter2 = null;
            }
            l.e(list, "it");
            bookChapterAdapter2.h(list);
            BookChapterAdapter bookChapterAdapter3 = bookChapterActivity.f1786d;
            if (bookChapterAdapter3 == null) {
                l.u("adapter");
                bookChapterAdapter3 = null;
            }
            bookChapterAdapter3.L().p();
        }
        if (bookChapterActivity.f1789g) {
            return;
        }
        bookChapterActivity.f1789g = true;
        LinearLayoutManager linearLayoutManager2 = bookChapterActivity.f1785c;
        if (linearLayoutManager2 == null) {
            l.u("mLayoutManager");
        } else {
            linearLayoutManager = linearLayoutManager2;
        }
        linearLayoutManager.scrollToPositionWithOffset(bookChapterActivity.b, 0);
    }

    public static final void G(BookChapterActivity bookChapterActivity, Book book) {
        l.f(bookChapterActivity, "this$0");
        l.e(book, "it");
        bookChapterActivity.t(book);
        BookChapter2ViewModel bookChapter2ViewModel = bookChapterActivity.f1787e;
        if (bookChapter2ViewModel == null) {
            l.u("viewModel");
            bookChapter2ViewModel = null;
        }
        bookChapter2ViewModel.l();
    }

    public static final void H(BookChapterActivity bookChapterActivity, Book book) {
        l.f(bookChapterActivity, "this$0");
        l.e(book, "it");
        bookChapterActivity.t(book);
    }

    public static final void I(BookChapterActivity bookChapterActivity, View view) {
        l.f(bookChapterActivity, "this$0");
        bookChapterActivity.finish();
    }

    public static final void J(BookChapterActivity bookChapterActivity, View view) {
        l.f(bookChapterActivity, "this$0");
        bookChapterActivity.K();
    }

    public static final void M(BookChapterActivity bookChapterActivity) {
        TextView textView;
        l.f(bookChapterActivity, "this$0");
        BookChapterAdapter bookChapterAdapter = bookChapterActivity.f1786d;
        if (bookChapterAdapter == null) {
            l.u("adapter");
            bookChapterAdapter = null;
        }
        FrameLayout D = bookChapterAdapter.D();
        if (D == null || (textView = (TextView) D.findViewById(R$id.tv_tip)) == null || !TextUtils.equals(textView.getText().toString(), "网页解析中...")) {
            return;
        }
        textView.setText("该站点解析较慢,更换其他站点试试吧~");
    }

    public static final void N(Long l2) {
    }

    public final void K() {
    }

    public final void L() {
        o.E(0L, 60L, 0L, 1L, TimeUnit.SECONDS).I(d.b.a.a.b.b.b()).s(new d.b.a.e.e() {
            @Override
            public final void accept(Object obj) {
                BookChapterActivity.N((Long) obj);
            }
        }).q(new d.b.a.e.a() {
            @Override
            public final void run() {
                BookChapterActivity.M(BookChapterActivity.this);
            }
        }).K();
    }

    public n getDataBindingConfig() {
        return new n(R$layout.reader_book_chapter_activity, 0, (ViewModel) null);
    }

    public void initViewModel() {
        BookChapter2ViewModel activityScopeViewModel = getActivityScopeViewModel(BookChapter2ViewModel.class);
        l.e(activityScopeViewModel, "getActivityScopeViewMode…er2ViewModel::class.java)");
        this.f1787e = activityScopeViewModel;
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        c.t.a.u.a.a.c(this);
        this.f1786d = new BookChapterAdapter(this);
        this.f1785c = new UpLinearLayoutManager(this);
        int i2 = R$id.recycler_view;
        FastScrollRecyclerView findViewById = findViewById(i2);
        RecyclerView.LayoutManager layoutManager = this.f1785c;
        BookChapter2ViewModel bookChapter2ViewModel = null;
        if (layoutManager == null) {
            l.u("mLayoutManager");
            layoutManager = null;
        }
        findViewById.setLayoutManager(layoutManager);
        BookChapterAdapter bookChapterAdapter = this.f1786d;
        if (bookChapterAdapter == null) {
            l.u("adapter");
            bookChapterAdapter = null;
        }
        bookChapterAdapter.L().setOnLoadMoreListener(new c.f.a.a.a.g.h() {
            public final void a() {
                BookChapterActivity.D(BookChapterActivity.this);
            }
        });
        BookChapterAdapter bookChapterAdapter2 = this.f1786d;
        if (bookChapterAdapter2 == null) {
            l.u("adapter");
            bookChapterAdapter2 = null;
        }
        bookChapterAdapter2.setOnItemClickListener(new d() {
            public final void a(BaseQuickAdapter baseQuickAdapter, View view, int i3) {
                BookChapterActivity.E(BookChapterActivity.this, baseQuickAdapter, view, i3);
            }
        });
        FastScrollRecyclerView findViewById2 = findViewById(i2);
        RecyclerView.Adapter adapter = this.f1786d;
        if (adapter == null) {
            l.u("adapter");
            adapter = null;
        }
        findViewById2.setAdapter(adapter);
        BookChapterAdapter bookChapterAdapter3 = this.f1786d;
        if (bookChapterAdapter3 == null) {
            l.u("adapter");
            bookChapterAdapter3 = null;
        }
        bookChapterAdapter3.j0(R$layout.reader_book_chapter_empty_view);
        String[] strArr = {"chapterParesError"};
        final b bVar = new b();
        Observer observer = new Observer() {
            public final void onChanged(String str) {
                h.b0.c.l.this.invoke(str);
            }
        };
        for (int i3 = 0; i3 < 1; i3++) {
            c b2 = c.o.a.a.b(strArr[i3], String.class);
            l.e(b2, "get(tag, EVENT::class.java)");
            b2.c(this, observer);
        }
        BookChapter2ViewModel bookChapter2ViewModel2 = this.f1787e;
        if (bookChapter2ViewModel2 == null) {
            l.u("viewModel");
            bookChapter2ViewModel2 = null;
        }
        bookChapter2ViewModel2.n().observe(this, new Observer() {
            public final void onChanged(Object obj) {
                BookChapterActivity.F(BookChapterActivity.this, (List) obj);
            }
        });
        BookChapter2ViewModel bookChapter2ViewModel3 = this.f1787e;
        if (bookChapter2ViewModel3 == null) {
            l.u("viewModel");
            bookChapter2ViewModel3 = null;
        }
        bookChapter2ViewModel3.o().observe(this, new Observer() {
            public final void onChanged(Object obj) {
                BookChapterActivity.G(BookChapterActivity.this, (Book) obj);
            }
        });
        BookChapter2ViewModel bookChapter2ViewModel4 = this.f1787e;
        if (bookChapter2ViewModel4 == null) {
            l.u("viewModel");
            bookChapter2ViewModel4 = null;
        }
        bookChapter2ViewModel4.q().observe(this, new Observer() {
            public final void onChanged(Object obj) {
                BookChapterActivity.H(BookChapterActivity.this, (Book) obj);
            }
        });
        ((ImageView) findViewById(R$id.iv_back)).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                BookChapterActivity.I(BookChapterActivity.this, view);
            }
        });
        ((TextView) findViewById(R$id.iv_chapter_order)).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                BookChapterActivity.J(BookChapterActivity.this, view);
            }
        });
        BookChapter2ViewModel bookChapter2ViewModel5 = this.f1787e;
        if (bookChapter2ViewModel5 == null) {
            l.u("viewModel");
        } else {
            bookChapter2ViewModel = bookChapter2ViewModel5;
        }
        Intent intent = getIntent();
        l.e(intent, "intent");
        bookChapter2ViewModel.r(intent);
        this.f1788f = getIntent().getBooleanExtra("from_reader_activity", false);
        L();
    }

    @SuppressLint({"SetTextI18n"})
    public final void t(Book book) {
        this.b = book.getDurChapterIndex();
        ((TextView) findViewById(R$id.tv_title)).setText(book.getName());
        TextView textView = (TextView) findViewById(R$id.tv_current_chapter_info);
        StringBuilder sb = new StringBuilder();
        sb.append((Object) book.getDurChapterTitle());
        sb.append('(');
        sb.append(book.getDurChapterIndex() + 1);
        sb.append('/');
        sb.append(book.getTotalChapterNum());
        sb.append(')');
        textView.setText(sb.toString());
    }
}