Skip to content

Commit

Permalink
add start screen animation
Browse files Browse the repository at this point in the history
  • Loading branch information
SlaVcE14 committed Dec 20, 2023
1 parent 8b663ef commit 88ce83b
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/src/main/java/com/sjapps/jsonlist/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
Expand All @@ -50,6 +54,7 @@ public class MainActivity extends AppCompatActivity {

final String TAG = "MainActivity";
ImageButton backBtn, menuBtn;
ImageView fileImg;
Button openFileBtn;
TextView titleTxt, emptyListTxt;
ListView list;
Expand All @@ -75,6 +80,10 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initialize();

setAnimation(this,fileImg,R.anim.scale_in_file_img, new DecelerateInterpolator());
setAnimation(this,openFileBtn,R.anim.button_pop, new OvershootInterpolator());

autoTransition.setDuration(150);
menuBtn.setOnClickListener(view -> open_closeMenu());

Expand Down Expand Up @@ -155,6 +164,7 @@ private void initialize() {
dim_bg = findViewById(R.id.dim_layout);
progressView = findViewById(R.id.loadingView);
progressBar = findViewById(R.id.progressBar);
fileImg = findViewById(R.id.fileImg);
dim_bg.bringToFront();
menu.bringToFront();
menuBtn.bringToFront();
Expand Down Expand Up @@ -225,7 +235,12 @@ private void LoadData(String Data) {
TransitionManager.beginDelayedTransition(viewGroup, autoTransition);
adapter = new ListAdapter(data.getRootList(), MainActivity.this, "");
list.setAdapter(adapter);
fileImg.clearAnimation();
openFileBtn.clearAnimation();
fileImg.setVisibility(View.GONE);
openFileBtn.setVisibility(View.GONE);
setAnimation(MainActivity.this,list,R.anim.scale_in2,new DecelerateInterpolator());
list.setVisibility(View.VISIBLE);
backBtn.setVisibility(View.GONE);
titleTxt.setText("");
data.clearPath();
Expand Down Expand Up @@ -363,8 +378,15 @@ void loadingFinished(boolean isFinished){
},1000);
}


public static void setAnimation(Context context, @NonNull View view, @AnimRes int animationRes) {
setAnimation(context,view,animationRes,null);
}

public static void setAnimation(Context context, @NonNull View view, @AnimRes int animationRes, Interpolator interpolator) {
Animation animation = AnimationUtils.loadAnimation(context, animationRes);
if (interpolator != null)
animation.setInterpolator(interpolator);
view.startAnimation(animation);
}

Expand Down
26 changes: 26 additions & 0 deletions app/src/main/res/anim/button_pop.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="400"
android:startOffset="400"
>
<scale android:pivotY="100%"
android:pivotX="50%"
android:fromXScale="1"
android:fromYScale="1"
android:toXScale="1.2"
android:toYScale="1.2"
/>

<set android:startOffset="400">
<scale android:pivotY="100%"
android:pivotX="50%"
android:fromXScale="1"
android:fromYScale="1"
android:toXScale="0.84"
android:toYScale="0.84"
/>

</set>


</set>
24 changes: 24 additions & 0 deletions app/src/main/res/anim/scale_in2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
>

<translate
android:fromYDelta="30%"
android:toYDelta="0"

/>

<scale
android:pivotY="100%"
android:pivotX="50%"
android:fromXScale=".6"
android:fromYScale=".6"
android:toXScale="1"
android:toYScale="1"
/>
<alpha
android:fromAlpha="0"
android:toAlpha="1"/>

</set>
47 changes: 47 additions & 0 deletions app/src/main/res/anim/scale_in_file_img.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="800"
android:startOffset="600"
>
<scale android:pivotY="100%"
android:pivotX="50%"
android:fromXScale=".3"
android:fromYScale=".3"
android:toXScale="1"
android:toYScale="1"
/>
<translate

android:fromYDelta="15%"
android:toYDelta="0"
/>



<rotate

android:pivotX="100%"
android:pivotY="50%"
android:fromDegrees="-15"
android:toDegrees="10"

/>

<set android:startOffset="850"
android:duration="10">

<rotate
android:pivotX="100%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="-10"

/>

</set>

<alpha
android:fromAlpha="0"
android:toAlpha="1"/>

</set>
14 changes: 14 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,22 @@
android:divider="@null"
android:layout_below="@+id/titlePanel"
android:listSelector="@drawable/transparent_drawable"
android:visibility="gone"
/>

<ImageView
android:id="@+id/fileImg"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_centerHorizontal="true"
android:layout_above="@id/openFileBtn"
android:background="@drawable/ic_open_file_foreground"
android:backgroundTint="?colorPrimary"
android:scaleX="2"
android:scaleY="2"
android:rotation="-15"
/>

<Button
android:id="@+id/openFileBtn"
android:layout_width="wrap_content"
Expand Down

0 comments on commit 88ce83b

Please sign in to comment.