From wiki.ginstr.com
Jump to: navigation, search
(Created page with "<div style="float:right; clear:both; margin-left:0.5em"><div style="background-color:#f8f9fa;border: 1px solid grey;margin-bottom:1px;padding-left:3px">added in Milestone 100<...")
 
(Action signatures)
Line 7: Line 7:
 
==Action signatures==
 
==Action signatures==
  
:;<code>[gn:act_addServiceListener]|[serviceId;target]</code>
+
:;<code>[gn:act_addServiceListener]|[serviceId;target{n}]</code>
  
 
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
 
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;"

Revision as of 13:34, 12 January 2018

added in Milestone 100

gn:act_removeServiceListener

Description
Action is used to remove a listener that is attached to ginstr launcher service, listeners can be widgets or variables (targets). When listener attached to a service is removed it will stop receiving any updates from service. i.e. if nfc listener(widget or variable) is removed from service, on scan of nfc that target will no longer receive tag content.
Action returns
void

Action signatures

[gn:act_addServiceListener]|[serviceId;target{n}]
Parameter Description
serviceId Name of the service which will be used
  • Valid services:
    • nfc, nfc service
    • gps, gps service
target{n} target id's of the widgets which were already added as listeners to the service via gn:act_addServiceListener action

Example

On before load service is started, listener is attached. After first nfc scan we decided that action set "gn:act_set" should be executed and we no longer want to save nfc scan events into widget so we call "gn:act_removeServiceListener". If we have 2 tags A and B only tag that is after coming to screen first scanned will be stored to listener because upon scan we remove the listener so any next scan will not store data to any listener.

hardware nfc data

TAG A
id: 04C357BA482780
TAG B
id: 99C357BA482799

initial contents

@+id/screen_nfc_input widget

screen.xml
<FrameLayout
    android:id="@+id/exampleFrame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    gn:act_beforeLoad="[gn:act_service]|[nfc;start;triggerActionSet,@+id/exampleFrame,gn:act_set],[gn:act_addServiceListener]|[nfc;@+id/screen_nfc_input]"
    gn:act_set="[gn:act_removeServiceListener]|[nfc;@+id/screen_nfc_input]" />

 <com.ginstr.widgets.GnEditText
    android:id="@+id/screen_nfc_input"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    gn:dataType="text"
    gn:s_sourceType="input"/>
after first nfc scan of TAG A contents

@+id/screen_nfc_input widget 04C357BA482780

after second nfc scan of TAG B contents

@+id/screen_nfc_input widget 04C357BA482780