2

I am a newbie to Sencha Touch 2 . I am building an PhoneGap + Sencha Touch 2 application for Android 2.3.4 . I completed developing my application . While testing the app , i found out that the navigation view i used is responding very slow on tap of disclosure item. I am using a list container view , list view and editor view . The code for them is given below . The below piece of code works fine but on the tap of disclosure item the incident editor view is shown after 10 secs and i sometimes even don't know whether it was clicked or not .

So i need help in two things : 1.) When i click on disclosure item i should show masking to know that i clicked it atleast 2.) Or speed up the show of incident editor view

ListContainer View :

Ext.define('Sample.view.ListContainer', {
    extend: 'Ext.NavigationView',
    xtype:'listContainer',
    id: 'idListContainer',
    config: {
        id:'idIncidentListContainer',
        items:[

               {
                   xtype:"incidentsList",
                   cls: "clsHeader"
               }

           ]
    }
});

List View:

Ext.define("Sample.view.IncidentsList", {
    extend: "Ext.Panel",
    xtype: 'incidentsList',
    id: 'idIncidentList',
    requires:[
              'Ext.dataview.List',
              'Ext.data.proxy.Memory',
              'Ext.data.Store',
          ],
    alias:'widget.incidentslist',
    config: {
        id: 'idIncidentList',
        layout:'fit',
        items: [
        {
            xtype: "toolbar",
            docked: "top",
            ui:'light',
            id:"idHeaderTwo",
            cls:"clsHeaderTwo" ,
                items: [
                        {   xtype: 'title' ,
                            cls: 'clsLeftTitle',
                            title: "My Incidents",
                        },
                        { xtype: 'spacer'},
                        {   xtype: 'title' ,
                            cls: 'clsRightTitle',
                            id: 'idIncidentsListTitle',
                            title:"Welcome",
                        },
                        ]
        }, 
        {
            xtype: "list",
            store: "IncidentStore",
            itemId:"incidentsList",
            id:"inclist",
            loadingText: "Loading Incidents...",
            emptyText: "<div class=\"empty-text\">No incidents found.</div>",
            onItemDisclosure: true,
            itemTpl: Ext.create('Ext.XTemplate',
                    '<tpl if="TKT_STATUS_NAME == \'CLOSED\'">',
                    '<div class="vm_statusRed">',
                    '</tpl>',
                    '<tpl if="TKT_STATUS_NAME == \'OPENED\'">',
                    '<div class="vm_statusYellow">',
                    '</tpl>',
                    '<tpl if="TKT_STATUS_NAME == \'ASSIGNED\'">',
                    '<div class="vm_statusOrange">',
                    '</tpl>',
                    '<tpl if="TKT_STATUS_NAME == \'PENDING\'">',
                    '<div class="vm_statusRed">',
                    '</tpl>',
                    '<tpl if="TKT_STATUS_NAME == \'RESOLVED\'">',
                    '<div class="vm_statusOrange">',
                    '</tpl>',
                    '<tpl if="TKT_STATUS_NAME == \'REOPEN\'">',
                    '<div class="vm_statusYellow">',
                    '</tpl>',
                    '<div class="vm_dvList"><h4 class="vm_txtName"><span class="vm_listHeader"><label>Inci.#{TKT_ID} by </label><label class="vm_txtFirstName"><i>{FIRST_NAME:ellipsis(15, true)}</i></label></span><div class="date vm_clsDate">{CREATED_ON:date("d-M-y H:i")}</div></h4>',
                    '<div class="vm_title">{TKT_SUBJECT}</div>',
                    '<div class="vm_subDesc">{TKT_DESC}</div></div></div>'
                )       
        }],
        listeners: [
        {
            delegate: "#incidentsList",
            event: "disclose",
            fn: "onIncidentsListDisclose",
            loadingText: "Loading ...",
        },
        ]
    }, 
    initialize: function() {
        this.callParent(arguments);
        var getLoginData = localStorage.getItem('userData');
        var parseData = JSON.parse(getLoginData);
        var fname = parseData[0].FIRST_NAME;
        var getIncidentData = localStorage.getItem('userIncidentData');
        var parseIncidentData = JSON.parse(getIncidentData);
        Ext.getCmp("idIncidentsListTitle").setTitle("Welcome, " + fname);
        Ext.getStore("IncidentStore").setData(localStorage.userIncidentData).load();
    },
    onIncidentsListDisclose: function (list, record, target, index, evt, options) {
        console.log("editIncidentCommand");
        /*var list = Ext.getCmp('idIncidentList');
        list.setMasked({
            xtype:'loadmask',
            message:'Loading...'
        });*/
        this.fireEvent('editIncidentCommand', this, record);
    }
});

Editor View :

Ext.define("Sample.view.IncidentEditor", {
    extend: 'Ext.form.Panel',
    xtype: 'incidentsEditor',
    id:'incidentsEditorView',
    alias: "widget.incidenteditorview",

    config: {
        scrollable: 'vertical',
        id:'idIncidentEditor',
        layout:'vbox',
        items: [
            {
                xtype: "toolbar",
                docked: "top",
                ui:'light',
                id:"idHeaderTwo",
                cls:"clsHeaderTwo",
                items: [
                        {   xtype: 'title' ,
                            cls: 'clsLeftTitle',
                            title: "Incident Details",
                        },
                        {xtype: 'spacer'},
                        {   xtype: 'title' ,
                            cls: 'clsRightTitle',
                            id: 'idIncidentEditorTitle',
                            title:"Welcome",
                        },
                        ]
            }, 
            { xtype: "fieldset",

                items: [
                    {
                        xtype: 'textfield',
                        name: 'TKT_SUBJECT',
                        label: 'Subject',
                        labelAlign: 'top',
                        cls:'vm_fieldFont',
                        clearIcon:false,
                        disabled:true
                    },
                    {
                        xtype: 'textareafield',
                        name: 'TKT_DESC',
                        label: 'Description',
                        labelAlign: 'top',
                        cls:'vm_fieldFont',
                        clearIcon:false,
                        disabled:true
                    },
                    {
                        xtype: 'textfield',
                        name: 'SEV_DESC',
                        label: 'Impact',
                        labelWidth:'45%',
                        cls:'vm_fieldFont',
                        clearIcon:false,
                        disabled:true
                    },
                    {
                        xtype: 'textfield',
                        name: 'SERVICE_NAME',
                        id:'displayIncident',
                        cls:'vm_fieldFont',
                        label: 'IncidentType',
                        disabled: true,
                        labelWidth:'45%',
                    },
                    {
                        xtype: 'textfield',
                        label: 'Category',
                        name: 'CATEGORY_NAME',
                        cls:'vm_fieldFont',
                        id:'getCategory',
                        labelWidth:'45%',
                        disabled: true,
                    },
            ]
            },
        ],            
    },    

    initialize: function() {
        var getLoginData = localStorage.getItem('userData');
        var parseData = JSON.parse(getLoginData);
        var fname = parseData[0].FIRST_NAME;
        Ext.getCmp("idIncidentEditorTitle").setTitle("Welcome, " + fname);
        //var list = Ext.getCmp('idIncidentList');
        //list.unmask();
     },
     onIncidentsListDisclose: function (list, record, target, index, evt, options) {
         console.log("editIncidentCommand");
         this.fireEvent('editIncidentCommand', this, record);
     }
});

Controller:

Ext.define("Sample.controller.Incidents", {        
    extend: "Ext.app.Controller",
    config: {
        refs: {
            //lookup for views by xtype
            incidentsListView:'incidentslist',
            incidentEditorView: 'incidenteditorview', 
            incidentsList: 'incidentsList',
            listContainer:'listContainer'
        },
        control: {
            incidentsListView: {
                //commands fired by the Incidents list container.
                editIncidentCommand: "onEditIncidentCommand",
            },
        }
    },
    //Transitions
    slideLeftTransition: { type: 'slide', direction: 'left' },
    slideRightTransition: { type: 'slide', direction: 'right' },

    //Helper function(generates random integer)
    getRandomInt: function (min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    },

    //Function to get incident details and set them to incidentview
    activateIncidentEditor: function (record) {
        var incidentContainer = this.getListContainer();
        var incidentEditorView = Ext.create("Sample.view.IncidentEditor");
        incidentEditorView.setRecord(record); // load() is deprecated.
        incidentContainer.push(incidentEditorView);            
    },

    //on edit incident command
    onEditIncidentCommand: function (list, record) {
        this.activateIncidentEditor(record);
    }
});

Please help me guys ... Thanks in Advance ...!!!

yrkapil
  • 444
  • 2
  • 7
  • 17

2 Answers2

0

I experience the same problems. Coding Sencha Touch 2 in MVC format makes the app's respond super-slow on "old" hardware. Especially Android. It's the drawback of HTML5 vs Native. However they claim the performance would increase when manually building the lib, I experienced almost no improvement.

On Android most performance based issues are related to Animations though. Try setting the show/hide animations to none and see if it improves. You can also try setting the onBackButtonTap and other events on the controller though. That should improve the page rendering allot.

Rae
  • 342
  • 6
  • 17
  • Thanks Rae for the quick reply .. !!! The other sample Sencha application navigation view seems to work fine ... I doubt whether the code i have written is faulty ... Can you please review it and give your feedback ... Meanwhile i'll try your suggestions ... !! – yrkapil Jun 18 '12 at 07:37
  • You code the same way I'm used to too, apart from not putting the listeners in the controller. small optimization : Ext.getCmp("idIncidentsListTitle").setTitle("Welcome, " + fname); this.down("#idIncidentsListTitle").set.... should be faster, since it queries the component instead of the whole application :) You could also try creating an instance of the editor at the startup of the app and simply manipulating the data in it when disclosed and showing it. Circumvents total rendering of the page – Rae Jun 18 '12 at 08:15
  • As for the masking -> on the disclose event set Ext.Viewport.setMasked({ xtype: "loadmask", message: "Loading..."} and Ext.Viewport.setMasked(false) afterwards. – Rae Jun 18 '12 at 08:19
  • I did not use any of the transitions mentioned in the controller to push the incident editor view ... Can you please tell me what exactly creating an instance of editor at startup means ?? – yrkapil Jun 18 '12 at 08:51
  • Thanks Rae .. I tried this.down("#idIncidentsListTitle").setTitle("Welcome, " + fname); .. It worked fine in initialize function .. But Ext.Viewport.setMasked({ xtype: "loadmask", message: "Loading..."}); and Ext.Viewport.setMasked(false) did not work .. Actually when should we set the value of setMasked to false , in the controller or in the disclosure event itself?? .. Thanks for your suggestions and code help ... – yrkapil Jun 18 '12 at 10:22
  • you set the masked value to false once the editor is shown. And you set it to true( or { xtype: 'loadmask', message:'fasdf'}) on the disclose event. p.s. my mask syntax might be wrong, docs.sencha.com :) glad to help out – Rae Jun 18 '12 at 10:53
  • I did the same Rae .. but i could not see any masking ... my navigation view is really slow .. I am not getting any idea on how to solve this problem .. Please help me by posting some samples on how you handled navigation view in Sencha touch .. My mail id ..yrkapil@gmail.com .. Thanks Rae .. Looking forward for your mail – yrkapil Jun 19 '12 at 09:14
  • as i don't have allot of time its best for you to post the same question on http://www.sencha.com/forum since thats the place the guru's decide :) – Rae Jun 20 '12 at 05:17
0

I had a similar problem, in my case the solution was this:

http://www.sencha.com/forum/showthread.php?184341-Best-practice-to-prevent-App-peformance-from-Slowly-degrading-after-drilling-around&p=900511&posted=1#post900511

Lou
  • 43
  • 7