Revision: 2396
http://sourceforge.net/p/swingme/code/2396
Author: yuranet
Date: 2020-11-19 17:43:26 +0000 (Thu, 19 Nov 2020)
Log Message:
-----------
handle bad UI threading a bit better
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/components/ScrollPane.java
SwingME/src/net/yura/mobile/gui/components/Slider.java
SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java
Modified: SwingME/src/net/yura/mobile/gui/components/ScrollPane.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/ScrollPane.java 2020-08-11 21:23:26 UTC (rev 2395)
+++ SwingME/src/net/yura/mobile/gui/components/ScrollPane.java 2020-11-19 17:43:26 UTC (rev 2396)
@@ -1094,6 +1094,7 @@
int diffBottomY = viewPortHeight - cY - cH;
// How far are we from the desire position?
+ // (difference in scrollarea pixels of the move) - (amount already moved since start of interaction)
int jumpY = (dragStartY - dragLastY) - (dragStartViewY - cY);
if (jumpY != 0 || bound) {
Modified: SwingME/src/net/yura/mobile/gui/components/Slider.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/Slider.java 2020-08-11 21:23:26 UTC (rev 2395)
+++ SwingME/src/net/yura/mobile/gui/components/Slider.java 2020-11-19 17:43:26 UTC (rev 2396)
@@ -670,10 +670,20 @@
/**
* this method is used by the ScrollPane
+ * @return the end value after adding scrollbarPixelsMoved in scrollArea coordinates
*/
- public int getNewValue(int x,int y,int w,int h,int value,int extent, int max,int pixels) {
+ public int getNewValue(int x, int y, int w, int h, int value, int extent, int max, int scrollbarPixelsMoved) {
int[] offsets = getOffsets(x, y, w, h, 0, extent, max);
- return value + ((max-extent)* pixels)/ (w - offsets[0]*2 - offsets[2]);
+ int scrollAreaHiddenSize = max - extent;
+ int scrollbarAvailableSpacePixels = w - offsets[0]*2 - offsets[2];
+ // if something has changed in the layout while we are trying to scroll
+ if (scrollbarAvailableSpacePixels == 0) {
+ //#debug info
+ Logger.info("scrollbarAvailableSpacePixels is zero, UI has been changed from non UI-Thread");
+ // no change in value
+ return value;
+ }
+ // start value + scrollAreaPixelsMoved
+ return value + (scrollAreaHiddenSize * scrollbarPixelsMoved) / scrollbarAvailableSpacePixels;
}
-
}
Modified: SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java 2020-08-11 21:23:26 UTC (rev 2395)
+++ SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java 2020-11-19 17:43:26 UTC (rev 2396)
@@ -57,7 +57,11 @@
}
return null;
}
-
+
+ /**
+ * The system or custom midlet may return a higher-resolution image
+ * @see Image#createImage(String)
+ */
protected Image createImage(String path) {
Image in = Midlet.createImage(path);
if (in==null) {
@@ -323,6 +327,7 @@
}
}
else {
+ // TODO: the image may come back as xhdpi and have a higher resolution, but the x,y,w,h are not being scaled
newImage = getIcon( path,x==null?0:Integer.parseInt(x),y==null?0:Integer.parseInt(y),width==null?0:Integer.parseInt(width),height==null?0:Integer.parseInt(height) );
}
if (newImage!=null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|