Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25634] Android: ScrollableView "cacheSize" cannot by dynamically changed

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2018-05-09T21:29:54.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.3.0
ComponentsAndroid
LabelsScrollableView, android
ReporterPrashant Saini
AssigneeJoshua Quick
Created2017-12-26T10:12:18.000+0000
Updated2018-06-26T21:23:10.000+0000

Description

On Android, calling ScrollableView's setCacheSize method is throwing error:
var win = Ti.UI.createWindow();

var view1 = Ti.UI.createView({ backgroundColor:'#123' });
var view2 = Ti.UI.createView({ backgroundColor:'#246' });
var view3 = Ti.UI.createView({ backgroundColor:'#48b' });

var scrollableView = Ti.UI.createScrollableView({
  views:[view1,view2,view3],
  showPagingControl:true
});

win.add(scrollableView);
win.open();

setTimeout(function (){
    scrollableView.setCacheSize(3);    // TypeError: setCacheSize is not a function
}, 5000);

I also looked out in the SDK source code & seems this method is missing in Android (perhaps iOS as well) source code. *There's no way at present we can set dynamic cacheSize. we can set it at creation only.*

Attachments

FileDateSize
ScrollableViewCacheSizeTest.js2018-05-03T23:54:05.000+0000957

Comments

  1. Sharif AbuDarda 2017-12-26

    Hello, Can you send a sample code for us to test. Also, send the source code link/file that you are referring to. Thanks.
  2. Prashant Saini 2017-12-27

    1- Added sample code. 2- Link to SDK source code which doesn't show any results to *setCacheSize* method : https://github.com/appcelerator/titanium_mobile/search?utf8=%E2%9C%93&q=setCacheSize&type= Now please do not ask me to test it on different SDK versions as I am not a tester.
  3. Joshua Quick 2018-01-05

    This is really a documentation error, but it's easy enough to add support for it. We'll look into adding it into 7.1.0. The below code can better exercise support for setting the cache size dynamically and setter/getter function support...
       var window = Ti.UI.createWindow();
       var scrollableView = Ti.UI.createScrollableView(
       {
       	views:
       	[
       		Ti.UI.createView({ backgroundColor: "orange", width: "25dp", height: "25dp" }),
       		Ti.UI.createView({ backgroundColor: "red", width: "75dp", height: "75dp" }),
       		Ti.UI.createView({ backgroundColor: "green", width: "150dp", height: "150dp" }),
       		Ti.UI.createView({ backgroundColor: "blue", width: "225dp", height: "225dp" }),
       		Ti.UI.createView({ backgroundColor: "purple", width: "300dp", height: "300dp" }),
       	],
       	cacheSize: 5,
       	showPagingControl: true,
       	backgroundColor: "gray",
       	width: Ti.UI.SIZE,
       	height: Ti.UI.SIZE,
       });
       Ti.API.info("@@@ Initialized cacheSize: " + scrollableView.cacheSize);
       scrollableView.cacheSize = 4;
       Ti.API.info("@@@ Property assigned cacheSize: " + scrollableView.cacheSize);
       scrollableView.setCacheSize(3);
       Ti.API.info("@@@ Method assigned cacheSize: " + scrollableView.getCacheSize());
       window.add(scrollableView);
       window.open();
       
  4. Joshua Quick 2018-01-06

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/9696
  5. Lokesh Choudhary 2018-05-05

    FR Passed. Waiting for merger to be enabled.
  6. Samir Mohammed 2018-06-26

    *Closing ticket.* Verified fix can be seen in SDK Version: 7.3.0.v20180625114905 *Test and other information can be found at:* https://github.com/appcelerator/titanium_mobile/pull/9696

JSON Source