Skip to content

Commit ba4aa12

Browse files
layout fix to support tablet and update improvements
1 parent 23b8616 commit ba4aa12

33 files changed

+185
-55
lines changed

app/alloy.js

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ Alloy.Globals.Map = require('ti.map');
1515
Alloy.Globals.osName = Ti.Platform.osname;
1616
Alloy.Globals.filesDownload = {};
1717
Alloy.Globals.updateCount = 0;
18+
Alloy.Globals.isAndroidTablet = false;
1819
switch(Alloy.Globals.osName){
1920
case 'android':
21+
Alloy.Globals.isAndroidTablet = (Ti.Platform.Android.getPhysicalSizeCategory() == Ti.Platform.Android.PHYSICAL_SIZE_CATEGORY_LARGE || Ti.Platform.Android.getPhysicalSizeCategory() == Ti.Platform.Android.PHYSICAL_SIZE_CATEGORY_XLARGE);
2022
Alloy.Globals.museo_slab_500 = 'museo_slab_500';
2123
Alloy.Globals.museo_slab_700 = 'museo_slab_700';
2224
Alloy.Globals.museosans_300 = 'museosans_300';
@@ -97,6 +99,15 @@ updateData = function(type){
9799
if(typeof mapping != 'undefined'){
98100
for(var key in node){
99101
if(typeof mapping[key] != 'undefined'){
102+
if(node[key] != ""){
103+
if(typeof mapping[key]['type'] != 'undefined' && mapping[key]['type'] == 'file' && typeof mapping[key]['callback'] != 'undefined' ){
104+
object[mapping[key]['field']] = (typeof mapping[key]['callback'] != 'undefined') ? mapping[key]['callback'](node[key], type) : node[key];
105+
}
106+
else{
107+
object[mapping[key]['field']] = (typeof mapping[key]['callback'] != 'undefined') ? mapping[key]['callback'](node[key]) : node[key];
108+
}
109+
}
110+
/*
100111
if(typeof mapping[key]['type'] != 'undefined' && mapping[key]['type'] == 'file' && typeof mapping[key]['callback'] != 'undefined' && node[key] != ""){
101112
file = true;
102113
files[files.length] = {
@@ -109,6 +120,7 @@ updateData = function(type){
109120
else if(node[key] != ""){
110121
object[mapping[key]['field']] = (typeof mapping[key]['callback'] != 'undefined') ? mapping[key]['callback'](node[key]) : node[key];
111122
}
123+
*/
112124
}
113125
}
114126
}
@@ -120,6 +132,10 @@ updateData = function(type){
120132
var currentCollection = collection.get(object[id]);
121133
if(typeof object['changed'] == 'undefined' || (typeof currentCollection != 'undefined' && object['changed'] > currentCollection.get('changed')) || typeof currentCollection == 'undefined'){
122134
ids[ids.length] = object[id];
135+
Ti.API.info(JSON.stringify(object));
136+
var row = Alloy.createModel(type,object);
137+
row.save();
138+
/*
123139
if(file){
124140
if(typeof Alloy.Globals.filesDownload[type] == 'undefined'){
125141
Alloy.Globals.filesDownload[type] = new Array();
@@ -130,6 +146,7 @@ updateData = function(type){
130146
var row = Alloy.createModel(type,object);
131147
row.save();
132148
}
149+
*/
133150
}
134151
}
135152
}
@@ -163,11 +180,17 @@ updateData = function(type){
163180
client.open("GET", url);
164181
client.send();
165182
};
166-
function getImageBlob(url, data, field, type, files){
183+
function getImageBlob(url, type){
167184
Alloy.Globals.updateCount++;
185+
var filename = url.substring(url.lastIndexOf('/')+1);
186+
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,filename);
168187
var xhr = Titanium.Network.createHTTPClient({
169188
onload : function(e){
170189
if (xhr.status == 200 ) {
190+
f.write(this.responseData); // write to the file
191+
var type = this._properties['type'];
192+
// this.responseData
193+
/*
171194
var data = this._properties['data'];
172195
var field = this._properties['field'];
173196
var files = this._properties['files'];
@@ -181,12 +204,15 @@ function getImageBlob(url, data, field, type, files){
181204
var currentFile = files.shift();
182205
currentFile.callback(currentFile.value, data, currentFile.field, type, files);
183206
}
207+
*/
184208
}
185209
event = {};
186210
event.type = type;
187211
Ti.App.fireEvent('updateDataEnd',event);
188212
},
189213
onerror : function(e) {
214+
var type = this._properties['type'];
215+
/*
190216
var data = this._properties['data'];
191217
var field = this._properties['field'];
192218
var files = this._properties['files'];
@@ -200,20 +226,26 @@ function getImageBlob(url, data, field, type, files){
200226
var currentFile = files.shift();
201227
currentFile.callback(currentFile.value, data, currentFile.field, type, files);
202228
}
229+
*/
203230
event = {};
204231
event.type = type;
205232
Ti.App.fireEvent('updateDataEnd',event);
206233
},
207234
});
208-
235+
xhr.applyProperties({
236+
'type' : type,
237+
});
238+
/*
209239
xhr.applyProperties({
210240
'data' : data,
211241
'field' : field,
212242
'type' : type,
213243
'files' : files
214244
});
245+
*/
215246
xhr.open('GET',url);
216247
xhr.send();
248+
return f.nativePath;
217249
}
218250
function getSponsorType(sponsorType){
219251
var sponsorTypes = {
@@ -530,4 +562,3 @@ function twitterShare(data){
530562
});
531563

532564
}
533-
Alloy.Globals.isAndroidTablet = (Ti.Platform.osname == "android" && (Ti.Platform.Android.getPhysicalSizeCategory() == Ti.Platform.Android.PHYSICAL_SIZE_CATEGORY_LARGE || Ti.Platform.Android.getPhysicalSizeCategory() == Ti.Platform.Android.PHYSICAL_SIZE_CATEGORY_XLARGE));
2.83 KB
Loading
1.37 KB
Loading
2.36 KB
Loading
1.23 KB
Loading
3.4 KB
Loading
1.69 KB
Loading
6.39 KB
Loading
3.74 KB
Loading
1008 Bytes
Loading

0 commit comments

Comments
 (0)