|
@@ -0,0 +1,124 @@
|
|
|
+package com.bomostory.sceneeditmodule
|
|
|
+
|
|
|
+import android.content.Context
|
|
|
+import android.content.Intent
|
|
|
+import android.graphics.drawable.Drawable
|
|
|
+import android.support.v7.app.AppCompatActivity
|
|
|
+import android.os.Bundle
|
|
|
+import android.support.v4.view.PagerAdapter
|
|
|
+import android.util.AttributeSet
|
|
|
+import android.view.LayoutInflater
|
|
|
+import android.view.View
|
|
|
+import com.bomostory.sceneeditmodule.basicdata.OtherThemes
|
|
|
+import com.example.tfat.myapplication.R
|
|
|
+import com.google.gson.Gson
|
|
|
+import kotlinx.android.synthetic.main.activity_choose_theme.*
|
|
|
+import android.widget.LinearLayout
|
|
|
+import kotlinx.android.synthetic.main.theme_page_view.view.*
|
|
|
+import android.view.ViewGroup
|
|
|
+import com.bomostory.sceneeditmodule.basicdata.ThemeActorResource
|
|
|
+import com.example.tfat.myapplication.SceneEditActivity
|
|
|
+
|
|
|
+
|
|
|
+class ChooseThemeActivity : AppCompatActivity() {
|
|
|
+
|
|
|
+ private lateinit var otherThemes: OtherThemes
|
|
|
+ private var pageList = ArrayList<ThemePageView>()
|
|
|
+ private var resourceObjectPath = ArrayList<String>()
|
|
|
+ private var resourceActorPath = ThemeActorResource()
|
|
|
+ private var coverPath = ArrayList<String>()
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ setContentView(R.layout.activity_choose_theme)
|
|
|
+ otherThemes = Gson().fromJson<OtherThemes>(intent.getStringExtra("other_theme"), OtherThemes::class.java)
|
|
|
+ for (i in 0 until otherThemes.themes.size) {
|
|
|
+ var theme = otherThemes.themes[i]
|
|
|
+ val path = "${theme.assetFolder.path}/${theme.themeAssetIndex.largeFile}"
|
|
|
+ coverPath.add(path)
|
|
|
+ }
|
|
|
+ for (i in 0 until coverPath.size) {
|
|
|
+ var themePageView = ThemePageView(this).apply {
|
|
|
+ iv_themePageView_cover.setImageDrawable(Drawable.createFromPath(coverPath[i]))
|
|
|
+ iv_themePageView_cover.setOnClickListener {
|
|
|
+ resourceActorPath.actorPath = ArrayList<ArrayList<String>>().apply {
|
|
|
+ otherThemes.themes[i].themeAssetIndex.contains.actor.forEach {
|
|
|
+ add(ArrayList<String>().apply {
|
|
|
+ it.value.values.forEach {
|
|
|
+ val path = "${otherThemes.themes[i].assetFolder.path}/${it.smallFile}"
|
|
|
+ add(path)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resourceObjectPath = java.util.ArrayList<String>().apply {
|
|
|
+ otherThemes.themes[i].themeAssetIndex.contains.obj.values.forEach {
|
|
|
+ val path = "${otherThemes.themes[i].assetFolder.path}/${it.smallFile}"
|
|
|
+ add(path)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ val intent = Intent(this@ChooseThemeActivity, SceneEditActivity::class.java).apply {
|
|
|
+ putExtra("project", intent.getStringExtra("project"))
|
|
|
+ putExtra("other_theme", Gson().toJson(otherThemes))
|
|
|
+ putExtra("resource_actor", Gson().toJson(resourceActorPath))
|
|
|
+ putStringArrayListExtra("resource_object", resourceObjectPath)
|
|
|
+ }
|
|
|
+ startActivity(intent)
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pageList.add(themePageView)
|
|
|
+ }
|
|
|
+ viewPager_newStory.adapter = SamplePagerAdapter(pageList)
|
|
|
+ }
|
|
|
+ override fun onResume() {
|
|
|
+ super.onResume()
|
|
|
+ window.decorView.apply {
|
|
|
+ systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
|
+ or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
|
+ or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
|
+ or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
|
|
+ or View.SYSTEM_UI_FLAG_FULLSCREEN
|
|
|
+ or View.SYSTEM_UI_FLAG_LOW_PROFILE
|
|
|
+ or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private class SamplePagerAdapter(pageList: ArrayList<ThemePageView>) : PagerAdapter() {
|
|
|
+ var pageList = pageList
|
|
|
+
|
|
|
+ override fun getCount(): Int {
|
|
|
+ return pageList.size
|
|
|
+ }
|
|
|
+ override fun isViewFromObject(p0: View, p1: Any): Boolean {
|
|
|
+ return p1 == p0
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
|
|
+ container.addView(pageList[position])
|
|
|
+ return pageList[position]
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
|
|
|
+ container.removeView(`object` as View)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private class ThemePageView : LinearLayout {
|
|
|
+
|
|
|
+ constructor(context: Context) : super(context) {
|
|
|
+ initView()
|
|
|
+ }
|
|
|
+
|
|
|
+ constructor(context: Context, attrs: AttributeSet): super(context, attrs) {
|
|
|
+ initView()
|
|
|
+ }
|
|
|
+
|
|
|
+ constructor(context: Context, attrs: AttributeSet, defStyle: Int): super(context, attrs, defStyle) {
|
|
|
+ initView()
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun initView() {
|
|
|
+ val inflater = LayoutInflater.from(context)
|
|
|
+ inflater.inflate(R.layout.theme_page_view, this, true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|