Merge pull request #1240 from dumganhar/gles20

fixed some warnings in java codes for android port.
This commit is contained in:
James Chen 2012-08-26 19:32:24 -07:00
commit 19589a3579
4 changed files with 50 additions and 22 deletions

View File

@ -1,5 +1,5 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2010-2012 cocos2d-x.org
http://www.cocos2d-x.org
@ -24,11 +24,12 @@ THE SOFTWARE.
package org.cocos2dx.lib;
import java.lang.ref.WeakReference;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@ -57,6 +58,28 @@ public class Cocos2dxActivity extends Activity{
private static native void nativeSetPaths(String apkPath);
private static native void nativeSetEditboxText(byte[] text);
static class ShowDialogHandler extends Handler {
WeakReference<Cocos2dxActivity> mActivity;
ShowDialogHandler(Cocos2dxActivity activity) {
mActivity = new WeakReference<Cocos2dxActivity>(activity);
}
@Override
public void handleMessage(Message msg) {
Cocos2dxActivity theActivity = mActivity.get();
switch(msg.what) {
case HANDLER_SHOW_DIALOG:
theActivity.showDialog(((DialogMessage)msg.obj).title, ((DialogMessage)msg.obj).message);
break;
case HANDLER_SHOW_EDITBOX_DIALOG:
theActivity.onShowEditBoxDialog((EditBoxMessage)msg.obj);
break;
}
}
};
public Cocos2dxGLSurfaceView getGLView() {
return mGLView;
}
@ -80,18 +103,7 @@ public class Cocos2dxActivity extends Activity{
// init bitmap context
Cocos2dxBitmap.setContext(this);
handler = new Handler(){
public void handleMessage(Message msg){
switch(msg.what){
case HANDLER_SHOW_DIALOG:
showDialog(((DialogMessage)msg.obj).title, ((DialogMessage)msg.obj).message);
break;
case HANDLER_SHOW_EDITBOX_DIALOG:
onShowEditBoxDialog((EditBoxMessage)msg.obj);
break;
}
}
};
handler = new ShowDialogHandler(this);
}
public static String getDeviceModel(){

View File

@ -36,11 +36,8 @@ import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.Paint.Align;
import android.graphics.Paint.FontMetricsInt;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.StyleSpan;
import android.util.Log;
public class Cocos2dxBitmap{

View File

@ -1,11 +1,32 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.lib;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.text.InputFilter;
@ -13,7 +34,6 @@ import android.text.InputType;
import android.util.Log;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;

View File

@ -30,7 +30,6 @@ import org.cocos2dx.lib.Cocos2dxRenderer;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;