we are writing an application at school with titanium. My part is to create a gallery. Here's the problem, I want to display images using imageAsThumbnail and passing the thumbnailBlob created to the imageView. Whenever the imageAsThumbnail method is used I get this error even if the images are displaying correctly in both android/ios. The error shows in the log just on android for each image. How can I solve this problem?
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/1GM_artiglieria.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/3527_primaguerramondiale.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/Trincea_alpina.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/Unknown.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/alpini.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/guerra_epocale_prima_guerra_mondiale_mostra__5__1.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/hqdefault.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/images.jpeg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/mondia46.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/soldato-francese-in-trincea-prima-guerra-mondiale.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/tesina-prima-guerra.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/trinceawwi.jpg'
[ERROR] JHEAD: can't open '/android_asset/Resources/images/1/1/images/trincee-russe-nella-foresta-di-sarikamish_h_partb.jpg'
file.js
exports.ApplicationWindow = function ApplicationWindow(a,b) {
var resourcesDirectory = Titanium.Filesystem.resourcesDirectory;
var imageWidth = 300;
/*TOP MENU*/
var numH=require('db').numH();
var numW=require('db').numW();
var distanzaOttimale=require('db').distanzaOttimale();
var h=require('db').defaultElementsHeight();
/*TOP MENU END*/
var dir = Titanium.Filesystem.getFile(resourcesDirectory + 'images/' + a + '/' + b + '/images');
var images = dir.getDirectoryListing();
dir = null;
var scrollView = Ti.UI.createScrollView({
backgroundColor: '#fff',
top:h,
contentWidth: Ti.UI.FILL,
contentHeight: 'auto',
height: 'auto',
scrollType: 'vertical',
showHorizontalScrollIndicator: 'false',
showVerticalScrollIndicator: 'true',
layout: 'horizontal',
horizontalWrap: true
});
var left, imageFile, thumbnailBlob, thumbnailImage;
for (var i = 0, l = images.length; i<l; ++i) {
imageFile = Titanium.Filesystem.getFile(resourcesDirectory, 'images/', a, '/', b, '/images/', images[i]);
imageBlob = imageFile.read();
thumbnailBlob = imageBlob.imageAsThumbnail(300,0 ,0); //ERROR
/* 3- [ 30 ] -2- [ 30 ] -2- [ 30 ] -3 */
// Ternary operator = condition ? then : else
left = (i % 3 === 0) ? 3 : 2;
thumbnailImage = Ti.UI.createImageView({
top: 10,
left: left + '%',
width: '30%',
image: thumbnailBlob,
rowID: i,
opacity: 0
});
thumbnailImage.addEventListener('click', onImageClick);
scrollView.add(thumbnailImage);
fadeIn(thumbnailImage, 50 * (i + 3));
}
// Aggiungo un piccolo filler… scusa…
scrollView.add(Ti.UI.createView({
width: Ti.UI.FILL,
height: 10
}));
function onImageClick(e) {/*
Ti.API.info('Row ID : ' + e.source.rowID);*/
var newWin = Ti.UI.createWindow({
url: 'display.js',
backgroundColor: '#000',
zIndex:1,
page: e.source.rowID,
a: a,
b: b
});
newWin.open();
}
function fadeIn(view, delay) {
setTimeout(function () {
view.animate({
opacity: 1,
duration: 200
});
}, delay);
}
return scrollView;
};
Aucun commentaire:
Enregistrer un commentaire