Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-20055

iOS: Refactor previewContext to be more memory-efficient

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: Release 5.1.0
    • Fix Version/s: Release 5.2.0
    • Component/s: iOS
    • Labels:
      None
    • Story Points:
      3
    • Sprint:
      2015 Sprint 24 SDK

      Description

      The current Ti.UI.iOS.PreviewContent implementation works. But to make it even more efficient related to memory management, I refactored a few parts:

      • Remove manual properties of TiUIiOSPreviewContext inside the TiPreviewingDelegate and access them through the previewContext property (since the delegate is not public and it keeps the object dependencies clean)
      • Release some properties that have not been released before
      • Add missing code docs in the TiPreviewingDelegate header file
      • Change counter index from int to NSUInteger and remove unused actionGroupIndex property that have been used during testing
      • Enable ARC in all related files

      Demo code (should work exactly like before):

      var actions = [];
      var win = Ti.UI.createWindow({
          backgroundColor: "white"
      });
       
      // The view to be previewed while popping.
      var previewView = Ti.UI.createView({
          backgroundColor: "blue"
      });
       
      // The window to be opened after popping the preview.
      var detailWindow = Ti.UI.createWindow({
          backgroundColor: "yellow"
      });
       
      detailWindow.add(Ti.UI.createLabel({
          text: "You made it!"
      }));
       
      // The actions to be added to the preview context.
      var action = Ti.UI.iOS.createPreviewAction({
          title: "Preview Action",
          style: Ti.UI.iOS.PREVIEW_ACTION_STYLE_DEFAULT
      });
       
      action.addEventListener("click", function(e) {
          alert("Title: " + e.title + " / Style: " + e.style+" / Index: " + e.index);
      });
       
      var subAction = Ti.UI.iOS.createPreviewAction({
          title: "Preview Subaction"
      })
       
      subAction.addEventListener("click", function(e) {
          alert("Title: " + e.title + " / Style: " + e.style+" / Subindex: " + e.index);
      });
       
      var actionGroup = Ti.UI.iOS.createPreviewActionGroup({
          title: "More actions...",
          style: Ti.UI.iOS.PREVIEW_ACTION_STYLE_DESTRUCTIVE,
          actions: [subAction]
      });
       
      actions.push(action);
      actions.push(actionGroup);
       
      // Create the preview context
      var context = Ti.UI.iOS.createPreviewContext({
          preview: previewView,
          actions: actions, // Can have both Ti.UI.iOS.PreviewAction + Ti.UI.iOS.PreviewActionGroup
           contentHeight: 300 // When unspecified, we use the available height
      });
       
      // Fired after popping the preview
      context.addEventListener("pop", function(e) {
          detailWindow.open();
      });
       
      // Assign the preview context
      var button = Ti.UI.createButton({
          previewContext: context, // Will be ignored on unsupported devices
          title : "Open Window!",
          backgroundColor: "#A6171C",
          width: 200,
          height: 50,
          tintColor: "#fff"
      });
       
      win.add(button);
      win.open();
      

        Attachments

          Activity

            People

            • Assignee:
              hknoechel Hans Knöchel
              Reporter:
              hknoechel Hans Knöchel
              Reviewer:
              Pedro Enrique (Inactive)
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code