OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046

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


package com.excelliance.kxqp.gs.ui.search;

import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
import android.text.TextUtils;
import android.util.Log;
import com.excelliance.kxqp.gs.bean.SearchKeyBean;
import com.excelliance.kxqp.gs.bean.SearchKeyResult;
import com.excelliance.kxqp.gs.discover.model.ResponseData;
import com.excelliance.kxqp.gs.provider.SearchProvider;
import com.excelliance.kxqp.gs.thpool.tp;
import com.excelliance.kxqp.gs.ui.search.b;
import com.excelliance.kxqp.gs.util.az;
import com.excelliance.kxqp.gs.util.bf;
import com.excelliance.kxqp.gs.util.cd;
import com.excelliance.kxqp.gs.util.cn;
import com.excelliance.kxqp.gs.util.s;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class c implements b.a {

    private Context f11022a;

    private b.InterfaceC0443b f11023b;
    private List<com.excelliance.kxqp.gs.view.taglayout.a> c = new ArrayList();
    private List<com.excelliance.kxqp.gs.view.taglayout.a> d = new ArrayList();
    private Handler e;

    @Override
    public void initData() {
    }

    public c(Context context, b.InterfaceC0443b interfaceC0443b) {
        this.f11023b = interfaceC0443b;
        this.f11022a = context;
        HandlerThread handlerThread = new HandlerThread("SearchPresenterWorker", 10);
        handlerThread.start();
        this.e = new Handler(handlerThread.getLooper());
    }

    @Override
    public void a() {
        this.e.post(new Runnable() {
            @Override
            public void run() {
                com.excelliance.kxqp.gs.c.b a2 = com.excelliance.kxqp.gs.c.b.a(c.this.f11022a);
                c.this.c.clear();
                List<String> query = a2.query("history");
                for (int i = 0; i < query.size(); i++) {
                    com.excelliance.kxqp.gs.view.taglayout.a aVar = new com.excelliance.kxqp.gs.view.taglayout.a();
                    aVar.a(i);
                    aVar.a(true);
                    aVar.a(query.get(i));
                    c.this.c.add(aVar);
                }
                if (c.this.d.size() == 0 && !com.excelliance.kxqp.gs.util.b.aS(c.this.f11022a)) {
                    List<String> query2 = a2.query("recommend");
                    for (int i2 = 0; i2 < query2.size(); i2++) {
                        com.excelliance.kxqp.gs.view.taglayout.a aVar2 = new com.excelliance.kxqp.gs.view.taglayout.a();
                        aVar2.a(i2);
                        aVar2.a(true);
                        aVar2.a(query2.get(i2));
                        c.this.d.add(aVar2);
                    }
                }
                tp.i(new Runnable() {
                    @Override
                    public void run() {
                        c.this.f11023b.a(c.this.c, c.this.d);
                    }
                });
            }
        });
    }

    @Override
    public void b() {
        this.e.post(new Runnable() {
            @Override
            public void run() {
                com.excelliance.kxqp.gs.c.b.a(c.this.f11022a).d();
                c.this.a();
            }
        });
    }

    @Override
    public void a(final String str) {
        this.e.post(new Runnable() {
            @Override
            public void run() {
                com.excelliance.kxqp.gs.c.b.a(c.this.f11022a).a(str);
            }
        });
    }

    @Override
    public void c() {
        this.e.post(new Runnable() {
            @Override
            public void run() {
                if (com.excelliance.kxqp.gs.util.b.aS(c.this.f11022a)) {
                    com.excelliance.kxqp.gs.discover.bbs.c cVar = new com.excelliance.kxqp.gs.discover.bbs.c(c.this.f11022a);
                    JSONObject i = cn.i(c.this.f11022a);
                    try {
                        i.put("controlapi", 1);
                        if (com.excelliance.kxqp.gs.util.b.bh(c.this.f11022a)) {
                            i.put("isFromDomestic", 1);
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    ResponseData a2 = cVar.a(i.toString(), "https://api.ourplay.com.cn/goneload/searchrecomd", new com.excelliance.kxqp.gs.discover.a.c<List<a>>() {
                        @Override
                        public ResponseData<List<a>> a(String str) {
                            try {
                                return (ResponseData) new Gson().a(str, new TypeToken<ResponseData<List<a>>>() {
                                }.getType());
                            } catch (Exception e2) {
                                Log.e("SearchPresenter", "getHotLabel/ex:" + e2);
                                return null;
                            }
                        }
                    });
                    Log.d("SearchPresenter", "getHotLabel/ResponseData:" + a2);
                    if (a2 == null || s.a((Collection) a2.data) || c.this.f11023b == null) {
                        return;
                    }
                    c.this.f11023b.a((List<a>) a2.data);
                }
            }
        });
    }

    @Override
    public boolean b(String str) {
        return cd.d(str).toLowerCase().contains("vpn");
    }

    @Override
    public void d() {
        this.e.post(new Runnable() {
            @Override
            public void run() {
                ResponseData a2 = new com.excelliance.kxqp.gs.discover.bbs.c(c.this.f11022a).a(cn.i(c.this.f11022a).toString(), "https://api.ourplay.com.cn/goneload/searchtag", new com.excelliance.kxqp.gs.discover.a.c<HotTagResult>() {
                    @Override
                    public ResponseData<HotTagResult> a(String str) {
                        try {
                            return (ResponseData) new Gson().a(str, new TypeToken<ResponseData<HotTagResult>>() {
                            }.getType());
                        } catch (Exception e) {
                            Log.e("SearchPresenter", "getHotTag/ex:" + e);
                            return null;
                        }
                    }
                });
                Log.d("SearchPresenter", "getHotTag/ResponseData:" + a2);
                if (a2 == null || a2.data == 0 || s.a(((HotTagResult) a2.data).list) || c.this.f11023b == null) {
                    return;
                }
                c.this.f11023b.b(((HotTagResult) a2.data).list);
            }
        });
    }

    @Override
    public void e() {
        this.e.getLooper().quit();
    }

    @Override
    public void c(final String str) {
        final SearchKeyResult searchKeyResult = new SearchKeyResult();
        searchKeyResult.mKey = str;
        if (bf.e(this.f11022a)) {
            this.e.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        String a2 = SearchProvider.a(c.this.f11022a, str, 5);
                        az.d("SearchPresenter", "search result:" + a2);
                        ArrayList arrayList = new ArrayList();
                        if (!TextUtils.isEmpty(a2)) {
                            try {
                                JSONArray optJSONArray = new JSONObject(a2).optJSONArray("data");
                                if (optJSONArray != null && optJSONArray.length() > 0) {
                                    for (int i = 0; i < optJSONArray.length(); i++) {
                                        String optString = optJSONArray.optJSONObject(i).optString("title");
                                        if (!TextUtils.isEmpty(optString)) {
                                            SearchKeyBean searchKeyBean = new SearchKeyBean();
                                            searchKeyBean.title = optString;
                                            searchKeyBean.key = str;
                                            arrayList.add(searchKeyBean);
                                        }
                                    }
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        searchKeyResult.mSearchKeyBeans = arrayList;
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                    if (c.this.f11023b != null) {
                        tp.i(new Runnable() {
                            @Override
                            public void run() {
                                c.this.f11023b.a(searchKeyResult);
                            }
                        });
                    }
                }
            });
        } else if (this.f11023b != null) {
            this.f11023b.a(searchKeyResult);
        }
    }
}