正在查看: Top浏览器 v4.6.16 应用的 TTSReadAloudService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Top浏览器 v4.6.16 应用的 TTSReadAloudService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.pocket.topbrowser.reader.service;
import android.app.PendingIntent;
import android.content.Intent;
import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
import c.t.a.k.e;
import c.t.c.o.s.i;
import c.t.c.o.u.h;
import com.pocket.topbrowser.reader.R$string;
import com.umeng.analytics.pro.ak;
import h.b0.c.p;
import h.b0.d.l;
import h.i0.s;
import h.l;
import h.m;
import h.u;
import h.y.j.a.f;
import i.a.n0;
import java.lang.reflect.Type;
import java.util.Locale;
public final class TTSReadAloudService extends BaseReadAloudService implements TextToSpeech.OnInitListener {
public TextToSpeech p;
public boolean q;
public final a r = new a(this);
public final class a extends UtteranceProgressListener {
public final TTSReadAloudService a;
public a(TTSReadAloudService tTSReadAloudService) {
l.f(tTSReadAloudService, "this$0");
this.a = tTSReadAloudService;
}
@Override
public void onDone(String str) {
l.f(str, ak.aB);
TTSReadAloudService tTSReadAloudService = this.a;
tTSReadAloudService.C(tTSReadAloudService.n() + this.a.k().get(this.a.l()).length() + 1);
TTSReadAloudService tTSReadAloudService2 = this.a;
tTSReadAloudService2.A(tTSReadAloudService2.l() + 1);
if (this.a.l() >= this.a.k().size()) {
this.a.s();
}
}
@Override
public void onError(String str) {
l.f(str, ak.aB);
}
@Override
public void onRangeStart(String str, int i2, int i3, int i4) {
super.onRangeStart(str, i2, i3, i4);
c.t.c.o.v.e.b o = this.a.o();
if (o == null) {
return;
}
TTSReadAloudService tTSReadAloudService = this.a;
if (tTSReadAloudService.n() + i2 > o.h(tTSReadAloudService.m() + 1)) {
tTSReadAloudService.B(tTSReadAloudService.m() + 1);
h.a.C();
c.o.a.a.a("ttsStart").b(Integer.valueOf(tTSReadAloudService.n() + i2));
}
}
@Override
public void onStart(String str) {
l.f(str, ak.aB);
c.t.c.o.v.e.b o = this.a.o();
if (o == null) {
return;
}
TTSReadAloudService tTSReadAloudService = this.a;
if (tTSReadAloudService.n() + 1 > o.h(tTSReadAloudService.m() + 1)) {
tTSReadAloudService.B(tTSReadAloudService.m() + 1);
h.a.C();
}
c.o.a.a.a("ttsStart").b(Integer.valueOf(tTSReadAloudService.n() + 1));
}
}
public static final class b extends c.l.c.z.a<c.t.c.o.t.a.a<String>> {
}
@f(c = "com.pocket.topbrowser.reader.service.TTSReadAloudService$play$1", f = "TTSReadAloudService.kt", l = {}, m = "invokeSuspend")
public static final class c extends h.y.j.a.l implements p<n0, h.y.d<? super u>, Object> {
public int a;
public c(h.y.d<? super c> dVar) {
super(2, dVar);
}
@Override
public final h.y.d<u> create(Object obj, h.y.d<?> dVar) {
return TTSReadAloudService.this.new c(dVar);
}
@Override
public final Object invoke(n0 n0Var, h.y.d<? super u> dVar) {
return ((c) create(n0Var, dVar)).invokeSuspend(u.a);
}
@Override
public final Object invokeSuspend(Object obj) {
h.y.i.c.c();
if (this.a != 0) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
m.b(obj);
i.a.c(TTSReadAloudService.this);
return u.a;
}
}
@f(c = "com.pocket.topbrowser.reader.service.TTSReadAloudService$play$2", f = "TTSReadAloudService.kt", l = {}, m = "invokeSuspend")
public static final class d extends h.y.j.a.l implements p<n0, h.y.d<? super u>, Object> {
public int a;
public d(h.y.d<? super d> dVar) {
super(2, dVar);
}
@Override
public final h.y.d<u> create(Object obj, h.y.d<?> dVar) {
return TTSReadAloudService.this.new d(dVar);
}
@Override
public final Object invoke(n0 n0Var, h.y.d<? super u> dVar) {
return ((d) create(n0Var, dVar)).invokeSuspend(u.a);
}
@Override
public final Object invokeSuspend(Object obj) {
h.y.i.c.c();
if (this.a != 0) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
m.b(obj);
TextToSpeech textToSpeech = TTSReadAloudService.this.p;
if (textToSpeech != null) {
TTSReadAloudService tTSReadAloudService = TTSReadAloudService.this;
textToSpeech.speak("", 0, null, null);
int l2 = tTSReadAloudService.l();
int size = tTSReadAloudService.k().size();
if (l2 < size) {
while (true) {
int i2 = l2 + 1;
String str = tTSReadAloudService.k().get(l2);
l.e(str, "contentList[i]");
textToSpeech.speak(d.a.a.a.a.a.f().f(str, ""), 1, null, l.m("Legado", h.y.j.a.b.b(l2)));
if (i2 >= size) {
break;
}
l2 = i2;
}
}
}
return u.a;
}
}
@Override
public void H(boolean z) {
if (c.h.b.i.c.b("ttsFollowSys", true)) {
if (z) {
K();
L();
return;
}
return;
}
TextToSpeech textToSpeech = this.p;
if (textToSpeech == null) {
return;
}
textToSpeech.setSpeechRate((c.t.a.e.a.a.t() + 5) / 10.0f);
}
public final synchronized void K() {
TextToSpeech textToSpeech = this.p;
if (textToSpeech != null) {
textToSpeech.stop();
}
TextToSpeech textToSpeech2 = this.p;
if (textToSpeech2 != null) {
textToSpeech2.shutdown();
}
this.p = null;
this.q = false;
}
public final synchronized void L() {
Object b2;
this.q = false;
c.l.c.f a2 = e.a();
String s = c.t.a.e.a.a.s();
String str = null;
try {
l.a aVar = h.l.a;
Type type = new b().getType();
h.b0.d.l.e(type, "object : TypeToken<T>() {}.type");
Object j2 = a2.j(s, type);
if (!(j2 instanceof c.t.c.o.t.a.a)) {
j2 = null;
}
b2 = h.l.b((c.t.c.o.t.a.a) j2);
} catch (Throwable th) {
l.a aVar2 = h.l.a;
b2 = h.l.b(m.a(th));
}
Throwable d2 = h.l.d(b2);
if (d2 != null) {
c.h.b.j.e.c(new Object[]{d2, s});
}
if (h.l.f(b2)) {
b2 = null;
}
c.t.c.o.t.a.a aVar3 = (c.t.c.o.t.a.a) b2;
if (aVar3 != null) {
str = (String) aVar3.a();
}
this.p = str == null || s.t(str) ? new TextToSpeech(this, this) : new TextToSpeech(this, this, str);
}
@Override
public PendingIntent i(String str) {
h.b0.d.l.f(str, "actionStr");
Intent intent = new Intent(this, (Class<?>) TTSReadAloudService.class);
intent.setAction(str);
return PendingIntent.getService(this, 0, intent, 134217728);
}
@Override
public void onCreate() {
super.onCreate();
L();
BaseReadAloudService.I(this, false, 1, null);
}
@Override
public void onDestroy() {
super.onDestroy();
K();
}
@Override
public void onInit(int i2) {
if (i2 != 0) {
c.t.a.k.a.g(this, R$string.reader_tts_init_failed);
return;
}
TextToSpeech textToSpeech = this.p;
if (textToSpeech == null) {
return;
}
textToSpeech.setOnUtteranceProgressListener(this.r);
textToSpeech.setLanguage(Locale.CHINA);
this.q = true;
v();
}
@Override
public void u(boolean z) {
super.u(z);
TextToSpeech textToSpeech = this.p;
if (textToSpeech == null) {
return;
}
textToSpeech.stop();
}
@Override
public synchronized void v() {
if ((!k().isEmpty()) && this.q && y()) {
super.v();
c.t.c.o.s.l.a.o(BaseService.b(this, null, null, new c(null), 3, null), null, new d(null), 1, null);
}
}
@Override
public void w() {
TextToSpeech textToSpeech = this.p;
if (textToSpeech == null) {
return;
}
textToSpeech.stop();
}
@Override
public void z() {
super.z();
v();
}
}