Skip to content

Commit

Permalink
Intent activity animation
Browse files Browse the repository at this point in the history
  • Loading branch information
kichan05 committed Feb 15, 2022
1 parent 95d372e commit 7e5df72
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 14 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/edcan/howtosunrin/base/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ abstract class BaseActivity<D : ViewDataBinding>(
return true
}

override fun finish() {
super.finish()
overridePendingTransition(R.anim.anim_hold, R.anim.anim_slide_to_right)
}

protected val gotoWebEDCAN = {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://edcan.kr"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ class MainActivity : BaseActivity<ActivityMainBinding>(R.layout.activity_main) {
private val gotoActivityQnA = { _: View ->
val intent = Intent(this, QnASliderActivity::class.java)
startActivity(intent)
overridePendingTransition(R.anim.anim_slide_from_right, R.anim.anim_hold)
}

private val gotoActivityChat = { _: View ->
val intent = Intent(this, ChatActivity::class.java)
intent.putExtra("userData", currentUserData)
startActivity(intent)
overridePendingTransition(R.anim.anim_slide_from_right, R.anim.anim_hold)
}

private val gotoActivitySaveQnA = { _ : View ->
val intent = Intent(this, SaveQuestionActivity::class.java)
startActivity(intent)
overridePendingTransition(R.anim.anim_slide_from_right, R.anim.anim_hold)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class OnBoardActivity : BaseActivity<ActivityOnBoardBinding>(R.layout.activity_o
startActivity(intent)

super.finish()
overridePendingTransition(R.anim.anim_slide_from_right, R.anim.anim_hold)
}

fun getFragments() : List<Fragment> = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,8 @@ class QnASliderActivity : BaseActivity<ActivityQnaSliderBinding>(R.layout.activi

btnQnaRemoveQuestion.setOnClickListener { removeQuestion(getCurrentQuestion()!!) }
}

// viewModel.isCurrentQnASave.observe(this){
// Log.d("isCurrentQnASave", it.toString())
// }
}


fun saveQuestion(questionData : Question) {
viewModel.saveQuestion(questionData)
Toast.makeText(this, "질문을 추가했습니다.", Toast.LENGTH_LONG).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SaveQuestionActivity : BaseActivity<ActivitySaveQuestionBinding>(R.layout.
binding.btnSaveQnAGotoQnA.setOnClickListener {
val intent = Intent(this, QnASliderActivity::class.java)
startActivity(intent)
overridePendingTransition(R.anim.anim_slide_from_right, R.anim.anim_hold)
}

viewModel.getSaveQuestions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@ import android.app.Activity
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import com.edcan.howtosunrin.R
import com.edcan.howtosunrin.utill.SharedUtil
import com.edcan.howtosunrin.utill.chat.ChatDB
import com.edcan.howtosunrin.utill.qna.DB
import com.edcan.howtosunrin.utill.user.UserDB
import com.edcan.howtosunrin.ui.main.MainActivity
import com.edcan.howtosunrin.ui.onboard.OnBoardActivity
import com.edcan.howtosunrin.ui.onboard.OnBoardFragment
import com.edcan.howtosunrin.ui.userData.UserDataActivity
import com.edcan.howtosunrin.utill.qna.Question
import com.edcan.howtosunrin.utill.qna.QuestionDatabase
import kotlinx.coroutines.*

Expand All @@ -40,7 +35,6 @@ class SplashActivity : AppCompatActivity() {
SharedUtil.editor = SharedUtil.pref.edit()



CoroutineScope(Dispatchers.Main).launch {
val userId = SharedUtil.pref.getString(SharedUtil.keyUserId, "none")

Expand All @@ -50,15 +44,19 @@ class SplashActivity : AppCompatActivity() {

val intent = Intent(this@SplashActivity, OnBoardActivity::class.java)
startActivity(intent)
overridePendingTransition(R.anim.anim_slide_up_before, R.anim.anim_slide_up)

finish()
} else{ //두번째 이상 실행인 경우
delay(700)

val intent = Intent(this@SplashActivity, MainActivity::class.java)

val userData = userDB.getUserDataById(userId!!)
intent.putExtra("userData", userData)


startActivity(intent)
overridePendingTransition(R.anim.anim_slide_up_before, R.anim.anim_slide_up)

finish()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class UserDataActivity : BaseActivity<ActivityUserDataBinding>(R.layout.activity
intent.putExtra("userData", viewModel.userData)
startActivity(intent)
finish()
overridePendingTransition(R.anim.anim_slide_from_right, R.anim.anim_hold)
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/anim/anim_hold.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0" android:toXDelta="0"
android:duration="@android:integer/config_longAnimTime"
/>
</set>
10 changes: 10 additions & 0 deletions app/src/main/res/anim/anim_slide_from_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="250"
android:interpolator="@android:anim/anticipate_interpolator"

android:fromXDelta="100%"
android:toXDelta="0"
/>
</set>
10 changes: 10 additions & 0 deletions app/src/main/res/anim/anim_slide_to_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="250"
android:interpolator="@android:anim/anticipate_interpolator"

android:fromXDelta="0"
android:toXDelta="100%"
/>
</set>
10 changes: 10 additions & 0 deletions app/src/main/res/anim/anim_slide_up.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1000"
android:interpolator="@android:anim/anticipate_interpolator"

android:fromYDelta="0"
android:toYDelta="-100%"
/>
</set>
10 changes: 10 additions & 0 deletions app/src/main/res/anim/anim_slide_up_before.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="700"
android:interpolator="@android:anim/anticipate_interpolator"

android:fromYDelta="100%"
android:toYDelta="0"
/>
</set>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/line.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="@color/gray1"
android:color="@color/gray3"
/>
</shape>

0 comments on commit 7e5df72

Please sign in to comment.