make use of the FAB at Select Contact activity
This commit is contained in:
parent
324d9ef399
commit
3da4c170d8
|
@ -18,8 +18,8 @@ import com.simplemobiletools.contacts.pro.helpers.*
|
|||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||
import com.simplemobiletools.contacts.pro.models.Contact
|
||||
import kotlinx.android.synthetic.main.activity_insert_edit_contact.*
|
||||
import kotlinx.android.synthetic.main.fragment_contacts.*
|
||||
import kotlinx.android.synthetic.main.fragment_favorites.*
|
||||
import kotlinx.android.synthetic.main.fragment_insert_or_edit_contacts.*
|
||||
|
||||
class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||
private val START_INSERT_ACTIVITY = 1
|
||||
|
@ -117,8 +117,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
|||
}
|
||||
|
||||
if (viewpager.adapter == null) {
|
||||
val fragments = arrayListOf(R.layout.fragment_insert_or_edit_contacts, R.layout.fragment_favorites)
|
||||
viewpager.adapter = ViewPagerAdapter(this, contactsFavoritesList, CONTACTS_TAB_MASK or FAVORITES_TAB_MASK, fragments)
|
||||
viewpager.adapter = ViewPagerAdapter(this, contactsFavoritesList, CONTACTS_TAB_MASK or FAVORITES_TAB_MASK)
|
||||
}
|
||||
|
||||
ContactsHelper(this).getContacts { contacts ->
|
||||
|
@ -127,7 +126,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
|||
}
|
||||
|
||||
if (refreshTabsMask and CONTACTS_TAB_MASK != 0) {
|
||||
insert_or_edit_contacts_fragment?.refreshContacts(contacts)
|
||||
contacts_fragment?.refreshContacts(contacts)
|
||||
}
|
||||
|
||||
if (refreshTabsMask and FAVORITES_TAB_MASK != 0) {
|
||||
|
@ -185,4 +184,8 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun fabClicked() {
|
||||
createNewContact()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -532,8 +532,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||
isGettingContacts = true
|
||||
|
||||
if (viewpager.adapter == null) {
|
||||
val fragments = arrayListOf(R.layout.fragment_contacts, R.layout.fragment_favorites, R.layout.fragment_groups)
|
||||
viewpager.adapter = ViewPagerAdapter(this, tabsList, config.showTabs, fragments)
|
||||
viewpager.adapter = ViewPagerAdapter(this, tabsList, config.showTabs)
|
||||
viewpager.currentItem = config.lastUsedViewPagerPage
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,14 @@ package com.simplemobiletools.contacts.pro.adapters
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.contacts.pro.fragments.MyViewPagerFragment
|
||||
import com.simplemobiletools.contacts.pro.helpers.CONTACTS_TAB_MASK
|
||||
import com.simplemobiletools.contacts.pro.helpers.FAVORITES_TAB_MASK
|
||||
import com.simplemobiletools.contacts.pro.helpers.GROUPS_TAB_MASK
|
||||
|
||||
class ViewPagerAdapter(val activity: SimpleActivity, val currTabsList: ArrayList<Int>, val showTabs: Int, val pagerFragments: ArrayList<Int>) : PagerAdapter() {
|
||||
class ViewPagerAdapter(val activity: SimpleActivity, val currTabsList: ArrayList<Int>, val showTabs: Int) : PagerAdapter() {
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
||||
val layout = getFragment(position)
|
||||
|
@ -34,15 +35,15 @@ class ViewPagerAdapter(val activity: SimpleActivity, val currTabsList: ArrayList
|
|||
private fun getFragment(position: Int): Int {
|
||||
val fragments = arrayListOf<Int>()
|
||||
if (showTabs and CONTACTS_TAB_MASK != 0) {
|
||||
fragments.add(pagerFragments[0])
|
||||
fragments.add(R.layout.fragment_contacts)
|
||||
}
|
||||
|
||||
if (showTabs and FAVORITES_TAB_MASK != 0) {
|
||||
fragments.add(pagerFragments[1])
|
||||
fragments.add(R.layout.fragment_favorites)
|
||||
}
|
||||
|
||||
if (showTabs and GROUPS_TAB_MASK != 0) {
|
||||
fragments.add(pagerFragments[2])
|
||||
fragments.add(R.layout.fragment_groups)
|
||||
}
|
||||
|
||||
return fragments[position]
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.simplemobiletools.commons.helpers.SORT_BY_FIRST_NAME
|
|||
import com.simplemobiletools.commons.helpers.SORT_BY_SURNAME
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.activities.GroupContactsActivity
|
||||
import com.simplemobiletools.contacts.pro.activities.InsertOrEditContactActivity
|
||||
import com.simplemobiletools.contacts.pro.activities.MainActivity
|
||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
|
||||
|
@ -40,7 +41,11 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||
if (this.activity == null) {
|
||||
this.activity = activity
|
||||
fragment_fab?.setOnClickListener {
|
||||
fabClicked()
|
||||
if (activity is InsertOrEditContactActivity) {
|
||||
activity.fabClicked()
|
||||
} else {
|
||||
fabClicked()
|
||||
}
|
||||
}
|
||||
|
||||
fragment_placeholder_2?.setOnClickListener {
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.simplemobiletools.contacts.pro.fragments.InsertOrEditContactsFragment
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/insert_or_edit_contacts_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/fragment_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/fragment_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
android:id="@+id/fragment_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignTop="@+id/fragment_list"
|
||||
android:layout_alignBottom="@+id/fragment_list"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</RelativeLayout>
|
||||
</com.simplemobiletools.contacts.pro.fragments.InsertOrEditContactsFragment>
|
Loading…
Reference in New Issue