Fix a bunch of deprecations in Kotlin, and a few misc things

This commit is contained in:
TacoTheDank 2020-06-28 16:49:50 -04:00
parent 894a4aa325
commit 536371eb89
78 changed files with 313 additions and 188 deletions

View File

@ -28,6 +28,7 @@ import android.database.Cursor
import android.graphics.PorterDuff.Mode import android.graphics.PorterDuff.Mode
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import androidx.loader.app.LoaderManager
import androidx.loader.app.LoaderManager.LoaderCallbacks import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.content.CursorLoader import androidx.loader.content.CursorLoader
import androidx.loader.content.Loader import androidx.loader.content.Loader
@ -157,7 +158,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
searchQuery.setSelection(searchQuery.length()) searchQuery.setSelection(searchQuery.length())
} }
supportLoaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
updateSubmitButton() updateSubmitButton()
promotionService.loadBanner(adContainer) promotionService.loadBanner(adContainer)
@ -179,7 +180,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
adapter.addRemovedPositions(reverseSortedPositions) adapter.addRemovedPositions(reverseSortedPositions)
ContentResolverUtils.bulkDelete(contentResolver, SearchHistory.CONTENT_URI, SearchHistory._ID, ContentResolverUtils.bulkDelete(contentResolver, SearchHistory.CONTENT_URI, SearchHistory._ID,
false, ids, null, null) false, ids, null, null)
supportLoaderManager.restartLoader(0, null, this) LoaderManager.getInstance(this).restartLoader(0, null, this)
} }
override fun onClick(v: View) { override fun onClick(v: View) {
@ -298,7 +299,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
} }
override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) { override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
supportLoaderManager.restartLoader(0, null, this) LoaderManager.getInstance(this).restartLoader(0, null, this)
} }
override fun onNothingSelected(parent: AdapterView<*>) { override fun onNothingSelected(parent: AdapterView<*>) {

View File

@ -583,9 +583,9 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
val builder = AlertDialog.Builder(requireContext()) val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_expandable_list) builder.setView(R.layout.dialog_expandable_list)
val dialog = builder.create() val dialog = builder.create()
dialog.onShow { dialog.onShow { alertDialog ->
it.applyTheme() alertDialog.applyTheme()
val listView = it.expandableList val listView = alertDialog.expandableList
val adapter = LoginTypeAdapter(requireContext()) val adapter = LoginTypeAdapter(requireContext())
listView.setAdapter(adapter) listView.setAdapter(adapter)
listView.setOnGroupClickListener { _, _, groupPosition, _ -> listView.setOnGroupClickListener { _, _, groupPosition, _ ->
@ -613,7 +613,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
return@setOnChildClickListener true return@setOnChildClickListener true
} }
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
} }
return dialog return dialog
} }

View File

@ -275,6 +275,24 @@ class TrendsLocationSelectorActivity : BaseActivity() {
dest.writeTypedArray(children, flags) dest.writeTypedArray(children, flags)
} }
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as LocationsData
if (root != other.root) return false
if (!children.contentEquals(other.children)) return false
return true
}
override fun hashCode(): Int {
var result = root.hashCode()
result = 31 * result + children.contentHashCode()
return result
}
companion object { companion object {
@JvmField @JvmField
val CREATOR = object : Parcelable.Creator<LocationsData> { val CREATOR = object : Parcelable.Creator<LocationsData> {

View File

@ -55,7 +55,7 @@ class UserListSelectorActivity : BaseActivity(),
override var refreshing: Boolean override var refreshing: Boolean
get() { get() {
return supportLoaderManager.hasRunningLoadersSafe() return LoaderManager.getInstance(this).hasRunningLoadersSafe()
} }
set(value) { set(value) {
} }
@ -199,9 +199,9 @@ class UserListSelectorActivity : BaseActivity(),
} }
if (!loaderInitialized) { if (!loaderInitialized) {
loaderInitialized = true loaderInitialized = true
supportLoaderManager.initLoader(0, args, this) LoaderManager.getInstance(this).initLoader(0, args, this)
} else { } else {
supportLoaderManager.restartLoader(0, args, this) LoaderManager.getInstance(this).restartLoader(0, args, this)
} }
} }

View File

@ -153,10 +153,10 @@ class UserSelectorActivity : BaseActivity(), OnItemClickListener, LoaderManager.
this[EXTRA_FROM_CACHE] = fromCache this[EXTRA_FROM_CACHE] = fromCache
} }
if (loaderInitialized) { if (loaderInitialized) {
supportLoaderManager.initLoader(0, args, this) LoaderManager.getInstance(this).initLoader(0, args, this)
loaderInitialized = true loaderInitialized = true
} else { } else {
supportLoaderManager.restartLoader(0, args, this) LoaderManager.getInstance(this).restartLoader(0, args, this)
} }
} }

View File

@ -177,7 +177,7 @@ class WebLinkHandlerActivity : Activity() {
if (pathSegments[0] in TWITTER_RESERVED_PATHS) { if (pathSegments[0] in TWITTER_RESERVED_PATHS) {
return Pair(null, true) return Pair(null, true)
} }
return handleUserSpecificPageIntent(uri, pathSegments, pathSegments[0]) return handleUserSpecificPageIntent(pathSegments, pathSegments[0])
} }
} }
} }
@ -185,7 +185,7 @@ class WebLinkHandlerActivity : Activity() {
return Pair(homeIntent, true) return Pair(homeIntent, true)
} }
private fun handleUserSpecificPageIntent(uri: Uri, pathSegments: List<String>, screenName: String): Pair<Intent?, Boolean> { private fun handleUserSpecificPageIntent(pathSegments: List<String>, screenName: String): Pair<Intent?, Boolean> {
val segsSize = pathSegments.size val segsSize = pathSegments.size
if (segsSize == 1) { if (segsSize == 1) {
val builder = Uri.Builder() val builder = Uri.Builder()

View File

@ -104,7 +104,7 @@ class DummyItemAdapter(
override fun getAccountKey(position: Int, raw: Boolean) = UserKey.INVALID override fun getAccountKey(position: Int, raw: Boolean) = UserKey.INVALID
override fun findStatusById(accountKey: UserKey, statusId: String) = null override fun findStatusById(accountKey: UserKey, statusId: String): Nothing? = null
override fun isCardNumbersShown(position: Int): Boolean { override fun isCardNumbersShown(position: Int): Boolean {
if (position == RecyclerView.NO_POSITION) return showCardNumbers if (position == RecyclerView.NO_POSITION) return showCardNumbers

View File

@ -22,7 +22,7 @@ package org.mariotaku.twidere.adapter
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.database.CursorIndexOutOfBoundsException import android.database.CursorIndexOutOfBoundsException
import androidx.legacy.widget.Space import android.widget.Space
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View

View File

@ -24,7 +24,7 @@ import android.database.CursorIndexOutOfBoundsException
import android.util.SparseBooleanArray import android.util.SparseBooleanArray
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.legacy.widget.Space import android.widget.Space
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import org.mariotaku.kpreferences.get import org.mariotaku.kpreferences.get

View File

@ -71,26 +71,26 @@ fun Activity.toParcelable(accountKey: UserKey, accountType: String, isGap: Boole
it.toParcelable(accountKey, accountType, profileImageSize = profileImageSize) it.toParcelable(accountKey, accountType, profileImageSize = profileImageSize)
} }
result.targets = ParcelableActivity.RelatedObject().also { result.targets = ParcelableActivity.RelatedObject().also { relatedObject ->
it.statuses = targetStatuses?.mapToArray { relatedObject.statuses = targetStatuses?.mapToArray {
it.toParcelable(accountKey, accountType, profileImageSize) it.toParcelable(accountKey, accountType, profileImageSize)
} }
it.users = targetUsers?.mapToArray { relatedObject.users = targetUsers?.mapToArray {
it.toParcelable(accountKey, accountType, profileImageSize = profileImageSize) it.toParcelable(accountKey, accountType, profileImageSize = profileImageSize)
} }
it.user_lists = targetUserLists?.mapToArray { relatedObject.user_lists = targetUserLists?.mapToArray {
it.toParcelable(accountKey, profileImageSize = profileImageSize) it.toParcelable(accountKey, profileImageSize = profileImageSize)
} }
} }
result.target_objects = ParcelableActivity.RelatedObject().also { result.target_objects = ParcelableActivity.RelatedObject().also { relatedObject ->
it.statuses = targetObjectStatuses?.mapToArray { relatedObject.statuses = targetObjectStatuses?.mapToArray {
it.toParcelable(accountKey, accountType, profileImageSize) it.toParcelable(accountKey, accountType, profileImageSize)
} }
it.users = targetObjectUsers?.mapToArray { relatedObject.users = targetObjectUsers?.mapToArray {
it.toParcelable(accountKey, accountType, profileImageSize = profileImageSize) it.toParcelable(accountKey, accountType, profileImageSize = profileImageSize)
} }
it.user_lists = targetObjectUserLists?.mapToArray { relatedObject.user_lists = targetObjectUserLists?.mapToArray {
it.toParcelable(accountKey, profileImageSize = profileImageSize) it.toParcelable(accountKey, profileImageSize = profileImageSize)
} }
} }

View File

@ -152,7 +152,7 @@ class APIEditorDialogFragment : BaseDialogFragment() {
adapter = CustomAPIConfigArrayAdapter(requireContext()) adapter = CustomAPIConfigArrayAdapter(requireContext())
val builder = AlertDialog.Builder(requireContext()) val builder = AlertDialog.Builder(requireContext())
builder.setAdapter(adapter, this) builder.setAdapter(adapter, this)
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
val dialog = builder.create() val dialog = builder.create()
dialog.onShow { it.applyTheme() } dialog.onShow { it.applyTheme() }
return dialog return dialog

View File

@ -33,6 +33,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.OnScrollListener import androidx.recyclerview.widget.RecyclerView.OnScrollListener
import android.view.* import android.view.*
import androidx.loader.app.LoaderManager
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import kotlinx.android.synthetic.main.fragment_content_recyclerview.* import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
import org.mariotaku.kpreferences.get import org.mariotaku.kpreferences.get
@ -110,7 +111,7 @@ abstract class AbsActivitiesFragment protected constructor() :
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderManager.initLoader(loaderId, loaderArgs, this) LoaderManager.getInstance(this).initLoader(loaderId, loaderArgs, this)
showProgress() showProgress()
} }
@ -531,7 +532,7 @@ abstract class AbsActivitiesFragment protected constructor() :
return true return true
} }
else -> activity?.let { else -> activity?.let {
fragmentManager?.let { fragmentManager -> parentFragmentManager.let { fragmentManager ->
MenuUtils.handleStatusClick(it, this, fragmentManager, MenuUtils.handleStatusClick(it, this, fragmentManager,
preferences, userColorNameManager, twitterWrapper, status, item) preferences, userColorNameManager, twitterWrapper, status, item)
} }

View File

@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import androidx.loader.app.LoaderManager
import androidx.loader.app.LoaderManager.LoaderCallbacks import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.app.hasRunningLoadersSafe import androidx.loader.app.hasRunningLoadersSafe
import androidx.loader.content.Loader import androidx.loader.content.Loader
@ -49,7 +50,7 @@ abstract class AbsMediaStatusesFragment : AbsContentRecyclerViewFragment<Stagger
final override var refreshing: Boolean final override var refreshing: Boolean
get() { get() {
if (context == null || isDetached) return false if (context == null || isDetached) return false
return loaderManager.hasRunningLoadersSafe() return LoaderManager.getInstance(this).hasRunningLoadersSafe()
} }
set(value) { set(value) {
super.refreshing = value super.refreshing = value
@ -69,7 +70,7 @@ abstract class AbsMediaStatusesFragment : AbsContentRecyclerViewFragment<Stagger
adapter.statusClickListener = this adapter.statusClickListener = this
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderManager.initLoader(loaderId, loaderArgs, this) LoaderManager.getInstance(this).initLoader(loaderId, loaderArgs, this)
showProgress() showProgress()
} }

View File

@ -35,6 +35,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.OnScrollListener import androidx.recyclerview.widget.RecyclerView.OnScrollListener
import android.view.* import android.view.*
import androidx.loader.app.LoaderManager
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import kotlinx.android.synthetic.main.fragment_content_recyclerview.* import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
import org.mariotaku.kpreferences.get import org.mariotaku.kpreferences.get
@ -490,7 +491,7 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
if (isDetached || host == null || loaderInitialized) return if (isDetached || host == null || loaderInitialized) return
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderManager.initLoader(loaderId, loaderArgs, this) LoaderManager.getInstance(this).initLoader(loaderId, loaderArgs, this)
loaderInitialized = true loaderInitialized = true
} }
@ -575,7 +576,7 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
resolver?.update(contentUri, values, where, null) resolver?.update(contentUri, values, where, null)
return true return true
} }
else -> return MenuUtils.handleStatusClick(requireActivity(), this, requireFragmentManager(), else -> return MenuUtils.handleStatusClick(requireActivity(), this, parentFragmentManager,
preferences, userColorNameManager, twitterWrapper, status, item) preferences, userColorNameManager, twitterWrapper, status, item)
} }
} }

View File

@ -46,6 +46,7 @@ import androidx.appcompat.view.SupportMenuInflater
import androidx.appcompat.widget.ActionMenuView.OnMenuItemClickListener import androidx.appcompat.widget.ActionMenuView.OnMenuItemClickListener
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.MenuItemCompat import androidx.core.view.MenuItemCompat
import androidx.loader.app.LoaderManager
import androidx.loader.app.LoaderManager.LoaderCallbacks import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.content.FixedAsyncTaskLoader import androidx.loader.content.FixedAsyncTaskLoader
import androidx.loader.content.Loader import androidx.loader.content.Loader
@ -286,9 +287,9 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
fun loadAccounts() { fun loadAccounts() {
if (!loaderInitialized) { if (!loaderInitialized) {
loaderInitialized = true loaderInitialized = true
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
} else { } else {
loaderManager.restartLoader(0, null, this) LoaderManager.getInstance(this).restartLoader(0, null, this)
} }
} }
@ -659,7 +660,25 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
data class AccountsInfo( data class AccountsInfo(
val accounts: Array<AccountDetails>, val accounts: Array<AccountDetails>,
val draftsCount: Int val draftsCount: Int
) ) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as AccountsInfo
if (!accounts.contentEquals(other.accounts)) return false
if (draftsCount != other.draftsCount) return false
return true
}
override fun hashCode(): Int {
var result = accounts.contentHashCode()
result = 31 * result + draftsCount
return result
}
}
class AccountsInfoLoader( class AccountsInfoLoader(
context: Context, context: Context,

View File

@ -86,7 +86,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
emptyIcon.setImageResource(R.drawable.ic_info_error_generic) emptyIcon.setImageResource(R.drawable.ic_info_error_generic)
setListShown(false) setListShown(false)
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

View File

@ -29,6 +29,7 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import androidx.loader.content.Loader import androidx.loader.content.Loader
import android.widget.Toast import android.widget.Toast
import androidx.loader.app.LoaderManager
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import org.mariotaku.ktextension.* import org.mariotaku.ktextension.*
import org.mariotaku.library.objectcursor.ObjectCursor import org.mariotaku.library.objectcursor.ObjectCursor
@ -174,7 +175,7 @@ abstract class CursorActivitiesFragment : AbsActivitiesFragment() {
} }
override val shouldAbort: Boolean override val shouldAbort: Boolean
get() = currentContext == null get() = false
}) })
} }
@ -237,7 +238,7 @@ abstract class CursorActivitiesFragment : AbsActivitiesFragment() {
args.putAll(fragmentArgs) args.putAll(fragmentArgs)
args.putBoolean(EXTRA_FROM_USER, true) args.putBoolean(EXTRA_FROM_USER, true)
} }
loaderManager.restartLoader(loaderId, args, this) LoaderManager.getInstance(this).restartLoader(loaderId, args, this)
} }
fun replaceStatusStates(result: ParcelableStatus?) { fun replaceStatusStates(result: ParcelableStatus?) {

View File

@ -28,6 +28,7 @@ import android.os.Bundle
import android.os.Handler import android.os.Handler
import androidx.loader.content.Loader import androidx.loader.content.Loader
import android.widget.Toast import android.widget.Toast
import androidx.loader.app.LoaderManager
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import kotlinx.android.synthetic.main.fragment_content_recyclerview.* import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
@ -236,7 +237,7 @@ abstract class CursorStatusesFragment : AbsStatusesFragment() {
args.putAll(fragmentArgs) args.putAll(fragmentArgs)
args.putBoolean(EXTRA_FROM_USER, true) args.putBoolean(EXTRA_FROM_USER, true)
} }
loaderManager.restartLoader(loaderId, args, this) LoaderManager.getInstance(this).restartLoader(loaderId, args, this)
} }
private fun showContentOrError() { private fun showContentOrError() {

View File

@ -39,6 +39,7 @@ import android.view.*
import android.widget.* import android.widget.*
import android.widget.AbsListView.MultiChoiceModeListener import android.widget.AbsListView.MultiChoiceModeListener
import android.widget.AdapterView.OnItemClickListener import android.widget.AdapterView.OnItemClickListener
import androidx.loader.app.LoaderManager
import com.mobeta.android.dslv.SimpleDragSortCursorAdapter import com.mobeta.android.dslv.SimpleDragSortCursorAdapter
import kotlinx.android.synthetic.main.dialog_custom_tab_editor.* import kotlinx.android.synthetic.main.dialog_custom_tab_editor.*
import kotlinx.android.synthetic.main.layout_draggable_list_with_empty_view.* import kotlinx.android.synthetic.main.layout_draggable_list_with_empty_view.*
@ -102,7 +103,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
df.arguments = Bundle { df.arguments = Bundle {
this[EXTRA_OBJECT] = tab this[EXTRA_OBJECT] = tab
} }
fragmentManager?.let { df.show(it, TabEditorDialogFragment.TAG_EDIT_TAB) } parentFragmentManager.let { df.show(it, TabEditorDialogFragment.TAG_EDIT_TAB) }
} }
listView.adapter = adapter listView.adapter = adapter
listView.emptyView = emptyView listView.emptyView = emptyView
@ -115,7 +116,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
} }
emptyText.setText(R.string.no_tab) emptyText.setText(R.string.no_tab)
emptyIcon.setImageResource(R.drawable.ic_info_tab) emptyIcon.setImageResource(R.drawable.ic_info_tab)
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
setListShown(false) setListShown(false)
} }

View File

@ -46,13 +46,13 @@ class EditUserListDialogFragment : BaseDialogFragment() {
builder.positive(android.R.string.ok, this::onPositiveClick) builder.positive(android.R.string.ok, this::onPositiveClick)
builder.setNegativeButton(android.R.string.cancel, null) builder.setNegativeButton(android.R.string.cancel, null)
val dialog = builder.create() val dialog = builder.create()
dialog.onShow { dialog -> dialog.onShow { alertDialog ->
dialog.applyTheme() alertDialog.applyTheme()
dialog.editName.addValidator(UserListNameValidator(getString(R.string.invalid_list_name))) alertDialog.editName.addValidator(UserListNameValidator(getString(R.string.invalid_list_name)))
if (savedInstanceState == null) { if (savedInstanceState == null) {
dialog.editName.setText(arguments?.getString(EXTRA_LIST_NAME)) alertDialog.editName.setText(arguments?.getString(EXTRA_LIST_NAME))
dialog.editDescription.setText(arguments?.getString(EXTRA_DESCRIPTION)) alertDialog.editDescription.setText(arguments?.getString(EXTRA_DESCRIPTION))
dialog.isPublic.isChecked = arguments?.getBoolean(EXTRA_IS_PUBLIC, true) ?: true alertDialog.isPublic.isChecked = arguments?.getBoolean(EXTRA_IS_PUBLIC, true) ?: true
} }
} }
return dialog return dialog

View File

@ -33,6 +33,7 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.AdapterView.AdapterContextMenuInfo import android.widget.AdapterView.AdapterContextMenuInfo
import androidx.loader.app.LoaderManager
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import kotlinx.android.synthetic.main.fragment_content_listview.* import kotlinx.android.synthetic.main.fragment_content_listview.*
import org.mariotaku.ktextension.isNullOrEmpty import org.mariotaku.ktextension.isNullOrEmpty
@ -52,7 +53,7 @@ class ExtensionsListFragment : AbsContentListViewFragment<ExtensionsAdapter>(),
listView.onItemClickListener = this listView.onItemClickListener = this
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
showProgress() showProgress()
} }

View File

@ -5,6 +5,7 @@ import android.nfc.NdefMessage
import android.nfc.NdefRecord import android.nfc.NdefRecord
import android.nfc.NfcAdapter import android.nfc.NfcAdapter
import android.os.Bundle import android.os.Bundle
import androidx.loader.app.LoaderManager
import androidx.loader.app.LoaderManager.LoaderCallbacks import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.content.FixedAsyncTaskLoader import androidx.loader.content.FixedAsyncTaskLoader
import androidx.loader.content.Loader import androidx.loader.content.Loader
@ -69,7 +70,7 @@ class GroupFragment : AbsToolbarTabPagesFragment(), LoaderCallbacks<SingleRespon
fun displayGroup(group: ParcelableGroup?) { fun displayGroup(group: ParcelableGroup?) {
val activity = activity ?: return val activity = activity ?: return
loaderManager.destroyLoader(0) LoaderManager.getInstance(this).destroyLoader(0)
this.group = group this.group = group
if (group != null) { if (group != null) {
@ -82,7 +83,7 @@ class GroupFragment : AbsToolbarTabPagesFragment(), LoaderCallbacks<SingleRespon
fun getGroupInfo(omitIntentExtra: Boolean) { fun getGroupInfo(omitIntentExtra: Boolean) {
val lm = loaderManager val lm = LoaderManager.getInstance(this)
lm.destroyLoader(0) lm.destroyLoader(0)
val args = Bundle(arguments) val args = Bundle(arguments)
args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, omitIntentExtra) args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, omitIntentExtra)

View File

@ -116,14 +116,14 @@ class HostMappingsListFragment : AbsContentListViewFragment<HostMappingsListFrag
args.putBoolean(EXTRA_EDIT_MODE, true) args.putBoolean(EXTRA_EDIT_MODE, true)
val df = AddMappingDialogFragment() val df = AddMappingDialogFragment()
df.arguments = args df.arguments = args
fragmentManager?.let { df.show(it, "add_mapping") } parentFragmentManager.let { df.show(it, "add_mapping") }
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.add -> { R.id.add -> {
val df = AddMappingDialogFragment() val df = AddMappingDialogFragment()
fragmentManager?.let { df.show(it, "add_mapping") } parentFragmentManager.let { df.show(it, "add_mapping") }
} }
} }
return super.onOptionsItemSelected(item) return super.onOptionsItemSelected(item)

View File

@ -11,6 +11,7 @@ import android.view.ContextMenu
import android.view.MenuInflater import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.loader.app.LoaderManager
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import kotlinx.android.synthetic.main.fragment_content_recyclerview.* import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
import org.mariotaku.kpreferences.get import org.mariotaku.kpreferences.get
@ -46,7 +47,7 @@ open class ItemsListFragment : AbsContentListRecyclerViewFragment<VariousItemsAd
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
registerForContextMenu(recyclerView) registerForContextMenu(recyclerView)
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
refreshEnabled = false refreshEnabled = false
showProgress() showProgress()
} }
@ -175,7 +176,7 @@ open class ItemsListFragment : AbsContentListRecyclerViewFragment<VariousItemsAd
startActivity(chooser) startActivity(chooser)
return true return true
} }
return MenuUtils.handleStatusClick(requireActivity(), this, requireFragmentManager(), return MenuUtils.handleStatusClick(requireActivity(), this, parentFragmentManager,
preferences, userColorNameManager, twitterWrapper, status, item) preferences, userColorNameManager, twitterWrapper, status, item)
} }
} }

View File

@ -24,6 +24,7 @@ import android.os.Bundle
import androidx.loader.app.LoaderManager.LoaderCallbacks import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.content.Loader import androidx.loader.content.Loader
import android.view.KeyEvent import android.view.KeyEvent
import androidx.loader.app.LoaderManager
import androidx.loader.app.hasRunningLoadersSafe import androidx.loader.app.hasRunningLoadersSafe
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import kotlinx.android.synthetic.main.fragment_content_recyclerview.* import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
@ -57,7 +58,7 @@ abstract class ParcelableGroupsFragment : AbsContentListRecyclerViewFragment<Par
override var refreshing: Boolean override var refreshing: Boolean
get() { get() {
if (context == null || isDetached) return false if (context == null || isDetached) return false
return loaderManager.hasRunningLoadersSafe() return LoaderManager.getInstance(this).hasRunningLoadersSafe()
} }
set(value) { set(value) {
super.refreshing = value super.refreshing = value
@ -101,7 +102,7 @@ abstract class ParcelableGroupsFragment : AbsContentListRecyclerViewFragment<Par
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderArgs.putParcelable(EXTRA_PAGINATION, nextPagination) loaderArgs.putParcelable(EXTRA_PAGINATION, nextPagination)
loaderManager.restartLoader(0, loaderArgs, this) LoaderManager.getInstance(this).restartLoader(0, loaderArgs, this)
} }
override fun handleKeyboardShortcutSingle(handler: KeyboardShortcutsHandler, keyCode: Int, event: KeyEvent, metaState: Int): Boolean { override fun handleKeyboardShortcutSingle(handler: KeyboardShortcutsHandler, keyCode: Int, event: KeyEvent, metaState: Int): Boolean {
@ -125,7 +126,7 @@ abstract class ParcelableGroupsFragment : AbsContentListRecyclerViewFragment<Par
this) this)
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderManager.initLoader(0, loaderArgs, this) LoaderManager.getInstance(this).initLoader(0, loaderArgs, this)
} }
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableGroup>?> { override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableGroup>?> {

View File

@ -24,6 +24,7 @@ import android.os.Bundle
import androidx.loader.app.hasRunningLoadersSafe import androidx.loader.app.hasRunningLoadersSafe
import androidx.loader.content.Loader import androidx.loader.content.Loader
import android.text.TextUtils import android.text.TextUtils
import androidx.loader.app.LoaderManager
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import org.mariotaku.twidere.R import org.mariotaku.twidere.R
@ -57,7 +58,7 @@ abstract class ParcelableStatusesFragment : AbsStatusesFragment() {
override var refreshing: Boolean override var refreshing: Boolean
get() { get() {
if (context == null || isDetached) return false if (context == null || isDetached) return false
return loaderManager.hasRunningLoadersSafe() return LoaderManager.getInstance(this).hasRunningLoadersSafe()
} }
set(value) { set(value) {
super.refreshing = value super.refreshing = value
@ -113,7 +114,7 @@ abstract class ParcelableStatusesFragment : AbsStatusesFragment() {
args.putBoolean(EXTRA_LOADING_MORE, param.isLoadingMore) args.putBoolean(EXTRA_LOADING_MORE, param.isLoadingMore)
args.putBoolean(EXTRA_FROM_USER, true) args.putBoolean(EXTRA_FROM_USER, true)
args.putParcelable(EXTRA_PAGINATION, param.pagination?.getOrNull(0)) args.putParcelable(EXTRA_PAGINATION, param.pagination?.getOrNull(0))
loaderManager.restartLoader(loaderId, args, this) LoaderManager.getInstance(this).restartLoader(loaderId, args, this)
return true return true
} }

View File

@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import androidx.loader.app.LoaderManager
import androidx.loader.app.LoaderManager.LoaderCallbacks import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.app.hasRunningLoadersSafe import androidx.loader.app.hasRunningLoadersSafe
import androidx.loader.content.Loader import androidx.loader.content.Loader
@ -62,7 +63,7 @@ abstract class ParcelableUserListsFragment : AbsContentListRecyclerViewFragment<
override var refreshing: Boolean override var refreshing: Boolean
get() { get() {
if (context == null || isDetached) return false if (context == null || isDetached) return false
return loaderManager.hasRunningLoadersSafe() return LoaderManager.getInstance(this).hasRunningLoadersSafe()
} }
set(value) { set(value) {
super.refreshing = value super.refreshing = value
@ -103,7 +104,7 @@ abstract class ParcelableUserListsFragment : AbsContentListRecyclerViewFragment<
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderArgs.putParcelable(EXTRA_PAGINATION, nextPagination) loaderArgs.putParcelable(EXTRA_PAGINATION, nextPagination)
loaderManager.restartLoader(0, loaderArgs, this) LoaderManager.getInstance(this).restartLoader(0, loaderArgs, this)
} }
override fun handleKeyboardShortcutSingle(handler: KeyboardShortcutsHandler, keyCode: Int, override fun handleKeyboardShortcutSingle(handler: KeyboardShortcutsHandler, keyCode: Int,
@ -130,7 +131,7 @@ abstract class ParcelableUserListsFragment : AbsContentListRecyclerViewFragment<
this) this)
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderManager.initLoader(0, loaderArgs, this) LoaderManager.getInstance(this).initLoader(0, loaderArgs, this)
} }
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableUserList>> { override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableUserList>> {
@ -159,7 +160,7 @@ abstract class ParcelableUserListsFragment : AbsContentListRecyclerViewFragment<
val loaderArgs = Bundle(arguments).apply { val loaderArgs = Bundle(arguments).apply {
this[EXTRA_FROM_USER] = true this[EXTRA_FROM_USER] = true
} }
loaderManager.restartLoader(0, loaderArgs, this) LoaderManager.getInstance(this).restartLoader(0, loaderArgs, this)
showProgress() showProgress()
return true return true
} }

View File

@ -28,6 +28,7 @@ import androidx.loader.content.Loader
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import android.view.KeyEvent import android.view.KeyEvent
import androidx.loader.app.LoaderManager
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import kotlinx.android.synthetic.main.fragment_content_recyclerview.* import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
@ -65,7 +66,7 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<Parc
override var refreshing: Boolean override var refreshing: Boolean
get() { get() {
if (context == null || isDetached) return false if (context == null || isDetached) return false
return loaderManager.hasRunningLoadersSafe() return LoaderManager.getInstance(this).hasRunningLoadersSafe()
} }
set(value) { set(value) {
super.refreshing = value super.refreshing = value
@ -102,7 +103,7 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<Parc
this) this)
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderManager.initLoader(0, loaderArgs, this) LoaderManager.getInstance(this).initLoader(0, loaderArgs, this)
} }
override fun onStart() { override fun onStart() {
@ -164,7 +165,7 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<Parc
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderArgs.putParcelable(EXTRA_PAGINATION, nextPagination) loaderArgs.putParcelable(EXTRA_PAGINATION, nextPagination)
loaderManager.restartLoader(0, loaderArgs, this) LoaderManager.getInstance(this).restartLoader(0, loaderArgs, this)
} }
override fun onCreateAdapter(context: Context, requestManager: RequestManager): ParcelableUsersAdapter { override fun onCreateAdapter(context: Context, requestManager: RequestManager): ParcelableUsersAdapter {
@ -212,7 +213,7 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<Parc
val accountKey = user.account_key ?: return val accountKey = user.account_key ?: return
if (twitterWrapper.isUpdatingRelationship(accountKey, user.key)) return if (twitterWrapper.isUpdatingRelationship(accountKey, user.key)) return
if (user.is_following) { if (user.is_following) {
fragmentManager?.let { DestroyFriendshipDialogFragment.show(it, user) } parentFragmentManager.let { DestroyFriendshipDialogFragment.show(it, user) }
} else { } else {
twitterWrapper.createFriendshipAsync(accountKey, user.key, user.screen_name) twitterWrapper.createFriendshipAsync(accountKey, user.key, user.screen_name)
} }

View File

@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import androidx.loader.app.LoaderManager
import androidx.loader.app.LoaderManager.LoaderCallbacks import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.app.hasRunningLoadersSafe import androidx.loader.app.hasRunningLoadersSafe
import androidx.loader.content.Loader import androidx.loader.content.Loader
@ -44,7 +45,7 @@ class SavedSearchesListFragment : AbsContentListViewFragment<SavedSearchesAdapte
AdapterView.OnItemLongClickListener { AdapterView.OnItemLongClickListener {
override var refreshing: Boolean override var refreshing: Boolean
get() = loaderManager.hasRunningLoadersSafe() get() = LoaderManager.getInstance(this).hasRunningLoadersSafe()
set(value) { set(value) {
super.refreshing = value super.refreshing = value
} }
@ -56,7 +57,7 @@ class SavedSearchesListFragment : AbsContentListViewFragment<SavedSearchesAdapte
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
listView.onItemClickListener = this listView.onItemClickListener = this
listView.onItemLongClickListener = this listView.onItemLongClickListener = this
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
showProgress() showProgress()
} }
@ -80,7 +81,7 @@ class SavedSearchesListFragment : AbsContentListViewFragment<SavedSearchesAdapte
override fun onItemLongClick(view: AdapterView<*>, child: View, position: Int, id: Long): Boolean { override fun onItemLongClick(view: AdapterView<*>, child: View, position: Int, id: Long): Boolean {
val item = adapter.findItem(id) ?: return false val item = adapter.findItem(id) ?: return false
fragmentManager?.let { DestroySavedSearchDialogFragment.show(it, accountKey, item.id, item.name) } parentFragmentManager.let { DestroySavedSearchDialogFragment.show(it, accountKey, item.id, item.name) }
return true return true
} }
@ -104,7 +105,7 @@ class SavedSearchesListFragment : AbsContentListViewFragment<SavedSearchesAdapte
override fun onRefresh() { override fun onRefresh() {
if (refreshing) return if (refreshing) return
loaderManager.restartLoader(0, null, this) LoaderManager.getInstance(this).restartLoader(0, null, this)
} }
@Subscribe @Subscribe

View File

@ -29,6 +29,7 @@ import androidx.loader.content.Loader
import android.view.View import android.view.View
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ListView import android.widget.ListView
import androidx.loader.app.LoaderManager
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import kotlinx.android.synthetic.main.fragment_content_listview.* import kotlinx.android.synthetic.main.fragment_content_listview.*
@ -68,7 +69,7 @@ class TrendsSuggestionsFragment : AbsContentListViewFragment<TrendsAdapter>(), L
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
listView.onItemClickListener = this listView.onItemClickListener = this
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
showProgress() showProgress()
} }
@ -123,7 +124,7 @@ class TrendsSuggestionsFragment : AbsContentListViewFragment<TrendsAdapter>(), L
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
loaderManager.restartLoader(0, null, this) LoaderManager.getInstance(this).restartLoader(0, null, this)
bus.register(this) bus.register(this)
} }

View File

@ -73,6 +73,7 @@ import android.view.View.OnTouchListener
import android.view.animation.AnimationUtils import android.view.animation.AnimationUtils
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.loader.app.LoaderManager
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import kotlinx.android.synthetic.main.fragment_user.* import kotlinx.android.synthetic.main.fragment_user.*
import kotlinx.android.synthetic.main.fragment_user.view.* import kotlinx.android.synthetic.main.fragment_user.view.*
@ -432,7 +433,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
} }
profileImage.visibility = View.VISIBLE profileImage.visibility = View.VISIBLE
val resources = resources val resources = resources
val lm = loaderManager val lm = LoaderManager.getInstance(this)
lm.destroyLoader(LOADER_ID_USER) lm.destroyLoader(LOADER_ID_USER)
lm.destroyLoader(LOADER_ID_FRIENDSHIP) lm.destroyLoader(LOADER_ID_FRIENDSHIP)
cardContent.visibility = View.VISIBLE cardContent.visibility = View.VISIBLE
@ -530,7 +531,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
externalThemeManager.emoji?.applyTo(it) externalThemeManager.emoji?.applyTo(it)
} }
val userCreationDay = condition@ if (user.created_at >= 0) { val userCreationDay = if (user.created_at >= 0) {
val cal = Calendar.getInstance() val cal = Calendar.getInstance()
val currentMonth = cal.get(Calendar.MONTH) val currentMonth = cal.get(Calendar.MONTH)
val currentDay = cal.get(Calendar.DAY_OF_MONTH) val currentDay = cal.get(Calendar.DAY_OF_MONTH)
@ -577,7 +578,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
fun getUserInfo(accountKey: UserKey, userKey: UserKey?, screenName: String?, fun getUserInfo(accountKey: UserKey, userKey: UserKey?, screenName: String?,
omitIntentExtra: Boolean) { omitIntentExtra: Boolean) {
val lm = loaderManager val lm = LoaderManager.getInstance(this)
lm.destroyLoader(LOADER_ID_USER) lm.destroyLoader(LOADER_ID_USER)
lm.destroyLoader(LOADER_ID_FRIENDSHIP) lm.destroyLoader(LOADER_ID_FRIENDSHIP)
val args = Bundle() val args = Bundle()
@ -787,7 +788,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
override fun onDestroyView() { override fun onDestroyView() {
user = null user = null
relationship = null relationship = null
val lm = loaderManager val lm = LoaderManager.getInstance(this)
lm.destroyLoader(LOADER_ID_USER) lm.destroyLoader(LOADER_ID_USER)
lm.destroyLoader(LOADER_ID_FRIENDSHIP) lm.destroyLoader(LOADER_ID_FRIENDSHIP)
super.onDestroyView() super.onDestroyView()
@ -903,7 +904,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
val twitter = twitterWrapper val twitter = twitterWrapper
val user = user ?: return false val user = user ?: return false
val accountKey = user.account_key ?: return false val accountKey = user.account_key ?: return false
val currentFragmentManager = fragmentManager ?: return false val currentFragmentManager = parentFragmentManager
val userRelationship = relationship val userRelationship = relationship
when (item.itemId) { when (item.itemId) {
R.id.block -> { R.id.block -> {
@ -1221,7 +1222,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
override fun onClick(view: View) { override fun onClick(view: View) {
val activity = activity ?: return val activity = activity ?: return
val fragmentManager = fragmentManager ?: return val fragmentManager = parentFragmentManager
val user = user ?: return val user = user ?: return
val accountKey = user.account_key ?: return val accountKey = user.account_key ?: return
when (view.id) { when (view.id) {
@ -1394,7 +1395,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
private fun getFriendship() { private fun getFriendship() {
val user = user ?: return val user = user ?: return
relationship = null relationship = null
val lm = loaderManager val lm = LoaderManager.getInstance(this)
lm.destroyLoader(LOADER_ID_FRIENDSHIP) lm.destroyLoader(LOADER_ID_FRIENDSHIP)
val args = Bundle() val args = Bundle()
args.putParcelable(EXTRA_ACCOUNT_KEY, user.account_key) args.putParcelable(EXTRA_ACCOUNT_KEY, user.account_key)
@ -1890,7 +1891,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
df.arguments = Bundle { df.arguments = Bundle {
this[EXTRA_ACCOUNT_KEY] = accountKey this[EXTRA_ACCOUNT_KEY] = accountKey
} }
df.show(requireFragmentManager(), "create_user_list") df.show(parentFragmentManager, "create_user_list")
} }
} }
return dialog return dialog

View File

@ -28,6 +28,7 @@ import android.nfc.NdefMessage
import android.nfc.NdefRecord import android.nfc.NdefRecord
import android.nfc.NfcAdapter.CreateNdefMessageCallback import android.nfc.NfcAdapter.CreateNdefMessageCallback
import android.os.Bundle import android.os.Bundle
import androidx.loader.app.LoaderManager
import androidx.loader.app.LoaderManager.LoaderCallbacks import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.content.FixedAsyncTaskLoader import androidx.loader.content.FixedAsyncTaskLoader
import androidx.loader.content.Loader import androidx.loader.content.Loader
@ -81,7 +82,7 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
fun displayUserList(userList: ParcelableUserList?) { fun displayUserList(userList: ParcelableUserList?) {
val activity = activity ?: return val activity = activity ?: return
loaderManager.destroyLoader(0) LoaderManager.getInstance(this).destroyLoader(0)
this.userList = userList this.userList = userList
if (userList != null) { if (userList != null) {
@ -93,7 +94,7 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
} }
fun getUserListInfo(omitIntentExtra: Boolean) { fun getUserListInfo(omitIntentExtra: Boolean) {
val lm = loaderManager val lm = LoaderManager.getInstance(this)
lm.destroyLoader(0) lm.destroyLoader(0)
val args = Bundle(arguments) val args = Bundle(arguments)
args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, omitIntentExtra) args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, omitIntentExtra)
@ -180,7 +181,7 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
override fun onDestroyView() { override fun onDestroyView() {
userList = null userList = null
loaderManager.destroyLoader(0) LoaderManager.getInstance(this).destroyLoader(0)
super.onDestroyView() super.onDestroyView()
} }
@ -227,7 +228,7 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
val twitter = twitterWrapper val twitter = twitterWrapper
val userList = userList ?: return false val userList = userList ?: return false
val activity = activity ?: return false val activity = activity ?: return false
val fragmentManager = fragmentManager ?: return false val fragmentManager = parentFragmentManager
when (item.itemId) { when (item.itemId) {
R.id.add -> { R.id.add -> {
if (userList.user_key != userList.account_key) return false if (userList.user_key != userList.account_key) return false

View File

@ -68,7 +68,7 @@ class UserListsOwnershipsFragment : ParcelableUserListsFragment() {
val args = Bundle() val args = Bundle()
args.putParcelable(EXTRA_ACCOUNT_KEY, accountKey) args.putParcelable(EXTRA_ACCOUNT_KEY, accountKey)
f.arguments = args f.arguments = args
fragmentManager?.let { f.show(it, null) } parentFragmentManager.let { f.show(it, null) }
return true return true
} }
} }

View File

@ -33,6 +33,7 @@ import android.text.TextUtils.isEmpty
import android.view.* import android.view.*
import android.view.View.OnClickListener import android.view.View.OnClickListener
import android.widget.Toast import android.widget.Toast
import androidx.loader.app.LoaderManager
import com.twitter.twittertext.Validator import com.twitter.twittertext.Validator
import kotlinx.android.synthetic.main.fragment_user_profile_editor.* import kotlinx.android.synthetic.main.fragment_user_profile_editor.*
import nl.komponents.kovenant.combine.and import nl.komponents.kovenant.combine.and
@ -337,7 +338,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
private fun getUserInfo() { private fun getUserInfo() {
if (activity == null || isDetached) return if (activity == null || isDetached) return
val lm = loaderManager val lm = LoaderManager.getInstance(this)
lm.destroyLoader(LOADER_ID_USER) lm.destroyLoader(LOADER_ID_USER)
getUserInfoCalled = true getUserInfoCalled = true
if (userInfoLoaderInitialized) { if (userInfoLoaderInitialized) {

View File

@ -125,13 +125,13 @@ class UserQrDialogFragment : BaseDialogFragment() {
return task { return task {
try { try {
return@task requestManager.loadOriginalProfileImage(requireContext(), user, 0) return@task requestManager.loadOriginalProfileImage(requireContext(), user, 0)
.into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).get() .submit(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).get()
} catch (e: ExecutionException) { } catch (e: ExecutionException) {
// Ignore // Ignore
} }
// Return fallback profile image // Return fallback profile image
return@task requestManager.loadProfileImage(requireContext(), user, 0, size = profileImageSize) return@task requestManager.loadProfileImage(requireContext(), user, 0, size = profileImageSize)
.into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).get() .submit(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).get()
} }
} }

View File

@ -41,6 +41,7 @@ import android.widget.AbsListView.MultiChoiceModeListener
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.AdapterView.OnItemClickListener import android.widget.AdapterView.OnItemClickListener
import android.widget.ListView import android.widget.ListView
import androidx.loader.app.LoaderManager
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import kotlinx.android.synthetic.main.fragment_content_listview.* import kotlinx.android.synthetic.main.fragment_content_listview.*
import org.mariotaku.kpreferences.get import org.mariotaku.kpreferences.get
@ -84,7 +85,7 @@ class DraftsListFragment : AbsContentListViewFragment<DraftsAdapter>(), LoaderCa
listView.choiceMode = ListView.CHOICE_MODE_MULTIPLE_MODAL listView.choiceMode = ListView.CHOICE_MODE_MULTIPLE_MODAL
listView.setMultiChoiceModeListener(this) listView.setMultiChoiceModeListener(this)
refreshEnabled = false refreshEnabled = false
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
showProgress() showProgress()
} }

View File

@ -151,7 +151,7 @@ class AddEditItemFragment : BaseDialogFragment() {
val df = ExtraFeaturesIntroductionDialogFragment.create( val df = ExtraFeaturesIntroductionDialogFragment.create(
ExtraFeaturesService.FEATURE_ADVANCED_FILTERS) ExtraFeaturesService.FEATURE_ADVANCED_FILTERS)
df.setTargetFragment(this@AddEditItemFragment, REQUEST_CHANGE_SCOPE_PURCHASE) df.setTargetFragment(this@AddEditItemFragment, REQUEST_CHANGE_SCOPE_PURCHASE)
df.show(requireFragmentManager(), ExtraFeaturesIntroductionDialogFragment.FRAGMENT_TAG) df.show(parentFragmentManager, ExtraFeaturesIntroductionDialogFragment.FRAGMENT_TAG)
} }
} }

View File

@ -88,7 +88,7 @@ abstract class BaseFiltersFragment : AbsContentListViewFragment<SimpleCursorAdap
onItemClick(pos) onItemClick(pos)
} }
listView.setMultiChoiceModeListener(this) listView.setMultiChoiceModeListener(this)
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
refreshEnabled = false refreshEnabled = false
showProgress() showProgress()
} }
@ -235,7 +235,7 @@ abstract class BaseFiltersFragment : AbsContentListViewFragment<SimpleCursorAdap
this[EXTRA_VALUE] = value this[EXTRA_VALUE] = value
this[EXTRA_SCOPE] = scope this[EXTRA_SCOPE] = scope
} }
fragmentManager?.let { dialog.show(it, "add_rule") } parentFragmentManager.let { dialog.show(it, "add_rule") }
} }

View File

@ -58,7 +58,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Se
setHasOptionsMenu(true) setHasOptionsMenu(true)
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderManager.initLoader(0, loaderArgs, this) LoaderManager.getInstance(this).initLoader(0, loaderArgs, this)
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@ -107,7 +107,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Se
return true return true
} }
if (!extraFeaturesService.isAdvancedFiltersEnabled) { if (!extraFeaturesService.isAdvancedFiltersEnabled) {
fragmentManager?.let { parentFragmentManager.let {
ExtraFeaturesIntroductionDialogFragment.show(it, ExtraFeaturesIntroductionDialogFragment.show(it,
feature = ExtraFeaturesService.FEATURE_ADVANCED_FILTERS, feature = ExtraFeaturesService.FEATURE_ADVANCED_FILTERS,
requestCode = REQUEST_PURCHASE_EXTRA_FEATURES) requestCode = REQUEST_PURCHASE_EXTRA_FEATURES)
@ -182,14 +182,14 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Se
val loaderArgs = Bundle(arguments) val loaderArgs = Bundle(arguments)
loaderArgs.putBoolean(EXTRA_FROM_USER, true) loaderArgs.putBoolean(EXTRA_FROM_USER, true)
loaderArgs.putParcelable(EXTRA_NEXT_PAGINATION, nextPagination) loaderArgs.putParcelable(EXTRA_NEXT_PAGINATION, nextPagination)
loaderManager.restartLoader(0, loaderArgs, this) LoaderManager.getInstance(this).restartLoader(0, loaderArgs, this)
} }
override fun onCreateAdapter(context: Context, requestManager: RequestManager): SelectableUsersAdapter { override fun onCreateAdapter(context: Context, requestManager: RequestManager): SelectableUsersAdapter {
val adapter = SelectableUsersAdapter(context, this.requestManager) val adapter = SelectableUsersAdapter(context, this.requestManager)
adapter.itemCheckedListener = listener@ { _, _ -> adapter.itemCheckedListener = listener@ { _, _ ->
if (!extraFeaturesService.isAdvancedFiltersEnabled) { if (!extraFeaturesService.isAdvancedFiltersEnabled) {
ExtraFeaturesIntroductionDialogFragment.show(requireFragmentManager(), ExtraFeaturesIntroductionDialogFragment.show(parentFragmentManager,
feature = ExtraFeaturesService.FEATURE_ADVANCED_FILTERS, feature = ExtraFeaturesService.FEATURE_ADVANCED_FILTERS,
requestCode = REQUEST_PURCHASE_EXTRA_FEATURES) requestCode = REQUEST_PURCHASE_EXTRA_FEATURES)
return@listener false return@listener false

View File

@ -67,7 +67,7 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
listContainer.visibility = View.GONE listContainer.visibility = View.GONE
progressContainer.visibility = View.VISIBLE progressContainer.visibility = View.VISIBLE
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
if (!extraFeaturesService.isSupported()) { if (!extraFeaturesService.isSupported()) {
@ -76,7 +76,7 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
} }
if (savedInstanceState == null) { if (savedInstanceState == null) {
fragmentManager?.let { fragmentManager -> parentFragmentManager.let { fragmentManager ->
when (arguments?.getString(EXTRA_ACTION)) { when (arguments?.getString(EXTRA_ACTION)) {
ACTION_ADD_URL_SUBSCRIPTION -> { ACTION_ADD_URL_SUBSCRIPTION -> {
if (!extraFeaturesService.isAdvancedFiltersEnabled) { if (!extraFeaturesService.isAdvancedFiltersEnabled) {
@ -131,17 +131,17 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
when (item.itemId) { when (item.itemId) {
R.id.add -> { R.id.add -> {
val df = AddUrlSubscriptionDialogFragment() val df = AddUrlSubscriptionDialogFragment()
fragmentManager?.let { df.show(it, "add_url_subscription") } parentFragmentManager.let { df.show(it, "add_url_subscription") }
return true return true
} }
R.id.refresh -> { R.id.refresh -> {
executeAfterFragmentResumed { fragment -> executeAfterFragmentResumed { fragment ->
ProgressDialogFragment.show(fragment.childFragmentManager, FRAGMENT_TAG_RREFRESH_FILTERS) ProgressDialogFragment.show(fragment.childFragmentManager, FRAGMENT_TAG_REFRESH_FILTERS)
val task = RefreshFiltersSubscriptionsTask(fragment.requireContext()) val task = RefreshFiltersSubscriptionsTask(fragment.requireContext())
val fragmentRef = WeakReference(fragment) val fragmentRef = WeakReference(fragment)
task.callback = { task.callback = {
fragmentRef.get()?.executeAfterFragmentResumed { fragment -> fragmentRef.get()?.executeAfterFragmentResumed { fragment ->
fragment.fragmentManager?.dismissDialogFragment(FRAGMENT_TAG_RREFRESH_FILTERS) fragment.parentFragmentManager.dismissDialogFragment(FRAGMENT_TAG_REFRESH_FILTERS)
} }
} }
TaskStarter.execute(task) TaskStarter.execute(task)
@ -255,7 +255,7 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
this[EXTRA_ADD_SUBSCRIPTION_URL] = arguments?.getString(EXTRA_ADD_SUBSCRIPTION_URL) this[EXTRA_ADD_SUBSCRIPTION_URL] = arguments?.getString(EXTRA_ADD_SUBSCRIPTION_URL)
this[EXTRA_ADD_SUBSCRIPTION_NAME] = arguments?.getString(EXTRA_ADD_SUBSCRIPTION_NAME) this[EXTRA_ADD_SUBSCRIPTION_NAME] = arguments?.getString(EXTRA_ADD_SUBSCRIPTION_NAME)
} }
fragmentManager?.let { df.show(it, "add_url_subscription") } parentFragmentManager.let { df.show(it, "add_url_subscription") }
} }
class FilterSubscriptionsAdapter(context: Context) : SimpleCursorAdapter(context, class FilterSubscriptionsAdapter(context: Context) : SimpleCursorAdapter(context,
@ -337,7 +337,7 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
const val EXTRA_ADD_SUBSCRIPTION_URL = "add_subscription.url" const val EXTRA_ADD_SUBSCRIPTION_URL = "add_subscription.url"
const val EXTRA_ADD_SUBSCRIPTION_NAME = "add_subscription.name" const val EXTRA_ADD_SUBSCRIPTION_NAME = "add_subscription.name"
private const val REQUEST_ADD_URL_SUBSCRIPTION_PURCHASE = 101 private const val REQUEST_ADD_URL_SUBSCRIPTION_PURCHASE = 101
private const val FRAGMENT_TAG_RREFRESH_FILTERS = "refresh_filters" private const val FRAGMENT_TAG_REFRESH_FILTERS = "refresh_filters"
} }
} }

View File

@ -28,20 +28,20 @@ import android.content.Intent
import android.graphics.Rect import android.graphics.Rect
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.*
import android.widget.CompoundButton
import android.widget.EditText
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import androidx.loader.app.LoaderManager import androidx.loader.app.LoaderManager
import androidx.loader.content.FixedAsyncTaskLoader import androidx.loader.content.FixedAsyncTaskLoader
import androidx.loader.content.Loader import androidx.loader.content.Loader
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.FixedLinearLayoutManager import androidx.recyclerview.widget.FixedLinearLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.appcompat.widget.Toolbar
import android.view.*
import android.widget.CompoundButton
import android.widget.EditText
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import kotlinx.android.synthetic.main.activity_home_content.view.* import kotlinx.android.synthetic.main.activity_home_content.view.*
import kotlinx.android.synthetic.main.fragment_messages_conversation_info.* import kotlinx.android.synthetic.main.fragment_messages_conversation_info.*
@ -72,7 +72,6 @@ import org.mariotaku.twidere.adapter.iface.IItemCountsAdapter
import org.mariotaku.twidere.annotation.AccountType import org.mariotaku.twidere.annotation.AccountType
import org.mariotaku.twidere.annotation.ImageShapeStyle import org.mariotaku.twidere.annotation.ImageShapeStyle
import org.mariotaku.twidere.annotation.ProfileImageSize import org.mariotaku.twidere.annotation.ProfileImageSize
import org.mariotaku.twidere.constant.IntentConstants
import org.mariotaku.twidere.constant.IntentConstants.* import org.mariotaku.twidere.constant.IntentConstants.*
import org.mariotaku.twidere.constant.nameFirstKey import org.mariotaku.twidere.constant.nameFirstKey
import org.mariotaku.twidere.constant.profileImageStyleKey import org.mariotaku.twidere.constant.profileImageStyleKey
@ -182,7 +181,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
} }
} }
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@ -331,10 +330,10 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
ProgressDialogFragment.show(childFragmentManager, "add_participant_progress") ProgressDialogFragment.show(childFragmentManager, "add_participant_progress")
val weakThis = WeakReference(this) val weakThis = WeakReference(this)
val task = AddParticipantsTask(requireContext(), accountKey, conversationId, listOf(user)) val task = AddParticipantsTask(requireContext(), accountKey, conversationId, listOf(user))
task.callback = callback@ { succeed -> task.callback = callback@ {
val f = weakThis.get() ?: return@callback val f = weakThis.get() ?: return@callback
f.dismissDialogThen("add_participant_progress") { f.dismissDialogThen("add_participant_progress") {
loaderManager.restartLoader(0, null, this) LoaderManager.getInstance(this).restartLoader(0, null, this)
} }
} }
TaskStarter.execute(task) TaskStarter.execute(task)
@ -347,7 +346,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
task.callback = callback@ { _ -> task.callback = callback@ { _ ->
val f = weakThis.get() ?: return@callback val f = weakThis.get() ?: return@callback
f.dismissDialogThen("set_notifications_disabled_progress") { f.dismissDialogThen("set_notifications_disabled_progress") {
loaderManager.restartLoader(0, null, this) LoaderManager.getInstance(this).restartLoader(0, null, this)
} }
} }
TaskStarter.execute(task) TaskStarter.execute(task)
@ -470,7 +469,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
}.alwaysUi { }.alwaysUi {
val fragment = weakThis.get() ?: return@alwaysUi val fragment = weakThis.get() ?: return@alwaysUi
fragment.dismissDialogThen(tag) { fragment.dismissDialogThen(tag) {
loaderManager.restartLoader(0, null, this) LoaderManager.getInstance(this).restartLoader(0, null, this)
} }
} }
} }

View File

@ -25,16 +25,17 @@ import android.graphics.Canvas
import android.graphics.Paint import android.graphics.Paint
import android.graphics.RectF import android.graphics.RectF
import android.os.Bundle import android.os.Bundle
import androidx.annotation.WorkerThread
import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.content.Loader
import androidx.recyclerview.widget.LinearLayoutManager
import android.text.Editable import android.text.Editable
import android.text.Spannable import android.text.Spannable
import android.text.SpannableStringBuilder import android.text.SpannableStringBuilder
import android.text.TextUtils import android.text.TextUtils
import android.text.style.ReplacementSpan import android.text.style.ReplacementSpan
import android.view.* import android.view.*
import androidx.annotation.WorkerThread
import androidx.loader.app.LoaderManager
import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.content.Loader
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.fragment_messages_conversation_new.* import kotlinx.android.synthetic.main.fragment_messages_conversation_new.*
import org.mariotaku.kpreferences.get import org.mariotaku.kpreferences.get
import org.mariotaku.ktextension.* import org.mariotaku.ktextension.*
@ -305,10 +306,10 @@ class MessageNewConversationFragment : BaseFragment(), LoaderCallbacks<List<Parc
this[EXTRA_FROM_CACHE] = fromType this[EXTRA_FROM_CACHE] = fromType
} }
if (loaderInitialized) { if (loaderInitialized) {
loaderManager.initLoader(0, args, this) LoaderManager.getInstance(this).initLoader(0, args, this)
loaderInitialized = true loaderInitialized = true
} else { } else {
loaderManager.restartLoader(0, args, this) LoaderManager.getInstance(this).restartLoader(0, args, this)
} }
if (performSearchRequestRunnable != null) { if (performSearchRequestRunnable != null) {
editParticipants.removeCallbacks(performSearchRequestRunnable) editParticipants.removeCallbacks(performSearchRequestRunnable)

View File

@ -205,7 +205,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment<Messages
updateMediaPreview() updateMediaPreview()
loaderManager.initLoader(0, null, this) LoaderManager.getInstance(this).initLoader(0, null, this)
showProgress() showProgress()
} }
@ -413,7 +413,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment<Messages
if (activity is LinkHandlerActivity) { if (activity is LinkHandlerActivity) {
activity.intent = IntentUtils.messageConversation(accountKey, newConversationId) activity.intent = IntentUtils.messageConversation(accountKey, newConversationId)
} }
loaderManager.restartLoader(0, null, this) LoaderManager.getInstance(this).restartLoader(0, null, this)
} }
private fun performSendMessage() { private fun performSendMessage() {
@ -526,8 +526,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment<Messages
val stateIcon = if (conversation.notificationDisabled) { val stateIcon = if (conversation.notificationDisabled) {
ContextCompat.getDrawable(context, R.drawable.ic_message_type_speaker_muted)?.apply { ContextCompat.getDrawable(context, R.drawable.ic_message_type_speaker_muted)?.apply {
mutate() mutate().setColorFilter(conversationTitle.currentTextColor, PorterDuff.Mode.SRC_ATOP)
setColorFilter(conversationTitle.currentTextColor, PorterDuff.Mode.SRC_ATOP)
} }
} else { } else {
null null

View File

@ -29,6 +29,7 @@ import android.view.ContextMenu
import android.view.MenuInflater import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.loader.app.LoaderManager
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import com.squareup.otto.Subscribe import com.squareup.otto.Subscribe
import kotlinx.android.synthetic.main.activity_premium_dashboard.* import kotlinx.android.synthetic.main.activity_premium_dashboard.*
@ -86,7 +87,7 @@ class MessagesEntriesFragment : AbsContentListRecyclerViewFragment<MessagesEntri
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
adapter.listener = this adapter.listener = this
adapter.loadMoreSupportedPosition = ILoadMoreSupportAdapter.END adapter.loadMoreSupportedPosition = ILoadMoreSupportAdapter.END
loaderManager.initLoader(loaderId, null, this) LoaderManager.getInstance(this).initLoader(loaderId, null, this)
registerForContextMenu(recyclerView) registerForContextMenu(recyclerView)
} }

View File

@ -79,9 +79,9 @@ abstract class AbsStatusDialogFragment : BaseDialogFragment() {
adapter.showAccountsColor = true adapter.showAccountsColor = true
val dialog = builder.create() val dialog = builder.create()
dialog.onShow { dialog.onShow { alertDialog ->
val context = it.context val context = alertDialog.context
it.applyTheme() alertDialog.applyTheme()
val am = AccountManager.get(context) val am = AccountManager.get(context)
val details = AccountUtils.getAccountDetails(am, accountKey, true) ?: run { val details = AccountUtils.getAccountDetails(am, accountKey, true) ?: run {
@ -89,7 +89,7 @@ abstract class AbsStatusDialogFragment : BaseDialogFragment() {
return@onShow return@onShow
} }
val weakThis = WeakReference(this) val weakThis = WeakReference(this)
val weakHolder = WeakReference(StatusViewHolder(adapter = adapter, itemView = it.itemContent).apply { val weakHolder = WeakReference(StatusViewHolder(adapter = adapter, itemView = alertDialog.itemContent).apply {
setupViewOptions() setupViewOptions()
}) })
val extraStatus = status val extraStatus = status

View File

@ -50,7 +50,7 @@ class BlockStatusUsersDialogFragment : BaseDialogFragment() {
}.toTypedArray() }.toTypedArray()
builder.setTitle(R.string.action_status_block_users) builder.setTitle(R.string.action_status_block_users)
builder.setItems(displayNames) { _, which -> builder.setItems(displayNames) { _, which ->
CreateUserBlockDialogFragment.show(requireFragmentManager(), referencedUsers[which]) CreateUserBlockDialogFragment.show(parentFragmentManager, referencedUsers[which])
} }
val dialog = builder.create() val dialog = builder.create()
dialog.applyOnShow { applyTheme() } dialog.applyOnShow { applyTheme() }

View File

@ -50,7 +50,7 @@ class MuteStatusUsersDialogFragment : BaseDialogFragment() {
}.toTypedArray() }.toTypedArray()
builder.setTitle(R.string.action_status_mute_users) builder.setTitle(R.string.action_status_mute_users)
builder.setItems(displayNames) { _, which -> builder.setItems(displayNames) { _, which ->
CreateUserMuteDialogFragment.show(requireFragmentManager(), referencedUsers[which]) CreateUserMuteDialogFragment.show(parentFragmentManager, referencedUsers[which])
} }
val dialog = builder.create() val dialog = builder.create()
dialog.onShow { it.applyTheme() } dialog.onShow { it.applyTheme() }

View File

@ -36,6 +36,7 @@ import android.text.TextUtils
import android.view.* import android.view.*
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.loader.app.LoaderManager
import androidx.loader.app.LoaderManager.LoaderCallbacks import androidx.loader.app.LoaderManager.LoaderCallbacks
import androidx.loader.app.hasRunningLoadersSafe import androidx.loader.app.hasRunningLoadersSafe
import androidx.loader.content.FixedAsyncTaskLoader import androidx.loader.content.FixedAsyncTaskLoader
@ -210,7 +211,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
if (args.containsKey(EXTRA_STATUS)) { if (args.containsKey(EXTRA_STATUS)) {
args.putParcelable(EXTRA_STATUS, status) args.putParcelable(EXTRA_STATUS, status)
} }
loaderManager.restartLoader(LOADER_ID_DETAIL_STATUS, args, this) LoaderManager.getInstance(this).restartLoader(LOADER_ID_DETAIL_STATUS, args, this)
} }
} }
REQUEST_SELECT_ACCOUNT -> { REQUEST_SELECT_ACCOUNT -> {
@ -261,7 +262,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
setState(STATE_LOADING) setState(STATE_LOADING)
loaderManager.initLoader(LOADER_ID_DETAIL_STATUS, arguments, this) LoaderManager.getInstance(this).initLoader(LOADER_ID_DETAIL_STATUS, arguments, this)
} }
override fun onMediaClick(holder: IStatusViewHolder, view: View, current: ParcelableMedia, statusPosition: Int) { override fun onMediaClick(holder: IStatusViewHolder, view: View, current: ParcelableMedia, statusPosition: Int) {
@ -425,7 +426,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
} }
override val refreshing: Boolean override val refreshing: Boolean
get() = loaderManager.hasRunningLoadersSafe() get() = LoaderManager.getInstance(this).hasRunningLoadersSafe()
override fun onLoadMoreContents(@IndicatorPosition position: Long) { override fun onLoadMoreContents(@IndicatorPosition position: Long) {
if (!hasMoreConversation) return if (!hasMoreConversation) return
@ -485,10 +486,10 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
this[EXTRA_STATUS] = status this[EXTRA_STATUS] = status
} }
if (conversationLoaderInitialized) { if (conversationLoaderInitialized) {
loaderManager.restartLoader(LOADER_ID_STATUS_CONVERSATIONS, args, conversationsLoaderCallback) LoaderManager.getInstance(this).restartLoader(LOADER_ID_STATUS_CONVERSATIONS, args, conversationsLoaderCallback)
return return
} }
loaderManager.initLoader(LOADER_ID_STATUS_CONVERSATIONS, args, conversationsLoaderCallback) LoaderManager.getInstance(this).initLoader(LOADER_ID_STATUS_CONVERSATIONS, args, conversationsLoaderCallback)
conversationLoaderInitialized = true conversationLoaderInitialized = true
} }
@ -500,10 +501,10 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
this[EXTRA_STATUS_ID] = status.originalId this[EXTRA_STATUS_ID] = status.originalId
} }
if (activityLoaderInitialized) { if (activityLoaderInitialized) {
loaderManager.restartLoader(LOADER_ID_STATUS_ACTIVITY, args, statusActivityLoaderCallback) LoaderManager.getInstance(this).restartLoader(LOADER_ID_STATUS_ACTIVITY, args, statusActivityLoaderCallback)
return return
} }
loaderManager.initLoader(LOADER_ID_STATUS_ACTIVITY, args, statusActivityLoaderCallback) LoaderManager.getInstance(this).initLoader(LOADER_ID_STATUS_ACTIVITY, args, statusActivityLoaderCallback)
activityLoaderInitialized = true activityLoaderInitialized = true
} }
@ -592,7 +593,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
override fun onContextItemSelected(item: MenuItem): Boolean { override fun onContextItemSelected(item: MenuItem): Boolean {
val activity = activity ?: return false val activity = activity ?: return false
val fragmentManager = fragmentManager ?: return false val fragmentManager = parentFragmentManager
if (!userVisibleHint) return false if (!userVisibleHint) return false
val contextMenuInfo = item.menuInfo as? ExtendedRecyclerView.ContextMenuInfo ?: return false val contextMenuInfo = item.menuInfo as? ExtendedRecyclerView.ContextMenuInfo ?: return false
val status = adapter.getStatus(contextMenuInfo.position) val status = adapter.getStatus(contextMenuInfo.position)
@ -650,7 +651,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
val fragment = weakThis.get() ?: return@successUi val fragment = weakThis.get() ?: return@successUi
val df = TranslationDestinationDialogFragment.create(languages, accountLanguage) val df = TranslationDestinationDialogFragment.create(languages, accountLanguage)
df.setTargetFragment(fragment, 0) df.setTargetFragment(fragment, 0)
df.show(fragment.requireFragmentManager(), "translation_destination_settings") df.show(fragment.parentFragmentManager, "translation_destination_settings")
}.alwaysUi { }.alwaysUi {
val fragment = weakThis.get() ?: return@alwaysUi val fragment = weakThis.get() ?: return@alwaysUi
fragment.dismissProgressDialog("get_language_settings") fragment.dismissProgressDialog("get_language_settings")

View File

@ -52,7 +52,7 @@ class TranslationDestinationDialogFragment : BaseDialogFragment() {
builder.setSingleChoiceItems(languages.mapToArray { it.name }, selectedIndex) { _, which -> builder.setSingleChoiceItems(languages.mapToArray { it.name }, selectedIndex) { _, which ->
currentIndex.set(which) currentIndex.set(which)
} }
builder.setPositiveButton(android.R.string.ok) lambda@ { di, _ -> builder.setPositiveButton(android.R.string.ok) lambda@ { _, _ ->
val idx = currentIndex.get() val idx = currentIndex.get()
if (idx < 0) return@lambda if (idx < 0) return@lambda
preferences[translationDestinationKey] = languages[idx].code preferences[translationDestinationKey] = languages[idx].code

View File

@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.statuses
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import androidx.loader.app.LoaderManager
import androidx.loader.content.Loader import androidx.loader.content.Loader
import org.mariotaku.twidere.TwidereConstants.* import org.mariotaku.twidere.TwidereConstants.*
import org.mariotaku.twidere.fragment.AbsMediaStatusesFragment import org.mariotaku.twidere.fragment.AbsMediaStatusesFragment
@ -52,7 +53,7 @@ class MediaStatusesSearchFragment : AbsMediaStatusesFragment() {
args.putString(EXTRA_MAX_ID, maxId) args.putString(EXTRA_MAX_ID, maxId)
args.putString(EXTRA_SINCE_ID, sinceId) args.putString(EXTRA_SINCE_ID, sinceId)
args.putBoolean(EXTRA_FROM_USER, true) args.putBoolean(EXTRA_FROM_USER, true)
loaderManager.restartLoader(loaderId, args, this) LoaderManager.getInstance(this).restartLoader(loaderId, args, this)
return 0 return 0
} }

View File

@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.statuses
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import androidx.loader.app.LoaderManager
import androidx.loader.content.Loader import androidx.loader.content.Loader
import org.mariotaku.twidere.constant.IntentConstants.* import org.mariotaku.twidere.constant.IntentConstants.*
import org.mariotaku.twidere.fragment.AbsMediaStatusesFragment import org.mariotaku.twidere.fragment.AbsMediaStatusesFragment
@ -52,7 +53,7 @@ class UserMediaTimelineFragment : AbsMediaStatusesFragment() {
args.putString(EXTRA_MAX_ID, maxId) args.putString(EXTRA_MAX_ID, maxId)
args.putString(EXTRA_SINCE_ID, sinceId) args.putString(EXTRA_SINCE_ID, sinceId)
args.putBoolean(EXTRA_FROM_USER, true) args.putBoolean(EXTRA_FROM_USER, true)
loaderManager.restartLoader(loaderId, args, this) LoaderManager.getInstance(this).restartLoader(loaderId, args, this)
return 0 return 0
} }

View File

@ -138,7 +138,7 @@ class UserTimelineFragment : ParcelableStatusesFragment() {
override fun onFilterClick(holder: TimelineFilterHeaderViewHolder) { override fun onFilterClick(holder: TimelineFilterHeaderViewHolder) {
val df = UserTimelineFilterDialogFragment() val df = UserTimelineFilterDialogFragment()
df.setTargetFragment(this, REQUEST_SET_TIMELINE_FILTER) df.setTargetFragment(this, REQUEST_SET_TIMELINE_FILTER)
fragmentManager?.let { df.show(it, "set_timeline_filter") } parentFragmentManager.let { df.show(it, "set_timeline_filter") }
} }
@Subscribe @Subscribe

View File

@ -110,7 +110,7 @@ class UserListMembersFragment : ParcelableUsersFragment() {
val user = adapter.getUser(contextMenuInfo.position) ?: return false val user = adapter.getUser(contextMenuInfo.position) ?: return false
when (item.itemId) { when (item.itemId) {
R.id.delete_from_list -> { R.id.delete_from_list -> {
fragmentManager?.let { DeleteUserListMembersDialogFragment.show(it, userList, user) } parentFragmentManager.let { DeleteUserListMembersDialogFragment.show(it, userList, user) }
return true return true
} }
} }

View File

@ -118,6 +118,35 @@ class ExtensionsListLoader(
info.metaData?.getString(METADATA_KEY_EXTENSION_SETTINGS) info.metaData?.getString(METADATA_KEY_EXTENSION_SETTINGS)
) )
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as ExtensionInfo
if (packageName != other.packageName) return false
if (label != other.label) return false
if (description != other.description) return false
if (icon != other.icon) return false
if (permissions != null) {
if (other.permissions == null) return false
if (!permissions.contentEquals(other.permissions)) return false
} else if (other.permissions != null) return false
if (settings != other.settings) return false
return true
}
override fun hashCode(): Int {
var result = packageName.hashCode()
result = 31 * result + label.hashCode()
result = 31 * result + (description?.hashCode() ?: 0)
result = 31 * result + (icon?.hashCode() ?: 0)
result = 31 * result + (permissions?.contentHashCode() ?: 0)
result = 31 * result + (settings?.hashCode() ?: 0)
return result
}
} }
/** /**
@ -126,8 +155,8 @@ class ExtensionsListLoader(
*/ */
class InterestingConfigChanges { class InterestingConfigChanges {
internal val lastConfiguration = Configuration() private val lastConfiguration = Configuration()
internal var lastDensity: Int = 0 private var lastDensity: Int = 0
internal fun applyNewConfig(res: Resources): Boolean { internal fun applyNewConfig(res: Resources): Boolean {
val configChanges = lastConfiguration.updateFrom(res.configuration) val configChanges = lastConfiguration.updateFrom(res.configuration)
@ -165,7 +194,7 @@ class ExtensionsListLoader(
} }
} }
class ExtensionInfoComparator(val collator: Collator) : Comparator<ExtensionInfo> { class ExtensionInfoComparator(private val collator: Collator) : Comparator<ExtensionInfo> {
override fun compare(o1: ExtensionInfo, o2: ExtensionInfo): Int { override fun compare(o1: ExtensionInfo, o2: ExtensionInfo): Int {
val label1 = o1.label.toString() val label1 = o1.label.toString()
val label2 = o2.label.toString() val label2 = o2.label.toString()

View File

@ -27,4 +27,22 @@ import org.mariotaku.sqliteqb.library.Expression
data class ParameterizedExpression(var expression: Expression, val parameters: Array<String>) { data class ParameterizedExpression(var expression: Expression, val parameters: Array<String>) {
val sql: String val sql: String
get() = expression.sql get() = expression.sql
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as ParameterizedExpression
if (expression != other.expression) return false
if (!parameters.contentEquals(other.parameters)) return false
return true
}
override fun hashCode(): Int {
var result = expression.hashCode()
result = 31 * result + parameters.contentHashCode()
return result
}
} }

View File

@ -69,15 +69,15 @@ object ParcelableRelationshipUtils {
*/ */
fun insert(cr: ContentResolver, relationships: Collection<ParcelableRelationship>) { fun insert(cr: ContentResolver, relationships: Collection<ParcelableRelationship>) {
val insertItems = ArraySet<ParcelableRelationship>() val insertItems = ArraySet<ParcelableRelationship>()
relationships.forEach { relationships.forEach { parcelableRelationship ->
if (it._id > 0) { if (parcelableRelationship._id > 0) {
val where = Expression.equals(CachedRelationships._ID, it._id).sql val where = Expression.equals(CachedRelationships._ID, parcelableRelationship._id).sql
cr.updateItems(CachedRelationships.CONTENT_URI, CachedRelationships.COLUMNS, where, null, cr.updateItems(CachedRelationships.CONTENT_URI, CachedRelationships.COLUMNS, where, null,
ParcelableRelationship::class.java) { ParcelableRelationship::class.java) {
return@updateItems it return@updateItems it
} }
} else { } else {
insertItems.add(it) insertItems.add(parcelableRelationship)
} }
} }
cr.bulkInsert(CachedRelationships.CONTENT_URI, insertItems, ParcelableRelationship::class.java) cr.bulkInsert(CachedRelationships.CONTENT_URI, insertItems, ParcelableRelationship::class.java)

View File

@ -81,7 +81,7 @@ class ColorPickerPreference(context: Context, attrs: AttributeSet? = null) :
override fun displayDialog(fragment: PreferenceFragmentCompat) { override fun displayDialog(fragment: PreferenceFragmentCompat) {
val df = ColorPickerPreferenceDialogFragment.newInstance(key) val df = ColorPickerPreferenceDialogFragment.newInstance(key)
df.setTargetFragment(fragment, 0) df.setTargetFragment(fragment, 0)
fragment.fragmentManager?.let { df.show(it, key) } fragment.parentFragmentManager.let { df.show(it, key) }
} }
override fun onBindViewHolder(holder: PreferenceViewHolder) { override fun onBindViewHolder(holder: PreferenceViewHolder) {

View File

@ -35,7 +35,7 @@ class DefaultAPIPreference(
override fun displayDialog(fragment: PreferenceFragmentCompat) { override fun displayDialog(fragment: PreferenceFragmentCompat) {
val df = APIEditorDialogFragment() val df = APIEditorDialogFragment()
df.setTargetFragment(fragment, 0) df.setTargetFragment(fragment, 0)
fragment.fragmentManager?.let { df.show(it, key) } fragment.parentFragmentManager.let { df.show(it, key) }
} }
} }

View File

@ -72,7 +72,7 @@ class KeyboardShortcutPreference(context: Context, attrs: AttributeSet? = null)
override fun displayDialog(fragment: PreferenceFragmentCompat) { override fun displayDialog(fragment: PreferenceFragmentCompat) {
val df = KeyboardShortcutDialogFragment.newInstance(action) val df = KeyboardShortcutDialogFragment.newInstance(action)
df.setTargetFragment(fragment, 0) df.setTargetFragment(fragment, 0)
fragment.fragmentManager?.let { df.show(it, action) } fragment.parentFragmentManager.let { df.show(it, action) }
} }
class KeyboardShortcutDialogFragment : ThemedPreferenceDialogFragmentCompat(), DialogInterface.OnKeyListener { class KeyboardShortcutDialogFragment : ThemedPreferenceDialogFragmentCompat(), DialogInterface.OnKeyListener {

View File

@ -58,7 +58,7 @@ class RandomizeAccountNamePreference @JvmOverloads constructor(
override fun displayDialog(fragment: PreferenceFragmentCompat) { override fun displayDialog(fragment: PreferenceFragmentCompat) {
val df = RenameAccountsConfirmDialogFragment.newInstance(key, getPersistedBoolean(false)) val df = RenameAccountsConfirmDialogFragment.newInstance(key, getPersistedBoolean(false))
df.setTargetFragment(fragment, 0) df.setTargetFragment(fragment, 0)
fragment.fragmentManager?.let { df.show(it, key) } fragment.parentFragmentManager.let { df.show(it, key) }
} }
class RenameAccountsConfirmDialogFragment : PreferenceDialogFragmentCompat() { class RenameAccountsConfirmDialogFragment : PreferenceDialogFragmentCompat() {

View File

@ -36,6 +36,6 @@ class ThemedEditTextPreference(context: Context, attrs: AttributeSet? = null) :
override fun displayDialog(fragment: PreferenceFragmentCompat) { override fun displayDialog(fragment: PreferenceFragmentCompat) {
val df = ThemedEditTextPreferenceDialogFragmentCompat.newInstance(key) val df = ThemedEditTextPreferenceDialogFragmentCompat.newInstance(key)
df.setTargetFragment(fragment, 0) df.setTargetFragment(fragment, 0)
fragment.fragmentManager?.let { df.show(it, key) } fragment.parentFragmentManager.let { df.show(it, key) }
} }
} }

View File

@ -17,6 +17,6 @@ open class ThemedListPreference(context: Context, attrs: AttributeSet? = null) :
override fun displayDialog(fragment: PreferenceFragmentCompat) { override fun displayDialog(fragment: PreferenceFragmentCompat) {
val df = ThemedListPreferenceDialogFragmentCompat.newInstance(key) val df = ThemedListPreferenceDialogFragmentCompat.newInstance(key)
df.setTargetFragment(fragment, 0) df.setTargetFragment(fragment, 0)
fragment.fragmentManager?.let { df.show(it, key) } fragment.parentFragmentManager.let { df.show(it, key) }
} }
} }

View File

@ -123,8 +123,8 @@ class GetActivitiesAboutMeTask(context: Context) : GetActivitiesTask(context) {
} }
return GetTimelineResult(account, activities, activities.flatMap { return GetTimelineResult(account, activities, activities.flatMap {
it.sources?.toList().orEmpty() it.sources?.toList().orEmpty()
}, timeline.flatMap { }, timeline.flatMap { status ->
it.entities?.hashtags?.map { it.text }.orEmpty() status.entities?.hashtags?.map { it.text }.orEmpty()
}) })
} }

View File

@ -687,7 +687,27 @@ class UpdateStatusTask(
val ids: Array<String>, val ids: Array<String>,
val deleteOnSuccess: List<MediaDeletionItem>, val deleteOnSuccess: List<MediaDeletionItem>,
val deleteAlways: List<MediaDeletionItem> val deleteAlways: List<MediaDeletionItem>
) ) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as SharedMediaUploadResult
if (!ids.contentEquals(other.ids)) return false
if (deleteOnSuccess != other.deleteOnSuccess) return false
if (deleteAlways != other.deleteAlways) return false
return true
}
override fun hashCode(): Int {
var result = ids.contentHashCode()
result = 31 * result + deleteOnSuccess.hashCode()
result = 31 * result + deleteAlways.hashCode()
return result
}
}
companion object { companion object {
@ -914,7 +934,7 @@ class UpdateStatusTask(
return null return null
} }
if (imageLimit == null || (imageLimit.checkGeomentry(o.outWidth, o.outHeight) if (imageLimit == null || (imageLimit.checkGeometry(o.outWidth, o.outHeight)
&& imageLimit.checkSize(imageSize, chucked))) return null && imageLimit.checkSize(imageSize, chucked))) return null
o.inSampleSize = o.calculateInSampleSize(imageLimit.maxWidth, imageLimit.maxHeight) o.inSampleSize = o.calculateInSampleSize(imageLimit.maxWidth, imageLimit.maxHeight)
o.inJustDecodeBounds = false o.inJustDecodeBounds = false
@ -1092,7 +1112,7 @@ class UpdateStatusTask(
context.contentResolver.delete(Drafts.CONTENT_URI, where, null) context.contentResolver.delete(Drafts.CONTENT_URI, where, null)
} }
fun AccountExtras.ImageLimit.checkGeomentry(width: Int, height: Int): Boolean { fun AccountExtras.ImageLimit.checkGeometry(width: Int, height: Int): Boolean {
if (this.maxWidth <= 0 || this.maxHeight <= 0) return true if (this.maxWidth <= 0 || this.maxHeight <= 0) return true
return (width <= this.maxWidth && height <= this.maxHeight) || (height <= this.maxWidth return (width <= this.maxWidth && height <= this.maxHeight) || (height <= this.maxWidth
&& width <= this.maxHeight) && width <= this.maxHeight)

View File

@ -360,10 +360,6 @@ class AsyncTwitterWrapper(
} }
override fun onException(callback: Any?, exception: MicroBlogException) { override fun onException(callback: Any?, exception: MicroBlogException) {
if (exception !is MicroBlogException) {
Analyzer.logException(exception)
return
}
DebugLog.w(TwidereConstants.LOGTAG, "Unable to update friendship", exception) DebugLog.w(TwidereConstants.LOGTAG, "Unable to update friendship", exception)
} }

View File

@ -242,7 +242,7 @@ object DataStoreUtils {
val (where, whereArgs) = getIdsWhere(isOfficial) val (where, whereArgs) = getIdsWhere(isOfficial)
getNewestActivityMaxSortPositions(context, uri, keys, where, whereArgs) getNewestActivityMaxSortPositions(context, uri, keys, where, whereArgs)
}, { arr1, arr2 -> }, { arr1, arr2 ->
LongArray(accountKeys.size) { arr1.elementAtOrNull(it)?.takeIf { it > 0 } ?: arr2.elementAtOrNull(it) ?: 0 } LongArray(accountKeys.size) { array -> arr1.elementAtOrNull(array)?.takeIf { it > 0 } ?: arr2.elementAtOrNull(array) ?: 0 }
}, accountKeys) }, accountKeys)
} }
@ -259,7 +259,7 @@ object DataStoreUtils {
val (where, whereArgs) = getIdsWhere(isOfficial) val (where, whereArgs) = getIdsWhere(isOfficial)
getOldestActivityMaxSortPositions(context, uri, keys, where, whereArgs) getOldestActivityMaxSortPositions(context, uri, keys, where, whereArgs)
}, { arr1, arr2 -> }, { arr1, arr2 ->
LongArray(accountKeys.size) { arr1.elementAtOrNull(it)?.takeIf { it > 0 } ?: arr2.elementAtOrNull(it) ?: 0 } LongArray(accountKeys.size) { array -> arr1.elementAtOrNull(array)?.takeIf { it > 0 } ?: arr2.elementAtOrNull(array) ?: 0 }
}, accountKeys) }, accountKeys)
} }

View File

@ -187,7 +187,7 @@ object IntentUtils {
intent.data = Uri.parse("${uri.scheme}://") intent.data = Uri.parse("${uri.scheme}://")
return intent.resolveActivity(context.packageManager)?.takeIf { return intent.resolveActivity(context.packageManager)?.takeIf {
it.className != null && it.packageName != "android" it.packageName != "android"
}?.packageName }?.packageName
} }

View File

@ -42,7 +42,7 @@ interface GifShareProvider {
fun newFactory(): Factory = ServiceLoader.load(Factory::class.java)?.firstOrNull() ?: NullFactory fun newFactory(): Factory = ServiceLoader.load(Factory::class.java)?.firstOrNull() ?: NullFactory
private object NullFactory : Factory { private object NullFactory : Factory {
override fun newInstance(context: Context) = null override fun newInstance(context: Context): Nothing? = null
} }
} }

View File

@ -71,8 +71,8 @@ class RoundedRectTransformation(
return "RoundedRectTransformation(radius=$radius, radiusPercent=$radius)" return "RoundedRectTransformation(radius=$radius, radiusPercent=$radius)"
} }
override fun equals(o: Any?): Boolean { override fun equals(other: Any?): Boolean {
return o is RoundedRectTransformation return other is RoundedRectTransformation
} }
override fun hashCode(): Int { override fun hashCode(): Int {

View File

@ -24,6 +24,7 @@ import android.os.Build
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.GlideBuilder import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.Registry import com.bumptech.glide.Registry
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
import com.bumptech.glide.load.model.GlideUrl import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.module.AppGlideModule import com.bumptech.glide.module.AppGlideModule
@ -39,7 +40,7 @@ import org.mariotaku.twidere.util.media.ThumborWrapper
import org.mariotaku.twidere.util.okhttp.ModifyRequestInterceptor import org.mariotaku.twidere.util.okhttp.ModifyRequestInterceptor
import java.io.InputStream import java.io.InputStream
@com.bumptech.glide.annotation.GlideModule @GlideModule
class TwidereGlideModule : AppGlideModule() { class TwidereGlideModule : AppGlideModule() {
override fun applyOptions(context: Context, builder: GlideBuilder) { override fun applyOptions(context: Context, builder: GlideBuilder) {
// Do nothing. // Do nothing.

View File

@ -70,12 +70,12 @@ class MediaPreloader(val context: Context) {
} }
private fun preLoadProfileImage(status: ParcelableStatus) { private fun preLoadProfileImage(status: ParcelableStatus) {
Glide.with(context).loadProfileImage(context, status, 0).into(Target.SIZE_ORIGINAL, Glide.with(context).loadProfileImage(context, status, 0).submit(Target.SIZE_ORIGINAL,
Target.SIZE_ORIGINAL) Target.SIZE_ORIGINAL)
} }
private fun preloadPreviewImage(url: String?) { private fun preloadPreviewImage(url: String?) {
Glide.with(context).load(url).into(Target.SIZE_ORIGINAL, Glide.with(context).load(url).submit(Target.SIZE_ORIGINAL,
Target.SIZE_ORIGINAL) Target.SIZE_ORIGINAL)
} }

View File

@ -42,8 +42,8 @@ object SystemDnsFetcher {
@SuppressLint("PrivateApi") @SuppressLint("PrivateApi")
open fun get(context: Context): List<String>? { open fun get(context: Context): List<String>? {
try { try {
val SystemProperties = Class.forName("android.os.SystemProperties") val systemProperties = Class.forName("android.os.SystemProperties")
val method = SystemProperties.getMethod("get", String::class.java) val method = systemProperties.getMethod("get", String::class.java)
val netdns = arrayOf("net.dns1", "net.dns2", "net.dns3", "net.dns4") val netdns = arrayOf("net.dns1", "net.dns2", "net.dns3", "net.dns4")
return netdns.mapNotNull { key -> return netdns.mapNotNull { key ->
return@mapNotNull method(null, key) as? String return@mapNotNull method(null, key) as? String

View File

@ -64,7 +64,7 @@ interface StatusScheduleProvider {
} }
private object NullFactory : Factory { private object NullFactory : Factory {
override fun newInstance(context: Context) = null override fun newInstance(context: Context): Nothing? = null
override fun parseInfo(json: String): ScheduleInfo? = null override fun parseInfo(json: String): ScheduleInfo? = null

View File

@ -90,7 +90,7 @@ abstract class TimelineSyncManager(val context: Context) {
} }
object DummyFactory : Factory() { object DummyFactory : Factory() {
override fun create(context: Context) = null override fun create(context: Context): Nothing? = null
} }
companion object { companion object {

View File

@ -22,6 +22,7 @@ package org.mariotaku.twidere.util.text
import com.twitter.twittertext.Extractor import com.twitter.twittertext.Extractor
import com.twitter.twittertext.Validator import com.twitter.twittertext.Validator
import java.text.Normalizer import java.text.Normalizer
import java.util.*
object TwitterValidator : Validator() { object TwitterValidator : Validator() {
@ -54,7 +55,7 @@ object TwitterValidator : Validator() {
for (urlEntity in extractor.extractURLsWithIndices(normalized)) { for (urlEntity in extractor.extractURLsWithIndices(normalized)) {
length += urlEntity.start - urlEntity.end length += urlEntity.start - urlEntity.end
length += if (urlEntity.value.toLowerCase().startsWith("https://")) shortUrlLengthHttps else shortUrlLength length += if (urlEntity.value.toLowerCase(Locale.ROOT).startsWith("https://")) shortUrlLengthHttps else shortUrlLength
} }
return length return length

View File

@ -23,7 +23,7 @@ open class IconActionView(
context: Context, attrs: AttributeSet? = null context: Context, attrs: AttributeSet? = null
) : AppCompatImageView(context, attrs), IIconActionButton { ) : AppCompatImageView(context, attrs), IIconActionButton {
override var defaultColor: Int = 0 final override var defaultColor: Int = 0
@ColorInt @ColorInt
get() { get() {
if (field == 0) { if (field == 0) {
@ -40,7 +40,7 @@ open class IconActionView(
updateColorFilter() updateColorFilter()
} }
override var activatedColor: Int = 0 final override var activatedColor: Int = 0
@ColorInt @ColorInt
get() { get() {
if (field != 0) return field if (field != 0) return field
@ -51,7 +51,7 @@ open class IconActionView(
updateColorFilter() updateColorFilter()
} }
override var disabledColor: Int = 0 final override var disabledColor: Int = 0
@ColorInt @ColorInt
get() { get() {
if (field != 0) return field if (field != 0) return field

View File

@ -15,7 +15,7 @@ class YandexAPIFactory(apiKey: String, endpoint: String) {
init { init {
factory.setEndpoint(Endpoint(endpoint)) factory.setEndpoint(Endpoint(endpoint))
factory.setExceptionFactory { cause, request, response -> factory.setExceptionFactory { cause, _, _ ->
cause?.let { YandexException(it) } cause?.let { YandexException(it) }
?: YandexException() ?: YandexException()
} }

View File

@ -29,7 +29,7 @@
app:cardPreventCornerOverlap="false" app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false"> app:cardUseCompatPadding="false">
<androidx.legacy.widget.Space <Space
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/element_spacing_xlarge"/> android:layout_height="@dimen/element_spacing_xlarge"/>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>