diff --git a/starter-code/.idea/.name b/starter-code/.idea/.name new file mode 100644 index 0000000..5e37776 --- /dev/null +++ b/starter-code/.idea/.name @@ -0,0 +1 @@ +starter-code \ No newline at end of file diff --git a/starter-code/.idea/compiler.xml b/starter-code/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/starter-code/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/starter-code/.idea/copyright/profiles_settings.xml b/starter-code/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/starter-code/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/starter-code/.idea/gradle.xml b/starter-code/.idea/gradle.xml new file mode 100644 index 0000000..1bbc21d --- /dev/null +++ b/starter-code/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/starter-code/.idea/misc.xml b/starter-code/.idea/misc.xml new file mode 100644 index 0000000..000e28a --- /dev/null +++ b/starter-code/.idea/misc.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + Android + + + Android Lint + + + CorrectnessLintAndroid + + + General + + + LintAndroid + + + Maven + + + + + Android + + + + + + + + + + + + + + + + + + + + + + + + + 1.7 + + + + + + + + \ No newline at end of file diff --git a/starter-code/.idea/modules.xml b/starter-code/.idea/modules.xml new file mode 100644 index 0000000..b66c03c --- /dev/null +++ b/starter-code/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/starter-code/.idea/runConfigurations.xml b/starter-code/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/starter-code/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/starter-code/.idea/vcs.xml b/starter-code/.idea/vcs.xml new file mode 100644 index 0000000..6564d52 --- /dev/null +++ b/starter-code/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/starter-code/app/src/main/java/generalassembly/yuliyakaleda/startercode/MainActivity.java b/starter-code/app/src/main/java/generalassembly/yuliyakaleda/startercode/MainActivity.java index 55d1d3a..66b5eb3 100644 --- a/starter-code/app/src/main/java/generalassembly/yuliyakaleda/startercode/MainActivity.java +++ b/starter-code/app/src/main/java/generalassembly/yuliyakaleda/startercode/MainActivity.java @@ -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 wishArray = new LinkedList<>(); + final ArrayList tempArray = new ArrayList<>(); + final ArrayAdapter wishAdapter = new ArrayAdapter(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(); + } + } + }); + + } + + } diff --git a/starter-code/app/src/main/res/anim/animation.xml b/starter-code/app/src/main/res/anim/animation.xml index 88c2c7c..4045970 100644 --- a/starter-code/app/src/main/res/anim/animation.xml +++ b/starter-code/app/src/main/res/anim/animation.xml @@ -2,10 +2,26 @@ android:shareInterpolator="false" android:fillAfter="false" > - /> + - /> + + + + \ No newline at end of file diff --git a/starter-code/app/src/main/res/anim/translate_animation.xml b/starter-code/app/src/main/res/anim/translate_animation.xml new file mode 100644 index 0000000..9c92b81 --- /dev/null +++ b/starter-code/app/src/main/res/anim/translate_animation.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/starter-code/app/src/main/res/layout/activity_main.xml b/starter-code/app/src/main/res/layout/activity_main.xml index b326849..5775932 100644 --- a/starter-code/app/src/main/res/layout/activity_main.xml +++ b/starter-code/app/src/main/res/layout/activity_main.xml @@ -10,5 +10,42 @@ android:paddingBottom="@dimen/activity_vertical_margin" tools:context="generalassembly.yuliyakaleda.startercode.MainActivity"> + +