aboutsummaryrefslogtreecommitdiffstats
path: root/android-templates/resources/liveTemplates/Android.xml
blob: 222f70892926f13acd2050f4fd5d9553523eb5ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?xml version="1.0" encoding="UTF-8"?>
<templateSet group="Android">
  <template name="Toast" value="android.widget.Toast.makeText($context$, &quot;$text$&quot;, Toast.LENGTH_SHORT).show();" description="Create a new Toast" toReformat="true" toShortenFQNames="true">
    <variable name="context" expression="variableOfType(&quot;android.content.Context&quot;)" defaultValue="" alwaysStopAt="true" />
    <variable name="text" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
    </context>
  </template>
  <template name="rouiT" value="getActivity().runOnUiThread(new java.lang.Runnable() {&#10;    @Override&#10;    public void run() {&#10;        $cursor$&#10;    }&#10;});" description="runOnUIThread" toReformat="true" toShortenFQNames="true">
    <variable name="cursor" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
    </context>
  </template>
  <template name="fbc" value="($cast$) findViewById(R.id.$resId$);" description="findViewById with cast" toReformat="true" toShortenFQNames="true">
    <variable name="cast" expression="expectedType()" defaultValue="" alwaysStopAt="true" />
    <variable name="resId" expression="completeSmart()" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
      <option name="JAVA_EXPRESSION" value="true" />
    </context>
  </template>
  <template name="foreach" value="for ($i$ : $data$) {&#10;    $cursor$&#10;}" description="Create a for each loop" toReformat="true" toShortenFQNames="true">
    <variable name="i" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="data" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="cursor" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
    </context>
  </template>
  <template name="sbc" value="///////////////////////////////////////////////////////////////////////////&#10;// $blockName$&#10;///////////////////////////////////////////////////////////////////////////" description="block comment for structuring code" toReformat="true" toShortenFQNames="true">
    <variable name="blockName" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_DECLARATION" value="true" />
    </context>
  </template>
  <template name="Sfmt" value="String.format(&quot;$string$&quot;, $params$);" description="String format" toReformat="true" toShortenFQNames="true">
    <variable name="string" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="params" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
      <option name="JAVA_EXPRESSION" value="true" />
    </context>
  </template>
  <template name="IntentView" value="android.content.Intent view = new Intent();&#10;view.setAction(Intent.ACTION_VIEW);&#10;view.setData(android.net.Uri.parse($url$));&#10;startActivity(view);" description="Creates an Intent with ACTION_VIEW" toReformat="true" toShortenFQNames="true">
    <variable name="url" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
    </context>
  </template>
  <template name="ViewConstructors" value="public $class$(android.content.Context context) {&#10;    this(context, null);&#10;}&#10;&#10;public $class$(Context context, android.util.AttributeSet attrs) {&#10;    this(context, attrs, 0);&#10;}&#10;&#10;public $class$(Context context, AttributeSet attrs, int defStyle) {&#10;    super(context, attrs, defStyle);&#10;    $cursor$&#10;}" description="Adds generic view constructors" toReformat="true" toShortenFQNames="true">
    <variable name="cursor" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="class" expression="className()" defaultValue="" alwaysStopAt="false" />
    <context>
      <option name="JAVA_DECLARATION" value="true" />
    </context>
  </template>
  <template name="rgS" value="$resources$.getString(R.string.$stringId$)" description="get a String from resources" toReformat="true" toShortenFQNames="true">
    <variable name="resources" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="stringId" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
      <option name="JAVA_EXPRESSION" value="true" />
    </context>
  </template>
  <template name="wrapIt" value="task wrapper(type: Wrapper) {&#10;    gradleVersion = &quot;$version$&quot;&#10;}" description="adds a gradle wrapper task" toReformat="true" toShortenFQNames="true">
    <variable name="version" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="GROOVY_DECLARATION" value="true" />
    </context>
  </template>
  <template name="newInstance" value="public static $fragment$ newInstance($args$) {&#10;    $nullChecks$&#10;    android.os.Bundle args = new Bundle();&#10;    $addArgs$&#10;    $fragment$ fragment = new $fragment$();&#10;    fragment.setArguments(args);&#10;    return fragment;&#10;}" description="create a new Fragment instance with arguments" toReformat="true" toShortenFQNames="true">
    <variable name="fragment" expression="className()" defaultValue="" alwaysStopAt="true" />
    <variable name="args" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="nullChecks" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="addArgs" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_DECLARATION" value="true" />
    </context>
  </template>
  <template name="noInstance" value="private $class$() {&#10;    //no instance&#10;}" description="private empty constructor to prohibit instance creation" toReformat="true" toShortenFQNames="true">
    <variable name="class" expression="className()" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_DECLARATION" value="true" />
    </context>
  </template>
  <template name="starter" value="public static void start(android.content.Context context) {&#10;    android.content.Intent starter = new Intent(context, $ACTIVITY$.class);&#10;    starter.putExtra($CURSOR$);&#10;    context.startActivity(starter);&#10;}" description="Creates a static start(...) helper method to start an Activity" toReformat="false" toShortenFQNames="true">
    <variable name="ACTIVITY" expression="className()" defaultValue="" alwaysStopAt="true" />
    <variable name="CURSOR" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_DECLARATION" value="true" />
    </context>
  </template>
  <template name="const" value="private static final int $name$ = $value$;" description="Define android style int constant" toReformat="true" toShortenFQNames="true">
    <variable name="name" expression="" defaultValue="NAME" alwaysStopAt="true" />
    <variable name="value" expression="groovyScript(&quot;new Random().nextInt(1000)&quot;)" defaultValue="0" alwaysStopAt="false" />
    <context>
      <option name="JAVA_DECLARATION" value="true" />
    </context>
  </template>
  <template name="key" value="private static final String KEY_$value$ = &quot;$value$&quot;;" description="Key for a bundle" toReformat="true" toShortenFQNames="true">
    <variable name="value" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_DECLARATION" value="true" />
    </context>
  </template>
  <template name="visible" value="$VIEW$.setVisibility(View.VISIBLE);" description="Set view visibility to VISIBLE" toReformat="true" toShortenFQNames="true">
    <variable name="VIEW" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
    </context>
  </template>
  <template name="gone" value="$VIEW$.setVisibility(android.view.View.GONE);" description="Set view visibility to GONE" toReformat="true" toShortenFQNames="true">
    <variable name="VIEW" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
    </context>
  </template>
</templateSet>