Skip to content

Commit

Permalink
Added animations
Browse files Browse the repository at this point in the history
  • Loading branch information
farazfazli committed Feb 20, 2016
1 parent 3f16a66 commit 3fdb1b4
Show file tree
Hide file tree
Showing 15 changed files with 262 additions and 27 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions starter-code/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions starter-code/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions starter-code/.idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions starter-code/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions starter-code/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions starter-code/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions starter-code/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions starter-code/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,27 +1,91 @@
package generalassembly.yuliyakaleda.startercode;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity implements View.OnClickListener {

private EditText mWishEditText;
private TextView mWishTextView;
private Button mButton;

private ViewGroup mViewGroup;

private TextView mTextView;

private static final int MIN_CHARACTER_COUNT = 3;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mWishEditText = (EditText) findViewById(R.id.edittext);
mWishEditText.setMaxLines(1);

mButton = (Button) findViewById(R.id.button);
mWishTextView = (TextView) findViewById(R.id.textview);

mViewGroup = (ViewGroup) findViewById(R.id.frameLayout);

mButton.setOnClickListener(this);
}

@Override
public void onClick(View v) {
String wishText = mWishEditText.getText().toString();

if (wishText.trim().length() > MIN_CHARACTER_COUNT) {

mWishTextView.setText(wishText);

Animation animation = AnimationUtils.loadAnimation(this, R.anim.rotate_and_fade_in);
mWishTextView.startAnimation(animation);

mTextView = new TextView(this);
mTextView.setText(wishText);

animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
log("started");
}

@Override
public void onAnimationEnd(Animation animation) {
log("finished");
addToBottom();
clearEditText();
}

@Override
public void onAnimationRepeat(Animation animation) {
log("repeating");
}
});
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
private void log(String thing) {
Log.i("[Animation]", "Animation " + thing + "!");
}

//TODO: set up all the view and event listeners.
}
private void addToBottom() {
Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_right);
mTextView.startAnimation(animation);
mViewGroup.addView(mTextView, 0); // the zero here adds to the top instead of the bottom
}

@Override
public void onClick(View v) {
// TODO: 1. get the text from the input field
// 2. animate it in the center of the screen
// 3. add it to the list wish
// 4. clear the input field
}
private void clearEditText() {
mWishEditText.setText("");
}
}
11 changes: 0 additions & 11 deletions starter-code/app/src/main/res/anim/animation.xml

This file was deleted.

6 changes: 6 additions & 0 deletions starter-code/app/src/main/res/anim/push_down.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="250"
android:fromYDelta="0"
android:toYDelta="100"/>
</set>
12 changes: 12 additions & 0 deletions starter-code/app/src/main/res/anim/rotate_and_fade_in.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="1000"
android:fromAlpha="0"
android:toAlpha="1"/>
<rotate
android:duration="500"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"/>
</set>
10 changes: 10 additions & 0 deletions starter-code/app/src/main/res/anim/slide_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="350"
android:fromXDelta="-100"
android:toXDelta="0"/>
<alpha
android:duration="350"
android:fromAlpha="0"
android:toAlpha="1"/>
</set>
38 changes: 37 additions & 1 deletion starter-code/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
Expand All @@ -10,5 +11,40 @@
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="generalassembly.yuliyakaleda.startercode.MainActivity">

<!-- TODO: add edit text, button, text view and a view group-->
<EditText
android:id="@+id/edittext"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<Button
android:id="@+id/button"
android:layout_marginTop="40dp"
android:layout_alignTop="@+id/edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Make a wish"/>

<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:text="Your wish"
android:layout_below="@+id/button"
android:layout_alignParentStart="true"
android:layout_marginBottom="20dp"
android:textColor="#64dd17"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/frameLayout"
android:layout_alignParentStart="true"
android:layout_below="@+id/textview">

</LinearLayout>
</RelativeLayout>

0 comments on commit 3fdb1b4

Please sign in to comment.