package com.tapjoy; import java.util.ArrayList; import java.util.Iterator; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import org.json.JSONArray; import org.json.JSONException; /* loaded from: classes4.dex */ public final class n1 extends Thread { public final /* synthetic */ JSONArray a; public final /* synthetic */ TJCacheListener b; public final /* synthetic */ TapjoyCache c; public n1(TapjoyCache tapjoyCache, JSONArray jSONArray, TJCacheListener tJCacheListener) { this.c = tapjoyCache; this.a = jSONArray; this.b = tJCacheListener; } @Override // java.lang.Thread, java.lang.Runnable public final void run() { TapjoyLog.d("TapjoyCache", "Starting to cache asset group size of " + this.a.length()); ArrayList arrayList = new ArrayList(); for (int i = 0; i < this.a.length(); i++) { try { Future cacheAssetFromJSONObject = this.c.cacheAssetFromJSONObject(this.a.getJSONObject(i)); if (cacheAssetFromJSONObject != null) { arrayList.add(cacheAssetFromJSONObject); } } catch (JSONException unused) { TapjoyLog.e("TapjoyCache", "Failed to load JSON object from JSONArray"); } } Iterator it = arrayList.iterator(); int i2 = 1; while (it.hasNext()) { try { } catch (InterruptedException e) { TapjoyLog.e("TapjoyCache", "Caching thread failed: " + e.toString()); } catch (ExecutionException e2) { TapjoyLog.e("TapjoyCache", "Caching thread failed: " + e2.toString()); } if (!((Boolean) ((Future) it.next()).get()).booleanValue()) { i2 = 2; } } TapjoyLog.d("TapjoyCache", "Finished caching group"); TJCacheListener tJCacheListener = this.b; if (tJCacheListener != null) { tJCacheListener.onCachingComplete(i2); } } }