Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

navGroup and Passing Data Problem

$
0
0

actually i have three files, i have solved one but when try the last i couldn't do it, i want to open the last file in navgroup again :( but couldn't do this:(

photoalbum.js

Ti.UI.backgroundColor = '#dddddd';
 
 
var url = "http://www.xxx.com/facebook/albums.php";
var win = Ti.UI.createWindow({
        title: 'Foto Galeri',
        barColor:'#000',
        height:'auto',
        backgroundColor:'#000',
    });
var table = Ti.UI.createTableView({
    backgroundColor:'transparent',
    backgroundImage:'transparent',
 
    separatorColor:'transparent',
    background:'transparent'
});
win.add(table);
var actInd = Titanium.UI.createActivityIndicator({
        height:50,
        width:210,
        font: {fontSize:12, fontWeight:'bold'},
        color: '#333',
        message: 'Yükleniyor...',
        style: Titanium.UI.iPhone.ActivityIndicatorStyle.DARK
    });
actInd.show();
win.add( actInd );
 
var navGroup = Ti.UI.iPhone.createNavigationGroup({
    window:win
});
 
var tableData = [];
var json, fighters, fighter, i, row, nameLabel, nickLabel, resimYol;
 
var xhr = Ti.Network.createHTTPClient({
    onload: function() {
        // Ti.API.debug(this.responseText);
 
        json = JSON.parse(this.responseText);
        for (i = 0; i < json.fighters.length; i++) {
            fighter = json.fighters[i];
            row = Ti.UI.createTableViewRow({
                height:'60',
                backgroundColor:'transparent',
 
                background:'transparent',
                //hasDetail:'true',
                selectedBackgroundColor:'#000',                
                data:fighter
            });
            nameLabel = Ti.UI.createLabel({
                text:fighter.name,
                font:{
                    fontSize:'12',
                    fontWeight:'bold'
                },
                height:'auto',
                left:'65',
                top:'5',
                color:'#FFF',
                touchEnabled:false
            });
            nickLabel = Ti.UI.createLabel({
                text:'"Toplam ' + fighter.count + ' foto?raf bulunmaktad?r.""',
                font:{
                    fontSize:'10'
                },
                height:'auto',
                left:'65',
                bottom:'5',
                color:'#FFF',
                touchEnabled:false
            });
 
            resimYol = Ti.UI.createImageView({
                image: 'https://graph.facebook.com/'+fighter.cover_photo+'/picture',
                left: 10,
                top:4,
                width:50,
                height:50
            });
 
 
            row.add(nameLabel);
            row.add(nickLabel);
            row.add(resimYol);
            tableData.push(row);
        }
 
        table.setData(tableData);
    },
    onerror: function(e) {
        Ti.API.debug("STATUS: " + this.status);
        Ti.API.debug("TEXT:   " + this.responseText);
        Ti.API.debug("ERROR:  " + e.error);
        alert('?nternet Ba?lant?n?z? Kontrol Ediniz. Bir Hata olu?tu.');
    },
    timeout:200000
});
 
 
 
 
 
 
xhr.open("GET", url);
xhr.send();
win.remove( actInd );
 
table.addEventListener("click", function(e) {
    //Burada e.row.data.name yazmam?z?n nedeni json objemizde name alan? var bunun yerine nameLabel yazam?yoruz.
    //alert(e.row.data.name);
  var w2 = Titanium.UI.createWindow({
    title:e.row.data.name ,
    barColor:'#000',
    url:'image_gallery2.js',
    backgroundColor:'#000'
    });
    w2.id = e.row.data.id;
    Ti.API.info(w2.id);
    w2.myFunc = function()
    {
        return navGroup;
    };
    navGroup.open(w2,{animated:true});  
});
var main = Ti.UI.currentWindow;
main.add(navGroup);
main.open();
image_gallery2.js
var win = Ti.UI.currentWindow;
var navGroup;
//win.backgroundColor = '#000';
 
//win.backgroundColor = '#2a675e';
var isAndroid = false;
 
if (Ti.Platform.name == 'android') {
    isAndroid = true;
}
 
var rows = 0;
var columns = 0;
var thumbPadding = 5;
 
var rowPosition = 2;
var rowPositionReset = 2;
var padding = 5;
 
var columnPosition = 15;
 
win.orientationModes = [ Ti.UI.PORTRAIT ];
 
 
var json_data = [];
var imagesArray = []; // image container
 
 
 
var actInd = Titanium.UI.createActivityIndicator({
        height:50,
        width:210,
        font: {fontSize:12, fontWeight:'bold'},
        color: '#333',
        message: 'Yükleniyor...',
        style: Titanium.UI.iPhone.ActivityIndicatorStyle.DARK
    });
actInd.show();
win.add( actInd );
 
var xhr_request = Titanium.Network.createHTTPClient( );
xhr_request.setTimeout(1000000);
xhr_request.onerror = function(e){ alert('?nternet Ba?lant?n?z? Kontrol Ediniz,ba?l? oldu?unuzdan Emin olunuz'); }
var url = 'http://www.xxx.com/facebook/facebook2.php?id='+win.id;
Ti.API.info(url);
xhr_request.open("GET",url);
xhr_request.onload = function(){
        Ti.API.info('Response: '+ xhr_request.responseText);
    try{
        json_data = eval('('+this.responseText+')');
        displayImages( );
        win.remove( actInd );
 
    }catch(e){
        alert('?nternet Ba?lant?n?z? Kontrol Ediniz,ba?l? oldu?unuzdan Emin olunuz');
    }
}
xhr_request.send( );
 
function displayImages( ){
    // format the json data so that it will work on codeboxed
    for(var i=0;i<json_data.fighters.length;i++){
        imagesArray.push({filename:json_data.fighters[i].thumbnail, caption: json_data.fighters[i].bigimage });
    }
 
    var scrollView = Ti.UI.createScrollView({
        contentWidth : 320,
        contentHeight : 'auto',
        top : 0,
        backgroundColor : 'transparent',
        showVerticalScrollIndicator : true,
        showHorizontalScrollIndicator : false
    });
 
    for (i = 0, b = imagesArray.length; i < b; i++) {
        if (columns % 4 == 0 && rows != 0) {
            columnPosition += 50 + thumbPadding;
            rowPosition = rowPositionReset;
        }
 
        var img = Ti.UI.createImageView({
            image : imagesArray[i].filename,
            defaultImage:'images/default_image.png',
            width : 75,
            height : 48,
            myID : i,
            left : rowPosition,
            top : columnPosition
        });
 
        img.borderColor = '#FFF';
        img.borderWidth = 2;
        img.backgroundPaddingLeft = 0;
        img.backgroundPaddingRight = 0;
        img.backgroundPaddingTop = 0;
        img.backgroundPaddingBottom = 0;
        img.backgroundLeftCap = 0;
        img.backgroundTopCap = 0;
 
        img.addEventListener('click', function(e) {
            var win_photo = Ti.UI.createWindow({
                //backgroundImage:'background_hadise.png',
                backgroundColor:'#494949',
                barImage:'images/barimage.png',
                title:'Foto Ayr?nt?',
                //title : e.source.myID + 1 + ' of ' + imagesArray.length,
                windowInfo : imagesArray,
                myID : e.source.myID,
                url : 'image_gallery_single.js'
            });
 
            win_photo.hideTabBar();
 
            Ti.UI.currentTab.open(win_photo, {
                animated : true
            });
        });
 
        scrollView.add(img);
 
        columns++;
        rows++;
        rowPosition += 75 + padding;
    }
 
    win.add(scrollView);
 
}
image_gallery_single.js
var win = Ti.UI.currentWindow;
win.backgroundColor='#000';
var isAndroid = false;
 
if (Ti.Platform.name == 'android') {
    isAndroid = true;
}
 
win.orientationModes = [ Ti.UI.PORTRAIT ];
 
var isFullscreen = false;
var isGesture = true;
var images = win.windowInfo;
var myID = win.myID;
var viewArray = [];
 
var photosView = Ti.UI.createScrollableView({
    width : 320,
    height : 480,
    top : 0,
    showPagingControl : false,
    pagingControlColor : '#fff',
    maxZoomScale : 2.0,
    currentPage : 0
});
 
var descriptionLabel = Ti.UI.createLabel({
    text : 'Aç?klama:'+images[myID].caption,
    width : 320,
    bottom : 45,
    height : 'auto',
    backgroundColor : '#000',
    font : {
        fontSize : 12,
        fontWeight : 'bold'
    },
    color : '#FFF',
    zIndex : 2,
    opacity : 0.8
});
 
if (!isAndroid) {
    for (i = 0; i < images.length; i++) {
        var view = Ti.UI.createImageView({
            backgroundColor : '#000',
            image : images[i].caption,
            top : 0
        });
 
        viewArray[i] = view;
    }
 
    photosView.views = viewArray;
}
 
if (!isAndroid) {
    photosView.currentPage = myID;
 
    win.add(photosView);
    //win.hideTabBar();
 
    var flexSpace = Ti.UI.createButton({
        systemButton : Ti.UI.iPhone.SystemButton.FLEXIBLE_SPACE
    });
 
    var leftButton = Ti.UI.createButton({
        image : 'images/icon_arrow_left.png'
    });
 
    leftButton.addEventListener('click', function() {
        var index = (photosView.currentPage - 1 < 0) ? 0
        : photosView.currentPage - 1;
        var view = photosView.views[index];
 
        isGesture = false;
 
        photosView.scrollToView(view);
    });
    var rightButton = Ti.UI.createButton({
        image : 'images/icon_arrow_right.png'
    });
 
    rightButton.addEventListener('click', function() {
        var index = (photosView.currentPage + 1 >= photosView.views.length) ? photosView.currentPage : photosView.currentPage + 1;
        var view = photosView.views[index];
 
        isGesture = false;
 
        photosView.scrollToView(view);
    });
 
    var toolbar = Ti.UI.createToolbar({
        items : [ flexSpace, leftButton, flexSpace, rightButton, flexSpace ],
        bottom : 0,
        borderTop : true,
        borderBottom : true,
        barColor : '#000'
    });
 
    win.add(toolbar);
 /*
    photosView.addEventListener('singletap', function() {
        if (isFullscreen) {
            Ti.UI.iPhone.showStatusBar();
            win.showNavBar();
            toolbar.show();
            descriptionLabel.show();
        } else {
            Ti.UI.iPhone.hideStatusBar();
            win.hideNavBar();
            toolbar.hide();
            descriptionLabel.hide();
        }
 
        isFullscreen = !isFullscreen;
    });
    */
 
    photosView.addEventListener('scroll', function(e) {
        if (isGesture) {
            //Ti.UI.iPhone.hideStatusBar();
            //win.hideNavBar();
            //toolbar.hide();
            //descriptionLabel.hide();
 
            isFullscreen = true;
        } else {
            isGesture = true;
        }
 
        i = e.currentPage;
        activeView = e.view;
        descriptionLabel.text = 'Aç?klama:'+images[i].caption;
 
        win.title = i + 1 + ' of ' + images.length;
    });
} else {
    var view = Ti.UI.createImageView({
        backgroundColor : 'transparent',
        backgroundImage:'images/albumler_arkaplan.png',
        image : imageLocation + images[myID].caption,
        width : 'auto',
        height : 350,
        top : 0,
        canScale : true
    });
 
    win.add(view);
 
    descriptionLabel.bottom = 0;
}
 
win.add(descriptionLabel);

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>