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

did assignment #21

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
73 changes: 70 additions & 3 deletions src/main/java/nyc/c4q/InitialActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@
import android.widget.Button;
import android.widget.TextView;

public class InitialActivity extends Activity {
import org.w3c.dom.Text;

public int counter = 0;
import java.util.ArrayList;

public class InitialActivity extends Activity implements View.OnClickListener {

public static int counter = 0;
public SharedPreferences preferences = null;
public final static String TAG = "C4QTAG";
TextView tvCounter;
Button buttonPlus;
Button buttonMinus;



public void loadState(){
Log.d(TAG, "loadState()");
Expand All @@ -31,8 +40,66 @@ public void saveState(){

@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate()");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_initial);
preferences = getPreferences(Context.MODE_PRIVATE);
}

tvCounter = (TextView) findViewById(R.id.tvCounter);
buttonPlus = (Button) findViewById(R.id.buttonPlus);
buttonMinus = (Button) findViewById(R.id.buttonMinus);
Button buttonTileActivity = (Button) findViewById(R.id.buttonTileActivity);
Button buttonEmpty = (Button) findViewById(R.id.buttonEmpty);
loadState();

// if (savedInstanceState != null) {
// int mCurrentCounter = savedInstanceState.getInt(String.valueOf(counter));
// }
}

@Override
protected void onStart() {
super.onStart();
saveState(); }

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


public void onClick (View v) {

Log.d(TAG, "onClick()");
if(v.getId()==R.id.buttonPlus){
counter += 1;
Log.d(TAG, "onClick().buttonPlus, counter="+counter);
tvCounter.setText(String.valueOf(counter));
saveState();
}
if (v.getId()==R.id.buttonMinus) {
counter -= 1;
Log.d(TAG, "onClick().buttonMinus, counter="+counter);
tvCounter.setText(String.valueOf(counter));
saveState();
}
}
@Override
protected void onSaveInstanceState(Bundle state) {
// state.get(String.valueOf(counter));


super.onSaveInstanceState(state);
// int mCurrentCounter = getInt(counter);
state.putInt("mCurrentCounter", counter);
Log.d("InitialActivity", "onSaveInstanceState");

}

@Override
protected void onStop() {
super.onStop();
}

}
9 changes: 7 additions & 2 deletions src/main/java/nyc/c4q/SubFunClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
/**
* Created by amyquispe on 5/19/15.
*/
public class SubFunClass {
public SubFunClass(){
public class SubFunClass extends SuperFunClass {
public SubFunClass (){
SubFunClass funObject = new SubFunClass();
}

public SubFunClass(String someName) {
super(someName);
}
}
62 changes: 56 additions & 6 deletions src/main/res/layout/activity_initial.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,61 @@
android:layout_height="match_parent"
tools:context="nyc.c4q.InitialActivity"
android:id="@+id/activity_initial">

<TextView
android:id="@+id/text"
<LinearLayout
android:orientation="horizontal"
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">
<LinearLayout
android:id="@+id/counterButtonsLayout"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/buttonPlus"
android:text="+"
android:layout_weight="1"
android:onClick="onClick"/>
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/buttonMinus"
android:text="-"
android:layout_weight="1"
android:onClick="onClick"
/>
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="@+id/tvCounter"
android:layout_weight="1"
android:textSize="60sp"
android:textAlignment="center"
android:text="0"/>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/buttonTileActivity"
android:text="TileActivity"
android:layout_weight="1"
android:onClick="onClick"/>
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/buttonEmpty"
android:text="Empty"
android:layout_weight="1"
android:onClick="onClick"/>
<!--<TextView-->
<!--android:id="@+id/text"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:text="InitialActivity"-->
<!--/>-->
</LinearLayout>
50 changes: 49 additions & 1 deletion src/main/res/layout/activity_tile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,56 @@
android:layout_height="match_parent"
tools:context="nyc.c4q.TileActivity"
android:id="@+id/activity_tile"
android:orientation="horizontal"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/leftSide"
android:orientation="vertical"
android:layout_weight="1">
<View
android:layout_height="0dp"
android:layout_width="match_parent"
android:background="@color/red"
android:id="@+id/redView"
android:layout_weight="40"></View>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/greenView"
android:background="@color/green"
android:layout_weight="60"></View>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/rightSide"
android:layout_weight="1"
>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/yellowView"
android:background="@color/yellow"
android:layout_weight="33"></View>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/whiteView"
android:background="@color/white"
android:layout_weight="44"></View>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/blueView"
android:background="@color/blue"
android:layout_weight="22"></View>
</LinearLayout>
<Button
android:layout_width="100dp"
android:layout_height="100dp" />
<TextView
android:layout_height="match_parent"
android:layout_width="match_parent"
Expand Down
9 changes: 9 additions & 0 deletions src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#ffff0000</color>
<color name="green">#ff00ff00</color>
<color name="yellow">#ffffff00</color>
<color name="white">#ffffffff</color>
<color name="blue">#ff0000ff</color>

</resources>