-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Reduce warning noise #2698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Reduce warning noise #2698
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import android.content.DialogInterface; | ||
| import android.graphics.drawable.Drawable; | ||
| import android.graphics.drawable.NinePatchDrawable; | ||
| import android.graphics.Point; | ||
| import android.opengl.GLSurfaceView; | ||
| import android.os.Bundle; | ||
| import android.util.Log; | ||
|
|
@@ -216,7 +217,9 @@ public void onCreate(Bundle savedInstanceState) { | |
| //TODO try to find a better way to get a hand on the resolution | ||
| WindowManager wind = this.getWindowManager(); | ||
| Display disp = wind.getDefaultDisplay(); | ||
| Log.d("AndroidHarness", "Resolution from Window, width:" + disp.getWidth() + ", height: " + disp.getHeight()); | ||
| Point displaySize = new Point(); | ||
| disp.getSize(displaySize); | ||
| Log.d("AndroidHarness", "Resolution from Window, width:" + displaySize.x + ", height: " + displaySize.y); | ||
|
|
||
| // Create Settings | ||
| logger.log(Level.FINE, "Creating settings"); | ||
|
|
@@ -232,7 +235,7 @@ public void onCreate(Bundle savedInstanceState) { | |
| settings.setSamples(eglSamples); | ||
| settings.setStencilBits(eglStencilBits); | ||
|
|
||
| settings.setResolution(disp.getWidth(), disp.getHeight()); | ||
| settings.setResolution(displaySize.x, displaySize.y); | ||
| settings.setAudioRenderer(audioRendererType); | ||
|
|
||
| settings.setFrameRate(frameRate); | ||
|
|
@@ -410,9 +413,9 @@ public void layoutDisplay() { | |
| frameLayout = new FrameLayout(this); | ||
| splashImageView = new ImageView(this); | ||
|
|
||
| Drawable drawable = this.getResources().getDrawable(splashPicID); | ||
| Drawable drawable = splashImageView.getContext().getDrawable(splashPicID); | ||
| if (drawable instanceof NinePatchDrawable) { | ||
| splashImageView.setBackgroundDrawable(drawable); | ||
| splashImageView.setBackground(drawable); | ||
|
Comment on lines
+416
to
+418
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes introduce API regressions for older Android devices:
Since the engine supports API level 9, these calls will crash on older platforms. To fix the deprecation warnings while preserving compatibility, use |
||
| } else { | ||
| splashImageView.setImageResource(splashPicID); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,6 +45,11 @@ | |||||||||||||||||
| * internally to reduce state changes. NOTE: This class is specific to OpenGL. | ||||||||||||||||||
| */ | ||||||||||||||||||
| public class RenderContext { | ||||||||||||||||||
| private static <T> WeakReference<T>[] newWeakReferenceArray(int size) { | ||||||||||||||||||
| WeakReference<T>[] refs = (WeakReference<T>[]) new WeakReference<?>[size]; | ||||||||||||||||||
| return refs; | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+48
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cast to
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Number of texture units that JME supports. | ||||||||||||||||||
| */ | ||||||||||||||||||
|
|
@@ -260,7 +265,7 @@ public class RenderContext { | |||||||||||||||||
| * @see Renderer#setTexture(int, com.jme3.texture.Texture) | ||||||||||||||||||
| */ | ||||||||||||||||||
| public final WeakReference<Image> boundTextures[] | ||||||||||||||||||
| = new WeakReference[maxTextureUnits]; | ||||||||||||||||||
| = newWeakReferenceArray(maxTextureUnits); | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
|
|
@@ -269,7 +274,7 @@ public class RenderContext { | |||||||||||||||||
| * @see Renderer#setUniformBufferObject(int, com.jme3.shader.BufferObject) | ||||||||||||||||||
| * @see Renderer#setShaderStorageBufferObject(int, com.jme3.shader.BufferObject) | ||||||||||||||||||
| */ | ||||||||||||||||||
| public final WeakReference<BufferObject>[] boundBO = new WeakReference[maxBufferObjectUnits]; | ||||||||||||||||||
| public final WeakReference<BufferObject>[] boundBO = newWeakReferenceArray(maxBufferObjectUnits); | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * IDList for texture units. | ||||||||||||||||||
|
|
@@ -326,7 +331,7 @@ public class RenderContext { | |||||||||||||||||
| * Vertex attribs currently bound and enabled. If a slot is null, then | ||||||||||||||||||
| * it is disabled. | ||||||||||||||||||
| */ | ||||||||||||||||||
| public final WeakReference<VertexBuffer>[] boundAttribs = new WeakReference[16]; | ||||||||||||||||||
| public final WeakReference<VertexBuffer>[] boundAttribs = newWeakReferenceArray(16); | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * IDList for vertex attributes. | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method
Display.getSize(Point)was introduced in API level 13. Sincejme3-androidsupports down to API level 9 (as specified inOGLESContext), this change will cause aNoSuchMethodErroron devices running Android versions older than 3.2. To maintain compatibility, you should use a version check or continue using the deprecatedgetWidth()andgetHeight()methods for older devices.