package com.tapjoy; import com.tapjoy.TapjoyErrorMessage; import com.tapjoy.internal.b3; import com.tapjoy.internal.c3; import java.util.Map; import org.w3c.dom.Document; /* loaded from: classes4.dex */ public final class h0 implements Runnable { public final /* synthetic */ Map a; public final /* synthetic */ TJAwardCurrencyListener b; public final /* synthetic */ TJCurrency c; public h0(TJCurrency tJCurrency, Map map, TJAwardCurrencyListener tJAwardCurrencyListener) { this.c = tJCurrency; this.a = map; this.b = tJAwardCurrencyListener; } @Override // java.lang.Runnable public final void run() { b3 a = c3.a(TapjoyConnectCore.getInstance().getHostURL() + TapjoyConstants.TJC_AWARD_CURRENCY_URL_PATH, this.a); TJCurrency tJCurrency = this.c; TJAwardCurrencyListener tJAwardCurrencyListener = this.b; synchronized (tJCurrency) { String str = "Failed to award currency"; String str2 = a.c; if (str2 != null) { Document buildDocument = TapjoyUtil.buildDocument(str2); if (buildDocument != null) { String nodeTrimValue = TapjoyUtil.getNodeTrimValue(buildDocument.getElementsByTagName("Success")); if (nodeTrimValue != null && nodeTrimValue.equals("true")) { String nodeTrimValue2 = TapjoyUtil.getNodeTrimValue(buildDocument.getElementsByTagName("TapPoints")); String nodeTrimValue3 = TapjoyUtil.getNodeTrimValue(buildDocument.getElementsByTagName("CurrencyName")); if (nodeTrimValue2 != null && nodeTrimValue3 != null) { int parseInt = Integer.parseInt(nodeTrimValue2); tJCurrency.saveCurrencyBalance(parseInt); if (tJAwardCurrencyListener != null) { tJAwardCurrencyListener.onAwardCurrencyResponse(nodeTrimValue3, parseInt); } return; } TapjoyLog.e("TJCurrency", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SERVER_ERROR, "awardCurrency response is invalid -- missing tags.")); } else if (nodeTrimValue == null || !nodeTrimValue.endsWith("false")) { TapjoyLog.e("TJCurrency", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SERVER_ERROR, "awardCurrency response is invalid -- missing tag.")); } else { str = TapjoyUtil.getNodeTrimValue(buildDocument.getElementsByTagName("Message")); TapjoyLog.i("TJCurrency", str); } } } else { TapjoyLog.e("TJCurrency", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SERVER_ERROR, "awardCurrency response is NULL")); } if (tJAwardCurrencyListener != null) { tJAwardCurrencyListener.onAwardCurrencyResponseFailure(str); } } } }