QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 GifEmotionDataSource.java 源代码,内容仅作参考
package com.tencent.tkd.comment.panel.gif.data;
import android.text.TextUtils;
import com.tencent.tkd.comment.panel.base.EmotionPanelBridge;
import com.tencent.tkd.comment.panel.base.data.IEmotionDataSource;
import com.tencent.tkd.comment.panel.base.listener.OnImageEmotionLoadListener;
import com.tencent.tkd.comment.panel.model.Emotion;
import com.tencent.tkd.comment.publisher.bridge.Result;
import com.tencent.tkd.comment.publisher.bridge.ResultCallback;
import com.tencent.tkd.comment.publisher.bridge.ThreadType;
import com.tencent.tkd.comment.util.CollectionUtil;
import com.tencent.tkd.comment.util.LogUtil;
import com.tencent.tkd.comment.util.StringUtil;
import com.tencent.tkd.comment.util.UiThreadUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
public class GifEmotionDataSource implements IEmotionDataSource {
private AtomicInteger f81116b;
private List<String> f81117c;
private List<Emotion> f81118d;
private OnImageEmotionLoadListener e;
private AtomicBoolean f81115a = new AtomicBoolean(false);
private GifEmotionCacheDataSource f = new GifEmotionCacheDataSource();
private void a(boolean z, boolean z2, List<Emotion> list) {
a(z, z2, false, list);
}
public void a(final boolean z, final boolean z2, final boolean z3, final List<Emotion> list) {
this.f81115a.getAndSet(false);
if (this.e != null) {
UiThreadUtil.a(new Runnable() {
@Override
public void run() {
if (z3) {
GifEmotionDataSource.this.e.a(z);
} else {
GifEmotionDataSource.this.e.a(z, z2, z3, list);
}
}
});
}
}
public void a(byte[] bArr) {
List<Emotion> list;
boolean z;
if (bArr != null && bArr.length > 0) {
GifUrlListResponse gifUrlListResponse = new GifUrlListResponse();
gifUrlListResponse.parseJson(StringUtil.a(bArr));
if (!CollectionUtil.a(gifUrlListResponse.dataList)) {
list = gifUrlListResponse.dataList;
d().addAll(list);
LogUtil.a("EmotionPanelTAG", "current gif size:" + d().size());
z = d().size() >= 32;
if (!z) {
this.f.a(d());
}
a(true, z, list);
}
}
list = null;
if (d().size() >= 32) {
}
if (!z) {
}
a(true, z, list);
}
public void e() {
EmotionPanelBridge.a().b().startHttpRequest("https://quan.qq.com/newscomment/api" + String.format("/getGifHotWords?startIndex=%s&count=%s", 0, 50), new ResultCallback<byte[]>() {
@Override
public void onResult(Result<byte[]> result) {
LogUtil.a("EmotionPanelTAG", "loadGifHotWord:" + result);
if (result.data != null) {
boolean z = false;
if (result.data.length > 0) {
GifHotWordResponse gifHotWordResponse = new GifHotWordResponse();
gifHotWordResponse.parseJson(StringUtil.a(result.data));
if (!CollectionUtil.a(gifHotWordResponse.dataList)) {
z = true;
GifEmotionDataSource.this.f81117c = gifHotWordResponse.dataList;
GifEmotionDataSource.this.c();
}
}
if (z) {
return;
}
}
GifEmotionDataSource.this.f();
}
});
}
public void f() {
a(false, false, null);
}
@Override
public void a() {
this.f.a();
}
public void a(OnImageEmotionLoadListener onImageEmotionLoadListener) {
this.e = onImageEmotionLoadListener;
}
public void b() {
if (this.f81115a.compareAndSet(false, true)) {
a();
EmotionPanelBridge.a().b().getThreadManagerImpl().post(ThreadType.IO, new Runnable() {
@Override
public void run() {
List<Emotion> b2 = GifEmotionDataSource.this.f.b();
if (CollectionUtil.a(b2)) {
if (CollectionUtil.a(GifEmotionDataSource.this.f81117c)) {
GifEmotionDataSource.this.e();
return;
} else {
GifEmotionDataSource.this.d().clear();
GifEmotionDataSource.this.c();
return;
}
}
LogUtil.a("EmotionPanelTAG", "load gif from cache");
GifEmotionDataSource.this.d().clear();
GifEmotionDataSource.this.d().addAll(b2);
GifEmotionDataSource gifEmotionDataSource = GifEmotionDataSource.this;
gifEmotionDataSource.a(true, false, true, gifEmotionDataSource.d());
}
});
}
}
public void c() {
if (this.f81116b == null) {
this.f81116b = new AtomicInteger(0);
}
if (CollectionUtil.a(this.f81117c) || this.f81116b.get() >= this.f81117c.size()) {
f();
return;
}
String str = this.f81117c.get(this.f81116b.get());
this.f81116b.getAndIncrement();
if (TextUtils.isEmpty(str)) {
a((byte[]) null);
return;
}
EmotionPanelBridge.a().b().startHttpRequest("https://quan.qq.com/newscomment/api" + String.format("/getGifByKw?word=%s&count=%s&startIndex=%s&needCache=%s", str, 4, 0, 1), new ResultCallback<byte[]>() {
@Override
public void onResult(Result<byte[]> result) {
LogUtil.a("EmotionPanelTAG", "loadGifUrlList:" + result);
if (result.data != null) {
GifEmotionDataSource.this.a(result.data);
} else {
GifEmotionDataSource.this.a((byte[]) null);
}
}
});
}
public List<Emotion> d() {
if (this.f81118d == null) {
this.f81118d = new ArrayList();
}
return this.f81118d;
}
}