package com.mbridge.msdk.videocommon.b; import android.text.TextUtils; import java.util.HashMap; import java.util.Map; import org.json.JSONArray; import org.json.JSONObject; /* loaded from: classes4.dex */ public final class c { private String a; private int b; public final String a() { return this.a; } public final void a(int i) { this.b = i; } public final void a(String str) { this.a = str; } public final int b() { return this.b; } public c(String str, int i) { this.a = str; this.b = i; } private static c c() { return new c("Virtual Item", 1); } public static c b(String str) { c cVar = null; try { com.mbridge.msdk.videocommon.d.a b = com.mbridge.msdk.videocommon.d.b.a().b(); if (TextUtils.isEmpty(str)) { cVar = c(); } else if (b != null && b.j() != null) { cVar = b.j().get(str); } return cVar == null ? c() : cVar; } catch (Exception e) { e.printStackTrace(); return null; } } public static Map a(JSONArray jSONArray) { if (jSONArray == null || jSONArray.length() <= 0) { return null; } try { HashMap hashMap = new HashMap(); for (int i = 0; i < jSONArray.length(); i++) { JSONObject optJSONObject = jSONArray.optJSONObject(i); hashMap.put(optJSONObject.optString("id"), new c(optJSONObject.optString("name"), optJSONObject.optInt("amount"))); } return hashMap; } catch (Exception e) { e.printStackTrace(); return null; } } public static c a(JSONObject jSONObject) { if (jSONObject == null) { return null; } try { String optString = jSONObject.optString("name"); int optInt = jSONObject.optInt("amount"); jSONObject.optString("id"); return new c(optString, optInt); } catch (Exception e) { e.printStackTrace(); return null; } } public final String toString() { return "Reward{name='" + this.a + "', amount=" + this.b + '}'; } }