Wayne 6 лет назад
Родитель
Сommit
e9d8457f36

+ 15 - 13
src/main/java/com/bomostory/sceneeditmodule/cover/Category.kt

@@ -1,16 +1,18 @@
 package com.bomostory.sceneeditmodule.cover
 
-enum class Category(val id: Int) {
-    Daily(1),
-    HumanRelations(2),
-    Character(3),
-    Ispirational(4),
-    Knowledge(5),
-    Natural(6),
-    EnvironmentalProtection(7),
-    Imagine(8),
-    Life(9),
-    Culture(10),
-    Fables(11),
-    Others(12),
+import com.example.tfat.myapplication.R
+
+enum class Category(val id: Int, val stringResId: Int) {
+    Daily(1, R.string.category_item_daily),
+    HumanRelations(2, R.string.category_item_human_relations),
+    Character(3, R.string.category_item_character),
+    Ispirational(4, R.string.category_item_ispirational),
+    Knowledge(5, R.string.category_item_knowledge),
+    Natural(6, R.string.category_item_natural),
+    EnvironmentalProtection(7, R.string.category_item_environmental_protection),
+    Imagine(8, R.string.category_item_imagine),
+    Life(9, R.string.category_item_life),
+    Culture(10, R.string.category_item_culture),
+    Fables(11, R.string.category_item_fables),
+    Others(12, R.string.category_item_others),
 }

+ 10 - 0
src/main/java/com/bomostory/sceneeditmodule/cover/FrontCoverEditorView.kt

@@ -3,6 +3,7 @@ package com.bomostory.sceneeditmodule.cover
 import android.content.Context
 import android.util.AttributeSet
 import android.view.View
+import android.widget.ArrayAdapter
 import com.example.tfat.myapplication.R
 import kotlinx.android.synthetic.main.view_front_cover_editor.view.*
 
@@ -48,5 +49,14 @@ class FrontCoverEditorView @JvmOverloads constructor(
         }
         btn_frontCoverEditor_save.setOnClickListener { onSave?.onClick(it) }
         btn_frontCoverEditor_cancel.setOnClickListener { onCancel?.onClick(it) }
+
+        // category spinner
+        val itemLayoutResId = android.R.layout.simple_dropdown_item_1line
+        spinner_frontCoverEditor_category.adapter = ArrayAdapter<String>(context, itemLayoutResId).apply {
+            Category.values().forEach {
+                val s = context.getString(it.stringResId)
+                add(s)
+            }
+        }
     }
 }

+ 5 - 0
src/main/res/layout/item_category.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent" />
+

+ 13 - 0
src/main/res/values/strings.xml

@@ -33,4 +33,17 @@
     <string name="front_cover_editor_dialog_save_btn">Save</string>
     <string name="front_cover_editor_dialog_choose_a_scene_btn">Choose a scene</string>
     <string name="front_cover_editor_dialog_cancel_btn">Cancel</string>
+
+    <string name="category_item_daily">Daily</string>
+    <string name="category_item_human_relations">Human relations</string>
+    <string name="category_item_character">Character</string>
+    <string name="category_item_ispirational">Ispirational</string>
+    <string name="category_item_knowledge">Knowledge</string>
+    <string name="category_item_natural">Natural</string>
+    <string name="category_item_environmental_protection">Environmental protection</string>
+    <string name="category_item_imagine">Imagine</string>
+    <string name="category_item_life">Life</string>
+    <string name="category_item_culture">Culture</string>
+    <string name="category_item_fables">Fables</string>
+    <string name="category_item_others">Others</string>
 </resources>