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
7 changes: 5 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,16 @@
*/
public abstract class AbstractAwesomeClass implements AwesomeInterface {

int data = 4;
int someData = 5;

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

@Override
public void setData(int someData) {

data = someData;
}
}
15 changes: 12 additions & 3 deletions src/main/java/nyc/c4q/AwesomeContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

/**
* Created by amyquispe on 5/19/15.
*/
public class AwesomeContainer {
public static Collection createAwesomeContainer(){
return null;

private static ArrayList myList;

public static Collection createAwesomeContainer() {

myList = new ArrayList();

return myList;
}

public static void addAwesomeObject(Collection awesomeContainer){
return;
ConcreteAwesomeClass cc = new ConcreteAwesomeClass();
myList.add(cc);
}
}
1 change: 1 addition & 0 deletions src/main/java/nyc/c4q/ConcreteAwesomeClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Created by amyquispe on 5/19/15.
*/
public class ConcreteAwesomeClass extends AbstractAwesomeClass {

public ConcreteAwesomeClass(){
}
public ConcreteAwesomeClass(int startData){
Expand Down
114 changes: 90 additions & 24 deletions src/main/java/nyc/c4q/InitialActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,103 @@

import android.app.Activity;
import android.content.Context;
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.LinearLayout;
import android.widget.TextView;

public class InitialActivity extends Activity {

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);
}

public void saveState(){
Log.d(TAG, "saveState()");
Log.d(TAG, "saveState(): counter=="+counter);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("counter", counter);
editor.commit();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_initial);
preferences = getPreferences(Context.MODE_PRIVATE);
}
public int counter = 0;
public SharedPreferences preferences = null;
public final static String TAG = "C4QTAG";
public TextView tvCounter;

private static final String COUNTER_KEY = "counter";

public void loadState() {
Log.d(TAG, "loadState()");
counter = preferences.getInt("counter", 0);
Log.d(TAG, "loadState(): counter==" + counter);
}

public void saveState() {
Log.d(TAG, "saveState()");
Log.d(TAG, "saveState(): counter==" + counter);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("counter", counter);
editor.commit();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_initial);
preferences = getPreferences(Context.MODE_PRIVATE);


LinearLayout layout = (LinearLayout) findViewById(R.id.activity_initial);

tvCounter = (TextView) findViewById(R.id.tvCounter);
loadState();
tvCounter.setText("" + counter);

Button buttonPlus = (Button) findViewById(R.id.buttonPlus);
buttonPlus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
counter++;
tvCounter.setText("" + counter);
Log.d("C4QTAG", "onCreate().buttonPlus.inside: " + counter);
}
});

Button buttonMinus = (Button) findViewById(R.id.buttonMinus);
buttonMinus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
counter--;
tvCounter.setText("" + counter);
Log.d("C4QTAG", "onCreate().buttonMinus.inside: " + counter);
}
});

Log.d("C4QTAG", "onCreate().outside: " + counter);

Button buttonTileActivity = (Button) findViewById(R.id.buttonTileActivity);
buttonTileActivity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(InitialActivity.this, TileActivity.class);
startActivity(intent);
}
});


// Log.d(TAG, "onCreate() -- savedInstanceState="+savedInstanceState);
// if(savedInstanceState!=null) {
// counter = savedInstanceState.getInt(COUNTER_KEY);
// Log.d(TAG, "onCreate() -- restoring counter, counter="+counter);
// tvCounter.setText("" + counter);
// }
}

// @Override
// protected void onSaveInstanceState(Bundle outState) {
// Log.d(TAG, "onSaveInstanceState(), counter="+counter);
// Log.d(TAG, "onSaveInstanceState(), before, outState="+outState);
// super.onSaveInstanceState(outState);
// outState.putInt(COUNTER_KEY, counter);
// Log.d(TAG, "onSaveInstanceState(), after, outState="+outState);
// }

@Override
protected void onPause() {
super.onPause();
saveState();
}
}
14 changes: 13 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,19 @@
/**
* Created by amyquispe on 5/19/15.
*/
public class SubFunClass {
public class SubFunClass extends SuperFunClass implements AwesomeInterface{
int data;

public SubFunClass(){
}

@Override
public int getData() {
return data;
}

@Override
public void setData(int someData) {
data = someData;
}
}
69 changes: 59 additions & 10 deletions src/main/res/layout/activity_initial.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:id="@+id/activity_initial"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="nyc.c4q.InitialActivity"
android:id="@+id/activity_initial">
android:orientation="vertical"
tools:context="nyc.c4q.InitialActivity">

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

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

<Button
android:id="@+id/buttonPlus"
android:layout_width="wrap_content"
android:layout_height='0dp'
android:layout_weight='1'
android:text="+"
android:textSize="60sp" />

<Button
android:id="@+id/buttonMinus"
android:layout_width="wrap_content"
android:layout_height='0dp'
android:layout_weight='1'
android:text="-"
android:textSize="60sp" />
</LinearLayout>

<TextView
android:id="@+id/text"

<TextView
android:id="@+id/tvCounter"
android:layout_width='0dp'
android:layout_height="match_parent"
android:layout_weight='1'
android:text="0"
android:textSize="60sp" />
</LinearLayout>


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

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

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

<TextView

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

<View
android:id="@+id/redView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight='40'
android:background="#ffff0000"/>

<View
android:id="@+id/greenView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight='60'
android:background="#ff00ff00"/>

</LinearLayout>

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

<View
android:id="@+id/yellowView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight='33'
android:background="#ffffff00"/>

<View
android:id="@+id/whiteView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight='44'
android:background="#ffffffff"/>

<View
android:id="@+id/blueView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight='22'
android:background="#ff0000ff"/>

</LinearLayout>


</LinearLayout>
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