13Poker by gametower unlimited gems v0.4版本的 MD5 值为:51324fc0f195c34821074948ab266846
以下内容为反编译后的 RevMobClient.java 源代码,内容仅作参考
package com.revmob.client;
import android.util.SparseArray;
import com.adeco.adsdk.net.ServerCommunicationException;
import com.adsdk.sdk.mraid.AdView;
import com.flurry.android.AdCreative;
import com.revmob.RevMobTestingMode;
import com.revmob.internal.HTTPHelper;
import com.revmob.internal.RMLog;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.HttpResponse;
import org.json.JSONException;
public class RevMobClient {
private static final String ADS_PATH = "/api/v4/mobile_apps/%s/%s/fetch_only.json";
private static final String BAD_RESPONSE_MESSAGE = "Bad response from server.";
private static final String DEFAULT_DOWNLOAD_ERROR_MESSAGE = "RevMob did not answered as expected.";
private static final int DEFAULT_TIMEOUT = 30;
private static final String INSTALL_URL = "/api/v4/mobile_apps/%s/install.json";
private static final String INVALID_APP_ID = "Invalid App ID.";
private static final String INVALID_TIMEOUT = "Invalid timeout.";
private static final String NO_MEMORY_MESSAGE = "It was not possible to load the RevMob banner because your device run out of RAM memory.";
private static final String ONE_APP_ID_PER_APP = "You can use just one App Id per application.";
private static final String PARSE_ERROR_MESSAGE = "Error on parse response from server.";
private static final String PARSE_ERROR_MESSAGE2 = "Error on parse response from server. Unknown error.";
private static final String PLACEMENT_ADS_PATH = "/api/v4/mobile_apps/%s/placements/%s/%s/fetch_only.json";
private static final String PRODUCTION_SERVER_ADDRESS = "https://android.revmob.com";
private static final String SESSIONS_PATH = "/api/v4/mobile_apps/%s/sessions.json";
public static final String SESSION_WARNING = "Call RevMobAds.start(activity, APP_ID) on application start/resume. It will help us to improve tracking and increase the eCPM.";
private static RevMobClient instance;
private String appId;
private boolean sessionStarted = false;
private RevMobTestingMode testingMode = RevMobTestingMode.DISABLED;
private static final SparseArray<String> LOG_MESSAGES = new SparseArray<>();
private static final Map<String, String> serverEndPoints = new HashMap();
public static String SDK_NAME = "android";
public static String SDK_VERSION = "6.4.2";
static {
LOG_MESSAGES.put(200, "OK.");
LOG_MESSAGES.put(202, "OK.");
LOG_MESSAGES.put(ServerCommunicationException.ERROR_NO_CONTENT, "Ad retrieval failed: No ads for this device/country right now or your App ID is paused.");
LOG_MESSAGES.put(404, "No ad retrieved: did you set a valid App ID? Get one at http://revmob.com.");
LOG_MESSAGES.put(409, "No ad retrieved: did you set a valid Placement ID? Get one at http://revmob.com.");
LOG_MESSAGES.put(422, "Request requirements did not met. Did you set required permissions?");
LOG_MESSAGES.put(423, "Is your ad unit paused? Please, check it in the RevMob Console.");
LOG_MESSAGES.put(500, "Unexpected server error.");
LOG_MESSAGES.put(503, "Unexpected server error.");
instance = new RevMobClient();
}
private RevMobClient() {
}
public static RevMobClient getInstance() {
return instance;
}
public boolean startSession(String appId, String payload, RevMobClientListener listener) {
if (this.appId == null) {
if (isAppIdValid(appId)) {
this.sessionStarted = true;
this.appId = appId;
String url = PRODUCTION_SERVER_ADDRESS + String.format(SESSIONS_PATH, appId);
serverRequest(url, payload, listener);
HTTPHelper.globalTimeoutInSeconds = 30;
return true;
}
RMLog.w(INVALID_APP_ID);
} else {
RMLog.w(ONE_APP_ID_PER_APP);
}
return false;
}
public void addServerEndPoint(String key, String url) {
if (key != null && url != null) {
serverEndPoints.put(key, url);
}
}
public void registerInstall(String payload, RevMobClientListener listener) {
String url = serverEndPoints.containsKey("install") ? serverEndPoints.get("install") : PRODUCTION_SERVER_ADDRESS + String.format(INSTALL_URL, this.appId);
serverRequestWithSessionVerification(url, payload, listener);
}
public void fetchFullscreen(String placementId, String payload, RevMobClientListener listener) {
String url = createFetchUrl("fullscreen", "fullscreens", this.appId, placementId);
fetch(url, payload, listener);
}
public void fetchBanner(String placementId, String payload, RevMobClientListener listener) {
String url = createFetchUrl(AdCreative.kFormatBanner, "banners", this.appId, placementId);
fetch(url, payload, listener);
}
public void fetchAdLink(String placementId, String payload, RevMobClientListener listener) {
String url = createFetchUrl("link", "anchors", this.appId, placementId);
fetch(url, payload, listener);
}
public void fetchPopup(String placementId, String payload, RevMobClientListener listener) {
String url = createFetchUrl("pop_up", "pop_ups", this.appId, placementId);
fetch(url, payload, listener);
}
public void fetchNotification(String placementId, String payload, RevMobClientListener listener) {
String url = createFetchUrl("local_notification", "local_notifications", this.appId, placementId);
fetch(url, payload, listener);
}
void fetch(String url, String payload, RevMobClientListener listener) {
if (this.testingMode != RevMobTestingMode.DISABLED) {
RMLog.i("Fetching ad using testing mode: " + this.testingMode.getValue());
}
serverRequestWithSessionVerification(url, payload, listener);
}
public void reportImpression(String url, String payload) {
if (url != null) {
if (this.testingMode != RevMobTestingMode.DISABLED) {
RMLog.i("Reporting impression using testing mode: " + this.testingMode.getValue());
}
serverRequestWithSessionVerification(url, payload, null);
}
}
void serverRequestWithSessionVerification(String url, String payload, RevMobClientListener listener) {
if (!this.sessionStarted) {
RMLog.w(SESSION_WARNING);
} else {
serverRequest(url, payload, listener);
}
}
boolean isPlacementIdValid(String placementId) {
return placementId != null && placementId.length() == 24;
}
String createFetchUrl(String adUnitKey, String adUnitOldKey, String appId, String placementId) {
if (isPlacementIdValid(placementId)) {
String key = "fetch_" + adUnitKey + "_with_placement";
return serverEndPoints.containsKey(key) ? serverEndPoints.get(key).replaceFirst("PLACEMENT_ID", placementId) : PRODUCTION_SERVER_ADDRESS + String.format(PLACEMENT_ADS_PATH, appId, placementId, adUnitOldKey);
}
String key2 = "fetch_" + adUnitKey;
return serverEndPoints.containsKey(key2) ? serverEndPoints.get(key2) : PRODUCTION_SERVER_ADDRESS + String.format(ADS_PATH, appId, adUnitOldKey);
}
void serverRequest(final String url, final String payload, final RevMobClientListener listener) {
Thread fetchThread = new Thread() {
@Override
public void run() {
HTTPHelper httpHelper = new HTTPHelper();
HttpResponse response = httpHelper.post(url, payload);
RevMobClient.this.processResponse(response, listener);
}
};
fetchThread.start();
}
void processResponse(HttpResponse response, RevMobClientListener listener) {
if (response == null) {
handleDownloadError(0, listener);
return;
}
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != 200 && statusCode != 202) {
handleDownloadError(statusCode, listener);
return;
}
String encodedResponseBody = HTTPHelper.encodedResponseBody(response.getEntity());
if (encodedResponseBody == null) {
RMLog.w(BAD_RESPONSE_MESSAGE);
if (listener != null) {
listener.handleError(BAD_RESPONSE_MESSAGE);
return;
}
return;
}
RMLog.d("Server request successful (" + statusCode + ")");
handleSuccess(encodedResponseBody, listener);
}
void handleSuccess(String encodedResponseBody, RevMobClientListener listener) {
if (listener != null) {
try {
listener.handleResponse(encodedResponseBody);
} catch (NullPointerException e) {
RMLog.w(PARSE_ERROR_MESSAGE2);
if (listener != null) {
listener.handleError(PARSE_ERROR_MESSAGE2);
}
} catch (OutOfMemoryError e2) {
RMLog.w(NO_MEMORY_MESSAGE);
if (listener != null) {
listener.handleError(NO_MEMORY_MESSAGE);
}
} catch (JSONException e3) {
RMLog.w(PARSE_ERROR_MESSAGE);
if (listener != null) {
listener.handleError(PARSE_ERROR_MESSAGE);
}
}
}
}
void handleDownloadError(int statusCode, RevMobClientListener listener) {
String message = LOG_MESSAGES.get(statusCode, DEFAULT_DOWNLOAD_ERROR_MESSAGE) + " (" + statusCode + ")";
RMLog.w(message);
if (listener != null) {
listener.handleError(message);
}
}
boolean isAppIdValid(String appId) {
return appId != null && appId.length() == 24;
}
public RevMobTestingMode getTestingMode() {
return this.testingMode;
}
public void setTestingMode(RevMobTestingMode testingMode) {
this.testingMode = testingMode;
if (testingMode != RevMobTestingMode.DISABLED) {
RMLog.i("Testing mode enabled: " + testingMode.getValue());
} else {
RMLog.i("Testing mode disabled");
}
}
public void setTimeoutInSeconds(int timeoutInSeconds) {
if (timeoutInSeconds > 1 && timeoutInSeconds < 300) {
HTTPHelper.globalTimeoutInSeconds = timeoutInSeconds;
RMLog.i("Timeout changed to " + timeoutInSeconds + AdView.DEVICE_ORIENTATION_SQUARE);
return;
}
RMLog.w(INVALID_TIMEOUT);
}
public static void setSDKName(String sdkName) {
if (sdkName != null) {
SDK_NAME = sdkName;
}
}
public static void setSDKVersion(String sdkVersion) {
if (sdkVersion != null) {
SDK_VERSION = sdkVersion;
}
}
public String getAppId() {
return this.appId;
}
}