2013年5月20日星期一

ADF_222:ADF Mobile 11.1.2.4 Samples 介绍(8):GestureDemo

开发运行环境:JDeveloper 11.1.2.4 + Android SDK r21.1

GestureDemo演示了各种手势的触发方式,比如:滑动(swipeRight,swipeLeft,swipeUp,swipeDown),按住并保持(tapHold)。

知识点:

1. 在amx:commandLink组件上设置手势
(1)在amx:commandLink滑动,触发setPropertyListener
<amx:commandLink id="pSR" text="Swipe Right (property)" inlineStyle="color:black">
    <amx:setPropertyListener from="p:SR" to="#{pageFlowScope.gesture}" type="swipeRight"/>
</amx:commandLink>
(2)在amx:commandLink滑动,触发actionListener,调用Managed Bean中的相应方法
<amx:commandLink id="mSR" text="Swipe Right (method)" inlineStyle="color:black">
    <amx:actionListener binding="#{GestureBean.SwipeRightHandler}" type="swipeRight"/>
</amx:commandLink>
(3)在amx:commandLink滑动,触发showPopupBehavior,弹出popup窗口
<amx:commandLink id="dSR" text="Swipe Right to show popup" inlineStyle="color:black">
    <amx:showPopupBehavior popupId="popup1" type="swipeRight" align="overlapBottom" alignId="pp1"/>
</amx:commandLink>
(4)在amx:commandLink滑动,触发closePopupBehavior,关闭popup窗口
<amx:commandLink id="clSR" text="Swipe Right to close popup" inlineStyle="color:black">
    <amx:closePopupBehavior popupId="popup1" type="swipeRight"/>
</amx:commandLink>

2. 在amx:listItem 组件上设置手势
(1)在amx:listItem 滑动,触发setPropertyListener
<amx:listItem id="SRp" showLinkIcon="false">
    <amx:outputText id="tSRp" value="Swipe Right (property)"/>
    <amx:setPropertyListener from="p:SR" to="#{pageFlowScope.gesture}" type="swipeRight"/>
</amx:listItem>
(2)在amx:listItem 滑动,触发actionListener,调用Managed Bean中的相应方法
<amx:listItem id="SRm" showLinkIcon="false">
    <amx:outputText id="tSRm" value="Swipe Right (method)"/>
    <amx:actionListener binding="#{GestureBean.SwipeRightHandler}" type="swipeRight"/>
</amx:listItem>
(3)在amx:listItem 滑动,触发showPopupBehavior,弹出popup窗口
<amx:listItem id="SRd" showLinkIcon="false">
    <amx:outputText id="tSRd" value="Swipe Right (popup)"/>
    <amx:showPopupBehavior popupId="popup1" type="swipeRight" align="overlapBottom" alignId="pp1"/>
</amx:listItem>

3. GestureHandler.java 代码
package mobile;

import javax.el.ValueExpression;

import oracle.adfmf.amx.event.ActionEvent;
import oracle.adfmf.framework.api.AdfmfJavaUtilities;

public class GestureHandler implements oracle.adfmf.feature.LifeCycleListener {
    public GestureHandler() {
    }

    public void activate() {
        ValueExpression ve = AdfmfJavaUtilities.getValueExpression("#{pageFlowScope.gesture}", String.class);
        String gesture = "";
        ve.setValue(AdfmfJavaUtilities.getAdfELContext(), gesture);
    }

    public void deactivate() {
    }


    public void SwipeRightHandler(ActionEvent actionEvent) {
        ValueExpression ve = AdfmfJavaUtilities.getValueExpression("#{pageFlowScope.gesture}", String.class);
        String gesture = "m:SR";
        ve.setValue(AdfmfJavaUtilities.getAdfELContext(), gesture);
    }

    public void SwipeLeftHandler(ActionEvent actionEvent) {
        ValueExpression ve = AdfmfJavaUtilities.getValueExpression("#{pageFlowScope.gesture}", String.class);
        String gesture = "m:SL";
        ve.setValue(AdfmfJavaUtilities.getAdfELContext(), gesture);
    }

    public void SwipeUpHandler(ActionEvent actionEvent) {
        ValueExpression ve = AdfmfJavaUtilities.getValueExpression("#{pageFlowScope.gesture}", String.class);
        String gesture = "m:SU";
        ve.setValue(AdfmfJavaUtilities.getAdfELContext(), gesture);
    }

    public void SwipeDownHandler(ActionEvent actionEvent) {
        ValueExpression ve = AdfmfJavaUtilities.getValueExpression("#{pageFlowScope.gesture}", String.class);
        String gesture = "m:SD";
        ve.setValue(AdfmfJavaUtilities.getAdfELContext(), gesture);
    }

    public void TapHoldHandler(ActionEvent actionEvent) {
        ValueExpression ve = AdfmfJavaUtilities.getValueExpression("#{pageFlowScope.gesture}", String.class);
        String gesture = "m:TH";
        ve.setValue(AdfmfJavaUtilities.getAdfELContext(), gesture);
    }
}

没有评论: