Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-20609

Windows: ImageView.image doesn't handle Windows-style path

    Details

    • Story Points:
      5
    • Sprint:
      2016 Sprint 07 SDK

      Description

      It's affected 5.2.0. Tested on emulator and on real device (same behaviour)

      What doing this sample app: copy .png file from Resources folder to dataDirectory and try to set copied image to imageView;

      index.js:

      var directory = (Ti.Filesystem.isExternalStoragePresent()) ? Ti.Filesystem.externalStorageDirectory : Ti.Filesystem.applicationDataDirectory;
      var fileIndex = 0;
      var toFile;
       
      function listFiles() {
          if(OS_WINDOWS) {
          	alert(Ti.Filesystem.getFile(directory).getDirectoryListing());
          } else {
          	console.warn(Ti.Filesystem.getFile(directory).getDirectoryListing());	
          }    
      }
       
      function copyFile() {
      	fileIndex++;
      	var fromFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "test.png");
      	toFile = Ti.Filesystem.getFile(directory, '' + fileIndex + '.png');
      	toFile.write(fromFile.read());
      }
      function onImageClick() {
      	$.imageView.image = toFile;
              // below another approaches
              // $.imageView.image = toFile.read();
              // $.imageView.image = toFile.nativePath;
              // $.imageView.image = directory + '/' + fileIndex + '.png';
      }
       
      $.win.open();
      

      index.xml:

      <Alloy>
          <Window id='win' backgroundColor="green" layout='vertical'>
      		 <Button top='10dp' backgroundColor="red" title='List files' onClick="listFiles" />
      		 <Button top='10dp' backgroundColor="blue" title='Copy' onClick="copyFile" />
      		 <View width='300dp' height='150dp' backgroundColor='yellow' top='30dp' onClick='onImageClick' >
      		 	<ImageView id='imageView' width='Ti.UI.FILL' height='Ti.UI.FILL' />
      		 </View>
          </Window>
      </Alloy>
      


      BUT, I found the way when it's working on windows phone(emulator and device).

      index.js:

      var directory = ''; // when directory is empty string, image will save in the root folder
       
      function onImageClick() {
              $.imageView.image = directory + '/' + fileIndex + '.png'; // set image by path
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kiguchi Kota Iguchi
                Reporter:
                zozo4kin Zakhar Zhuravlev
                Reviewer:
                Christopher Williams
                Tester:
                Josh Longton
              • Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code