酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319
以下内容为反编译后的 ag.java 源代码,内容仅作参考
package com.kugou.android.app.home.channel.protocol;
import android.text.TextUtils;
import c.a.a.i;
import c.t;
import com.huawei.hms.push.constant.RemoteMessageConst;
import com.kugou.android.app.a.a;
import com.kugou.android.app.ads.AdsCenterMgr;
import com.kugou.android.app.ads.protocol.CheckAdCanShowProtocol;
import com.kugou.android.app.channeltopic.SpecialTopicEntity;
import com.kugou.android.app.home.channel.entity.CommonResponse;
import com.kugou.android.app.home.channel.entity.DiscoveryAdType;
import com.kugou.android.app.home.channel.entity.contributionrec.ChannelSpecialWrapper;
import com.kugou.android.app.home.channel.entity.k;
import com.kugou.android.app.home.channel.f.d;
import com.kugou.android.common.entity.KGMusic;
import com.kugou.android.common.entity.KGSong;
import com.kugou.android.netmusic.discovery.e;
import com.kugou.common.app.KGCommonApplication;
import com.kugou.common.config.c;
import com.kugou.common.network.w;
import com.kugou.common.q.b;
import com.kugou.common.utils.as;
import com.kugou.common.utils.br;
import com.kugou.common.utils.cz;
import com.kugou.framework.database.channel.entity.ChannelEntity;
import com.kugou.framework.database.contribution.entity.ContributionEntity;
import com.kugou.framework.database.userbehavior.entity.UserBehavior;
import com.kugou.framework.netmusic.topic.TopicEntity;
import com.qq.e.comm.constants.TangramHippyConstants;
import com.tencent.open.SocialOperation;
import com.tencent.stat.DeviceInfo;
import com.tencent.tauth.AuthActivity;
import com.wandoujia.upgradesdk.UpgradeManager;
import com.wandoujia.upgradesdk.model.MarketAppInfo;
import d.ab;
import d.u;
import d.z;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import rx.e;
public class ag {
public static String a() {
return "main-page-contribution-rec";
}
private static String b() {
return "ChannelRecommendSong";
}
public static e<k> a(List<UserBehavior> list, final int i, final int i2, String str, String str2, String str3, String str4, final boolean z) {
t b2 = new t.a().b(b()).a(i.a()).a(w.a(a.eD, "https://youth.kugou.com/api/channel/v7/recommend_list")).a(c.b.a.a.a()).a().b();
String a2 = a(list);
HashMap hashMap = new HashMap();
hashMap.put("appid", Integer.valueOf(c.a().d(a.lo)));
hashMap.put("clientver", Integer.valueOf(br.F(KGCommonApplication.getContext())));
hashMap.put("clienttime", Long.valueOf(br.d() / 1000));
hashMap.put(DeviceInfo.TAG_MID, br.j(KGCommonApplication.getContext()));
hashMap.put("dfid", b.a().cS());
hashMap.put("uuid", b.a().ak());
hashMap.put("page", Integer.valueOf(i));
hashMap.put("pagesize", Integer.valueOf(i2));
hashMap.put("platform", String.valueOf(1));
if (com.kugou.common.environment.a.u()) {
hashMap.put("userid", Long.valueOf(com.kugou.common.environment.a.Y()));
hashMap.put(UpgradeManager.PARAM_TOKEN, com.kugou.common.environment.a.j());
}
if (TextUtils.isEmpty(str3)) {
str3 = "";
}
hashMap.put("fill_last_one", str3);
hashMap.put("with_topic", "1");
hashMap.put(SocialOperation.GAME_SIGNATURE, w.a(w.c(hashMap) + a2));
return ((bi) b2.a(bi.class)).b(hashMap, z.a(u.a("application/json"), a2)).c(new rx.b.e<ab, e<k>>() {
@Override
public e<k> call(ab abVar) {
final String str5;
try {
str5 = abVar.f();
try {
return ag.a(str5, i, i2, false, z, new Runnable() {
@Override
public void run() {
com.kugou.common.utils.ag.b(str5, "Channel", ag.a());
}
});
} catch (Exception unused) {
return e.a((Throwable) new com.kugou.android.app.home.channel.f.c(str5));
}
} catch (Exception unused2) {
str5 = null;
}
}
});
}
private static String a(List<UserBehavior> list) {
if (list != null && list.size() != 0) {
try {
JSONObject jSONObject = new JSONObject();
JSONArray jSONArray = new JSONArray();
for (UserBehavior userBehavior : list) {
if (userBehavior != null && !TextUtils.isEmpty(userBehavior.b())) {
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("key", userBehavior.b());
jSONObject2.put(DeviceInfo.TAG_TIMESTAMPS, userBehavior.c() / 1000);
jSONObject2.put(AuthActivity.ACTION_KEY, userBehavior.e());
jSONObject2.put(TangramHippyConstants.COUNT, userBehavior.d());
jSONArray.put(jSONObject2);
}
}
if (jSONArray.length() > 0) {
jSONObject.put("data", jSONArray);
return jSONObject.toString();
}
} catch (JSONException e2) {
e2.printStackTrace();
}
}
return "";
}
public static e<k> a(final String str, final int i, final int i2, final boolean z, final boolean z2, final Runnable runnable) {
return CheckAdCanShowProtocol.f4441a.a().c(new rx.b.e<CommonResponse<Boolean>, e<k>>() {
@Override
public e<k> call(CommonResponse<Boolean> commonResponse) {
return ag.c(str, i, i2, z, z2, runnable);
}
});
}
public static e<k> c(String str, int i, int i2, boolean z, boolean z2, Runnable runnable) {
try {
as.f("lzq-young", str);
JSONObject jSONObject = new JSONObject(str);
int optInt = jSONObject.optInt("status");
int optInt2 = jSONObject.optInt("error_code");
k kVar = new k();
kVar.a(optInt);
kVar.b(optInt2);
if (optInt == 1) {
JSONObject optJSONObject = jSONObject.optJSONObject("data");
ArrayList arrayList = new ArrayList();
JSONArray optJSONArray = optJSONObject.optJSONArray("list");
if (optJSONArray != null) {
for (int i3 = 0; i3 < optJSONArray.length(); i3++) {
JSONObject jSONObject2 = optJSONArray.getJSONObject(i3);
int optInt3 = jSONObject2.optInt("recommend_type");
if (optInt3 == 1) {
a(arrayList, jSONObject2);
} else if (optInt3 == 2) {
ContributionEntity a2 = ContributionEntity.a(jSONObject2);
if (a2.f57766e != null) {
a2.f57766e.bm = 1024;
a2.f57766e.z("/频道/推荐帖子");
}
arrayList.add(new com.kugou.android.app.home.channel.entity.contributionrec.c(a2));
} else if (optInt3 == 3) {
b(arrayList, jSONObject2);
}
}
if (!z && cz.a(arrayList) && runnable != null) {
runnable.run();
}
if (AdsCenterMgr.f4446a.c().get()) {
as.b("module-gdt-ad", "插入发现页广告");
a(i, i2, arrayList, z2);
}
kVar.d(arrayList.size());
kVar.e(optJSONObject.optInt("is_end"));
kVar.c(optJSONObject.optString("new_last_one"));
kVar.d(optJSONObject.optString("fill_last_one"));
kVar.e(optJSONObject.optString("topic_last_one"));
kVar.b(z);
kVar.b(arrayList);
return e.a(kVar);
}
return e.a((Throwable) new d(optInt2));
}
return e.a((Throwable) new d(optInt2));
} catch (Exception unused) {
return e.a((Throwable) new com.kugou.android.app.home.channel.f.c(str));
}
}
private static void a(int i, int i2, List<com.kugou.android.app.home.channel.entity.contributionrec.a.a> list, boolean z) {
String b2 = c.a().b(a.FW, "3,6");
if (TextUtils.isEmpty(b2) || "-1".equals(b2)) {
return;
}
int i3 = z ? 1 : i;
String[] split = b2.split(",");
int size = list.size();
int i4 = (i3 - 1) * i2;
for (String str : split) {
try {
int parseInt = Integer.parseInt(str.replace("(", "").replace(")", ""));
if (AdsCenterMgr.f4446a.f().get(Integer.valueOf(parseInt)).booleanValue() && parseInt < size && parseInt > i4) {
list.add(parseInt - i4, new DiscoveryAdType(parseInt, i));
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
private static void a(List<com.kugou.android.app.home.channel.entity.contributionrec.a.a> list, JSONObject jSONObject) throws JSONException {
SpecialTopicEntity specialTopicEntity = new SpecialTopicEntity();
TopicEntity topicEntity = new TopicEntity();
topicEntity.a(jSONObject.optInt("topic_id"));
topicEntity.a(jSONObject.optString("topic_name"));
topicEntity.b(jSONObject.optString("add_time"));
topicEntity.d(jSONObject.optString(RemoteMessageConst.Notification.ICON));
topicEntity.c(jSONObject.optString("brief"));
specialTopicEntity.a(topicEntity);
e.a aVar = new e.a();
aVar.C = jSONObject.optString("specail_id");
aVar.f34548a = jSONObject.optInt("specialid");
aVar.f34549b = jSONObject.optString("special_name");
aVar.g = jSONObject.optString("special_pic");
aVar.f34551d = jSONObject.optString("special_intro");
aVar.h = jSONObject.optInt("list_create_userid");
aVar.u = jSONObject.optString("create_user_pic");
aVar.m = jSONObject.optString("list_create_username");
aVar.k = jSONObject.optInt("collect_total");
aVar.j = jSONObject.optLong("heat");
aVar.i = jSONObject.optInt("list_create_listid");
aVar.f34552e = jSONObject.optString("publish_date");
specialTopicEntity.a(aVar);
ChannelEntity channelEntity = new ChannelEntity();
channelEntity.f57740c = jSONObject.optString("global_collection_id");
channelEntity.f57741d = jSONObject.optString("channel_name");
channelEntity.f57738a = jSONObject.optInt("channel_creator");
specialTopicEntity.a(channelEntity);
StringBuilder sb = new StringBuilder();
JSONArray optJSONArray = jSONObject.optJSONArray("song_list");
int length = optJSONArray == null ? 0 : optJSONArray.length();
ArrayList arrayList = new ArrayList(length);
for (int i = 0; i < length; i++) {
JSONObject jSONObject2 = optJSONArray.getJSONObject(i);
if (jSONObject2 != null && jSONObject2.optInt("mixsongid") > 0) {
KGSong a2 = a(optJSONArray.getJSONObject(i));
a2.z(String.format("/发现页/话题歌单/%s/%s/%s", channelEntity.f57740c, Integer.valueOf(topicEntity.getId()), Integer.valueOf(aVar.f34548a)));
a2.b(1);
a2.H(300);
a2.C("18");
arrayList.add(a2);
sb.append(a2.bD_());
sb.append(i + 1 == length ? "" : "、");
}
}
specialTopicEntity.a(arrayList);
specialTopicEntity.a(sb.toString());
specialTopicEntity.a(jSONObject.optInt("song_count"));
specialTopicEntity.b(4);
list.add(new ChannelSpecialWrapper(specialTopicEntity, 4));
}
private static void b(List<com.kugou.android.app.home.channel.entity.contributionrec.a.a> list, JSONObject jSONObject) throws JSONException {
SpecialTopicEntity specialTopicEntity = new SpecialTopicEntity();
TopicEntity topicEntity = new TopicEntity();
topicEntity.a(jSONObject.optInt("topic_id"));
topicEntity.a(jSONObject.optString("topic_name"));
topicEntity.b(jSONObject.optString("add_time"));
topicEntity.d(jSONObject.optString(RemoteMessageConst.Notification.ICON));
topicEntity.c(jSONObject.optString("brief"));
specialTopicEntity.a(topicEntity);
JSONArray optJSONArray = jSONObject.optJSONArray("file_list");
ArrayList arrayList = new ArrayList(optJSONArray.length());
ArrayList arrayList2 = new ArrayList(optJSONArray.length());
for (int i = 0; i < optJSONArray.length(); i++) {
ContributionEntity a2 = ContributionEntity.a(optJSONArray.getJSONObject(i));
if (a2.f57766e != null) {
arrayList.add(a2.f57766e);
}
arrayList2.add(a2);
}
specialTopicEntity.a(arrayList);
specialTopicEntity.b(arrayList2);
ChannelEntity channelEntity = new ChannelEntity();
channelEntity.f57740c = jSONObject.optString("global_collection_id");
channelEntity.f57741d = jSONObject.optString("channel_name");
channelEntity.f57738a = jSONObject.optInt("channel_creator");
specialTopicEntity.a(channelEntity);
specialTopicEntity.a(jSONObject.optInt("tag_nums"));
list.add(new ChannelSpecialWrapper(specialTopicEntity, 6));
}
private static KGSong a(JSONObject jSONObject) {
int i;
int i2;
KGMusic kGMusic = new KGMusic();
String optString = jSONObject.optString("name");
int lastIndexOf = optString.lastIndexOf(".");
int i3 = 0;
if (lastIndexOf > 0) {
kGMusic.b(optString.substring(0, lastIndexOf));
} else {
kGMusic.b(optString);
}
String str = "hash";
kGMusic.j(jSONObject.optString("hash"));
kGMusic.h(jSONObject.optLong(MarketAppInfo.KEY_SIZE));
kGMusic.i(jSONObject.optLong("timelen"));
kGMusic.k(jSONObject.optInt("bitrate"));
kGMusic.p(jSONObject.optString("mvhash"));
kGMusic.l(jSONObject.optInt("mvtrack"));
kGMusic.q(jSONObject.optInt("privilege"));
kGMusic.A(jSONObject.optInt("media_old_cpy"));
kGMusic.t(jSONObject.optString("cover"));
if (jSONObject.has("relate_goods")) {
JSONArray optJSONArray = jSONObject.optJSONArray("relate_goods");
if (optJSONArray != null) {
int i4 = 0;
i = 0;
i2 = 0;
while (i3 < optJSONArray.length()) {
JSONObject optJSONObject = optJSONArray.optJSONObject(i3);
int optInt = optJSONObject.optInt("level");
int optInt2 = optJSONObject.optInt("privilege");
String optString2 = optJSONObject.optString(str);
JSONArray jSONArray = optJSONArray;
int i5 = i4;
long optLong = optJSONObject.optLong(MarketAppInfo.KEY_SIZE);
String str2 = str;
if (optInt == 2) {
kGMusic.j(optString2);
kGMusic.h(optLong);
i4 = optInt2;
} else {
if (optInt == 4) {
kGMusic.n(optString2);
kGMusic.k(optLong);
i = optInt2;
} else if (optInt == 5) {
kGMusic.o(optString2);
kGMusic.l(optLong);
i2 = optInt2;
}
i4 = i5;
}
com.kugou.framework.musicfees.a.i.a(optJSONObject, kGMusic);
i3++;
optJSONArray = jSONArray;
str = str2;
}
i3 = i4;
} else {
i = 0;
i2 = 0;
}
kGMusic.a(i3, i, i2);
}
KGSong a2 = KGSong.a(kGMusic);
a2.A(jSONObject.optString("cover"));
return a2;
}
}