Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Development and suggestions about third part tool integration.
Cordova, Xamarin, Basic4Android topics are listed here.

Titanium demo

More
IP: 192.168.0.123 11 years 6 months ago - 11 years 6 months ago #7083 by support
Titanium demo was created by support
Here you will find the first Appcelerator Titanium demo: www.androidpdf.mobi/download/download-pr...ile/95-titanium-demo
Below actual code:
Code:
var eboxapdf = require('com.ebox.apdf'); var imageViewTransformed = Titanium.UI.createImageView({ enableZoomControls : true, top: 0, left: 0, width: '100%', height: '90%' }); //var win = Ti.UI.createScrollableView({ backgroundColor: '#fff' }); var MainView = Titanium.UI.createScrollView({ views:imageViewTransformed, //minZoomScale:1.0, canScale: true, enableZoomControls: true, //maxZoomScale:3.0, //size:{width:Titanium.Platform.platformWidth, //height:Titanium.Platform.platformHeight} height : '90%', width: '100%' }); var total_pages = 0; var PDF_URL_str = ''; var httpClient = Titanium.Network.createHTTPClient(); httpClient.setTimeout(1000000); var myExampleView = eboxapdf.createExample({top:0, left:0, bottom:80, right:80,}); //----file copy start here function download_file(PDF_URL_str){ var length = 0; var localDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'pdf'); if(!localDir.exists()) { localDir.createDirectory(); } var localFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'pdf/'+'test.pdf'); remoteFile = PDF_URL_str; function getContentLength(evt) { length = this.getResponseHeader("Content-Length"); httpClient.ondatastream = null; if (length > 0) { Ti.API.info("======> " + length); } else { // tell the user we don't know the content length } } httpClient.open('GET', remoteFile); httpClient.send(); }; httpClient.onload = function(e) { Ti.API.info("======> onload"); var writeFile = Titanium.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'pdf/'+'test.pdf'); if (writeFile.write(this.responseData)===false) { Ti.API.info("======> Error"); }else { //Ti.API.info("======> this.responseData:" + this.responseData.getLength()); //Ti.API.info("======> Write Complete:"); //Ti.API.info("======> :"+ localFile.resolve()); //var myExampleView = eboxapdf.createExample(); imageViewTransformed.backgroundColor = 'silver'; //imageViewTransformed.image = myExampleView.getMessage(1,800,1000,1); total_pages = myExampleView.getMessage2(); pagelable.text = 1 + "/"+ total_pages; slider.max = total_pages; //Ti.API.info("======> :"+ myExampleView.getMessage2()); //win.add(imageViewTransformed); } }; httpClient.onreadystatechange = function() { if (httpClient.status == 4) { // Download finished Ti.API.info("======> download completed"); }else{ Ti.API.info("======> state:"+ httpClient.status); } }; // Handle progress event //httpClient.ondatastream = getContentLength; // Handle error event httpClient.onerror = function(e) { Ti.API.info("======> HTTP error."); }; //----file copy end here..... //--- PDF URL input window--- pagelable = Ti.UI.createLabel({ left:1, right:'20%', width:'10%', top:'90%', height:'5%', text:"0", color:"white", font:{ fontSize:12 } }); slider = Ti.UI.createSlider({ color:"white", width: '70%', left:'15%', right:'5%', top:'90%', height:'5%', min:1, max:8 }); var backBtn = Titanium.UI.createButton({ title:'Back', top:'90%', left:'87%', width:'14%', height:'7%', borderRadius:1, font:{fontFamily:'Arial',fontSize:8} }); var PDFwindow = Titanium.UI.createWindow({ backgroundColor:'#fff', title:':', }); var PDF_URL = Titanium.UI.createTextField({ value:'http://backoffice.com.hk/test.pdf', //value:'http://127.0.0.1/BLUEBOOK.PDF', //value:'http://127.0.0.1/test.pdf', color:'#336699', top:'10%', left:'10%', width: '80%', height:'10%', keyboardType:Titanium.UI.KEYBOARD_DEFAULT, returnKeyType:Titanium.UI.RETURNKEY_DEFAULT, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED }); var downloadBtn = Titanium.UI.createButton({ title:'Download PDF', top:'30%', left:'10%', width:'40%', height:'10%', borderRadius:1, font:{fontFamily:'Arial',fontWeight:'bold',fontSize:14} }); function goto_page(goto){ Ti.API.info("======> goto:"+ goto); //imageViewTransformed.setEnableZoomControls imageViewTransformed.setImage(myExampleView.getMessage(goto,800,1000,1)); } slider.addEventListener('change',function(evt){ slider_to =(this.value).toFixed(0); pagelable.text = slider_to + "/"+ total_pages; // goto_page(slider_to); }); slider.addEventListener('touchend',function(evt){ slider_to = 0; slider_to =(this.value).toFixed(0); pagelable.text = slider_to + "/"+ total_pages; goto_page(Number(slider_to)); }); downloadBtn.addEventListener('click',function(e) { PDF_URL_str = PDF_URL.value; PDFwindow.close(); download_file(PDF_URL_str); win.add(imageViewTransformed); win.add(pagelable); win.add(slider); win.add(backBtn); goto_page(1); win.open(); }); backBtn.addEventListener('click',function(e) { PDFwindow.open(); win.close(); }); var win = Titanium.UI.createWindow({ backgroundColor : '#000', modal : true, //fullscreen : true width: '100%', height:'100%' }); PDFwindow.add(PDF_URL); PDFwindow.add(downloadBtn); PDFwindow.open();
Last edit: 11 years 6 months ago by .
Time to create page: 0.370 seconds
Powered by Kunena Forum