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

Jackie Ho - Animation Lab #7

Open
wants to merge 1 commit 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
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.

18 changes: 18 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.

96 changes: 96 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
Expand Up @@ -5,23 +5,82 @@
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.LinkedList;

public class MainActivity extends AppCompatActivity {

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

//TODO: set up all the view and event listeners.
}

@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
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final EditText editText = (EditText) findViewById(R.id.wish_edit);
final TextView textView = (TextView) findViewById(R.id.wish_text);
ListView listView = (ListView) findViewById(R.id.wish_list);
Button wishSubmit = (Button) findViewById(R.id.wish_button);
Button removeWish = (Button)findViewById(R.id.remove_wish);
//TODO: set up all the view and event listeners.

final LinkedList<String> wishArray = new LinkedList<>();
final ArrayList<String> tempArray = new ArrayList<>();
final ArrayAdapter<String> wishAdapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, wishArray);
listView.setAdapter(wishAdapter);

wishSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String wish = editText.getText().toString();
textView.setText(wish);
editText.setText("");
Animation textAnimation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.animation);
textView.startAnimation(textAnimation);
textAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
tempArray.clear();
tempArray.addAll(wishArray);
}

@Override
public void onAnimationEnd(Animation animation) {

//Move wish to top of list
wishArray.clear();
wishArray.add(wish);
wishArray.addAll(tempArray);
wishAdapter.notifyDataSetChanged();
textView.setText("");

}

@Override
public void onAnimationRepeat(Animation animation) {

}
});


}
});

removeWish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (wishArray != null && !wishArray.isEmpty()) {
wishArray.remove(0);
wishAdapter.notifyDataSetChanged();
}
}
});

}


}
20 changes: 18 additions & 2 deletions starter-code/app/src/main/res/anim/animation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@
android:shareInterpolator="false"
android:fillAfter="false" >
<alpha
android:duration="1000"
android:fromAlpha="0.0"
android:toAlpha="1.0"/>
<!--TODO: finish fading animation-->
/>


<rotate
android:duration="1000"
android:fromDegrees="0"
android:toDegrees="360"/>
<!--TODO: finish rotating animation-->
/>
<translate
android:duration="500"
android:fromYDelta="0%p"
android:toYDelta="17%p"
android:fromXDelta="0%p"
android:toXDelta="-40%p"
android:startOffset="1000"
>

</translate>

</set>
8 changes: 8 additions & 0 deletions starter-code/app/src/main/res/anim/translate_animation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="400"
android:fromYDelta="0"
android:toYDelta="40%"
android:startOffset="400">

</translate>
37 changes: 37 additions & 0 deletions starter-code/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,42 @@
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="generalassembly.yuliyakaleda.startercode.MainActivity">

<EditText
android:id="@+id/wish_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter your wish"
android:maxLines="1"
android:singleLine="true"/>
<Button
android:id="@+id/wish_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wish"
android:layout_below="@id/wish_edit"
/>
<Button
android:id="@+id/remove_wish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/wish_edit"
android:text="remove text"/>
<TextView
android:id="@+id/wish_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/wish_button"
android:layout_marginTop="10dp"
android:textSize="20sp"
android:text="wish"
android:layout_centerHorizontal="true"/>
<ListView
android:id="@+id/wish_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:layout_marginTop="200dp"></ListView>

<!-- TODO: add edit text, button, text view and a view group-->
</RelativeLayout>