Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/nyc/c4q/AbstractAwesomeClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
*/
public abstract class AbstractAwesomeClass implements AwesomeInterface {

int num = 4;

@Override
public int getData() {
return 0;
return num;
}

@Override
public void setData(int someData) {

num = someData;
}
}
10 changes: 8 additions & 2 deletions src/main/java/nyc/c4q/AwesomeContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
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 {

private static ArrayList myList = new ArrayList();
private static ConcreteAwesomeClass o = new ConcreteAwesomeClass();

public static Collection createAwesomeContainer(){
return null;

return myList;
}

public static void addAwesomeObject(Collection awesomeContainer){
return;
awesomeContainer.add(o);
}
}
2 changes: 1 addition & 1 deletion src/main/java/nyc/c4q/ConcreteAwesomeClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Created by amyquispe on 5/19/15.
*/
public class ConcreteAwesomeClass extends AbstractAwesomeClass {
public class ConcreteAwesomeClass extends AbstractAwesomeClass implements AwesomeInterface {
public ConcreteAwesomeClass(){
}
public ConcreteAwesomeClass(int startData){
Expand Down
110 changes: 109 additions & 1 deletion src/main/java/nyc/c4q/InitialActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class InitialActivity extends Activity {
public class InitialActivity extends Activity implements View.OnClickListener {

Button plus;
Button minus;
Button empty;
Button tileActivity;
TextView tvCounter;
public int counter = 0;
public SharedPreferences preferences = null;
public final static String TAG = "C4QTAG";
Expand All @@ -33,6 +40,107 @@ public void saveState(){
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_initial);

SharedPreferences preferences1 = getPreferences(MODE_PRIVATE);

plus = (Button)findViewById(R.id.buttonPlus);
minus = (Button)findViewById(R.id.buttonMinus);
empty = (Button)findViewById(R.id.buttonEmpty);
tileActivity = (Button)findViewById(R.id.buttonTileActivity);

tvCounter = (TextView)findViewById(R.id.tvCounter);
String counterValue = tvCounter.getText().toString();
tvCounter.setText(preferences1.getString("Counter", counterValue));

plus.setOnClickListener(this);
minus.setOnClickListener(this);
empty.setOnClickListener(this);
tileActivity.setOnClickListener(this);

preferences = getPreferences(Context.MODE_PRIVATE);
}

@Override
protected void onResume() {
super.onResume();

SharedPreferences preference = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();

TextView tvCounter = (TextView)findViewById(R.id.tvCounter);
String counter = tvCounter.getText().toString();

editor.putString("Counter", counter);
}

@Override
protected void onSaveInstanceState(Bundle savedInstanceSate) {
super.onSaveInstanceState(savedInstanceSate);

TextView tvCounter = (TextView)findViewById(R.id.tvCounter);
String countValue = tvCounter.getText().toString();

savedInstanceSate.putString("Count", countValue);
}

@Override
protected void onPause() {
super.onPause();

SharedPreferences preference = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();

TextView tvCounter = (TextView)findViewById(R.id.tvCounter);
String counter = tvCounter.getText().toString();

editor.putString("Counter", counter);
}

@Override
protected void onStop() {
super.onStop();

SharedPreferences preference = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();

TextView tvCounter = (TextView)findViewById(R.id.tvCounter);
String counter = tvCounter.getText().toString();

editor.putString("Counter", counter);
}

@Override
protected void onDestroy() {
super.onDestroy();

SharedPreferences preference = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();

TextView tvCounter = (TextView)findViewById(R.id.tvCounter);
String counter = tvCounter.getText().toString();

editor.putString("Counter", counter);
}

@Override
public void onClick(View v){
if (v == plus){
counter++;
tvCounter.setText(Integer.toString(counter));
}
if (v == minus){
counter--;
tvCounter.setText(Integer.toString(counter));
}
if (v == empty){
counter = 0;
tvCounter.setText(Integer.toString(counter));
}
if (v == tileActivity){
Intent nextStartedActivity = new Intent(InitialActivity.this, TileActivity.class);
InitialActivity.this.startActivity(nextStartedActivity);
}
}


}
12 changes: 11 additions & 1 deletion src/main/java/nyc/c4q/SubFunClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
/**
* 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) {

}
}
68 changes: 63 additions & 5 deletions src/main/res/layout/activity_initial.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,68 @@
tools:context="nyc.c4q.InitialActivity"
android:id="@+id/activity_initial">

<TextView
android:id="@+id/text"
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:id="@+id/counterLayout"
android:layout_weight="2">

<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:id="@+id/counterButtonsLayout"
android:layout_weight="1">

<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="+"
android:id="@+id/buttonPlus"
android:layout_weight="1"
android:textSize="40sp"
android:onClick="onClick" />

<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="-"
android:id="@+id/buttonMinus"
android:layout_weight="1"
android:textSize="40sp"
android:onClick="onClick" />
</LinearLayout>

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="0"
android:id="@+id/tvCounter"
android:layout_weight="1"
android:layout_gravity="center"
android:gravity="center"
android:textSize="40sp" />
</LinearLayout>

<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="TileActivity"
android:id="@+id/buttonTileActivity"
android:layout_weight="1"
android:gravity="center"
android:textSize="35sp"
android:textStyle="normal"
android:typeface="normal" />

<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="InitialActivity"
/>
android:layout_height="0dp"
android:text="Empty"
android:id="@+id/buttonEmpty"
android:layout_weight="1"
android:textSize="35sp"
android:onClick="onClick" />

</LinearLayout>
57 changes: 52 additions & 5 deletions src/main/res/layout/activity_tile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,58 @@
android:layout_height="match_parent"
tools:context="nyc.c4q.TileActivity"
android:id="@+id/activity_tile"
>
android:orientation="horizontal">

<TextView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="TileActivity"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/leftSide"
android:layout_weight="1">

<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/redView"
android:autoText="false"
android:background="@color/red"
android:layout_weight="40" />

<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/greenView"
android:background="@color/green"
android:layout_weight="60" />
</LinearLayout>

<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/rightSide"
android:layout_weight="1">

<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/yellowView"
android:background="@color/yellow"
android:layout_weight="33" />

<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/whiteView"
android:background="@color/white"
android:layout_weight="44" />

<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/blueView"
android:background="@color/blue"
android:layout_weight="22" />
</LinearLayout>

</LinearLayout>
8 changes: 8 additions & 0 deletions src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#ffff0000</color>
<color name="green">#ff00ff00</color>
<color name="yellow">#ffffff00</color>
<color name="white">#ffffffff</color>
<color name="blue">#ff0000ff</color>
</resources>
1 change: 1 addition & 0 deletions src/test/java/nyc/c4q/Unit1AssessmentTestsJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down