-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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(""); | ||
} | ||
} |
This file was deleted.
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> |
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> |
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> |