Skip to content

Commit

Permalink
Merge pull request #2 from sam43/java_implementation
Browse files Browse the repository at this point in the history
Java implementation of the library
  • Loading branch information
sam43 authored May 10, 2020
2 parents 28be2e1 + 61e0976 commit 3ad1027
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//implementation project(":lets_go_splash")
implementation 'com.github.sam43:AnimateViewLibrary:1.0.0'
implementation project(":lets_go_splash")
//implementation 'com.github.sam43:AnimateViewLibrary:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
Expand Down
20 changes: 19 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,34 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".StarterActivity"
<activity
android:name=".JavaSplashActivity"
android:theme="@style/SplashTheme">

<!--
this below block will be uncommented when you want to test the library in java projects,
JavaSplashActivity is the implementation fpr that
-->

<!--<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>-->
</activity>
<activity
android:name=".StarterActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.app.splashapplication;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.app.lets_go_splash.CreateAnim;
import com.app.lets_go_splash.OnAnimationListener;
import com.app.lets_go_splash.StarterAnimation;

import java.util.ArrayList;

public class JavaSplashActivity extends AppCompatActivity {

private ImageView appLogo;

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

private void useStarterLibrary() {
appLogo = findViewById(R.id.imageView);
new StarterAnimation(getAnimList(), new OnAnimationListener() {
@Override
public void onStartAnim() { // TODO::
}

@Override
public void onRepeat() { // TODO::
}

@Override
public void onEnd() {
whatToDoNext();
}
}).startSequentialAnimation(appLogo);
}

private void whatToDoNext() {
appLogo.setVisibility(View.GONE);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.whole_animation, R.anim.no_animaiton);
finish();
}

private ArrayList<Animation> getAnimList() {
ArrayList<Animation> animList = new ArrayList<>();
animList.add(CreateAnim.INSTANCE.createAnimation(getApplicationContext(), R.anim.no_animaiton));
animList.add(CreateAnim.INSTANCE.createAnimation(getApplicationContext(), R.anim.rotate));
animList.add(CreateAnim.INSTANCE.createAnimation(getApplicationContext(), R.anim.zoom_out_fast));
animList.add(CreateAnim.INSTANCE.createAnimation(getApplicationContext(), R.anim.fade_in));

return animList;
}
}
27 changes: 6 additions & 21 deletions app/src/main/java/com/app/splashapplication/StarterActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import android.os.Bundle
import android.view.View
import android.view.WindowManager
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.app.lets_go_splash.CreateAnim.createAnimation
import com.app.lets_go_splash.OnAnimationListener
import com.app.lets_go_splash.StarterAnimation
import kotlinx.android.synthetic.main.activity_starter.*
Expand Down Expand Up @@ -44,26 +44,11 @@ class StarterActivity : AppCompatActivity() {
private fun getAnimList(): ArrayList<Animation> {
// create list of animations
val animList: ArrayList<Animation> = ArrayList()
val anim = AnimationUtils.loadAnimation(
applicationContext,
R.anim.no_animaiton
)
val anim1 = AnimationUtils.loadAnimation(
applicationContext,
R.anim.rotate
)
val anim2 = AnimationUtils.loadAnimation(
applicationContext,
R.anim.zoom_out_fast
)
val anim4 = AnimationUtils.loadAnimation(
applicationContext,
R.anim.fade_in
)
animList.add(anim)
animList.add(anim1)
animList.add(anim2)
animList.add(anim4)

animList.add(createAnimation(applicationContext, R.anim.no_animaiton))
animList.add(createAnimation(applicationContext, R.anim.rotate))
animList.add(createAnimation(applicationContext, R.anim.zoom_out_fast))
animList.add(createAnimation(applicationContext, R.anim.fade_in))

return animList
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/activity_java_splash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".JavaSplashActivity">

</androidx.constraintlayout.widget.ConstraintLayout>
14 changes: 14 additions & 0 deletions lets_go_splash/src/main/java/com/app/lets_go_splash/CreateAnim.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.app.lets_go_splash

import android.content.Context
import android.view.animation.Animation
import android.view.animation.AnimationUtils

object CreateAnim {
fun createAnimation(applicationContext: Context, animFile: Int): Animation {
return AnimationUtils.loadAnimation(
applicationContext,
animFile
)
}
}

0 comments on commit 3ad1027

Please sign in to comment.