Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit-1 Assessment #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
4 changes: 3 additions & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nyc.c4q" >

<application android:name=".Unit1AssessmentApplication" >
<application android:name=".MyApplication" >
<activity
android:name=".InitialActivity"
android:label="@string/title_activity_initial"
Expand All @@ -20,3 +20,5 @@
</application>

</manifest>


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

int data = 4;

public AbstractAwesomeClass() {
super();
}

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

@Override
public void setData(int someData) {
data = someData;


}
}
1 change: 1 addition & 0 deletions src/main/java/nyc/c4q/AwesomeContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

/**
* Created by amyquispe on 5/19/15.
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/nyc/c4q/ConcreteAwesomeClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
* Created by amyquispe on 5/19/15.
*/
public class ConcreteAwesomeClass extends AbstractAwesomeClass {
@Override
public int getData() {
return super.getData();
}

public ConcreteAwesomeClass(){
}
public ConcreteAwesomeClass(int startData){
Expand Down
89 changes: 65 additions & 24 deletions src/main/java/nyc/c4q/InitialActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,71 @@
import android.widget.Button;
import android.widget.TextView;

import org.w3c.dom.Text;

public class InitialActivity extends Activity {
int numCounter = 0;

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);
SharedPreferences sharedPref= getSharedPreferences("mypref", 0);
Integer counter = sharedPref.getInt("counter", numCounter);
}

public void saveState() {
Log.d(TAG, "saveState()");
Log.d(TAG, "saveState(): counter==" + counter);
//SharedPreferences.Editor editor = preferences.edit();
//editor.putInt("counter", counter);
//editor.commit();
SharedPreferences sharedPref= getSharedPreferences("mypref", 0);
SharedPreferences.Editor editor= sharedPref.edit();
editor.putInt("counter", numCounter);
editor.commit();


}

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


SharedPreferences sharedPref= getSharedPreferences("mypref", 0);
Integer counter = sharedPref.getInt("counter", numCounter);
numCounter = counter;



Log.d(TAG, "onCreate()");
Button plus = (Button) findViewById(R.id.buttonPlus);
plus.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
numCounter++;
Log.d(TAG, "plus.onClick(): counter==" + numCounter);
TextView counter = (TextView) findViewById(R.id.tvCounter);
counter.setText(Integer.toString(numCounter));
}
});

Button minus = (Button) findViewById(R.id.buttonMinus);
minus.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
numCounter--;
Log.d(TAG, "minus.onClick(): counter==" + numCounter);
TextView counter = (TextView) findViewById(R.id.tvCounter);
counter.setText(Integer.toString(numCounter));
}
});

}

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);
}
}
18 changes: 17 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,23 @@
/**
* Created by amyquispe on 5/19/15.
*/
public class SubFunClass {
public class SubFunClass extends SuperFunClass implements AwesomeInterface{
@Override
public int getData() {
return 0;
}

@Override
public void setData(int someData) {

}

public SubFunClass(String someName) {
super(someName);
}

public SubFunClass(){


}
}
68 changes: 61 additions & 7 deletions src/main/res/layout/activity_initial.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,71 @@

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"

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

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

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

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

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


</LinearLayout>

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

</LinearLayout>


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

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

</LinearLayout>
65 changes: 59 additions & 6 deletions src/main/res/layout/activity_tile.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>

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

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

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

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


</LinearLayout>

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

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

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

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


</LinearLayout>

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

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

<string name="hello_world">Hello world!</string>
<color name="red">#ff00ff00</color>
<color name="green">#ff00ff00</color>
<color name="yellow">#ffffff00</color>
<color name="white">#ffffffff</color>
<color name="blue">#ff0000ff</color>

</resources>