package com.kwad.components.ct.kwai.kwai; import android.content.SharedPreferences; import android.text.TextUtils; import com.kwad.sdk.core.config.item.b; import com.kwad.sdk.utils.ag; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONObject; public final class a extends b<List<com.kwad.sdk.core.response.model.a>> { public a() { super("posContentInfoList", new ArrayList()); } @Override // com.kwad.sdk.core.config.item.b public final void a(SharedPreferences.Editor editor) { List<com.kwad.sdk.core.b> list = (List) getValue(); if (ag.ao(list)) { JSONArray jSONArray = new JSONArray(); for (com.kwad.sdk.core.b bVar : list) { jSONArray.put(bVar.toJson()); } editor.putString("posContentInfoList", jSONArray.toString()); } } @Override // com.kwad.sdk.core.config.item.b public final void a(SharedPreferences sharedPreferences) { try { String string = sharedPreferences.getString("posContentInfoList", ""); if (!TextUtils.isEmpty(string)) { JSONArray jSONArray = new JSONArray(string); if (jSONArray.length() > 0) { ArrayList arrayList = new ArrayList(); for (int i = 0; i < jSONArray.length(); i++) { JSONObject optJSONObject = jSONArray.optJSONObject(i); com.kwad.sdk.core.response.model.a aVar = new com.kwad.sdk.core.response.model.a(); aVar.parseJson(optJSONObject); arrayList.add(aVar); } if (arrayList.size() > 0) { setValue(arrayList); return; } } } } catch (Exception e) { com.kwad.sdk.core.e.b.printStackTraceOnly(e); } setValue(Lw()); } @Override // com.kwad.sdk.core.config.item.b public final void e(JSONObject jSONObject) { JSONArray optJSONArray; if (!(jSONObject == null || (optJSONArray = jSONObject.optJSONArray("posContentInfoList")) == null || optJSONArray.length() <= 0)) { ArrayList arrayList = new ArrayList(); for (int i = 0; i < optJSONArray.length(); i++) { JSONObject optJSONObject = optJSONArray.optJSONObject(i); if (optJSONObject != null) { com.kwad.sdk.core.response.model.a aVar = new com.kwad.sdk.core.response.model.a(); aVar.parseJson(optJSONObject); arrayList.add(aVar); } } if (arrayList.size() > 0) { setValue(arrayList); return; } } setValue(Lw()); } }