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: 6 additions & 1 deletion src/main/java/nyc/c4q/AbstractAwesomeClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
*/
public abstract class AbstractAwesomeClass implements AwesomeInterface {

int data=4;

@Override
public int getData() {
return 0;

return data;
}

@Override
public void setData(int someData) {

data=someData;

}
}
8 changes: 6 additions & 2 deletions src/main/java/nyc/c4q/AwesomeContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
*/
public class AwesomeContainer {
public static Collection createAwesomeContainer(){
return null;

return new ArrayList();
}

public static void addAwesomeObject(Collection awesomeContainer){
return;

ConcreteAwesomeClass classAdd= new ConcreteAwesomeClass();

awesomeContainer.add(classAdd);
}
}
112 changes: 87 additions & 25 deletions src/main/java/nyc/c4q/InitialActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,99 @@

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.TextView;

import org.w3c.dom.Text;

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 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(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_initial);
preferences = getPreferences(Context.MODE_PRIVATE);

loadState();

final Button button = (Button) findViewById(R.id.buttonPlus);
final TextView countertv = (TextView) findViewById(R.id.tvCounter);

if(savedInstanceState!=null){
counter= Integer.parseInt(savedInstanceState.get("click_count").toString());
saveState();
countertv.setText(counter);

}

button.setOnClickListener(new View.OnClickListener() {
@Override

public void onClick(View view) {
counter++;
saveState();
countertv.setText(String.valueOf(counter));

}

});

Button buttonMin = (Button) findViewById(R.id.buttonMinus);
buttonMin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
counter--;
saveState();
countertv.setText(String.valueOf(counter));

}
});

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

}
});

saveState();

}

protected void onPause(){
super.onPause();
saveState();
}

protected void onResume(){
super.onResume();
loadState();
}
}
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) {

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


<LinearLayout

android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/counterLayout"
android:layout_weight="2"
android:orientation="horizontal">


<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"

android:id="@+id/counterButtonsLayout">

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



</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/tvCounter"
android:layout_weight="1"
android:height="0dp"
android:text="0"/>

</LinearLayout>

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

<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/buttonEmpty"
android:text="Empty"

android:layout_weight="1"/>



<TextView
android:id="@+id/text"
android:layout_width="match_parent"
Expand Down
62 changes: 60 additions & 2 deletions src/main/res/layout/activity_tile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,67 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context="nyc.c4q.TileActivity"
android:id="@+id/activity_tile"
>
android:id="@+id/activity_tile">

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


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

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


</LinearLayout>



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

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

<View
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/whiteView"
android:layout_weight="44"
android:background="#ffffff"/>
<View
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/blueView"
android:layout_weight="22"
android:background="#ff0000ff"/>


</LinearLayout>


<TextView
android:layout_height="match_parent"
Expand Down
11 changes: 11 additions & 0 deletions src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<color name="redViewBackground">#ffff0000</color>

<color name="greenViewBackground">#ff00ff00</color>
<color name="yellowViewBackground">#ffffff00</color>

<color name="whiteViewBackground">#ffffffff</color>
<color name="blueViewBackground">#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