diff --git a/android/modules/ui/src/java/ti/modules/titanium/ui/RefreshControlProxy.java b/android/modules/ui/src/java/ti/modules/titanium/ui/RefreshControlProxy.java index f4a8fd62783..c5f5a82f61d 100644 --- a/android/modules/ui/src/java/ti/modules/titanium/ui/RefreshControlProxy.java +++ b/android/modules/ui/src/java/ti/modules/titanium/ui/RefreshControlProxy.java @@ -13,7 +13,9 @@ import org.appcelerator.kroll.annotations.Kroll; import org.appcelerator.kroll.common.Log; import org.appcelerator.titanium.TiC; +import org.appcelerator.titanium.TiDimension; import org.appcelerator.titanium.util.TiColorHelper; +import org.appcelerator.titanium.util.TiConvert; import java.util.HashSet; @@ -30,7 +32,8 @@ public class RefreshControlProxy extends KrollProxy * The default Android log tag name to be used by this class. */ private static final String TAG = "RefreshControlProxy"; - + private static int offsetStart = -1; + private static int offsetEnd = -1; /** * Android's default progress indicator color used by the SwipeRefreshLayout class. * This is defined in Google's "MaterialProgressDrawable.java", which is an internal class. @@ -134,9 +137,18 @@ public void handleCreationDict(KrollDict properties) super.handleCreationDict(properties); // Fetch "tintColor" property, if provided. - value = properties.get(TiC.PROPERTY_TINT_COLOR); - if (value != null) { - onTintColorChanged(value); + if (properties.containsKeyAndNotNull(TiC.PROPERTY_TINT_COLOR)) { + value = properties.get(TiC.PROPERTY_TINT_COLOR); + if (value != null) { + onTintColorChanged(value); + } + } + if (properties.containsKeyAndNotNull("offset")) { + KrollDict offset = properties.getKrollDict("offset"); + offsetStart = new TiDimension(TiConvert.toInt(offset.get("start"), 0), TiDimension.TYPE_TOP) + .getAsPixels(this.swipeRefreshLayout); + offsetEnd = new TiDimension(TiConvert.toInt(offset.get("end"), 80), TiDimension.TYPE_BOTTOM) + .getAsPixels(this.swipeRefreshLayout); } } @@ -275,6 +287,9 @@ public void assignTo(TiSwipeRefreshLayout view) // Set up the given view for pull-down refresh support. view.setColorSchemeColors(this.tintColor); + if (offsetStart != -1 && offsetEnd != -1) { + view.setProgressViewOffset(false, offsetStart, offsetEnd); + } view.setSwipeRefreshEnabled(true); view.setOnRefreshListener(new TiSwipeRefreshLayout.OnRefreshListener() { diff --git a/apidoc/Titanium/UI/RefreshControl.yml b/apidoc/Titanium/UI/RefreshControl.yml index 1abd9a4c6c8..d3c78eb2b35 100644 --- a/apidoc/Titanium/UI/RefreshControl.yml +++ b/apidoc/Titanium/UI/RefreshControl.yml @@ -55,6 +55,13 @@ properties: platforms: [android, iphone, ipad, macos] since: { android: "6.2.0", iphone: "3.2.0", ipad: "3.2.0" } + - name: offset + summary: Offset of the refresh control view. + type: RefreshControlOffset + platforms: [android] + since: { android: "12.7.0" } + availability: creation + - name: backgroundColor summary: The background color for the refresh control, as a color name or hex triplet. description: | @@ -146,3 +153,13 @@ examples: $.index.open(); ``` +--- +name: RefreshControlOffset +summary: Offset of the refresh control view. +properties: + - name: start + summary: The offset from the top of this view at which the progress spinner should appear. + type: Number + - name: end + summary: The offset from the top of this view at which the progress spinner should come to rest after a successful swipe gesture. + type: Number