Ejemplo n.º 1
0
  private void showBannerAd(final String adId, final String adPosition) {
    removeBannerAd();
    if (adId.length() > 0) {
      bannerAd = new AdView(context, adId);
    } else {
      bannerAd = new AdView(context);
    }
    bannerAd.setPublisherId(appId);

    if (adPosition.compareToIgnoreCase("bottom") == 0) {
      RelativeLayout relativeLayout = new RelativeLayout(context);
      RelativeLayout.LayoutParams relativeParams =
          new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
      relativeParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      context.addContentView(
          relativeLayout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
      relativeLayout.addView(bannerAd, relativeParams);
      relativeLayout.setFocusable(false);
    } else {
      LinearLayout bannerAdLayout = new LinearLayout(context);
      bannerAdLayout.setOrientation(LinearLayout.VERTICAL);
      context.addContentView(
          bannerAdLayout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
      bannerAdLayout.addView(bannerAd);
      bannerAdLayout.setFocusable(false);
    }

    ViewGroup group = (ViewGroup) bannerAd.getParent().getParent();
    group.findViewById(Cocos2dxActivity.GLVIEW_ID).requestFocus();

    bannerAd.setFocusable(false);
    bannerAd.setAdListener(this);
    bannerAd.loadAd(new AdRequest());
  }
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String packageName = getApplication().getPackageName();
    super.setPackageName(packageName);

    setContentView(R.layout.activity_main);
    mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.game_gl_surfaceview);
    mGLView.setTextField((EditText) findViewById(R.id.textField));
  }
Ejemplo n.º 3
0
 /**
  * Constructor
  * @param context The Context within which to work, used to create the DB
  * @return 
  */
 public static boolean init(String dbName, String tableName) {
     if (Cocos2dxActivity.getContext() != null) {
         DATABASE_NAME = dbName;
         TABLE_NAME = tableName;
         mDatabaseOpenHelper = new DBOpenHelper(Cocos2dxActivity.getContext());
         mDatabase = mDatabaseOpenHelper.getWritableDatabase();
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   PSNative.init(this);
   PSNetwork.init(this);
   PluginWrapper.init(this);
 }
 @Override
 protected void onDestroy() {
   AdsMogoLayout.clear();
   // 清除 adsMogoLayout 实例 所产生用于多线程缓冲机制的线程池
   // 此方法请不要轻易调用,如果调用时间不当,会造成无法统计计数
   adsMogoLayoutCode.clearThread();
   super.onDestroy();
 }
Ejemplo n.º 6
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (detectOpenGLES20()) {
      // get the packageName,it's used to set the resource path
      String packageName = getApplication().getPackageName();
      super.setPackageName(packageName);

      // FrameLayout
      ViewGroup.LayoutParams framelayout_params =
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
      FrameLayout framelayout = new FrameLayout(this);
      framelayout.setLayoutParams(framelayout_params);

      // Cocos2dxEditText layout
      ViewGroup.LayoutParams edittext_layout_params =
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      Cocos2dxEditText edittext = new Cocos2dxEditText(this);
      edittext.setLayoutParams(edittext_layout_params);

      // ...add to FrameLayout
      framelayout.addView(edittext);

      // Cocos2dxGLSurfaceView
      mGLView = new Cocos2dxGLSurfaceView(this);

      // ...add to FrameLayout
      framelayout.addView(mGLView);

      mGLView.setEGLContextClientVersion(2);
      mGLView.setCocos2dxRenderer(new Cocos2dxRenderer());
      mGLView.setTextField(edittext);

      // Set framelayout as the content view
      setContentView(framelayout);
    } else {
      Log.d("activity", "don't support gles2.0");
      finish();
    }
  }
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    adsMogoLayoutCode = new AdsMogoLayout(this, "2bad837a65c040f0aee41cf992b26b21");
    FrameLayout.LayoutParams params =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    // 设置广告出现的位置(悬浮于底部)
    params.bottomMargin = 0;
    // adsMogoLayoutCode.setGListener(this);
    params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;

    params.topMargin = 40;
    addContentView(adsMogoLayoutCode, params);

    this.VP();
    this.JP();
  }
  public AdViewHelper(Cocos2dxActivity activity) {
    com.adsmogo.util.L.debug = true;
    mActivity = activity;

    mLayout = new RelativeLayout(mActivity);

    activity.addContentView(
        mLayout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    AdsMogoLayout adViewLayout =
        new AdsMogoLayout(mActivity, "20d18f3561a34075bcc2514294239317", true);

    // ¶¥²¿¾ÓÖÐ
    RelativeLayout.LayoutParams layoutParams =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    adViewLayout.setLayoutParams(layoutParams);

    mLayout.addView(adViewLayout);
    mLayout.invalidate();

    mHandler =
        new Handler() {
          @Override
          public void handleMessage(Message msg) {
            switch (msg.what) {
              case 1:
                {
                  if (mLayout != null) mLayout.setVisibility(View.VISIBLE);
                  break;
                }
              case 2:
                {
                  if (mLayout != null) mLayout.setVisibility(View.GONE);
                  break;
                }
              default:
                break;
            }
          }
        };
  }
Ejemplo n.º 9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    PluginWrapper.init(this); // for plugins

    if (nativeIsLandScape()) {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }

    // 2.Set the format of window

    // Check the wifi is opened when the native is debug.
    if (nativeIsDebug()) {
      getWindow()
          .setFlags(
              WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
              WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
      if (!isNetworkConnected()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Warning");
        builder.setMessage("Open Wifi for debuging...");
        builder.setPositiveButton(
            "OK",
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
                finish();
                System.exit(0);
              }
            });
        builder.setCancelable(false);
        builder.show();
      }
    }
    hostIPAdress = getHostIpAddress();
  }
Ejemplo n.º 10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    m_instance = this;

    super.onCreate(savedInstanceState);

    if (nativeIsLandScape()) {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }

    // 2.Set the format of window

    // Check the wifi is opened when the native is debug.
    if (nativeIsDebug()) {
      getWindow()
          .setFlags(
              WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
              WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
      if (!isNetworkConnected()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Warning");
        builder.setMessage("Please open WIFI for debuging...");
        builder.setPositiveButton(
            "OK",
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
                finish();
                System.exit(0);
              }
            });

        builder.setNegativeButton("Cancel", null);
        builder.setCancelable(true);
        builder.show();
      }
      hostIPAdress = getHostIpAddress();
    }

    Udid.m_activity = this;

    NBGNative.nativeSetCountryCode(Locale.getDefault().getCountry());
    try {
      PackageInfo info = this.getPackageManager().getPackageInfo(this.getPackageName(), 0);
      // 当前应用的版本名称
      String versionName = info.versionName;
      // 当前版本的版本号
      int versionCode = info.versionCode;
      // 当前版本的包名
      String packageNames = info.packageName;
      NBGNative.nativeSetAppInfo(packageNames, versionName, versionCode);
    } catch (NameNotFoundException e) {
      e.printStackTrace();
    }

    NBGNetManager.getInstance();
    NBGNetManager.init(this);
  }
Ejemplo n.º 11
0
 @Override
 protected void onNewIntent(Intent intent) {
   PluginWrapper.onNewIntent(intent);
   super.onNewIntent(intent);
 }
Ejemplo n.º 12
0
 @Override
 public void onPause() {
   PluginWrapper.onPause();
   super.onPause();
 }
Ejemplo n.º 13
0
 @Override
 protected void onResume() {
   super.onResume();
   PluginWrapper.onResume();
 }
Ejemplo n.º 14
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   GameKit.onActivityResult(requestCode, resultCode, data);
 }
Ejemplo n.º 15
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
 }
 public static void setKeepScreenOn(boolean value) {
   ((Cocos2dxActivity) sActivity).setKeepScreenOn(value);
 }
Ejemplo n.º 17
0
 @Override
 protected void onResume() {
   super.onResume();
   mGLView.onResume();
 }
Ejemplo n.º 18
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   GameKit.onDestroy();
 }
Ejemplo n.º 19
0
 @Override
 public void onResume() {
   super.onResume();
   GameKit.onResume();
 }
Ejemplo n.º 20
0
 @Override
 public void onPause() {
   super.onPause();
   GameKit.onPause();
 }
Ejemplo n.º 21
0
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   GameKit.onSaveInstanceState(outState);
 }
 private void closeKeyboard() {
   InputMethodManager imm =
       (InputMethodManager) mParentActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
   imm.hideSoftInputFromWindow(mInputEditText.getWindowToken(), 0);
   Log.d("Cocos2dxEditBox", "closeKeyboard");
 }
Ejemplo n.º 23
0
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   if (!isFolderExists("/sdcard/ninjadash")) {
     return;
   }
 }
Ejemplo n.º 24
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   PluginWrapper.onActivityResult(requestCode, resultCode, data);
 }
Ejemplo n.º 25
0
 @Override
 protected void onPause() {
   super.onPause();
   mGLView.onPause();
 }
 public static void runOnGLThread(final Runnable r) {
   ((Cocos2dxActivity) sActivity).runOnGLThread(r);
 }
Ejemplo n.º 27
0
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
 }
 private void openKeyboard() {
   InputMethodManager imm =
       (InputMethodManager) mParentActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
   imm.showSoftInput(mInputEditText, 0);
   Log.d("Cocos2dxEditBox", "openKeyboard");
 }