15. uix.jarの Rules/ UselessLayout.rule ファイル
// Rule: UselessLayout
//
// Description: Checks whether current node can be removed.
//
// Conditions: com.android.layoutopt.uix.groovy.LayoutA
// - The node has children nalysisCategory
// - The node does not have siblings public static LayoutAnalysis leftShift(
// - The node's parent is not a scroll view (horizontal or vertical)
// - The node does not have a background or its parent does not have a
// background or neither the node and its parent have a background
// - The parent is not a <merge/>
if (!node.isRoot() && !(node['..'].name() in ["ScrollView", "HorizontalScrollView"])
&&
node['..']['*'].size() == 1 && node['*'].size() > 0 &&
((node.'@android:background' ||
node['..'].'@android:background') || (!node.'@android:background' &&
!node['..'].'@android:background'))) {
analysis << "This ${node.name()} layout or its ${node['..'].name()} parent is " +
"${node['..'].'@android:id' ? "possibly useless" : "useless"}"
}
16. com.android.layoutopt.uix.groovy.LayoutAnalysisCategory
public static int getStartLine(Node node)
public static int getEndLine(Node node)
com.android.layoutopt.uix.groovy.LayoutAnalysisCategory
public static class Issue
内部Innerクラスで使っている
からあえて宣言書いていると思われ
com.android.layoutopt.uix.LayoutAnalysis
public int getStartLine() {
return LayoutAnalysisCategory.getStartLine(this.mNode);
}
public int getEndLine() {
return LayoutAnalysisCategory.getEndLine(this.mNode);
}
26. そんなに便利なら何で
Androidに使われてないのw
一応こんなのあります<要Linux環境
@uehaj さん解説 Groovy on android by discobot
http://d.hatena.ne.jp/uehaj/20100515/1273934021
CentOS5.5で試して動かなかったのでパッチココに置きました
https://github.com/kimukou/gradlestudy/tree/master/discobot
27. 使用コードイメージ(UTF8保存)
package org.jggug.sample
import android.app.Activity;
import android.os.Bundle
import android.widget.TextView
public class Main extends Activity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
TextView tv = new TextView(this)
def list = ["Welcome","to", "discobot." , "¥nAnd", "good",
"luck", "with", "Main!",日本語もOK!"]
def str = ""
list.each {
str += it + " "
}
tv.setText(str)
this.setContentView(tv)
}
}