酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319

以下内容为反编译后的 AwardListProtocol.java 源代码,内容仅作参考


package com.kugou.android.topic2.detail.protocol;

import android.support.v4.app.NotificationCompat;
import c.t;
import com.kugou.android.app.home.channel.f.d;
import com.kugou.android.app.home.channel.protocol.bi;
import com.kugou.android.topic2.detail.act.award.AwardUserItem;
import com.kugou.android.topic2.detail.act.award.AwardWrapper;
import com.kugou.android.topic2.detail.base.CommonListResponse;
import com.kugou.common.app.KGCommonApplication;
import com.kugou.common.config.c;
import com.kugou.common.network.w;
import com.kugou.common.utils.br;
import com.tencent.open.SocialConstants;
import com.tencent.open.SocialOperation;
import com.tencent.stat.DeviceInfo;
import com.wandoujia.upgradesdk.UpgradeManager;
import d.ab;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import kotlin.Metadata;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Lambda;
import kotlin.jvm.internal.i;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONObject;
import rx.e;

@Metadata(bv = {1, 0, 3}, d1 = {"\u0000V\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\bÆ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u001e\u0010\b\u001a\b\u0012\u0004\u0012\u00020\n0\t2\u0006\u0010\u000b\u001a\u00020\f2\u0006\u0010\r\u001a\u00020\u000eH\u0002J\"\u0010\u000f\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\n0\u00110\u00102\u0006\u0010\r\u001a\u00020\u000e2\u0006\u0010\u0012\u001a\u00020\u000eJ \u0010\u0013\u001a\u0012\u0012\u0004\u0012\u00020\n0\u0014j\b\u0012\u0004\u0012\u00020\n`\u00152\u0006\u0010\u0016\u001a\u00020\u0017H\u0002JD\u0010\u0018\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u0002H\u00190\u00110\u0010\"\u0004\b\u0000\u0010\u00192\u0006\u0010\u001a\u001a\u00020\u000e2\u0006\u0010\u0012\u001a\u00020\u000e2\u0018\u0010\u001b\u001a\u0014\u0012\u0004\u0012\u00020\f\u0012\n\u0012\b\u0012\u0004\u0012\u0002H\u00190\t0\u001cH\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u001e\u0010\u0005\u001a\u0012\u0012\u0004\u0012\u00020\u00040\u0006j\b\u0012\u0004\u0012\u00020\u0004`\u0007X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u001d"}, d2 = {"Lcom/kugou/android/topic2/detail/protocol/AwardListProtocol;", "", "()V", "MODULE_NAME", "", "mAwardNameMap", "Ljava/util/HashSet;", "Lkotlin/collections/HashSet;", "createItemFromJson", "", "Lcom/kugou/android/topic2/detail/act/award/AwardWrapper;", "json", "Lorg/json/JSONObject;", "topicId", "", "getList", "Lrx/Observable;", "Lcom/kugou/android/topic2/detail/base/CommonListResponse;", "curPage", "parseArray", "Ljava/util/ArrayList;", "Lkotlin/collections/ArrayList;", "array", "Lorg/json/JSONArray;", SocialConstants.TYPE_REQUEST, "T", "topic_id", "func", "Lkotlin/Function1;", "androidkugou_release"}, k = 1, mv = {1, 1, 15})
public final class AwardListProtocol {

    public static final AwardListProtocol f42383a = new AwardListProtocol();

    private static final HashSet<String> f42384b = new HashSet<>();

    private AwardListProtocol() {
    }

    @NotNull
    public final e<CommonListResponse<AwardWrapper>> a(int i, int i2) {
        if (i2 == 1) {
            f42384b.clear();
        }
        return a(i, i2, new a(i));
    }

    @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0012\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\u0010\u0000\u001a\b\u0012\u0004\u0012\u00020\u00020\u00012\u0006\u0010\u0003\u001a\u00020\u0004H\n¢\u0006\u0002\b\u0005"}, d2 = {"<anonymous>", "", "Lcom/kugou/android/topic2/detail/act/award/AwardWrapper;", "it", "Lorg/json/JSONObject;", "invoke"}, k = 3, mv = {1, 1, 15})
    static final class a extends Lambda implements Function1<JSONObject, List<? extends AwardWrapper>> {

        final int f42385a;

        a(int i) {
            super(1);
            this.f42385a = i;
        }

        @Override
        @NotNull
        public final List<AwardWrapper> a(@NotNull JSONObject jSONObject) {
            i.b(jSONObject, "it");
            return AwardListProtocol.f42383a.a(jSONObject, this.f42385a);
        }
    }

    public final List<AwardWrapper> a(JSONObject jSONObject, int i) {
        ArrayList arrayList = new ArrayList();
        JSONArray optJSONArray = jSONObject.optJSONArray("list");
        i.a((Object) optJSONArray, "includeUsers");
        arrayList.addAll(a(optJSONArray));
        return arrayList;
    }

    private final ArrayList<AwardWrapper> a(JSONArray jSONArray) {
        ArrayList<AwardWrapper> arrayList = new ArrayList<>();
        AwardUserItem awardUserItem = new AwardUserItem();
        int length = jSONArray.length();
        for (int i = 0; i < length; i++) {
            JSONObject jSONObject = jSONArray.getJSONObject(i);
            i.a((Object) jSONObject, "getJSONObject(index)");
            String optString = jSONObject.optString("award_name");
            AwardUserItem.a a2 = new AwardUserItem.a().a(jSONObject);
            if (!f42384b.contains(optString)) {
                if (!awardUserItem.a().isEmpty()) {
                    arrayList.add(new AwardWrapper(2, awardUserItem));
                    awardUserItem = new AwardUserItem();
                }
                if (arrayList.size() != 0) {
                    arrayList.add(new AwardWrapper(3, null));
                }
                arrayList.add(new AwardWrapper(1, optString));
                f42384b.add(optString);
            }
            if (!awardUserItem.b()) {
                awardUserItem.a(a2);
            } else {
                arrayList.add(new AwardWrapper(2, awardUserItem));
                awardUserItem = new AwardUserItem();
                awardUserItem.a(a2);
            }
        }
        if (!awardUserItem.a().isEmpty()) {
            arrayList.add(new AwardWrapper(2, awardUserItem));
        }
        return arrayList;
    }

    private final <T> e<CommonListResponse<T>> a(int i, int i2, Function1<? super JSONObject, ? extends List<? extends T>> function1) {
        t b2 = new t.a().b("topic_get_award_list").a(c.a.a.i.a()).a(w.a(com.kugou.android.app.a.a.uA, "https://gateway.kugou.com/youth/v1/topic/award_user")).a(c.b.a.a.a()).a().b();
        HashMap hashMap = new HashMap();
        hashMap.put("appid", Integer.valueOf(c.a().d(com.kugou.android.app.a.a.lo)));
        hashMap.put("clientver", Integer.valueOf(br.F(KGCommonApplication.getContext())));
        hashMap.put("clienttime", Long.valueOf(br.d() / 1000));
        String j = br.j(KGCommonApplication.getContext());
        i.a((Object) j, "SystemUtils.getMid(KGCom…Application.getContext())");
        hashMap.put(DeviceInfo.TAG_MID, j);
        com.kugou.common.q.b a2 = com.kugou.common.q.b.a();
        i.a((Object) a2, "CommonSettingPrefs.getInstance()");
        String cS = a2.cS();
        i.a((Object) cS, "CommonSettingPrefs.getIn…deviceFingerIdDateNotNull");
        hashMap.put("dfid", cS);
        com.kugou.common.q.b a3 = com.kugou.common.q.b.a();
        i.a((Object) a3, "CommonSettingPrefs.getInstance()");
        String ak = a3.ak();
        i.a((Object) ak, "CommonSettingPrefs.getInstance().uuid");
        hashMap.put("uuid", ak);
        if (com.kugou.common.environment.a.u()) {
            hashMap.put("userid", Long.valueOf(com.kugou.common.environment.a.Y()));
            String j2 = com.kugou.common.environment.a.j();
            i.a((Object) j2, "CommonEnvManager.getToken()");
            hashMap.put(UpgradeManager.PARAM_TOKEN, j2);
        }
        hashMap.put("topic_id", Integer.valueOf(i));
        hashMap.put("page", Integer.valueOf(i2));
        String a4 = w.a(w.c(hashMap));
        i.a((Object) a4, "Utils.getSign(Utils.map2SortString(params))");
        hashMap.put(SocialOperation.GAME_SIGNATURE, a4);
        hashMap.put("userid", Long.valueOf(com.kugou.common.environment.a.Y()));
        e<CommonListResponse<T>> eVar = (e<CommonListResponse<T>>) ((bi) b2.a(bi.class)).a(hashMap).c(new b(function1));
        i.a((Object) eVar, "request.create(IChannelC…\n            }\n        })");
        return eVar;
    }

    @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0014\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\u0010\u0000\u001a>\u0012\u0018\u0012\u0016\u0012\u0004\u0012\u0002H\u0003 \u0004*\n\u0012\u0004\u0012\u0002H\u0003\u0018\u00010\u00020\u0002 \u0004*\u001e\u0012\u0018\u0012\u0016\u0012\u0004\u0012\u0002H\u0003 \u0004*\n\u0012\u0004\u0012\u0002H\u0003\u0018\u00010\u00020\u0002\u0018\u00010\u00010\u0001\"\u0004\b\u0000\u0010\u00032\u000e\u0010\u0005\u001a\n \u0004*\u0004\u0018\u00010\u00060\u0006H\n¢\u0006\u0002\b\u0007"}, d2 = {"<anonymous>", "Lrx/Observable;", "Lcom/kugou/android/topic2/detail/base/CommonListResponse;", "T", "kotlin.jvm.PlatformType", "responseBody", "Lokhttp3/ResponseBody;", NotificationCompat.CATEGORY_CALL}, k = 3, mv = {1, 1, 15})
    public static final class b<T, R> implements rx.b.e<ab, e<CommonListResponse<T>>> {

        final Function1 f42386a;

        b(Function1 function1) {
            this.f42386a = function1;
        }

        @Override
        public final e<CommonListResponse<T>> call(ab abVar) {
            String str = (String) null;
            try {
                JSONObject jSONObject = new JSONObject(abVar.f());
                int optInt = jSONObject.optInt("status");
                JSONObject optJSONObject = jSONObject.optJSONObject("data");
                CommonListResponse commonListResponse = new CommonListResponse(0, null, 0, 0, null, 31, null);
                if (optInt == 1) {
                    Function1 function1 = this.f42386a;
                    i.a((Object) optJSONObject, "data");
                    List<? extends T> list = (List) function1.a(optJSONObject);
                    int optInt2 = optJSONObject.optInt("is_end");
                    commonListResponse.a((List) list);
                    commonListResponse.e(optInt2);
                    return e.a(commonListResponse);
                }
                return e.a((Throwable) new d(jSONObject.optInt("error_code")));
            } catch (Exception e2) {
                e2.printStackTrace();
                return e.a((Throwable) new com.kugou.android.app.home.channel.f.c(str));
            }
        }
    }
}