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: 4 additions & 3 deletions src/main/java/nyc/c4q/AbstractAwesomeClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
* Created by amyquispe on 5/19/15.
*/
public abstract class AbstractAwesomeClass implements AwesomeInterface {
private int data = 4;

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

@Override
public void setData(int someData) {

this.data = someData;
}
}
}
90 changes: 66 additions & 24 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,28 +12,69 @@

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(Bundle savedInstanceState) {
// want to check bundle if counter is null? if not, restore.

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_initial);
preferences = getPreferences(Context.MODE_PRIVATE);

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

buttonPlus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
counter++;
TextView tvCounter = (TextView) findViewById(R.id.tvCounter);
tvCounter.setText(String.valueOf(counter));
}
});

buttonMinus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
counter--;
TextView tvCounter = (TextView) findViewById(R.id.tvCounter);
tvCounter.setText(String.valueOf(counter));
}
});

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

// Wasn't able to finish this part.
@Override
protected void onDestroy() {
super.onDestroy();

Bundle b = new Bundle();
b.putString("counter", String.valueOf(counter));
}
}
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) {

}
}
75 changes: 65 additions & 10 deletions src/main/res/layout/activity_initial.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,73 @@
<?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">

<TextView
android:id="@+id/text"
<LinearLayout
android:id="@+id/counterLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="InitialActivity"
/>
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="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:onClick="onClick"
android:text="+"
android:textSize="80sp"/>

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

</LinearLayout>

<TextView
android:id="@+id/tvCounter"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="80sp"/>

</LinearLayout>

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

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

</LinearLayout>
71 changes: 64 additions & 7 deletions src/main/res/layout/activity_tile.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,72 @@
<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:id="@+id/activity_tile"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="nyc.c4q.TileActivity"
android:id="@+id/activity_tile"
>
android:orientation="horizontal"
tools:context="nyc.c4q.TileActivity">

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

<LinearLayout
android:id="@+id/redView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="40"
android:background="@color/red"
android:orientation="vertical"></LinearLayout>

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

</LinearLayout>

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

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

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

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

</LinearLayout>

<TextView
android:layout_width="match_parent"
android:text="TileActivity"/>
android:layout_height="wrap_content"
android:text="TileActivity" />

</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>
<item name="red" type="color">#ffff0000</item>
<item name="green" type="color">#ff00ff00</item>
<item name="yellow" type="color">#ffffff00</item>
<item name="white" type="color">#ffffffff</item>
<item name="blue" type="color">#ff0000ff</item>
</resources>