Commits

Giulio Piancastelli committed a6ed2d3

Refactorings.

Comments (0)

Files changed (3)

src/it/synergia/courses/android/lifecycle/A.java

 package it.synergia.courses.android.lifecycle;
 
-import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.View;
 import android.widget.Button;
 import android.widget.TextView;
 
-public class A extends Activity {
-	private static final String TAG = "ANDROID_LIFECYCLE";
-	
+public class A extends LifecycleActivity {
 	private int counter = 0;
 	private TextView counterView;
 	
 		log("ON_RESTART");
 	}
 
-	private void log(String method) {
-		Log.i(TAG, method + " " + getClass().getSimpleName());
-	}
-	
 	private void showCounterValue() {
-		String counterLabel = getResources().getString(R.string.counter);
+		String counterLabel = getString(R.string.counter);
 		counterView.setText(counterLabel + counter);
 	}
 

src/it/synergia/courses/android/lifecycle/B.java

 package it.synergia.courses.android.lifecycle;
 
-import android.app.Activity;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.View;
 import android.widget.Button;
 import android.widget.TextView;
 
-public class B extends Activity {
-	private static final String TAG = "ANDROID_LIFECYCLE";
-	
+public class B extends LifecycleActivity {	
 	private char letter = 'a';
 	private TextView letterView;
 
 		super.onDestroy();
 		log("ON_DESTROY");
 	}
-
-	private void log(String method) {
-		Log.i(TAG, method + " " + getClass().getSimpleName());
-	}
 	
 	private void showLetterValue() {
-		String letterLabel = getResources().getString(R.string.letter);
+		String letterLabel = getString(R.string.letter);
 		letterView.setText(letterLabel + String.valueOf(letter));
 	}
 

src/it/synergia/courses/android/lifecycle/LifecycleActivity.java

+package it.synergia.courses.android.lifecycle;
+
+import android.app.Activity;
+import android.util.Log;
+
+public class LifecycleActivity extends Activity {
+
+	private static final String TAG = "ANDROID_LIFECYCLE";
+
+	protected void log(String method) {
+		Log.i(TAG, method + " " + getClass().getSimpleName());
+	}
+
+}