Merge pull request #2930 from natural-law/develop

Optimize class ProtocolAds for more Ads plugins.
This commit is contained in:
James Chen 2013-06-19 05:13:09 -07:00
commit 12c21172c0
11 changed files with 51 additions and 12 deletions

1
plugin/.gitignore vendored
View File

@ -94,4 +94,5 @@ tools/toolsForPublish/environment.sh
.settings .settings
plugins/china* plugins/china*
plugins/punchbox* plugins/punchbox*
plugins/touchpay*
samplesPrivate* samplesPrivate*

View File

@ -99,6 +99,9 @@ public class AdsAdmob implements InterfaceAds {
case AdsWrapper.ADS_TYPE_FULL_SCREEN: case AdsWrapper.ADS_TYPE_FULL_SCREEN:
LogD("Now not support full screen view in Admob"); LogD("Now not support full screen view in Admob");
break; break;
case AdsWrapper.ADS_TYPE_MORE_APP:
LogD("Now not support more app ads in Admob");
break;
default: default:
break; break;
} }
@ -106,7 +109,7 @@ public class AdsAdmob implements InterfaceAds {
@Override @Override
public void spendPoints(int points) { public void spendPoints(int points) {
// do nothing, Admob don't have this function LogD("Admob not support spend points!");
} }
@Override @Override
@ -213,7 +216,7 @@ public class AdsAdmob implements InterfaceAds {
@Override @Override
public void onDismissScreen(Ad arg0) { public void onDismissScreen(Ad arg0) {
LogD("onDismissScreen invoked"); LogD("onDismissScreen invoked");
AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_FullScreenViewDismissed, "Full screen ads view dismissed!"); AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsDismissed, "Ads view dismissed!");
} }
@Override @Override
@ -247,7 +250,7 @@ public class AdsAdmob implements InterfaceAds {
@Override @Override
public void onPresentScreen(Ad arg0) { public void onPresentScreen(Ad arg0) {
LogD("onPresentScreen invoked"); LogD("onPresentScreen invoked");
AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_FullScreenViewShown, "Full screen ads view shown!"); AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsShown, "Ads view shown!");
} }
@Override @Override
@ -261,4 +264,9 @@ public class AdsAdmob implements InterfaceAds {
public String getPluginVersion() { public String getPluginVersion() {
return "0.2.0"; return "0.2.0";
} }
@Override
public void queryPoints() {
LogD("Admob not support query points!");
}
} }

View File

@ -50,6 +50,7 @@ typedef enum {
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo; - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo;
- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos; - (void) showAds: (int) type size:(int) sizeEnum position:(int) pos;
- (void) hideAds: (int) type; - (void) hideAds: (int) type;
- (void) queryPoints;
- (void) spendPoints: (int) points; - (void) spendPoints: (int) points;
- (void) setDebugMode: (BOOL) isDebugMode; - (void) setDebugMode: (BOOL) isDebugMode;
- (NSString*) getSDKVersion; - (NSString*) getSDKVersion;

View File

@ -62,10 +62,18 @@
return; return;
} }
if (type == kTypeBanner) { switch (type) {
case kTypeBanner:
[self showBanner:sizeEnum atPos:pos]; [self showBanner:sizeEnum atPos:pos];
} else { break;
case kTypeFullScreen:
OUTPUT_LOG(@"Now not support full screen view in Admob"); OUTPUT_LOG(@"Now not support full screen view in Admob");
break;
case kTypeMoreApp:
OUTPUT_LOG(@"Now not support more app ads in Admob");
break;
default:
break;
} }
} }
@ -82,9 +90,14 @@
} }
} }
- (void) queryPoints
{
OUTPUT_LOG(@"Admob not support query points!");
}
- (void) spendPoints: (int) points - (void) spendPoints: (int) points
{ {
OUTPUT_LOG(@"Admob not support spend points!");
} }
- (void) setDebugMode: (BOOL) isDebugMode - (void) setDebugMode: (BOOL) isDebugMode

View File

@ -36,8 +36,8 @@ typedef enum
{ {
kAdsReceived = 0, // The ad is received kAdsReceived = 0, // The ad is received
kFullScreenViewShown, // The full screen advertisement shown kAdsShown, // The advertisement shown
kFullScreenViewDismissed, // The full screen advertisement dismissed kAdsDismissed, // The advertisement dismissed
kPointsSpendSucceed, // The points spend succeed kPointsSpendSucceed, // The points spend succeed
kPointsSpendFailed, // The points spend failed kPointsSpendFailed, // The points spend failed
@ -72,6 +72,7 @@ public:
typedef enum { typedef enum {
kBannerAd = 0, kBannerAd = 0,
kFullScreenAd, kFullScreenAd,
kMoreApp,
} AdsType; } AdsType;
typedef enum { typedef enum {
@ -111,6 +112,11 @@ public:
*/ */
void hideAds(AdsType type); void hideAds(AdsType type);
/**
@brief Query the points of player
*/
void queryPoints();
/** /**
@brief Spend the points. @brief Spend the points.
Use this method to notify server spend points. Use this method to notify server spend points.

View File

@ -119,6 +119,11 @@ void ProtocolAds::hideAds(AdsType type)
PluginUtils::callJavaFunctionWithName_oneParam(this, "hideAds", "(I)V", type); PluginUtils::callJavaFunctionWithName_oneParam(this, "hideAds", "(I)V", type);
} }
void ProtocolAds::queryPoints()
{
PluginUtils::callJavaFunctionWithName(this, "queryPoints");
}
void ProtocolAds::spendPoints(int points) void ProtocolAds::spendPoints(int points)
{ {
PluginUtils::callJavaFunctionWithName_oneParam(this, "spendPoints", "(I)V", points); PluginUtils::callJavaFunctionWithName_oneParam(this, "spendPoints", "(I)V", points);

View File

@ -28,8 +28,8 @@ THE SOFTWARE.
typedef enum { typedef enum {
kAdsReceived = 0, kAdsReceived = 0,
kFullScreenViewShown, kAdsShown,
kFullScreenViewDismissed, kAdsDismissed,
kPointsSpendSucceed, kPointsSpendSucceed,
kPointsSpendFailed, kPointsSpendFailed,
@ -41,6 +41,7 @@ typedef enum {
typedef enum { typedef enum {
kTypeBanner = 0, kTypeBanner = 0,
kTypeFullScreen, kTypeFullScreen,
kTypeMoreApp,
} AdsTypeEnum; } AdsTypeEnum;
typedef enum { typedef enum {

View File

@ -29,6 +29,7 @@ THE SOFTWARE.
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo; - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo;
- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos; - (void) showAds: (int) type size:(int) sizeEnum position:(int) pos;
- (void) hideAds: (int) type; - (void) hideAds: (int) type;
- (void) queryPoints;
- (void) spendPoints: (int) points; - (void) spendPoints: (int) points;
- (void) setDebugMode: (BOOL) debug; - (void) setDebugMode: (BOOL) debug;
- (NSString*) getSDKVersion; - (NSString*) getSDKVersion;

View File

@ -30,8 +30,8 @@ import android.view.WindowManager;
public class AdsWrapper { public class AdsWrapper {
public static final int RESULT_CODE_AdsReceived = 0; // The ad is received public static final int RESULT_CODE_AdsReceived = 0; // The ad is received
public static final int RESULT_CODE_FullScreenViewShown = 1; // The full screen advertisement shown public static final int RESULT_CODE_AdsShown = 1; // The advertisement shown
public static final int RESULT_CODE_FullScreenViewDismissed = 2; // The full screen advertisement dismissed public static final int RESULT_CODE_AdsDismissed = 2; // The advertisement dismissed
public static final int RESULT_CODE_PointsSpendSucceed = 3; // The points spend succeed public static final int RESULT_CODE_PointsSpendSucceed = 3; // The points spend succeed
public static final int RESULT_CODE_PointsSpendFailed = 4; // The points spend failed public static final int RESULT_CODE_PointsSpendFailed = 4; // The points spend failed
public static final int RESULT_CODE_NetworkError = 5; // Network error public static final int RESULT_CODE_NetworkError = 5; // Network error
@ -39,6 +39,7 @@ public class AdsWrapper {
public static final int ADS_TYPE_BANNER = 0; public static final int ADS_TYPE_BANNER = 0;
public static final int ADS_TYPE_FULL_SCREEN = 1; public static final int ADS_TYPE_FULL_SCREEN = 1;
public static final int ADS_TYPE_MORE_APP = 2;
public static final int POS_CENTER = 0; public static final int POS_CENTER = 0;
public static final int POS_TOP = 1; public static final int POS_TOP = 1;

View File

@ -32,6 +32,7 @@ public interface InterfaceAds {
public void configDeveloperInfo(Hashtable<String, String> devInfo); public void configDeveloperInfo(Hashtable<String, String> devInfo);
public void showAds(int type, int sizeEnum, int pos); public void showAds(int type, int sizeEnum, int pos);
public void hideAds(int type); public void hideAds(int type);
public void queryPoints();
public void spendPoints(int points); public void spendPoints(int points);
public void setDebugMode(boolean debug); public void setDebugMode(boolean debug);
public String getSDKVersion(); public String getSDKVersion();

View File

@ -34,6 +34,7 @@ const std::string s_aTestCases[] = {
const std::string s_aTestTypes[] = { const std::string s_aTestTypes[] = {
"Banner", "Banner",
"Full Screen", "Full Screen",
"More App",
}; };
const std::string s_aTestPoses[] = { const std::string s_aTestPoses[] = {