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

Jorge #28

Open
wants to merge 3 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
75 changes: 74 additions & 1 deletion 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 @@ -19,6 +20,7 @@ public void loadState(){
Log.d(TAG, "loadState()");
counter = preferences.getInt("counter", 0);
Log.d(TAG, "loadState(): counter=="+counter);

}

public void saveState(){
Expand All @@ -27,12 +29,83 @@ public void saveState(){
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("counter", counter);
editor.commit();

}

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

}

@Override
protected void onResume() {
super.onResume();
loadState();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate()");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_initial);
preferences = getPreferences(Context.MODE_PRIVATE);
Button plus = (Button) findViewById(R.id.buttonPlus);
Button minus = (Button) findViewById(R.id.buttonMinus);
Button tile = (Button) findViewById(R.id.buttonTileActivity);
final TextView screen = (TextView) findViewById(R.id.tvCounter);



plus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "plus.onClick(), counter="+counter);

counter+=1;
screen.setText(counter+"");


}
});
minus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "minus.onClick(), counter="+counter);

counter-=1;
screen.setText(counter+"");


}
});
tile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

Log.d(TAG, "tile.onClick()");
Intent mainIntent = new Intent(InitialActivity.this,
TileActivity.class);
startActivity(mainIntent);
}
});
}

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

TextView screen = (TextView) findViewById(R.id.tvCounter);
String myText= screen.getText().toString();

savedInstanceState.putString("MyString",myText);

}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);

savedInstanceState.getString("MyString");
}
}
13 changes: 12 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,18 @@
/**
* 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) {

}
}

71 changes: 61 additions & 10 deletions src/main/res/layout/activity_initial.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,69 @@
<?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="match_parent"
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:text="+" />

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

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

</LinearLayout>
<TextView
android:id="@+id/tvCounter"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="0"
android:freezesText="true"
android:textSize="130dp"
android:gravity="center_horizontal"
android:layout_gravity="center"/>

</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>
79 changes: 70 additions & 9 deletions src/main/res/layout/activity_tile.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,76 @@
<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">

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

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

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

</View>

</LinearLayout>

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

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

</View>


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

</View>


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

</View>



</LinearLayout>

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

</LinearLayout>