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

Android: showTimePickerDialog doesn't work

    Details

    • Type: Bug
    • Status: Reopened
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: Release 3.2.1
    • Fix Version/s: None
    • Component/s: Android
    • Labels:
    • Environment:

      OS: Debian 7 64bit
      Device: Nexus 5
      Ti: 3.2.1 GA

      Description

      So, the issue is that showTimePickerDialog does nothing when I call it and it throws no errors.

      showDatePickerDialog works as expected.

      And here's the code ->

      addJob.xml

      <Alloy>
      	<Window
              title="Add Job"
              exitOnClose="true"
              navBarHidden="true"
              layout="vertical"
              width="90%">
              <Picker
                  id="locationField"
                  hintText="LOCATION"
                  borderStyle="Ti.UI.INPUT_BORDERSTYLE_LINE"
                  color="#acacac"
                  top="10"
                  height="60"
                  width="100%" />
              <TextField
                  id="descriptionField"
                  hintText="DESCRIPTION"
                  borderStyle="Ti.UI.INPUT_BORDERSTYLE_LINE"
                  color="#acacac"
                  top="10"
                  height="60"
                  width="100%" />
              <TextField
                  id="dateField"
                  hintText="DATE"
                  editable="false"
                  borderStyle="Ti.UI.INPUT_BORDERSTYLE_LINE"
                  color="#acacac"
                  top="10"
                  height="60"
                  width="100%"
                  onClick="openDatePicker" />
              <TextField
                  id="startTimeField"
                  hintText="START TIME"
                  editable="false"
                  borderStyle="Ti.UI.INPUT_BORDERSTYLE_LINE"
                  color="#acacac"
                  top="10"
                  height="60"
                  width="100%"
                  onClick="openStartTimePicker" />
      	</Window>
      </Alloy>
      

      addJob.js

      var window = $.getView();
       
      if (Ti.UI.Android){
      	window.windowSoftInputMode = Ti.UI.Android.SOFT_INPUT_ADJUST_PAN;
      }
       
      var datePickerController = Alloy.createController('fields/datePickerDialog');
      var startTimePickerController = Alloy.createController('fields/timePickerDialog');
       
      function openDatePicker(e){
      	datePickerController.showForTextField(e.source);
      }
       
      function openStartTimePicker(e){
      	startTimePickerController.showForTextField(e.source);
      }
      

      fields/timePickerDialog.xml

      <Alloy>
          <Picker type="Ti.UI.PICKER_TYPE_TIME" />
      </Alloy>
      

      fields/timePickerDialog.js

      var args = arguments[0] || null;
       
      var timePicker = $.getView();
       
      if(args){
      	timePicker.applyProperties(args);
      }
       
      function showForTextField(textField, opts){
       
      	opts = opts || {};
       
      	opts.callback = function(e) {
      		if(!e.cancel) {
      			var timeValue = e.value;
      			textField.value = timeValue.getHours() + ':' + timeValue.getMinutes();
      			textField.blur();
      		}
      	};
       
      	timePicker.showTimePickerDialog(opts);
      }
       
      exports.showForTextField = showForTextField;
      

      fields/datePickerDialog.xml

      <Alloy>
          <Picker type="Ti.UI.PICKER_TYPE_DATE" />
      </Alloy>
      

      fields/datePickerDialog.js

      var args = arguments[0] || null;
       
      var datePicker = $.getView();
       
      if(args){
      	datePicker.applyProperties(args);
      }
       
      function showForTextField(textField, opts){
       
      	opts = opts || {};
       
      	opts.callback = function(e) {
      		if(!e.cancel) {
      			var dateValue = e.value;
      			textField.value = dateValue.getDate() + '/'
      				+ (dateValue.getMonth() + 1) + '/'
      				+ dateValue.getFullYear();
      			textField.blur();
      		}
      	};
       
      	datePicker.showDatePickerDialog(opts);
      }
       
      exports.showForTextField = showForTextField;
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                lsdriscoll Lee Driscoll
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-18455
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration