Prechádzať zdrojové kódy

Add ViewerEditView.OnViewerEditTabAddButtonClickListener

cooperku_kdanmobile 5 rokov pred
rodič
commit
e5c6f00bff

+ 36 - 9
reader/src/main/java/com/kdanmobile/reader/ReaderActivity.kt

@@ -22,13 +22,13 @@ import android.widget.LinearLayout
 import android.widget.TextView
 import com.kdanmobile.kmpdfkit.pdfcommon.KMPDFReaderView
 import com.kdanmobile.reader.Utils.applyConstraintSet
-import com.kdanmobile.reader.screen.view.BookmarkView
-import com.kdanmobile.reader.screen.view.OutlineView
-import com.kdanmobile.reader.screen.view.SearchView
-import com.kdanmobile.reader.screen.view.ThumbnailView
 import com.kdanmobile.reader.utils.AnimationUtil
 import com.kdanmobile.reader.utils.DensityUtil
 import com.kdanmobile.reader.screen.ViewerSettingActivity
+import com.kdanmobile.reader.screen.view.*
+import com.kdanmobile.reader.screen.view.edit.ShapeTabView
+import com.kdanmobile.reader.screen.view.edit.StampTabView
+import com.kdanmobile.reader.screen.view.edit.TextBoxTabView
 import kotlinx.android.synthetic.main.activity_reader.*
 import kotlin.Exception
 
@@ -82,6 +82,7 @@ abstract class ReaderActivity : AppCompatActivity() {
         setupLeftToolbar()
         setupRightSideToolbar()
         setupBottomToolbar()
+        setupViewerEditView()
 
         val factory = ReaderViewModelFactory()
         viewModel = ViewModelProviders.of(this, factory).get(ReaderViewModel::class.java)
@@ -161,9 +162,9 @@ abstract class ReaderActivity : AppCompatActivity() {
                 isHideToolbar = !isHideToolbar
             }
 
-            override fun onMoveToChild(p0: Int) {
-                super.onMoveToChild(p0)
-                viewModel.setPageIndex(p0)
+            override fun onMoveToChild(pageIndex: Int) {
+                super.onMoveToChild(pageIndex)
+                viewModel.setPageIndex(pageIndex)
                 updateThumbnailViewSelectedPage()
             }
 
@@ -223,6 +224,7 @@ abstract class ReaderActivity : AppCompatActivity() {
             AnimationUtil.hideViewFromTopToBottom(viewGroup_readerActivity_bottomToolbar, UI_ANIMATION_DURATION)
             AnimationUtil.hideViewFromRightToLeft(viewGroup_readerActivity_leftToolbar, UI_ANIMATION_DURATION)
             AnimationUtil.hideViewFromLeftToRight(viewGroup_readerActivity_rightToolbar, UI_ANIMATION_DURATION)
+            viewerEditView.visibility = View.GONE
             hideSearchViewSoftKeyboard()
         } else {
             constrainLayout_readerActivity_root.applyConstraintSet(this, R.layout.activity_reader_hide_all, UI_ANIMATION_DURATION)
@@ -361,6 +363,32 @@ abstract class ReaderActivity : AppCompatActivity() {
         Utils.setTintDrawableList(context, ib_readerActivity_bottomToolbarKdanCloud, R.drawable.ic_kdan_cloud, normalColor, pressColor)
     }
 
+    private fun setupViewerEditView() {
+
+        ib_readerActivity_bottomToolbarKdanCloud.setOnClickListener {
+            viewerEditView.visibility = View.VISIBLE
+        }
+
+        viewerEditView.apply {
+            onViewerEditTabAddButtonClickListener = object : ViewerEditView.OnViewerEditTabAddButtonClickListener {
+                override fun onTabTextBoxAddButtonClick(textBoxTabView: TextBoxTabView) {
+                    hideAllToolbars()
+                    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+                }
+
+                override fun onTabStampAddButtonClick(stampTabView: StampTabView) {
+                    hideAllToolbars()
+                    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+                }
+
+                override fun onTabShapeAddButtonClick(shapeTabView: ShapeTabView) {
+                    hideAllToolbars()
+                    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+                }
+            }
+        }
+    }
+
     private fun setLeftToolbarWidth(width: Int) {
         var params = viewGroup_readerActivity_leftToolbar.layoutParams as ConstraintLayout.LayoutParams
         params.width = width + w_left
@@ -461,8 +489,7 @@ abstract class ReaderActivity : AppCompatActivity() {
         leftToolbarType = type
     }
 
-    fun onClick(view: View)
-    {
+    fun onClick(view: View) {
         when (view.id) {
             R.id.iv_readerActivity_thumbnail -> {
                 onThumbnailClick()

+ 23 - 0
reader/src/main/java/com/kdanmobile/reader/screen/view/ViewerEditView.kt

@@ -11,6 +11,7 @@ import com.kdanmobile.reader.R
 import com.kdanmobile.reader.screen.view.edit.ShapeTabView
 import com.kdanmobile.reader.screen.view.edit.StampTabView
 import com.kdanmobile.reader.screen.view.edit.TextBoxTabView
+import com.kdanmobile.reader.screen.view.edit.TitleButton
 import kotlinx.android.synthetic.main.view_viewer_edit.view.*
 import kotlinx.android.synthetic.main.view_viewer_edit_tab.view.*
 
@@ -22,6 +23,7 @@ class ViewerEditView : ConstraintLayout {
 
     private var tabType = ViewerEditTabType.NONE
     private var selected: ImageButton? = null
+    var onViewerEditTabAddButtonClickListener: OnViewerEditTabAddButtonClickListener? = null
 
     constructor(context: Context) : super(context) {
         initView()
@@ -86,6 +88,11 @@ class ViewerEditView : ConstraintLayout {
             val textBoxTabView = TextBoxTabView(context)
             val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
             viewEdit_layout_tab_content.addView(textBoxTabView, params)
+            textBoxTabView.onTitleButtonClickListener = object: TitleButton.OnTitleButtonClickListener {
+                override fun onTitleButtonClick() {
+                    onViewerEditTabAddButtonClickListener?.onTabTextBoxAddButtonClick(textBoxTabView)
+                }
+            }
         }
     }
 
@@ -103,6 +110,11 @@ class ViewerEditView : ConstraintLayout {
             val stampTabView = StampTabView(context)
             val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
             viewEdit_layout_tab_content.addView(stampTabView, params)
+            stampTabView.onTitleButtonClickListener = object: TitleButton.OnTitleButtonClickListener {
+                override fun onTitleButtonClick() {
+                    onViewerEditTabAddButtonClickListener?.onTabStampAddButtonClick(stampTabView)
+                }
+            }
         }
     }
 
@@ -112,6 +124,11 @@ class ViewerEditView : ConstraintLayout {
             val shapeTabView = ShapeTabView(context)
             val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
             viewEdit_layout_tab_content.addView(shapeTabView, params)
+            shapeTabView.onTitleButtonClickListener = object: TitleButton.OnTitleButtonClickListener {
+                override fun onTitleButtonClick() {
+                    onViewerEditTabAddButtonClickListener?.onTabShapeAddButtonClick(shapeTabView)
+                }
+            }
         }
     }
 
@@ -122,4 +139,10 @@ class ViewerEditView : ConstraintLayout {
             LayoutInflater.from(context).inflate(R.layout.view_viewer_edit_tab, viewEdit_layout_tab_content)
         }
     }
+
+    interface OnViewerEditTabAddButtonClickListener {
+        fun onTabTextBoxAddButtonClick(textBoxTabView: TextBoxTabView)
+        fun onTabStampAddButtonClick(stampTabView: StampTabView)
+        fun onTabShapeAddButtonClick(shapeTabView: ShapeTabView)
+    }
 }

+ 1 - 0
reader/src/main/res/layout/activity_reader.xml

@@ -286,6 +286,7 @@
     </android.support.constraint.ConstraintLayout>
 
     <com.kdanmobile.reader.screen.view.ViewerEditView
+        android:id="@+id/viewerEditView"
         android:layout_width="match_parent"
         android:layout_height="match_parent" />
 </android.support.constraint.ConstraintLayout>