diff --git a/src/main/java/nyc/c4q/AbstractAwesomeClass.java b/src/main/java/nyc/c4q/AbstractAwesomeClass.java
index e3f9c21..f55f74c 100644
--- a/src/main/java/nyc/c4q/AbstractAwesomeClass.java
+++ b/src/main/java/nyc/c4q/AbstractAwesomeClass.java
@@ -4,14 +4,17 @@
* Created by amyquispe on 5/19/15.
*/
public abstract class AbstractAwesomeClass implements AwesomeInterface {
+ private int data;
+
+
@Override
public int getData() {
- return 0;
+ return this.data;
}
@Override
- public void setData(int someData) {
-
+ public void setData(int someData) {
+ this.data = someData;
}
}
diff --git a/src/main/java/nyc/c4q/AwesomeContainer.java b/src/main/java/nyc/c4q/AwesomeContainer.java
index 64e9fd9..b40e562 100644
--- a/src/main/java/nyc/c4q/AwesomeContainer.java
+++ b/src/main/java/nyc/c4q/AwesomeContainer.java
@@ -3,16 +3,23 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
/**
* Created by amyquispe on 5/19/15.
*/
public class AwesomeContainer {
+ static ArrayList awesomeStuff;
+
public static Collection createAwesomeContainer(){
- return null;
+ awesomeStuff = new ArrayList();
+ return (List) awesomeStuff;
}
public static void addAwesomeObject(Collection awesomeContainer){
+ awesomeContainer.add(new ConcreteAwesomeClass());
+ awesomeContainer.add(new ConcreteAwesomeClass());
return;
+
}
}
diff --git a/src/main/java/nyc/c4q/ConcreteAwesomeClass.java b/src/main/java/nyc/c4q/ConcreteAwesomeClass.java
index f39acca..bbcbde0 100644
--- a/src/main/java/nyc/c4q/ConcreteAwesomeClass.java
+++ b/src/main/java/nyc/c4q/ConcreteAwesomeClass.java
@@ -4,8 +4,25 @@
* Created by amyquispe on 5/19/15.
*/
public class ConcreteAwesomeClass extends AbstractAwesomeClass {
+ private int data;
+
+
+ @Override
+ public int getData() {
+ return this.data;
+ }
+
+ @Override
+ public void setData(int someData) {
+ this.data = someData;
+ }
+
public ConcreteAwesomeClass(){
+ this.data = 4;
}
+
public ConcreteAwesomeClass(int startData){
+
+ this.data = startData;
}
}
diff --git a/src/main/java/nyc/c4q/InitialActivity.java b/src/main/java/nyc/c4q/InitialActivity.java
index 2213b83..c7fab29 100644
--- a/src/main/java/nyc/c4q/InitialActivity.java
+++ b/src/main/java/nyc/c4q/InitialActivity.java
@@ -2,6 +2,7 @@
import android.app.Activity;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
@@ -9,12 +10,20 @@
import android.widget.Button;
import android.widget.TextView;
+
public class InitialActivity extends Activity {
+ private int textCount;
+ private TextView tvCount;
+ private Button buttonPlus;
+ private Button buttonMinus;
+ private Button tileActivity;
public int counter = 0;
public SharedPreferences preferences = null;
public final static String TAG = "C4QTAG";
+
+
public void loadState(){
Log.d(TAG, "loadState()");
counter = preferences.getInt("counter", 0);
@@ -29,10 +38,66 @@ public void saveState(){
editor.commit();
}
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_initial);
- preferences = getPreferences(Context.MODE_PRIVATE);
+
+ @Override
+ protected void onPause() {
+ saveState();
+ super.onPause();
+ }
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_initial);
+
+
+ preferences = getPreferences(Context.MODE_PRIVATE);
+ loadState();
+
+
+ buttonPlus = (Button) findViewById(R.id.buttonPlus);
+ buttonMinus = (Button) findViewById(R.id.buttonMinus);
+ tvCount = (TextView) findViewById(R.id.tvCounter);
+ tvCount.setText("" + counter);
+
+// if ((preferences != null)) {
+// loadState();
+// textCount = preferences.getInt("counter", counter);
+// } else {
+// textCount = -1;
+//
+// //textCount = Integer.parseInt( (String) tvCount.getText());
+// }
+
+ View redView = findViewById(R.id.redView);
+ //redView.setBackground(-65536);
+
+
+ Button tileActivityBtn = (Button) findViewById(R.id.buttonTileActivity);
+ tileActivityBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Intent intent = new Intent(InitialActivity.this, TileActivity.class);
+ startActivity(intent);
+ }
+ });
+ }
+
+
+ public void onPlusClick(View view) {
+ counter += 1;
+ tvCount.setText("" + counter);
+ }
+
+ public void onMinusClick(View view) {
+ counter -= 1;
+ tvCount.setText("" + counter);
+ }
+
+
+
}
-}
+
+
+
+
diff --git a/src/main/java/nyc/c4q/SubFunClass.java b/src/main/java/nyc/c4q/SubFunClass.java
index ef94dce..f031f5f 100644
--- a/src/main/java/nyc/c4q/SubFunClass.java
+++ b/src/main/java/nyc/c4q/SubFunClass.java
@@ -3,7 +3,19 @@
/**
* Created by amyquispe on 5/19/15.
*/
-public class SubFunClass {
+public class SubFunClass extends SuperFunClass
+ implements AwesomeInterface{
public SubFunClass(){
}
+
+
+ @Override
+ public int getData() {
+ return 0;
+ }
+
+ @Override
+ public void setData(int someData) {
+
+ }
}
diff --git a/src/main/java/nyc/c4q/TileActivity.java b/src/main/java/nyc/c4q/TileActivity.java
index c0d4639..5f0500d 100644
--- a/src/main/java/nyc/c4q/TileActivity.java
+++ b/src/main/java/nyc/c4q/TileActivity.java
@@ -1,16 +1,37 @@
package nyc.c4q;
import android.app.Activity;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
+import android.text.Layout;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
public class TileActivity extends Activity {
+// public Color ColorDrawable(int colorRed){
+//
+// }
+
+
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tile);
+
+ View redView = findViewById(R.id.redView);
+ View greenView = findViewById(R.id.greenView);
+ View yelloWView = findViewById(R.id.yellowView);
+ View blueView = findViewById(R.id.blueView);
+ redView.setBackgroundColor(Color.RED);
+ greenView.setBackgroundColor(Color.GREEN);
+ blueView.setBackgroundColor(Color.BLUE);
+ yelloWView.setBackgroundColor(Color.YELLOW);
+
+
}
@Override
diff --git a/src/main/java/nyc/c4q/Unit1AssessmentApplication.java b/src/main/java/nyc/c4q/Unit1AssessmentApplication.java
index 84bfeb8..f61e832 100644
--- a/src/main/java/nyc/c4q/Unit1AssessmentApplication.java
+++ b/src/main/java/nyc/c4q/Unit1AssessmentApplication.java
@@ -1,7 +1,13 @@
package nyc.c4q;
import android.app.Application;
+import android.widget.Button;
+
public class Unit1AssessmentApplication extends Application {
+
+
+
+
}
diff --git a/src/main/res/layout/activity_initial.xml b/src/main/res/layout/activity_initial.xml
index 49e22b0..774370b 100644
--- a/src/main/res/layout/activity_initial.xml
+++ b/src/main/res/layout/activity_initial.xml
@@ -1,5 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_height="0dp"
+ android:text="Empty"
+ android:textSize="42dp"
+ android:layout_weight="1"
+ android:id="@+id/buttonEmpty"/>
+_
\ No newline at end of file
diff --git a/src/main/res/layout/activity_tile.xml b/src/main/res/layout/activity_tile.xml
index 4e36a11..bf33d44 100644
--- a/src/main/res/layout/activity_tile.xml
+++ b/src/main/res/layout/activity_tile.xml
@@ -7,9 +7,63 @@
android:id="@+id/activity_tile"
>
-
+
+
+
+
+
+
+
+ android:orientation="vertical"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:id="@+id/rightSide">
+
+
+
+
+
+
+
+
diff --git a/src/test/java/nyc/c4q/Unit1AssessmentTestsAndroid.java b/src/test/java/nyc/c4q/Unit1AssessmentTestsAndroid.java
index bae0f78..1bf77f8 100644
--- a/src/test/java/nyc/c4q/Unit1AssessmentTestsAndroid.java
+++ b/src/test/java/nyc/c4q/Unit1AssessmentTestsAndroid.java
@@ -4,6 +4,7 @@
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.view.View;
+import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -36,6 +37,7 @@ public void test01FixInitialActivityLayout() throws Exception {
InitialActivity activity = Robolectric.buildActivity(InitialActivity.class).setup().get();
LinearLayout layout = (LinearLayout) activity.findViewById(R.id.activity_initial);
+ assertTrue("LinearLayout(@+id/activity_initial) should have a vertical orientation", layout.getOrientation() == LinearLayout.VERTICAL);
assertTrue("LinearLayout(@+id/activity_initial)[0] should be a LinearLayout", layout.getChildAt(0) instanceof LinearLayout);
LinearLayout counterLayout = (LinearLayout) layout.getChildAt(0);
assertTrue("LinearLayout(@+id/activity_initial)[0] should have R.id.counterLayout", Helpers.getResourceId(counterLayout).equals("counterLayout"));
@@ -61,7 +63,7 @@ public void test01FixInitialActivityLayout() throws Exception {
assertEquals("-", buttonMinus.getText());
View tvCounter = counterLayout.getChildAt(1);
- assertTrue("LinearLayout(@+id/activity_initial)[0][1] should be equal to TextView(@+id/tvCounter)",
+ assertTrue("LinearLayout(@+id/counterLayout)[1] should be equal to TextView(@+id/tvCounter)",
tvCounter instanceof TextView && Helpers.getResourceId(tvCounter).equals("tvCounter"));
assertEquals("0", ((TextView) tvCounter).getText());
@@ -75,23 +77,32 @@ public void test01FixInitialActivityLayout() throws Exception {
buttonEmpty instanceof Button && Helpers.getResourceId(buttonEmpty).equals("buttonEmpty"));
assertEquals("Empty", ((Button) buttonEmpty).getText());
+ assertEquals("LinearLayout(@+id/counterLayout) should have layout_height='0dp'", 0, counterLayout.getLayoutParams().height);
+ assertEquals("LinearLayout(@+id/counterLayout) should have layout_width='match_parent'", LayoutParams.MATCH_PARENT, counterLayout.getLayoutParams().width);
assertEquals("LinearLayout(@+id/counterLayout) should have layout_weight='2'", 2, ((LinearLayout.LayoutParams) counterLayout.getLayoutParams()).weight, 0.01);
+ assertEquals("Button (@+id/buttonTileActivity) should have layout_height='0dp'", 0, buttonTileActivity.getLayoutParams().height);
+ assertEquals("Button (@+id/buttonTileActivity) should have layout_width='match_parent'", LayoutParams.MATCH_PARENT, buttonTileActivity.getLayoutParams().width);
assertEquals("Button (@+id/buttonTileActivity) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) buttonTileActivity.getLayoutParams()).weight, 0.01);
+
+ assertEquals("Button (@+id/buttonEmpty) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) buttonEmpty.getLayoutParams()).weight, 0.01);
+
+ assertEquals("Button (@+id/buttonEmpty) should have layout_height='0dp'", 0, buttonEmpty.getLayoutParams().height);
+ assertEquals("Button (@+id/buttonEmpty) should have layout_width='match_parent'", LayoutParams.MATCH_PARENT, buttonEmpty.getLayoutParams().width);
assertEquals("Button (@+id/buttonEmpty) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) buttonEmpty.getLayoutParams()).weight, 0.01);
+ assertEquals("LinearLayout(@+id/counterButtonsLayout) should have layout_height='match_parent'", LayoutParams.MATCH_PARENT, counterButtonsLayout.getLayoutParams().height);
+ assertEquals("LinearLayout(@+id/counterButtonsLayout) should have layout_width='0dp'", 0, counterButtonsLayout.getLayoutParams().width);
+
assertEquals("LinearLayout(@+id/counterButtonsLayout) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) counterButtonsLayout.getLayoutParams()).weight, 0.01);
+ assertEquals("TextView (@+id/tvCounter) should have layout_height='match_parent'", LayoutParams.MATCH_PARENT, tvCounter.getLayoutParams().height);
+ assertEquals("TextView (@+id/tvCounter) should have layout_width='0dp'", 0, tvCounter.getLayoutParams().width);
assertEquals("TextView (@+id/tvCounter) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) tvCounter.getLayoutParams()).weight, 0.01);
+ assertEquals("Button (@+id/buttonPlus) should have layout_height='0dp'", 0, buttonPlus.getLayoutParams().height);
+ assertEquals("Button (@+id/buttonPlus) should have layout_width='match_parent'", LayoutParams.MATCH_PARENT, buttonPlus.getLayoutParams().width);
assertEquals("Button (@+id/buttonPlus) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) buttonPlus.getLayoutParams()).weight, 0.01);
+ assertEquals("Button (@+id/buttonMinus) should have layout_height='0dp'", 0, buttonMinus.getLayoutParams().height);
+ assertEquals("Button (@+id/buttonMinus) should have layout_width='match_parent'", LayoutParams.MATCH_PARENT, buttonMinus.getLayoutParams().width);
assertEquals("Button (@+id/buttonMinus) should have layout_weight='1'", 1, ((LinearLayout.LayoutParams) buttonMinus.getLayoutParams()).weight, 0.01);
-
- assertEquals("LinearLayout(@+id/counterLayout) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) counterLayout.getLayoutParams()).height);
- assertEquals("Button (@+id/buttonTileActivity) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) buttonTileActivity.getLayoutParams()).height);
- assertEquals("Button (@+i/buttonEmpty) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) buttonEmpty.getLayoutParams()).height);
- assertEquals("LinearLayout(@+id/counterButtonsLayout) should have layout_width='0dp'", 0, ((LinearLayout.LayoutParams) counterButtonsLayout.getLayoutParams()).width);
- assertEquals("TextView (@+id/tvCounter) should have layout_width='0dp'", 0, ((LinearLayout.LayoutParams) tvCounter.getLayoutParams()).width);
- assertEquals("Button (@+id/buttonPlus) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) buttonPlus.getLayoutParams()).height);
- assertEquals("Button (@+id/buttonMinus) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) buttonMinus.getLayoutParams()).height);
-
}
@Test
@@ -100,7 +111,7 @@ public void test02ButtonPlusShouldIncreaseTvCounter() throws Exception {
Button buttonPlus = (Button) Helpers.findViewByIdString(activity, "buttonPlus");
TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
- assertNotNull("TextView(@+id/buttonPlus) should not be null", buttonPlus);
+ assertNotNull("Button(@+id/buttonPlus) should not be null", buttonPlus);
assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);
assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
@@ -116,7 +127,7 @@ public void test03ButtonMinusShouldDecreaseTvCounter() throws Exception {
Button buttonMinus = (Button) Helpers.findViewByIdString(activity, "buttonMinus");
TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
- assertNotNull("TextView(@+id/buttonMinus) should not be null", buttonMinus);
+ assertNotNull("Button(@+id/buttonMinus) should not be null", buttonMinus);
assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);
assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
@@ -133,8 +144,8 @@ public void test04ButtonPlusAndButtonMinusShouldWork() throws Exception {
Button buttonMinus = (Button) Helpers.findViewByIdString(activity, "buttonMinus");
TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
- assertNotNull("TextView(@+id/buttonPlus) should not be null", buttonPlus);
- assertNotNull("TextView(@+id/buttonMinus) should not be null", buttonMinus);
+ assertNotNull("Button(@+id/buttonPlus) should not be null", buttonPlus);
+ assertNotNull("Button(@+id/buttonMinus) should not be null", buttonMinus);
assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);
Random r = new Random(3680);
@@ -163,8 +174,8 @@ public void test05TvCounterStateShouldBeSavedThroughActivityLifeCycle(){
Button buttonMinus = (Button) Helpers.findViewByIdString(activity, "buttonMinus");
TextView tvCounter = (TextView) Helpers.findViewByIdString(activity, "tvCounter");
- assertNotNull("TextView(@+id/buttonPlus) should not be null", buttonPlus);
- assertNotNull("TextView(@+id/buttonMinus) should not be null", buttonMinus);
+ assertNotNull("Button(@+id/buttonPlus) should not be null", buttonPlus);
+ assertNotNull("Button(@+id/buttonMinus) should not be null", buttonMinus);
assertNotNull("TextView(@+id/tvCounter) should not be null", tvCounter);
assertEquals(0, Integer.parseInt((String) tvCounter.getText()));
@@ -258,17 +269,21 @@ public void test07FixTileActivityLayout() throws Exception {
assertThat(blueViewBackground, instanceOf(ColorDrawable.class));
assertEquals(0xff0000ff, ((ColorDrawable) blueViewBackground).getColor());
+ assertEquals("View(@+id/redView) should have layout_height='0dp'", 0, redView.getLayoutParams().height);
+ assertEquals("View(@+id/redView) should have layout_width='match_parent'", LayoutParams.MATCH_PARENT, redView.getLayoutParams().width);
assertEquals("View(@+id/redView) should have layout_weight='40'", 40, ((LinearLayout.LayoutParams) redView.getLayoutParams()).weight, 0.01);
+ assertEquals("View(@+id/greenView) should have layout_height='0dp'", 0, greenView.getLayoutParams().height);
+ assertEquals("View(@+id/greenView) should have layout_width='match_parent'", LayoutParams.MATCH_PARENT, greenView.getLayoutParams().width);
assertEquals("View(@+id/greenView) should have layout_weight='60'", 60, ((LinearLayout.LayoutParams) greenView.getLayoutParams()).weight, 0.01);
+ assertEquals("View(@+id/yellowView) should have layout_height='0dp'", 0, yellowView.getLayoutParams().height);
+ assertEquals("View(@+id/yellowView) should have layout_width='match_parent'", LayoutParams.MATCH_PARENT, yellowView.getLayoutParams().width);
assertEquals("View(@+id/yellowView) should have layout_weight='33'", 33, ((LinearLayout.LayoutParams) yellowView.getLayoutParams()).weight, 0.01);
+ assertEquals("View(@+id/whiteView) should have layout_height='0dp'", 0, whiteView.getLayoutParams().height);
+ assertEquals("View(@+id/whiteView) should have layout_width='match_parent'", LayoutParams.MATCH_PARENT, whiteView.getLayoutParams().width);
assertEquals("View(@+id/whiteView) should have layout_weight='44'", 44, ((LinearLayout.LayoutParams) whiteView.getLayoutParams()).weight, 0.01);
+ assertEquals("View(@+id/blueView) should have layout_height='0dp'", 0, blueView.getLayoutParams().height);
+ assertEquals("View(@+id/blueView) should have layout_width='match_parent'", LayoutParams.MATCH_PARENT, blueView.getLayoutParams().width);
assertEquals("View(@+id/blueView) should have layout_weight='22'", 22, ((LinearLayout.LayoutParams) blueView.getLayoutParams()).weight, 0.01);
- assertEquals("View(@+id/redView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) redView.getLayoutParams()).height);
- assertEquals("View(@+id/greenView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) greenView.getLayoutParams()).height);
- assertEquals("View(@+id/yellowView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) yellowView.getLayoutParams()).height);
- assertEquals("View(@+id/whiteView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) whiteView.getLayoutParams()).height);
- assertEquals("View(@+id/blueView) should have layout_height='0dp'", 0, ((LinearLayout.LayoutParams) blueView.getLayoutParams()).height);
-
}
}
diff --git a/src/test/java/nyc/c4q/Unit1AssessmentTestsJava.java b/src/test/java/nyc/c4q/Unit1AssessmentTestsJava.java
index a965446..ae9b679 100644
--- a/src/test/java/nyc/c4q/Unit1AssessmentTestsJava.java
+++ b/src/test/java/nyc/c4q/Unit1AssessmentTestsJava.java
@@ -7,6 +7,7 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -42,9 +43,9 @@ public void test03AbstractAwesomeClassImplementsAwesomeInterface() throws Except
@Test
public void test04AwesomeContainerContainsAwesomeObject() throws Exception{
Collection myList = AwesomeContainer.createAwesomeContainer();
- assertEquals(myList.getClass(), List.class);
+ assertEquals(myList.getClass(), ArrayList.class);
AwesomeContainer.addAwesomeObject(myList);
- assertEquals(((List) myList).get(0).getClass(), AwesomeInterface.class);
+ assertEquals(((ArrayList) myList).get(0).getClass(), ConcreteAwesomeClass.class);
}
}