Skip to content
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
9 changes: 7 additions & 2 deletions .idea/deploymentTargetSelector.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 @@ -185,8 +185,8 @@ private class popOneAndGo_TimerTask extends TimerTask {

@Override
public void run() {
achievement_timer.schedule(new AchievementTimerTaskStart(myAchievement), 1);
achievement_timer.schedule(new AchievementTimerTaskEnd(isLast), Constants.Achievements.DISPLAY_TIME);
achievement_timer.schedule(new AchievementTimerTaskStart(myAchievement), 500);
achievement_timer.schedule(new AchievementTimerTaskEnd(isLast), Constants.Achievements.DISPLAY_TIME + 500);
}
}

Expand All @@ -208,10 +208,7 @@ public void run() {
submitDataBinding.textAchievementDesc.setText(myAchievement.description);

//Animation animation = AnimationUtils.loadAnimation(SubmitData.this, R.anim.blink);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can get rid of this comment. It was "saved" as a way to trigger a blink animation. Since you have a fn() to start the animation, we don't need this.


submitDataBinding.imageAchievement.setVisibility(View.VISIBLE);
submitDataBinding.textAchievementTitle.setVisibility(View.VISIBLE);
submitDataBinding.textAchievementDesc.setVisibility(View.VISIBLE);
animateAchievementStart();
});

// in_submitDataBinding.imageAchievement.startAnimation(animation);
Expand All @@ -237,9 +234,7 @@ private class AchievementTimerTaskEnd extends TimerTask {
@Override
public void run() {
SubmitData.this.runOnUiThread(() -> {
submitDataBinding.imageAchievement.setVisibility(View.INVISIBLE);
submitDataBinding.textAchievementTitle.setVisibility(View.INVISIBLE);
submitDataBinding.textAchievementDesc.setVisibility(View.INVISIBLE);
animateAchievementEnd();
});

if (isLast) closeAchievements();
Expand Down Expand Up @@ -278,6 +273,7 @@ private void initAchievements() {
ArrayList<Achievements.PoppedAchievement> pop_list = Achievements.popAchievements();

// Keep Achievements invisible
submitDataBinding.imageAchievementOpen.setVisibility(View.INVISIBLE);
submitDataBinding.imageAchievement.setVisibility(View.INVISIBLE);
submitDataBinding.textAchievementTitle.setVisibility(View.INVISIBLE);
submitDataBinding.textAchievementDesc.setVisibility(View.INVISIBLE);
Expand All @@ -304,6 +300,64 @@ private void initAchievements() {
}
}

public void animateAchievementStart() {
final float openingScaleValue = 1.2f;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a constant in Constans.java ? perhaps that's overkill, but you should comment why it's 1.2f and not 1.1f or 1.6f, etc. Instead of all of my constants comments below, if you had a set of variables inside here with a comment block explaining what they are there for, that would be enough. (can be set to a hard-coded value then). I didn't look (yet) but if these are equally used in animateAchievementEnd(), then they should be Class Globals and defined up around line 34. Still commented to explain them.

// Show the opening logo overlay
submitDataBinding.imageAchievementOpen.setVisibility(View.VISIBLE);

//scale opening image at beginning
submitDataBinding.imageAchievementOpen.animate().scaleX(openingScaleValue).scaleY(openingScaleValue).setDuration(500)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's against coding standards to have hard-coded values like "500". Should probably be a constant - it's referenced below as well.

.withEndAction(new Runnable() {
@Override
public void run() {
submitDataBinding.imageAchievementOpen.animate().scaleX(1.0f).scaleY(1.0f).setDuration(500);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with the scalex values of 1.0f but the 500 seems like a Constant (see above comment)

}
});

// set pivot to a little bit in from the left
submitDataBinding.imageAchievement.setPivotX(20f);

// Set the achievement image visibility and shrink it to 0 immediately
submitDataBinding.imageAchievement.setScaleX(0.0f);
submitDataBinding.imageAchievement.setVisibility(View.VISIBLE);

// Scale it up to full size
submitDataBinding.imageAchievement.animate()
.scaleX(1.0f)
.setDuration(750)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

750 is a Constant. 1.0f is okay.

.withEndAction(new Runnable() {
@Override
public void run() {
// Reveal the text details after the scaling finishes
submitDataBinding.imageAchievement.setVisibility(View.VISIBLE);
submitDataBinding.textAchievementTitle.setVisibility(View.VISIBLE);
submitDataBinding.textAchievementDesc.setVisibility(View.VISIBLE);
}
})
.start();
}

// hiding achievements
public void animateAchievementEnd() {
final float openingScaleValue = 1.2f;
// hide all acheivement eliments while keeping opener visible
submitDataBinding.imageAchievementOpen.setVisibility(View.VISIBLE);
submitDataBinding.imageAchievementOpen.animate().scaleX(openingScaleValue).scaleY(openingScaleValue).setDuration(250);
submitDataBinding.textAchievementDesc.setVisibility(View.INVISIBLE);
submitDataBinding.textAchievementTitle.setVisibility(View.INVISIBLE);
submitDataBinding.imageAchievement.animate()
.scaleX(0.18f)
.setDuration(750)
.withEndAction(new Runnable() {
@Override
public void run() {
submitDataBinding.imageAchievement.setVisibility(View.INVISIBLE);
submitDataBinding.imageAchievementOpen.animate().scaleX(0.0f).scaleY(0.0f).setDuration(250).start();
}
});

}

// =============================================================================================
// Function: initMatch
// Description: Initialize the Match field
Expand Down
Binary file added app/src/main/res/drawable/achievement_open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/src/main/res/layout/submit_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@
app:layout_constraintBottom_toBottomOf="parent"
app:srcCompat="@drawable/achievement" />

<ImageView
android:id="@+id/image_Achievement_Open"
android:layout_width="400dp"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really need to be 400dp wide? and this shifted -318dp?

if it's the right width, you might be able to use:

this way, if we move the image_Achievement, this goes with it. Give this a try and if it looks the same when it's actually popped, it'll be better.

android:layout_height="80dp"
android:layout_marginBottom="50dp"
android:layout_marginStart="-318dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:srcCompat="@drawable/achievement_open" />

<TextView
android:id="@+id/text_AchievementTitle"
android:gravity="center_vertical"
Expand Down