Skip to content

Commit

Permalink
feat(animation): menu animation added, fade in and floating
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrucesdeveloper committed Mar 6, 2023
1 parent 0347759 commit 858b3dd
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 9 deletions.
7 changes: 0 additions & 7 deletions app/src/main/assets/metro_santiago.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,4 @@
<station>Lo valledor</station>
<station>Cerrillos</station>
</line>
<line name="TEST" color="#A53CEB">
<station>station 1</station>
<station>station 2</station>
<station>station 3</station>
<station>station 4</station>
</line>

</metro>
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.SpringAnimation;

import com.jorgecruces.metrometro.R;
import com.jorgecruces.metrometro.sound.BackgroundMusic;
Expand All @@ -24,10 +24,14 @@

public class MainActivity extends AppCompatActivity {

private ImageView imageViewMenuLogo;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.imageViewMenuLogo = findViewById(R.id.imageViewLogo);
this.animateFadeInButtons();
}


Expand All @@ -37,6 +41,30 @@ protected void onStart() {
BackgroundMusic.onStart(this);
}

@Override
protected void onResume() {
super.onResume();
this.startMenuLogoAnimation();
}

private void animateFadeInButtons() {
Animation fadeInAnimation = AnimationUtils.loadAnimation(this,R.anim.fadein);
ImageView imageViewPlayButton = findViewById(R.id.imageViewButtonPlay);
ImageView imageViewInformationButton = findViewById(R.id.imageViewButtonInformation);
ImageView imageViewResetButton = findViewById(R.id.imageViewButtonReset);
ImageView imageViewConfigurationButton = findViewById(R.id.imageViewButtonConfiguration);

imageViewPlayButton.startAnimation(fadeInAnimation);
imageViewInformationButton.startAnimation(fadeInAnimation);
imageViewResetButton.startAnimation(fadeInAnimation);
imageViewConfigurationButton.startAnimation(fadeInAnimation);
}

private void startMenuLogoAnimation() {
Animation floatingAnimation = AnimationUtils.loadAnimation(this,R.anim.floating);
this.imageViewMenuLogo.startAnimation(floatingAnimation);
}

@Override
protected void onStop() {
super.onStop();
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/anim/fadein.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:fillAfter="true"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="1000"/>
</set>
13 changes: 13 additions & 0 deletions app/src/main/res/anim/floating.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:repeatMode="reverse"
android:repeatCount="infinite"
android:fromYDelta="0"
android:fromXDelta="0"
android:toXDelta="0"
android:toYDelta="70"
android:duration="2000"
/>

</set>

0 comments on commit 858b3dd

Please sign in to comment.