30. public static class PlaceholderFragment extends Fragment {
private boolean mClickFlag;
public boolean isClickFlag() {
return mClickFlag;
}
Field Prefixの設定
30
33. インラインの記述をローカル変数に移動
33
Command + Option + V
Control + Alt + V
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content,
new PlaceholderFragment(), "main")
.commit();
}
34. 変数をフィールドに移動
34
Command + Option + F
Control + Alt + F
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Fragment fragment = new PlaceholderFragment();
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content,
fragment, "main")
.commit();
}
35. 変数をフィールドに移動
35
private Fragment fragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fragment = new PlaceholderFragment();
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content,
fragment, "main")
.commit();
}
36. 処理をメソッドへ切り出す
36
Command + Option + M
Control + Alt + M
private void initializa() {
placeholderFragment = new PlaceholderFragment();
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content,
placeholderFragment, "main")
.commit();
}
44. テストを実行
io.keiji.tryandroidstudio.UserTest > 眼鏡をかけている
[Nexus_5_API_18(AVD) - 4.3.1] [31mFAILED [0m
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
:app:connectedDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task
':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at:
file:///Users/keiji_ariyama/Desktop/
TryAndroidStudio/app/build/reports/androidTests/
connected/index.html
44
48. テストを実行
:app:testDebugUnitTest
io.keiji.tryandroidstudio.UserTest > 眼鏡をかけている
FAILED
java.lang.AssertionError at UserTest.java:11
2 tests completed, 1 failed
:app:testDebugUnitTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:testDebugUnitTest'.
> There were failing tests. See the report at:
file:///Users/keiji_ariyama/Desktop/
TryAndroidStudio/app/build/reports/tests/debug/
index.html
* Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log
output.
BUILD FAILED
Total time: 2.389 secs