Commit ef2ddec9 by Paktalin

introduced TagFragment

parent 6dbccfca
......@@ -19,7 +19,6 @@ import com.paktalin.vocabularynotebook.vocabulary.Sort
import com.paktalin.vocabularynotebook.vocabulary.VocabSet
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.content_main.*
import kotlinx.android.synthetic.main.tag.*
class MainActivity : AppCompatActivity() {
......@@ -129,10 +128,10 @@ class MainActivity : AppCompatActivity() {
if (!selection.isEmpty) {
vocabularyAdapter.showPopupMenu = false
Log.d(TAG, "selection ${selection.toList()}")
visible(tagLayout)
addTagFragment(supportFragmentManager, R.id.main_activity_container)
} else {
vocabularyAdapter.showPopupMenu = true
gone(tagLayout)
removeTagFragment(supportFragmentManager)
}
}
......
package com.paktalin.vocabularynotebook.ui.fragments
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.paktalin.vocabularynotebook.R
class TagFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_tag, container, false)
}
}
\ No newline at end of file
......@@ -3,15 +3,17 @@ package com.paktalin.vocabularynotebook.utils
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import android.view.View
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.paktalin.vocabularynotebook.R
import com.paktalin.vocabularynotebook.ui.fragments.ProgressFragment
import com.paktalin.vocabularynotebook.ui.fragments.TagFragment
import org.apache.commons.lang3.StringUtils
val progressFragment: Fragment = ProgressFragment()
val progressFragment = ProgressFragment()
val tagFragment = TagFragment()
fun addFragment(fragmentManager: FragmentManager, fragment: Fragment, containerId: Int, arguments: Bundle? = null, tag: String? = null) {
fragment.arguments = arguments
......@@ -26,7 +28,16 @@ fun removeFragment(fragmentManager: FragmentManager, fragment: Fragment) {
}
fun addProgressBar(fragmentManager: FragmentManager, containerId: Int) {
addFragment(fragmentManager, progressFragment, containerId, null)
addFragment(fragmentManager, progressFragment, containerId)
}
fun addTagFragment(fragmentManager: FragmentManager, containerId: Int) {
if (fragmentManager.findFragmentById(tagFragment.id) == null)
addFragment(fragmentManager, tagFragment, containerId)
}
fun removeTagFragment(fragmentManager: FragmentManager) {
removeFragment(fragmentManager, tagFragment)
}
fun removeProgressBar(fragmentManager: FragmentManager) {
......
......@@ -2,6 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="@+id/main_activity_container"
android:layout_height="match_parent">
<LinearLayout
......@@ -43,6 +44,4 @@
<include layout="@layout/submit" />
<include layout="@layout/tag" />
</RelativeLayout>
\ No newline at end of file
......@@ -7,8 +7,7 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary"
android:orientation="horizontal"
android:visibility="gone">
android:orientation="horizontal">
<ImageButton
android:id="@+id/btnCancelTag"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment