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 someData;

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

@Override
public void setData(int someData) {

this.someData = someData;
}
}
11 changes: 7 additions & 4 deletions src/main/java/nyc/c4q/AwesomeContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

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 {
public static Collection createAwesomeContainer(){
return null;
public static ArrayList<AwesomeInterface> createAwesomeContainer(){
ArrayList list = new ArrayList<AwesomeInterface>();
return list;
}

public static void addAwesomeObject(Collection awesomeContainer){
return;
awesomeContainer.add(new ConcreteAwesomeClass());

}
}
2 changes: 2 additions & 0 deletions src/main/java/nyc/c4q/ConcreteAwesomeClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
*/
public class ConcreteAwesomeClass extends AbstractAwesomeClass {
public ConcreteAwesomeClass(){
this.setData(4);
}
public ConcreteAwesomeClass(int startData){
this.setData(startData);
}
}
69 changes: 67 additions & 2 deletions src/main/java/nyc/c4q/InitialActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -11,19 +12,25 @@

public class InitialActivity extends Activity {

Button buttonPlus;
Button buttonMinus;
TextView tvCounter;

Button buttonTileActivity;

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);
Log.d(TAG, "loadState(): counter=="+counter);
Log.d(TAG, "loadState(): counter==" + counter);
}

public void saveState(){
Log.d(TAG, "saveState()");
Log.d(TAG, "saveState(): counter=="+counter);
Log.d(TAG, "saveState(): counter==" + counter);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("counter", counter);
editor.commit();
Expand All @@ -33,6 +40,64 @@ public void saveState(){
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_initial);

buttonPlus = (Button) findViewById(R.id.buttonPlus);
buttonMinus = (Button) findViewById(R.id.buttonMinus);
tvCounter = (TextView) findViewById(R.id.tvCounter);

buttonTileActivity = (Button) findViewById(R.id.buttonTileActivity);

SharedPreferences sharedPref = this.getPreferences(Context.MODE_PRIVATE);
tvCounter.setText(sharedPref.getString("tvCounter", "0"));


if (savedInstanceState != null) {
tvCounter.setText(savedInstanceState.getString("tvCounter"));
}


buttonPlus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
counter = Integer.parseInt(tvCounter.getText().toString());
counter++;
tvCounter.setText(counter + "");
}
});

buttonMinus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
counter = Integer.parseInt(tvCounter.getText().toString());
counter--;
tvCounter.setText(counter + "");
}
});

buttonTileActivity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), TileActivity.class);
startActivity(intent);
}
});

preferences = getPreferences(Context.MODE_PRIVATE);
}

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

}

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

SharedPreferences sharedPref = this.getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("tvCounter", tvCounter.getText().toString());
editor.commit();
}
}
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: 62 additions & 6 deletions src/main/res/layout/activity_initial.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
Expand All @@ -9,10 +9,66 @@
tools:context="nyc.c4q.InitialActivity"
android:id="@+id/activity_initial">

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

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

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

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





</LinearLayout>

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="@+id/tvCounter"
android:layout_weight="1"
android:textSize="100dp"
android:text="0"
android:gravity="center_vertical|center_horizontal" />



</LinearLayout>

<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/buttonTileActivity"
android:text="TileActivity"/>

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


</LinearLayout>
65 changes: 65 additions & 0 deletions src/main/res/layout/activity_tile.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,77 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="nyc.c4q.TileActivity"
android:id="@+id/activity_tile"
>

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

<View
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="40"
android:background="@color/red"
android:id="@+id/redView">

</View>

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

</View>

</LinearLayout>

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

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

</View>

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

</View>

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

</View>


</LinearLayout>

<TextView
android:layout_height="match_parent"
android:layout_width="match_parent"
Expand Down
10 changes: 10 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@
<string name="action_settings">Settings</string>

<string name="hello_world">Hello world!</string>

<string name="saved_counter"></string>

<color name="white">#ffffff</color>
<color name="blue">#0000ff</color>
<color name="green">#00ff00</color>
<color name="yellow">#ffff00</color>
<color name="red">#ff0000</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