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

David Sarker - Animation Lab #13

Open
wants to merge 2 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
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,77 @@
package generalassembly.yuliyakaleda.startercode;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
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;

public class MainActivity extends AppCompatActivity {
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

ArrayList<String> mArrayList;
ArrayAdapter<String> mArrayAdapter;
TextView mTextView;
EditText mEditText;
Button mButton;

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


//TODO: set up all the view and event listeners.
final ListView listView = (ListView) findViewById(R.id.listview);
mTextView = (TextView) findViewById(R.id.textview);
mEditText = (EditText) findViewById(R.id.edittext);
mButton = (Button) findViewById(R.id.button);

mArrayList = new ArrayList();
mArrayAdapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, mArrayList);
listView.setAdapter(mArrayAdapter);

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

//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
public void onClick(View v) {
if (!mEditText.getText().toString().isEmpty()) {
mTextView.setText(mEditText.getText().toString());

Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.animation);


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

@Override
public void onAnimationEnd(Animation animation) {
mArrayAdapter.insert(mTextView.getText().toString(), 0);
mArrayAdapter.notifyDataSetChanged();
mTextView.setText("");
}

@Override
public void onAnimationRepeat(Animation animation) {

}
});

mTextView.startAnimation(animation);
} else {
mEditText.setError("Please enter your wish");
}
}
}

36 changes: 26 additions & 10 deletions starter-code/app/src/main/res/anim/animation.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:fillAfter="false" >
<alpha
<!--TODO: finish fading animation-->
/>

<rotate
<!--TODO: finish rotating animation-->
/>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<rotate
android:duration="500"
android:fromDegrees="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">

<alpha
android:duration="1000"
android:fromAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="0.0">

<translate
android:duration="1000"
android:fromXDelta="0"
android:fromYDelta="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="-300"
android:toYDelta="200" />

</alpha>
</rotate>
</set>
46 changes: 43 additions & 3 deletions starter-code/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="generalassembly.yuliyakaleda.startercode.MainActivity">

<!-- TODO: add edit text, button, text view and a view group-->
<TextView
android:id="@+id/textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="@+id/button"
android:layout_marginTop="48dp"
android:text="Your wish"
android:textSize="20sp"
android:textAlignment="center"
android:textColor="@android:color/holo_blue_dark" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/edittext"
android:layout_centerHorizontal="true"
android:text="Make a wish"
android:onClick="onCick"/>

<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:hint="Enter a wish"
android:singleLine="true" />

<ListView
android:id="@+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
android:layout_below="@+id/textview"
android:layout_alignParentStart="true"
android:layout_marginTop="25dp" />

</RelativeLayout>