mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
some minor code cleanup
This commit is contained in:
@ -8,7 +8,6 @@ import android.os.Bundle
|
||||
import android.provider.ContactsContract
|
||||
import android.provider.ContactsContract.CommonDataKinds.Email
|
||||
import android.provider.ContactsContract.CommonDataKinds.Phone
|
||||
import android.view.MenuItem
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
@ -35,8 +34,6 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||
private val START_INSERT_ACTIVITY = 1
|
||||
private val START_EDIT_ACTIVITY = 2
|
||||
|
||||
private var isSearchOpen = false
|
||||
private var searchMenuItem: MenuItem? = null
|
||||
private var isSelectContactIntent = false
|
||||
private var specialMimeType: String? = null
|
||||
|
||||
@ -89,11 +86,6 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||
setupTabColors()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
searchMenuItem?.collapseActionView()
|
||||
}
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
insert_edit_menu.getToolbar().inflateMenu(R.menu.menu_insert_or_edit)
|
||||
insert_edit_menu.toggleHideOnScroll(false)
|
||||
@ -344,15 +336,6 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun closeSearch() {
|
||||
if (isSearchOpen) {
|
||||
getAllFragments().forEach {
|
||||
it?.onSearchQueryChanged("")
|
||||
}
|
||||
searchMenuItem?.collapseActionView()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSortingDialog() {
|
||||
ChangeSortingDialog(this) {
|
||||
refreshContacts(getTabsMask())
|
||||
|
@ -513,7 +513,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||
try {
|
||||
startActivityForResult(this, PICK_EXPORT_FILE_INTENT)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
toast(R.string.system_service_disabled, Toast.LENGTH_LONG)
|
||||
toast(R.string.no_app_found, Toast.LENGTH_LONG)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ class ContactsAdapter(
|
||||
private val enableDrag: Boolean = false,
|
||||
itemClick: (Any) -> Unit
|
||||
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate, ItemTouchHelperContract {
|
||||
|
||||
private val NEW_GROUP_ID = -1
|
||||
|
||||
private var config = activity.config
|
||||
@ -64,12 +65,11 @@ class ContactsAdapter(
|
||||
var showContactThumbnails = config.showContactThumbnails
|
||||
var showPhoneNumbers = config.showPhoneNumbers
|
||||
var fontSize = activity.getTextSize()
|
||||
var onDragEndListener: (() -> Unit)? = null
|
||||
|
||||
private val itemLayout = if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
|
||||
|
||||
private var touchHelper: ItemTouchHelper? = null
|
||||
private var startReorderDragListener: StartReorderDragListener? = null
|
||||
var onDragEndListener: (() -> Unit)? = null
|
||||
|
||||
init {
|
||||
setupDragListener(true)
|
||||
@ -465,7 +465,7 @@ class ContactsAdapter(
|
||||
notifyItemMoved(fromPosition, toPosition)
|
||||
}
|
||||
|
||||
override fun onRowSelected(myViewHolder: ViewHolder?) { }
|
||||
override fun onRowSelected(myViewHolder: ViewHolder?) {}
|
||||
|
||||
override fun onRowClear(myViewHolder: ViewHolder?) {
|
||||
onDragEndListener?.invoke()
|
||||
|
@ -78,17 +78,6 @@ class SelectContactsAdapter(
|
||||
|
||||
override fun getItemCount() = contacts.size
|
||||
|
||||
fun updateItems(newItems: ArrayList<Contact>, highlightText: String = "") {
|
||||
if (newItems.hashCode() != contacts.hashCode()) {
|
||||
contacts = newItems.clone() as ArrayList<Contact>
|
||||
textToHighlight = highlightText
|
||||
notifyDataSetChanged()
|
||||
} else if (textToHighlight != highlightText) {
|
||||
textToHighlight = highlightText
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
if (!activity.isDestroyed && !activity.isFinishing) {
|
||||
|
@ -35,7 +35,6 @@ class ExportContactsDialog(
|
||||
|
||||
if (hidePath) {
|
||||
export_contacts_folder_hint.beGone()
|
||||
export_contacts_folder.beGone()
|
||||
} else {
|
||||
export_contacts_folder.setOnClickListener {
|
||||
activity.hideKeyboard(export_contacts_filename)
|
||||
|
@ -9,7 +9,7 @@ import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.contacts.pro.adapters.SelectContactsAdapter
|
||||
import com.simplemobiletools.contacts.pro.extensions.getVisibleContactSources
|
||||
import com.simplemobiletools.contacts.pro.models.Contact
|
||||
import kotlinx.android.synthetic.main.layout_select_contact.view.*
|
||||
import kotlinx.android.synthetic.main.dialog_select_contact.view.*
|
||||
import java.util.*
|
||||
|
||||
class SelectContactsDialog(
|
||||
@ -17,7 +17,7 @@ class SelectContactsDialog(
|
||||
selectContacts: ArrayList<Contact>? = null, val callback: (addedContacts: ArrayList<Contact>, removedContacts: ArrayList<Contact>) -> Unit
|
||||
) {
|
||||
private var dialog: AlertDialog? = null
|
||||
private var view = activity.layoutInflater.inflate(R.layout.layout_select_contact, null)
|
||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_select_contact, null)
|
||||
private var initiallySelectedContacts = ArrayList<Contact>()
|
||||
|
||||
init {
|
||||
|
Reference in New Issue
Block a user