AI2 Component  (Version nb184)
Picker.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2009-2011 Google, All Rights reserved
3 // Copyright 2011-2012 MIT, All rights reserved
4 // Released under the Apache License, Version 2.0
5 // http://www.apache.org/licenses/LICENSE-2.0
6 
7 package com.google.appinventor.components.runtime;
8 
13 import android.content.Intent;
14 
19 @SimpleObject
20 public abstract class Picker extends ButtonBase implements ActivityResultListener {
21  protected final ComponentContainer container;
22 
23  /* Used to identify the call to startActivityForResult. Will be passed back into the
24  resultReturned() callback method. */
25  protected int requestCode;
26 
28  super(container);
29  this.container = container;
30  }
31 
35  protected abstract Intent getIntent();
36 
37  @Override
38  public void click() {
39  BeforePicking();
40  if (requestCode == 0) { // only need to register once
42  }
43  container.$context().startActivityForResult(getIntent(), requestCode);
44  String openAnim = container.$form().getOpenAnimType();
46  }
47 
48  // Functions
49 
53  @SimpleFunction(description = "Opens the %type%, as though the user clicked on it.")
54  public void Open() {
55  click();
56  }
57 
58  // Events
59 
66  public void BeforePicking() {
67  EventDispatcher.dispatchEvent(this, "BeforePicking");
68  }
69 
75  public void AfterPicking() {
76  EventDispatcher.dispatchEvent(this, "AfterPicking");
77  }
78 }
com.google.appinventor.components.runtime.EventDispatcher
Definition: EventDispatcher.java:22
com.google.appinventor.components.annotations.SimpleFunction
Definition: SimpleFunction.java:23
com.google.appinventor.components.runtime.util
-*- mode: java; c-basic-offset: 2; -*-
Definition: AccountChooser.java:7
com.google.appinventor.components
com.google.appinventor.components.runtime.util.AnimationUtil
Definition: AnimationUtil.java:24
com.google.appinventor.components.annotations.SimpleEvent
Definition: SimpleEvent.java:20
com.google.appinventor.components.runtime.Picker.Open
void Open()
Definition: Picker.java:54
com.google.appinventor.components.runtime.Form.getOpenAnimType
String getOpenAnimType()
Definition: Form.java:1687
com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent
static boolean dispatchEvent(Component component, String eventName, Object...args)
Definition: EventDispatcher.java:188
com.google.appinventor.components.runtime.util.AnimationUtil.ApplyOpenScreenAnimation
static void ApplyOpenScreenAnimation(Activity activity, String animType)
Definition: AnimationUtil.java:81
com.google.appinventor.components.runtime.Picker.requestCode
int requestCode
Definition: Picker.java:25
com.google.appinventor.components.runtime.Picker.AfterPicking
void AfterPicking()
Definition: Picker.java:75
com.google.appinventor.components.runtime.Picker.container
final ComponentContainer container
Definition: Picker.java:21
com.google.appinventor.components.runtime.ComponentContainer
Definition: ComponentContainer.java:16
com.google.appinventor.components.runtime
Copyright 2009-2011 Google, All Rights reserved.
Definition: AccelerometerSensor.java:8
com.google.appinventor.components.runtime.ActivityResultListener
Definition: ActivityResultListener.java:16
com.google.appinventor.components.runtime.Picker
Definition: Picker.java:20
com.google.appinventor.components.annotations.SimpleObject
Definition: SimpleObject.java:23
com.google
com.google.appinventor.components.runtime.ButtonBase
Definition: ButtonBase.java:47
com
com.google.appinventor.components.runtime.ComponentContainer.$form
Form $form()
com.google.appinventor.components.runtime.Picker.getIntent
abstract Intent getIntent()
com.google.appinventor.components.runtime.ComponentContainer.$context
Activity $context()
com.google.appinventor.components.runtime.Picker.click
void click()
Definition: Picker.java:38
com.google.appinventor.components.runtime.Form.registerForActivityResult
int registerForActivityResult(ActivityResultListener listener)
Definition: Form.java:638
com.google.appinventor.components.runtime.Picker.Picker
Picker(ComponentContainer container)
Definition: Picker.java:27
com.google.appinventor.components.annotations
com.google.appinventor
com.google.appinventor.components.runtime.Picker.BeforePicking
void BeforePicking()
Definition: Picker.java:66