first commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package kr.co.vividnext.sodalive.base
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
|
||||
abstract class BaseActivity<T : ViewBinding>(
|
||||
private val inflate: (LayoutInflater) -> T
|
||||
) : AppCompatActivity() {
|
||||
|
||||
val compositeDisposable = CompositeDisposable()
|
||||
|
||||
lateinit var binding: T
|
||||
private set
|
||||
|
||||
val screenWidth: Int by lazy {
|
||||
resources.displayMetrics.widthPixels
|
||||
}
|
||||
|
||||
val screenHeight: Int by lazy {
|
||||
resources.displayMetrics.heightPixels
|
||||
}
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
|
||||
binding = inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
setupView()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
compositeDisposable.clear()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
fun showToast(message: String) {
|
||||
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
abstract fun setupView()
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package kr.co.vividnext.sodalive.base
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
|
||||
open class BaseFragment<T : ViewBinding>(
|
||||
private val inflate: (LayoutInflater, ViewGroup?, Boolean) -> T
|
||||
) : Fragment() {
|
||||
|
||||
val compositeDisposable = CompositeDisposable()
|
||||
|
||||
private var _binding: T? = null
|
||||
val binding get() = _binding!!
|
||||
|
||||
val screenWidth: Int by lazy {
|
||||
resources.displayMetrics.widthPixels
|
||||
}
|
||||
|
||||
val screenHeight: Int by lazy {
|
||||
resources.displayMetrics.heightPixels
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
_binding = inflate.invoke(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
_binding = null
|
||||
compositeDisposable.clear()
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
fun showToast(message: String) {
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package kr.co.vividnext.sodalive.base
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
|
||||
open class BaseViewModel : ViewModel() {
|
||||
val compositeDisposable = CompositeDisposable()
|
||||
|
||||
override fun onCleared() {
|
||||
compositeDisposable.dispose()
|
||||
super.onCleared()
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package kr.co.vividnext.sodalive.main
|
||||
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityMainBinding
|
||||
|
||||
class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::inflate) {
|
||||
override fun setupView() {}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package kr.co.vividnext.sodalive.splash
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.databinding.ActivitySplashBinding
|
||||
import kr.co.vividnext.sodalive.main.MainActivity
|
||||
|
||||
@SuppressLint("CustomSplashScreen")
|
||||
class SplashActivity : BaseActivity<ActivitySplashBinding>(ActivitySplashBinding::inflate) {
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
handler.postDelayed({
|
||||
startActivity(
|
||||
Intent(applicationContext, MainActivity::class.java).apply {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
}
|
||||
)
|
||||
finish()
|
||||
}, 500)
|
||||
}
|
||||
|
||||
override fun setupView() {}
|
||||
}
|
Reference in New Issue
Block a user