Use require instead of get for better error messages

This commit is contained in:
TacoTheDank 2020-05-31 01:54:57 -04:00
parent 95f407ee2b
commit 11a2d99c39
90 changed files with 197 additions and 197 deletions

View File

@ -1839,8 +1839,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = activity!!
val builder = AlertDialog.Builder(context!!)
val context = requireActivity()
val builder = AlertDialog.Builder(requireContext())
builder.setMessage(R.string.quote_protected_status_warning_message)
builder.setPositiveButton(R.string.send_anyway, this)
builder.setNegativeButton(android.R.string.cancel, null)
@ -1873,8 +1873,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = activity!!
val builder = AlertDialog.Builder(context!!)
val context = requireActivity()
val builder = AlertDialog.Builder(requireContext())
builder.setMessage(getString(R.string.message_format_compose_message_convert_to_status,
"@$screenName"))
builder.setPositiveButton(R.string.action_send, this)

View File

@ -1070,7 +1070,7 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
class AutoRefreshConfirmDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(R.string.auto_refresh)
builder.setMessage(R.string.message_auto_refresh_confirm)
builder.setPositiveButton(android.R.string.ok) { _, _ ->

View File

@ -30,7 +30,7 @@ class InvalidAccountAlertActivity : FragmentActivity() {
class InvalidAccountAlertDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(R.string.title_error_invalid_account)
builder.setMessage(R.string.message_error_invalid_account)
builder.setPositiveButton(android.R.string.ok) { _, _ ->

View File

@ -388,7 +388,7 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
class RestartConfirmDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(activity!!)
val builder = AlertDialog.Builder(requireActivity())
if (arguments?.getBoolean(EXTRA_SHOULD_TERMINATE) == true) {
builder.setMessage(R.string.app_terminate_confirm)
builder.setNegativeButton(R.string.action_dont_terminate, this)

View File

@ -573,13 +573,13 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
class SignInTypeChooserDialogFragment : BaseDialogFragment(),
LoaderManager.LoaderCallbacks<List<CustomAPIConfig>> {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_expandable_list)
val dialog = builder.create()
dialog.onShow {
it.applyTheme()
val listView = it.expandableList
val adapter = LoginTypeAdapter(context!!)
val adapter = LoginTypeAdapter(requireContext())
listView.setAdapter(adapter)
listView.setOnGroupClickListener { _, _, groupPosition, _ ->
val type = adapter.getGroup(groupPosition)
@ -623,7 +623,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
AccountType.MASTODON, AccountType.STATUSNET)
val result = supportedAccountTypes.mapNotNullTo(ArrayList()) { type ->
if (type == AccountType.MASTODON) return@mapNotNullTo LoginType(type,
listOf(CustomAPIConfig.mastodon(context!!)))
listOf(CustomAPIConfig.mastodon(requireContext())))
return@mapNotNullTo configGroup[type]?.let { list ->
LoginType(type, list.sortedBy { !it.isDefault })
}
@ -632,7 +632,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<CustomAPIConfig>> {
return DefaultAPIConfigLoader(context!!)
return DefaultAPIConfigLoader(requireContext())
}
override fun onLoaderReset(loader: Loader<List<CustomAPIConfig>>) {
@ -694,7 +694,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
var challengeType: String? = null
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(R.string.login_verification)
builder.setView(R.layout.dialog_login_verification_code)
builder.positive(android.R.string.ok, this::performVerification)
@ -753,7 +753,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
class PasswordSignInDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_password_sign_in)
builder.positive(R.string.action_sign_in, this::onPositiveButton)
builder.setNegativeButton(android.R.string.cancel, null)

View File

@ -93,7 +93,7 @@ class TrendsLocationSelectorActivity : BaseActivity() {
private val list: Array<LocationsMap.LocationsData> get() = arguments?.getTypedArray(EXTRA_DATA) ?: emptyArray()
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val selectorBuilder = AlertDialog.Builder(context!!)
val selectorBuilder = AlertDialog.Builder(requireContext())
selectorBuilder.setTitle(R.string.trends_location)
selectorBuilder.setView(R.layout.dialog_expandable_list)
selectorBuilder.setNegativeButton(android.R.string.cancel, null)
@ -101,7 +101,7 @@ class TrendsLocationSelectorActivity : BaseActivity() {
dialog.onShow {
it.applyTheme()
val listView = it.expandableList
val adapter = ExpandableTrendLocationsListAdapter(context!!)
val adapter = ExpandableTrendLocationsListAdapter(requireContext())
adapter.data = list
listView.setAdapter(adapter)
listView.setOnGroupClickListener(ExpandableListView.OnGroupClickListener { _, _, groupPosition, _ ->

View File

@ -51,7 +51,7 @@ import org.mariotaku.twidere.view.holder.status.DetailStatusViewHolder
class StatusDetailsAdapter(
val fragment: StatusFragment
) : LoadMoreSupportAdapter<RecyclerView.ViewHolder>(fragment.context!!, fragment.requestManager),
) : LoadMoreSupportAdapter<RecyclerView.ViewHolder>(fragment.requireContext(), fragment.requestManager),
IStatusesAdapter<List<ParcelableStatus>>, IItemCountsAdapter {
override val twidereLinkify: TwidereLinkify

View File

@ -43,7 +43,7 @@ class APIEditorDialogFragment : BaseDialogFragment() {
private lateinit var apiConfig: CustomAPIConfig
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_api_editor)
builder.setPositiveButton(R.string.action_save) { _, _ ->
val targetFragment = this.targetFragment
@ -76,8 +76,8 @@ class APIEditorDialogFragment : BaseDialogFragment() {
accountTypeSpinner.adapter = AccountTypeSpinnerAdapter(this)
editConsumerKey.addValidator(ConsumerKeySecretValidator(context!!.getString(R.string.invalid_consumer_key)))
editConsumerSecret.addValidator(ConsumerKeySecretValidator(context!!.getString(R.string.invalid_consumer_secret)))
editConsumerKey.addValidator(ConsumerKeySecretValidator(requireContext().getString(R.string.invalid_consumer_key)))
editConsumerSecret.addValidator(ConsumerKeySecretValidator(requireContext().getString(R.string.invalid_consumer_secret)))
editNoVersionSuffix.setOnCheckedChangeListener { _, _ -> editNoVersionSuffixChanged = true }
editAuthType.setOnCheckedChangeListener { _, checkedId ->
@ -145,8 +145,8 @@ class APIEditorDialogFragment : BaseDialogFragment() {
private lateinit var adapter: ArrayAdapter<CustomAPIConfig>
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
adapter = CustomAPIConfigArrayAdapter(context!!)
val builder = AlertDialog.Builder(context!!)
adapter = CustomAPIConfigArrayAdapter(requireContext())
val builder = AlertDialog.Builder(requireContext())
builder.setAdapter(adapter, this)
loaderManager.initLoader(0, null, this)
val dialog = builder.create()
@ -162,7 +162,7 @@ class APIEditorDialogFragment : BaseDialogFragment() {
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<CustomAPIConfig>> {
return DefaultAPIConfigLoader(context!!)
return DefaultAPIConfigLoader(requireContext())
}
override fun onLoadFinished(loader: Loader<List<CustomAPIConfig>>, data: List<CustomAPIConfig>) {
@ -189,7 +189,7 @@ class APIEditorDialogFragment : BaseDialogFragment() {
private class AccountTypeSpinnerAdapter(
fragment: APIEditorDialogFragment
) : BaseArrayAdapter<String>(fragment.context!!, R.layout.support_simple_spinner_dropdown_item,
) : BaseArrayAdapter<String>(fragment.requireContext(), R.layout.support_simple_spinner_dropdown_item,
requestManager = fragment.requestManager) {
init {
add(AccountType.TWITTER)

View File

@ -185,7 +185,7 @@ abstract class AbsActivitiesFragment protected constructor() :
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableActivity>> {
val fromUser = args?.getBoolean(EXTRA_FROM_USER)
args?.remove(EXTRA_FROM_USER)
return onCreateActivitiesLoader(activity!!, args!!, fromUser!!)
return onCreateActivitiesLoader(requireActivity(), args!!, fromUser!!)
}
protected fun saveReadPosition() {

View File

@ -129,12 +129,12 @@ abstract class AbsContentListViewFragment<A : ListAdapter> : BaseFragment(),
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val backgroundColor = ThemeUtils.getColorBackground(context!!)
val backgroundColor = ThemeUtils.getColorBackground(requireContext())
val colorRes = TwidereColorUtils.getContrastYIQ(backgroundColor,
R.color.bg_refresh_progress_color_light, R.color.bg_refresh_progress_color_dark)
swipeLayout.setOnRefreshListener(this)
swipeLayout.setProgressBackgroundColorSchemeResource(colorRes)
adapter = onCreateAdapter(context!!, requestManager)
adapter = onCreateAdapter(requireContext(), requestManager)
listView.setOnTouchListener { _, event ->
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
updateRefreshProgressOffset()

View File

@ -182,13 +182,13 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
super.onActivityCreated(savedInstanceState)
drawerCallback = SimpleDrawerCallback(recyclerView)
val backgroundColor = ThemeUtils.getColorBackground(context!!)
val backgroundColor = ThemeUtils.getColorBackground(requireContext())
val colorRes = TwidereColorUtils.getContrastYIQ(backgroundColor,
R.color.bg_refresh_progress_color_light, R.color.bg_refresh_progress_color_dark)
swipeLayout.setOnRefreshListener(this)
swipeLayout.setProgressBackgroundColorSchemeResource(colorRes)
adapter = onCreateAdapter(context!!, requestManager)
layoutManager = onCreateLayoutManager(context!!)
adapter = onCreateAdapter(requireContext(), requestManager)
layoutManager = onCreateLayoutManager(requireContext())
scrollListener = RecyclerViewScrollHandler(this, RecyclerViewScrollHandler.RecyclerViewCallback(recyclerView))
recyclerView.layoutManager = layoutManager
@ -216,7 +216,7 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
} else {
recyclerView.setOnTouchListener(scrollListener.touchListener)
}
setupRecyclerView(context!!, recyclerView)
setupRecyclerView(requireContext(), recyclerView)
recyclerView.adapter = adapter
scrollListener.touchSlop = ViewConfiguration.get(context).scaledTouchSlop

View File

@ -88,7 +88,7 @@ abstract class AbsMediaStatusesFragment : AbsContentRecyclerViewFragment<Stagger
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableStatus>?> {
val fromUser = args?.getBoolean(EXTRA_FROM_USER)
args?.remove(EXTRA_FROM_USER)
return onCreateStatusesLoader(activity!!, args!!, fromUser!!)
return onCreateStatusesLoader(requireActivity(), args!!, fromUser!!)
}
final override fun onLoadFinished(loader: Loader<List<ParcelableStatus>?>, data: List<ParcelableStatus>?) {

View File

@ -239,7 +239,7 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableStatus>?> {
val fromUser = args?.getBoolean(EXTRA_FROM_USER)
args?.remove(EXTRA_FROM_USER)
return onCreateStatusesLoader(activity!!, args!!, fromUser!!)
return onCreateStatusesLoader(requireActivity(), args!!, fromUser!!)
}
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
@ -562,7 +562,7 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
resolver?.update(contentUri, values, where, null)
return true
}
else -> return MenuUtils.handleStatusClick(activity!!, this, fragmentManager!!,
else -> return MenuUtils.handleStatusClick(requireActivity(), this, requireFragmentManager(),
preferences, userColorNameManager, twitterWrapper, status, item)
}
}

View File

@ -47,7 +47,7 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val activity = activity
pagerAdapter = SupportTabsAdapter(activity!!, childFragmentManager, null)
pagerAdapter = SupportTabsAdapter(requireActivity(), childFragmentManager, null)
viewPager.adapter = pagerAdapter
viewPager.offscreenPageLimit = 2
viewPager.addOnPageChangeListener(this)
@ -149,7 +149,7 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
if (height != 0) {
insets.top = height
} else {
insets.top = ThemeUtils.getActionBarHeight(context!!)
insets.top = ThemeUtils.getActionBarHeight(requireContext())
}
return true
}

View File

@ -48,7 +48,7 @@ abstract class AbsUserMuteBlockDialogFragment : BaseDialogFragment(), DialogInte
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(getTitle(user))
builder.setView(R.layout.dialog_block_mute_filter_user_confirm)
builder.setPositiveButton(getPositiveButtonTitle(user), this)

View File

@ -259,7 +259,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<AccountsInfo> {
return AccountsInfoLoader(activity!!, accountsAdapter.accounts == null)
return AccountsInfoLoader(requireActivity(), accountsAdapter.accounts == null)
}
@ -538,10 +538,10 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
} else if (user.account_color != 0) {
ColorDrawable(user.account_color)
} else {
ColorDrawable(Chameleon.getOverrideTheme(activity!!, activity).colorPrimary)
ColorDrawable(Chameleon.getOverrideTheme(requireActivity(), activity).colorPrimary)
}
requestManager.loadProfileBanner(context!!, account.user, width).fallback(fallbackBanner)
requestManager.loadProfileBanner(requireContext(), account.user, width).fallback(fallbackBanner)
.into(bannerView)
}
@ -557,7 +557,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
} else {
"${if (showType) account.type else ""}@${account.user.screen_name}"
}
requestManager.loadProfileImage(context!!, account, preferences[profileImageStyleKey],
requestManager.loadProfileImage(requireContext(), account, preferences[profileImageStyleKey],
accountProfileImageView.cornerRadius, accountProfileImageView.cornerRadiusRatio,
ProfileImageSize.REASONABLY_SMALL).placeholder(profileImageSnapshot).into(accountProfileImageView)
//TODO complete border color

View File

@ -60,7 +60,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true)
val am = AccountManager.get(context)
adapter = AccountDetailsAdapter(context!!, requestManager).apply {
adapter = AccountDetailsAdapter(requireContext(), requestManager).apply {
sortEnabled = true
switchEnabled = true
accountToggleListener = { pos, checked ->
@ -158,7 +158,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<AccountDetails>> {
return AccountDetailsLoader(context!!)
return AccountDetailsLoader(requireContext())
}
override fun onLoaderReset(loader: Loader<List<AccountDetails>>) {
@ -227,7 +227,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = context
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setNegativeButton(android.R.string.cancel, null)
builder.setPositiveButton(android.R.string.ok, this)
builder.setTitle(R.string.title_account_delete_confirm)

View File

@ -48,7 +48,7 @@ class AddStatusFilterDialogFragment : BaseDialogFragment() {
private var filterItems: Array<FilterItemInfo>? = null
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
filterItems = filterItemsInfo
val entries = arrayOfNulls<String>(filterItems!!.size)
val nameFirst = preferences[nameFirstKey]

View File

@ -63,7 +63,7 @@ open class BaseDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestManager = Glide.with(context!!)// TODO: Upgrade Glide usage
requestManager = Glide.with(requireContext())// TODO: Upgrade Glide usage
}
override fun onStart() {

View File

@ -102,7 +102,7 @@ open class BaseFragment : Fragment(), IBaseFragment<BaseFragment> {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestManager = Glide.with(context!!)// TODO: Upgrade Glide usage
requestManager = Glide.with(requireContext())// TODO: Upgrade Glide usage
}
override fun onStart() {

View File

@ -48,7 +48,7 @@ open class BaseWebViewFragment : BaseFragment() {
protected fun createWebViewClient(): WebViewClient {
return DefaultWebViewClient(activity!!)
return DefaultWebViewClient(requireActivity())
}
/**

View File

@ -68,7 +68,7 @@ class ColorPickerDialogFragment : BaseDialogFragment(), DialogInterface.OnClickL
}
val activity = activity
val builder = AlertDialog.Builder(activity!!)
val builder = AlertDialog.Builder(requireActivity())
builder.setView(me.uucky.colorpicker.R.layout.cp__dialog_color_picker)
builder.setPositiveButton(android.R.string.ok, this)
if (args!!.getBoolean(EXTRA_CLEAR_BUTTON, false)) {
@ -82,7 +82,7 @@ class ColorPickerDialogFragment : BaseDialogFragment(), DialogInterface.OnClickL
val showAlphaSlider = args.getBoolean(EXTRA_ALPHA_SLIDER, true)
for (presetColor in PRESET_COLORS) {
controller!!.addColor(ContextCompat.getColor(context!!, presetColor))
controller!!.addColor(ContextCompat.getColor(requireContext(), presetColor))
}
controller!!.setAlphaEnabled(showAlphaSlider)
controller!!.setInitialColor(color)

View File

@ -38,7 +38,7 @@ import org.mariotaku.twidere.util.ParseUtils
class CreateUserListDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_user_list_detail_editor)
builder.setTitle(R.string.new_user_list)

View File

@ -59,7 +59,7 @@ import org.mariotaku.twidere.util.Utils
abstract class CursorActivitiesFragment : AbsActivitiesFragment() {
override val accountKeys: Array<UserKey>
get() = Utils.getAccountKeys(context!!, arguments) ?: DataStoreUtils.getActivatedAccountKeys(context!!)
get() = Utils.getAccountKeys(requireContext(), arguments) ?: DataStoreUtils.getActivatedAccountKeys(requireContext())
abstract val contentUri: Uri

View File

@ -70,7 +70,7 @@ abstract class CursorStatusesFragment : AbsStatusesFragment() {
get() = false
override val accountKeys: Array<UserKey>
get() = Utils.getAccountKeys(context!!, arguments) ?: DataStoreUtils.getActivatedAccountKeys(context!!)
get() = Utils.getAccountKeys(requireContext(), arguments) ?: DataStoreUtils.getActivatedAccountKeys(requireContext())
abstract val errorInfoKey: String
abstract val isFilterEnabled: Boolean

View File

@ -93,7 +93,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true)
adapter = CustomTabsAdapter(context!!)
adapter = CustomTabsAdapter(requireContext())
listView.choiceMode = ListView.CHOICE_MODE_MULTIPLE_MODAL
listView.setMultiChoiceModeListener(this)
listView.onItemClickListener = OnItemClickListener { _, _, position, _ ->
@ -130,7 +130,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor?> {
return CursorLoader(activity!!, Tabs.CONTENT_URI, Tabs.COLUMNS, null, null, Tabs.DEFAULT_SORT_ORDER)
return CursorLoader(requireActivity(), Tabs.CONTENT_URI, Tabs.COLUMNS, null, null, Tabs.DEFAULT_SORT_ORDER)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
@ -138,7 +138,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
val context = this.context
val accounts = AccountUtils.getAllAccountDetails(AccountManager.get(context), false)
val itemAdd = menu.findItem(R.id.add_submenu)
val theme = Chameleon.getOverrideTheme(context!!, context)
val theme = Chameleon.getOverrideTheme(requireContext(), context)
if (itemAdd != null && itemAdd.hasSubMenu()) {
val subMenu = itemAdd.subMenu
subMenu.clear()
@ -394,7 +394,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_custom_tab_editor)
builder.setPositiveButton(R.string.action_save, null)
builder.setNegativeButton(android.R.string.cancel, null)

View File

@ -44,7 +44,7 @@ class DateTimePickerDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_date_time_picker)
builder.setNegativeButton(android.R.string.cancel, null)
builder.setPositiveButton(android.R.string.ok, null)

View File

@ -50,7 +50,7 @@ class DeleteUserListMembersDialogFragment : BaseDialogFragment(), DialogInterfac
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
val users = users
val userList = userList
if (users == null || userList == null) throw NullPointerException()

View File

@ -48,7 +48,7 @@ class DestroyFriendshipDialogFragment : BaseDialogFragment(), DialogInterface.On
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
val nameFirst = preferences[nameFirstKey]
val displayName = userColorNameManager.getDisplayName(user, nameFirst)
builder.setTitle(getString(R.string.unfollow_user, displayName))

View File

@ -48,7 +48,7 @@ class DestroySavedSearchDialogFragment : BaseDialogFragment(), DialogInterface.O
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = activity
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
val name = searchName
builder.setTitle(getString(R.string.destroy_saved_search, name))
builder.setMessage(getString(R.string.destroy_saved_search_confirm_message, name))

View File

@ -46,7 +46,7 @@ class DestroyUserListDialogFragment : BaseDialogFragment(), DialogInterface.OnCl
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = activity
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
val userList = userList
builder.setTitle(getString(R.string.delete_user_list, userList.name))
builder.setMessage(getString(R.string.delete_user_list_confirm_message, userList.name))

View File

@ -47,7 +47,7 @@ class DestroyUserListSubscriptionDialogFragment : BaseDialogFragment(), DialogIn
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = activity
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
val userList = userList
if (userList != null) {
builder.setTitle(getString(R.string.unsubscribe_from_user_list, userList.name))

View File

@ -36,11 +36,11 @@ import org.mariotaku.twidere.extension.applyTheme
class EditAltTextDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(R.string.edit_description)
builder.setView(R.layout.dialog_compose_edit_alt_text)
builder.setNegativeButton(android.R.string.cancel, null)
val position = arguments!!.getInt(EXTRA_POSITION)
val position = requireArguments().getInt(EXTRA_POSITION)
builder.setPositiveButton(android.R.string.ok) { dialog, _ ->
val altText = (dialog as Dialog).editText.string
callback?.onSetAltText(position, altText)
@ -51,7 +51,7 @@ class EditAltTextDialogFragment : BaseDialogFragment() {
val dialog = builder.create()
dialog.applyOnShow {
applyTheme()
editText.setText(arguments!!.getString(EXTRA_TEXT))
editText.setText(requireArguments().getString(EXTRA_TEXT))
}
return dialog
}

View File

@ -40,7 +40,7 @@ class EditUserListDialogFragment : BaseDialogFragment() {
private val listId: String by lazy { arguments?.getString(EXTRA_LIST_ID)!! }
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_user_list_detail_editor)
builder.setTitle(R.string.title_user_list)
builder.positive(android.R.string.ok, this::onPositiveClick)

View File

@ -57,11 +57,11 @@ class ExtensionsListFragment : AbsContentListViewFragment<ExtensionsAdapter>(),
}
override fun onCreateAdapter(context: Context, requestManager: RequestManager): ExtensionsAdapter {
return ExtensionsAdapter(activity!!, requestManager)
return ExtensionsAdapter(requireActivity(), requestManager)
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ExtensionInfo>> {
return ExtensionsListLoader(activity!!)
return ExtensionsListLoader(requireActivity())
}
override fun onLoadFinished(loader: Loader<List<ExtensionInfo>>, data: List<ExtensionInfo>) {
@ -128,7 +128,7 @@ class ExtensionsListFragment : AbsContentListViewFragment<ExtensionsAdapter>(),
if (info.settings != null) {
intent.setClassName(info.packageName, info.settings)
} else {
val pm = activity!!.packageManager
val pm = requireActivity().packageManager
val activities = pm.queryIntentActivities(intent, 0)
if (activities.isEmpty()) {
return false

View File

@ -32,7 +32,7 @@ class ExtraFeaturesIntroductionDialogFragment : BaseDialogFragment() {
val requestCode: Int get() = arguments?.getInt(EXTRA_REQUEST_CODE, 0) ?: 0
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(R.string.title_extra_features)
builder.setView(R.layout.dialog_extra_features_introduction)
builder.setPositiveButton(R.string.action_purchase) { _, _ ->
@ -42,7 +42,7 @@ class ExtraFeaturesIntroductionDialogFragment : BaseDialogFragment() {
builder.setNegativeButton(R.string.action_later) { _, _ ->
onDialogCancelled()
}
val restorePurchaseIntent = extraFeaturesService.createRestorePurchaseIntent(context!!, feature)
val restorePurchaseIntent = extraFeaturesService.createRestorePurchaseIntent(requireContext(), feature)
if (restorePurchaseIntent != null) {
builder.setNeutralButton(R.string.action_restore_purchase) { _, _ ->
startActivityForResultOnTarget(restorePurchaseIntent)
@ -56,7 +56,7 @@ class ExtraFeaturesIntroductionDialogFragment : BaseDialogFragment() {
} else {
View.GONE
}
val description = ExtraFeaturesService.getIntroduction(context!!, feature)
val description = ExtraFeaturesService.getIntroduction(requireContext(), feature)
val featureIcon = it.featureIcon
val featureDescription = it.featureDescription
featureIcon.setImageResource(description.icon)

View File

@ -53,7 +53,7 @@ class GroupFragment : AbsToolbarTabPagesFragment(), LoaderCallbacks<SingleRespon
val groupId = args.getString(EXTRA_GROUP_ID)
val groupName = args.getString(EXTRA_GROUP_NAME)
val omitIntentExtra = args.getBoolean(EXTRA_OMIT_INTENT_EXTRA, true)
return ParcelableGroupLoader(context!!, omitIntentExtra, arguments, accountKey, groupId,
return ParcelableGroupLoader(requireContext(), omitIntentExtra, arguments, accountKey, groupId,
groupName)
}

View File

@ -57,7 +57,7 @@ class HostMappingsListFragment : AbsContentListViewFragment<HostMappingsListFrag
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true)
hostMapping = activity!!.getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE)
hostMapping = requireActivity().getSharedPreferences(HOST_MAPPING_PREFERENCES_NAME, Context.MODE_PRIVATE)
hostMapping.registerOnSharedPreferenceChangeListener(this)
listView.choiceMode = ListView.CHOICE_MODE_MULTIPLE_MODAL
listView.setMultiChoiceModeListener(this)
@ -65,7 +65,7 @@ class HostMappingsListFragment : AbsContentListViewFragment<HostMappingsListFrag
}
override fun onCreateAdapter(context: Context, requestManager: RequestManager): HostMappingAdapter {
return HostMappingAdapter(activity!!)
return HostMappingAdapter(requireActivity())
}
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
@ -179,7 +179,7 @@ class HostMappingsListFragment : AbsContentListViewFragment<HostMappingsListFrag
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = activity
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_add_host_mapping)
builder.setTitle(R.string.add_host_mapping)
builder.positive(android.R.string.ok, this::onPositiveClick)

View File

@ -127,7 +127,7 @@ open class ItemsListFragment : AbsContentListRecyclerViewFragment<VariousItemsAd
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<Any>?> {
return ItemsLoader(context!!, arguments!!)
return ItemsLoader(requireContext(), requireArguments())
}
final override fun onLoadFinished(loader: Loader<List<Any>?>, data: List<Any>?) {
@ -176,7 +176,7 @@ open class ItemsListFragment : AbsContentListRecyclerViewFragment<VariousItemsAd
startActivity(chooser)
return true
}
return MenuUtils.handleStatusClick(activity!!, this, fragmentManager!!,
return MenuUtils.handleStatusClick(requireActivity(), this, requireFragmentManager(),
preferences, userColorNameManager, twitterWrapper, status, item)
}
}

View File

@ -36,9 +36,9 @@ import org.mariotaku.twidere.extension.onShow
class MessageDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val activity = activity!!
val activity = requireActivity()
val builder = AlertDialog.Builder(activity)
val args = arguments!!
val args = requireArguments()
builder.setTitle(args.getString(EXTRA_TITLE))
builder.setMessage(args.getString(EXTRA_MESSAGE))
builder.setPositiveButton(android.R.string.ok, null)

View File

@ -132,7 +132,7 @@ abstract class ParcelableGroupsFragment : AbsContentListRecyclerViewFragment<Par
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableGroup>?> {
val fromUser = args?.getBoolean(EXTRA_FROM_USER)
args?.remove(EXTRA_FROM_USER)
return onCreateUserListsLoader(activity!!, args!!, fromUser!!)
return onCreateUserListsLoader(requireActivity(), args!!, fromUser!!)
}
override fun onLoaderReset(loader: Loader<List<ParcelableGroup>?>) {

View File

@ -137,7 +137,7 @@ abstract class ParcelableUserListsFragment : AbsContentListRecyclerViewFragment<
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableUserList>> {
val fromUser = args?.getBoolean(EXTRA_FROM_USER)
args?.remove(EXTRA_FROM_USER)
return onCreateUserListsLoader(activity!!, args!!, fromUser!!)
return onCreateUserListsLoader(requireActivity(), args!!, fromUser!!)
}
override fun onLoaderReset(loader: Loader<List<ParcelableUserList>>) {

View File

@ -124,7 +124,7 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<Parc
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableUser>?> {
val fromUser = args?.getBoolean(EXTRA_FROM_USER)
args?.remove(EXTRA_FROM_USER)
return onCreateUsersLoader(activity!!, args!!, fromUser!!).apply {
return onCreateUsersLoader(requireActivity(), args!!, fromUser!!).apply {
if (this is AbsRequestUsersLoader) {
pagination = args.getParcelable(EXTRA_PAGINATION)
}

View File

@ -18,10 +18,10 @@ import org.mariotaku.twidere.extension.onShow
class PermissionRequestDialog : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val permissions = arguments!!.getStringArray(EXTRA_PERMISSIONS).orEmpty()
val requestCode = arguments!!.getInt(EXTRA_REQUEST_CODE)
builder.setMessage(arguments!!.getString(EXTRA_MESSAGE))
val builder = AlertDialog.Builder(requireContext())
val permissions = requireArguments().getStringArray(EXTRA_PERMISSIONS).orEmpty()
val requestCode = requireArguments().getInt(EXTRA_REQUEST_CODE)
builder.setMessage(requireArguments().getString(EXTRA_MESSAGE))
builder.setPositiveButton(android.R.string.ok) { _, _ ->
activity?.let { ActivityCompat.requestPermissions(it, permissions, requestCode) }
}

View File

@ -47,7 +47,7 @@ class PhishingLinkWarningDialogFragment : BaseDialogFragment(), OnClickListener
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(android.R.string.dialog_alert_title)
builder.setView(R.layout.dialog_phishing_link_warning)
builder.setPositiveButton(android.R.string.ok, this)

View File

@ -75,7 +75,7 @@ class SavedSearchesListFragment : AbsContentListViewFragment<SavedSearchesAdapte
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<ResponseList<SavedSearch>?> {
return SavedSearchesLoader(activity!!, accountKey)
return SavedSearchesLoader(requireActivity(), accountKey)
}
override fun onItemLongClick(view: AdapterView<*>, child: View, position: Int, id: Long): Boolean {

View File

@ -55,7 +55,7 @@ class SensitiveContentWarningDialogFragment : BaseDialogFragment(), DialogInterf
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = activity
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(android.R.string.dialog_alert_title)
builder.setMessage(R.string.sensitive_content_warning)
builder.setPositiveButton(android.R.string.ok, this)

View File

@ -57,7 +57,7 @@ class SetUserNicknameDialogFragment : BaseDialogFragment(), OnClickListener {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val nick = arguments?.getString(EXTRA_NAME)
val context = activity
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(R.string.title_set_nickname)
builder.setPositiveButton(android.R.string.ok, this)
if (!nick.isNullOrEmpty()) {

View File

@ -29,7 +29,7 @@ abstract class ThemedPreferenceDialogFragmentCompat : PreferenceDialogFragmentCo
val context = context
val preference = preference
onClick(null, DialogInterface.BUTTON_NEGATIVE)
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
.setTitle(preference.dialogTitle)
.setIcon(preference.dialogIcon)
.setPositiveButton(preference.positiveButtonText, this)

View File

@ -73,7 +73,7 @@ class TrendsSuggestionsFragment : AbsContentListViewFragment<TrendsAdapter>(), L
}
override fun onCreateAdapter(context: Context, requestManager: RequestManager): TrendsAdapter {
return TrendsAdapter(activity!!)
return TrendsAdapter(requireActivity())
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor> {
@ -81,7 +81,7 @@ class TrendsSuggestionsFragment : AbsContentListViewFragment<TrendsAdapter>(), L
val loaderWhere = Expression.and(Expression.equalsArgs(CachedTrends.ACCOUNT_KEY),
Expression.equalsArgs(CachedTrends.WOEID)).sql
val loaderWhereArgs = arrayOf(accountKey?.toString().orEmpty(), woeId.toString())
return CursorLoader(activity!!, uri, CachedTrends.COLUMNS, loaderWhere, loaderWhereArgs, CachedTrends.TREND_ORDER)
return CursorLoader(requireActivity(), uri, CachedTrends.COLUMNS, loaderWhere, loaderWhereArgs, CachedTrends.TREND_ORDER)
}
override fun onItemClick(view: AdapterView<*>, child: View, position: Int, id: Long) {

View File

@ -687,7 +687,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
if (profileBannerSpace.toolbarHeight == 0) {
var toolbarHeight = toolbar.measuredHeight
if (toolbarHeight == 0) {
toolbarHeight = ThemeUtils.getActionBarHeight(context!!)
toolbarHeight = ThemeUtils.getActionBarHeight(requireContext())
}
profileBannerSpace.toolbarHeight = toolbarHeight
}
@ -813,7 +813,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
menu.setItemAvailability(R.id.block, !isMyself)
menu.setItemAvailability(R.id.add_to_home_screen_submenu,
ShortcutManagerCompat.isRequestPinShortcutSupported(context!!))
ShortcutManagerCompat.isRequestPinShortcutSupported(requireContext()))
var canAddToList = false
var canMute = false
@ -1634,7 +1634,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
return result
}
val microBlog = MicroBlogAPIFactory.getInstance(fragment.context!!, accountKey)
val microBlog = MicroBlogAPIFactory.getInstance(fragment.requireContext(), accountKey)
val ownedLists = ArrayList<ParcelableUserList>()
val listMemberships = microBlog.getUserListOwnerMemberships(user.key.id)
val paging = Paging()
@ -1669,7 +1669,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
}
}.failUi {
val fragment = weakThis.get() ?: return@failUi
Toast.makeText(fragment.context, it.getErrorMessage(fragment.context!!),
Toast.makeText(fragment.context, it.getErrorMessage(fragment.requireContext()),
Toast.LENGTH_SHORT).show()
}
}
@ -1803,10 +1803,10 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
class AddRemoveUserListDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val lists = arguments!!.getTypedArray<ParcelableUserList>(EXTRA_USER_LISTS)
val userKey = arguments!!.getParcelable<UserKey>(EXTRA_USER_KEY)!!
val accountKey = arguments!!.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)!!
val builder = AlertDialog.Builder(context!!)
val lists = requireArguments().getTypedArray<ParcelableUserList>(EXTRA_USER_LISTS)
val userKey = requireArguments().getParcelable<UserKey>(EXTRA_USER_KEY)!!
val accountKey = requireArguments().getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)!!
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(R.string.title_add_or_remove_from_list)
val entries = Array(lists.size) { idx ->
lists[idx].name
@ -1866,7 +1866,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
states[pos] = checked
}
}
Toast.makeText(context, e.getErrorMessage(context!!), Toast.LENGTH_SHORT).show()
Toast.makeText(context, e.getErrorMessage(requireContext()), Toast.LENGTH_SHORT).show()
}
}
d.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener {
@ -1874,7 +1874,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
df.arguments = Bundle {
this[EXTRA_ACCOUNT_KEY] = accountKey
}
df.show(fragmentManager!!, "create_user_list")
df.show(requireFragmentManager(), "create_user_list")
}
}
return dialog

View File

@ -316,7 +316,7 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
val listName = args.getString(EXTRA_LIST_NAME)
val screenName = args.getString(EXTRA_SCREEN_NAME)
val omitIntentExtra = args.getBoolean(EXTRA_OMIT_INTENT_EXTRA, true)
return ParcelableUserListLoader(activity!!, omitIntentExtra, arguments, accountKey, listId,
return ParcelableUserListLoader(requireActivity(), omitIntentExtra, arguments, accountKey, listId,
listName, userKey, screenName)
}
@ -401,8 +401,8 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
class UserListDetailsDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val userList = arguments!!.getParcelable<ParcelableUserList>(EXTRA_USER_LIST)!!
val builder = AlertDialog.Builder(context!!)
val userList = requireArguments().getParcelable<ParcelableUserList>(EXTRA_USER_LIST)!!
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(userList.name)
builder.setMessage(userList.description)
builder.setPositiveButton(android.R.string.ok, null)

View File

@ -34,7 +34,7 @@ class UserListMembershipsFragment : ParcelableUserListsFragment() {
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
val screenName = args.getString(EXTRA_SCREEN_NAME)
return UserListMembershipsLoader(activity!!, accountKey, userKey, screenName, data).apply {
return UserListMembershipsLoader(requireActivity(), accountKey, userKey, screenName, data).apply {
pagination = args.getParcelable(EXTRA_PAGINATION)
}
}

View File

@ -33,7 +33,7 @@ class UserListSubscriptionsFragment : ParcelableUserListsFragment() {
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
val screenName = args.getString(EXTRA_SCREEN_NAME)
return UserListSubscriptionsLoader(activity!!, accountKey, userKey, screenName, data).apply {
return UserListSubscriptionsLoader(requireActivity(), accountKey, userKey, screenName, data).apply {
pagination = args.getParcelable(EXTRA_PAGINATION)
}
}

View File

@ -47,7 +47,7 @@ class UserListsOwnershipsFragment : ParcelableUserListsFragment() {
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
val screenName = args.getString(EXTRA_SCREEN_NAME)
return UserListOwnershipsLoader(activity!!, accountKey, userKey, screenName, data).apply {
return UserListOwnershipsLoader(requireActivity(), accountKey, userKey, screenName, data).apply {
pagination = args.getParcelable(EXTRA_PAGINATION)
}
}
@ -82,7 +82,7 @@ class UserListsOwnershipsFragment : ParcelableUserListsFragment() {
menu.setItemAvailability(R.id.new_user_list, true)
} else {
menu.setItemAvailability(R.id.new_user_list, screenName != null &&
Utils.isMyAccount(activity!!, screenName))
Utils.isMyAccount(requireActivity(), screenName))
}
}

View File

@ -132,7 +132,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
override fun onCreateLoader(id: Int, args: Bundle?): Loader<SingleResponse<ParcelableUser>> {
progressContainer.visibility = View.VISIBLE
editProfileContent.visibility = View.GONE
return ParcelableUserLoader(activity!!, accountKey, accountKey, null, arguments, false, false)
return ParcelableUserLoader(requireActivity(), accountKey, accountKey, null, arguments, false, false)
}
override fun onLoadFinished(loader: Loader<SingleResponse<ParcelableUser>>,
@ -175,7 +175,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true)
if (!Utils.isMyAccount(activity!!, accountKey)) {
if (!Utils.isMyAccount(requireActivity(), accountKey)) {
activity?.finish()
return
}
@ -379,7 +379,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
private val linkColor: Int,
private val backgroundColor: Int
) : AbsAccountRequestTask<Any?, Pair<ParcelableUser, AccountDetails>,
UserProfileEditorFragment>(fragment.context!!, accountKey) {
UserProfileEditorFragment>(fragment.requireContext(), accountKey) {
init {
this.callback = fragment
@ -490,7 +490,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
accountKey: UserKey,
imageUri: Uri,
deleteImage: Boolean
) : UpdateProfileBannerImageTask<UserProfileEditorFragment>(fragment.context!!, accountKey, imageUri, deleteImage) {
) : UpdateProfileBannerImageTask<UserProfileEditorFragment>(fragment.requireContext(), accountKey, imageUri, deleteImage) {
init {
callback = fragment
@ -513,7 +513,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
imageUri: Uri,
tile: Boolean,
deleteImage: Boolean
) : UpdateProfileBackgroundImageTask<UserProfileEditorFragment>(fragment.context!!, accountKey, imageUri,
) : UpdateProfileBackgroundImageTask<UserProfileEditorFragment>(fragment.requireContext(), accountKey, imageUri,
tile, deleteImage) {
init {
@ -538,7 +538,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
accountKey: UserKey,
imageUri: Uri,
deleteImage: Boolean
) : UpdateProfileImageTask<UserProfileEditorFragment>(fragment.context!!, accountKey, imageUri, deleteImage) {
) : UpdateProfileImageTask<UserProfileEditorFragment>(fragment.requireContext(), accountKey, imageUri, deleteImage) {
init {
callback = fragment

View File

@ -120,17 +120,17 @@ class UserQrDialogFragment : BaseDialogFragment() {
}
val profileImageSize = getString(R.string.profile_image_size)
val context = context?.applicationContext
val requestManager = Glide.with(context!!)
val requestManager = Glide.with(requireContext())
val user = this.user
return task {
try {
return@task requestManager.loadOriginalProfileImage(context!!, user, 0)
return@task requestManager.loadOriginalProfileImage(requireContext(), user, 0)
.into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).get()
} catch (e: ExecutionException) {
// Ignore
}
// Return fallback profile image
return@task requestManager.loadProfileImage(context!!, user, 0, size = profileImageSize)
return@task requestManager.loadProfileImage(requireContext(), user, 0, size = profileImageSize)
.into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).get()
}
}

View File

@ -111,7 +111,7 @@ class DraftsListFragment : AbsContentListViewFragment<DraftsAdapter>(), LoaderCa
}
override fun onCreateAdapter(context: Context, requestManager: RequestManager): DraftsAdapter {
return DraftsAdapter(activity!!, requestManager).apply {
return DraftsAdapter(requireActivity(), requestManager).apply {
textSize = preferences[textSizeKey].toFloat()
}
}
@ -125,7 +125,7 @@ class DraftsListFragment : AbsContentListViewFragment<DraftsAdapter>(), LoaderCa
Pair(Expression.inArgs(Drafts.ACTION_TYPE, actions.size).sql, actions)
} else Pair(null, null)
val orderBy = OrderBy(Drafts.TIMESTAMP, false).sql
return CursorLoader(activity!!, uri, cols, selection, selectionArgs, orderBy)
return CursorLoader(requireActivity(), uri, cols, selection, selectionArgs, orderBy)
}
override fun onLoadFinished(loader: Loader<Cursor?>, cursor: Cursor?) {
@ -289,7 +289,7 @@ class DraftsListFragment : AbsContentListViewFragment<DraftsAdapter>(), LoaderCa
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = activity
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setMessage(R.string.delete_drafts_confirm)
builder.setPositiveButton(android.R.string.ok, this)
builder.setNegativeButton(android.R.string.cancel, null)

View File

@ -114,7 +114,7 @@ class AddEditItemFragment : BaseDialogFragment() {
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_filter_rule_editor)
if (arguments?.getLong(EXTRA_ID, -1) ?: -1 >= 0) {
@ -129,10 +129,10 @@ class AddEditItemFragment : BaseDialogFragment() {
applyTheme()
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
editText.setAdapter(when (contentUri) {
Filters.Sources.CONTENT_URI -> SourceAutoCompleteAdapter(activity!!)
Filters.Users.CONTENT_URI -> ComposeAutoCompleteAdapter(activity!!, requestManager).apply {
Filters.Sources.CONTENT_URI -> SourceAutoCompleteAdapter(requireActivity())
Filters.Users.CONTENT_URI -> ComposeAutoCompleteAdapter(requireActivity(), requestManager).apply {
val am = AccountManager.get(activity)
account = AccountUtils.getDefaultAccountDetails(activity!!, am, false)
account = AccountUtils.getDefaultAccountDetails(requireActivity(), am, false)
}
else -> null
})
@ -151,7 +151,7 @@ class AddEditItemFragment : BaseDialogFragment() {
val df = ExtraFeaturesIntroductionDialogFragment.create(
ExtraFeaturesService.FEATURE_ADVANCED_FILTERS)
df.setTargetFragment(this@AddEditItemFragment, REQUEST_CHANGE_SCOPE_PURCHASE)
df.show(fragmentManager!!, ExtraFeaturesIntroductionDialogFragment.FRAGMENT_TAG)
df.show(requireFragmentManager(), ExtraFeaturesIntroductionDialogFragment.FRAGMENT_TAG)
}
}

View File

@ -179,7 +179,7 @@ abstract class BaseFiltersFragment : AbsContentListViewFragment<SimpleCursorAdap
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor?> {
val selection = Expression.isNull(Columns.Column(Filters.USER_KEY))
return CursorLoader(activity!!, contentUri, contentColumns, selection.sql, null, sortOrder)
return CursorLoader(requireActivity(), contentUri, contentColumns, selection.sql, null, sortOrder)
}
override fun onLoadFinished(loader: Loader<Cursor?>, data: Cursor?) {

View File

@ -130,7 +130,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Se
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableUser>?> {
val fromUser = args!!.getBoolean(EXTRA_FROM_USER)
args.remove(EXTRA_FROM_USER)
return onCreateUsersLoader(context!!, args, fromUser)
return onCreateUsersLoader(requireContext(), args, fromUser)
}
override fun onLoaderReset(loader: Loader<List<ParcelableUser>?>) {
@ -189,7 +189,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Se
val adapter = SelectableUsersAdapter(context, this.requestManager)
adapter.itemCheckedListener = listener@ { _, _ ->
if (!extraFeaturesService.isAdvancedFiltersEnabled) {
ExtraFeaturesIntroductionDialogFragment.show(fragmentManager!!,
ExtraFeaturesIntroductionDialogFragment.show(requireFragmentManager(),
feature = ExtraFeaturesService.FEATURE_ADVANCED_FILTERS,
requestCode = REQUEST_PURCHASE_EXTRA_FEATURES)
return@listener false
@ -246,7 +246,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Se
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(R.string.action_add_to_filter)
builder.setView(R.layout.dialog_block_mute_filter_user_confirm)
builder.setPositiveButton(android.R.string.ok, this)

View File

@ -105,7 +105,7 @@ class FilteredUsersFragment : BaseFiltersFragment() {
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor?> {
return CursorLoader(activity!!, contentUri, contentColumns, null, null, sortOrder)
return CursorLoader(requireActivity(), contentUri, contentColumns, null, null, sortOrder)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
@ -218,7 +218,7 @@ class FilteredUsersFragment : BaseFiltersFragment() {
val am = AccountManager.get(fragment.context)
val account = AccountUtils.getAccountDetails(am, accountKey, true) ?:
throw AccountNotFoundException()
CreateUserMuteTask.muteUsers(fragment.context!!, account, items)
CreateUserMuteTask.muteUsers(fragment.requireContext(), account, items)
}.alwaysUi {
weakThis.get()?.dismissProgressDialog("export_to_muted")
}

View File

@ -60,7 +60,7 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true)
adapter = FilterSubscriptionsAdapter(context!!)
adapter = FilterSubscriptionsAdapter(requireContext())
listView.adapter = adapter
listView.choiceMode = ListView.CHOICE_MODE_MULTIPLE_MODAL
listView.setMultiChoiceModeListener(this)
@ -137,7 +137,7 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
R.id.refresh -> {
executeAfterFragmentResumed { fragment ->
ProgressDialogFragment.show(fragment.childFragmentManager, FRAGMENT_TAG_RREFRESH_FILTERS)
val task = RefreshFiltersSubscriptionsTask(fragment.context!!)
val task = RefreshFiltersSubscriptionsTask(fragment.requireContext())
val fragmentRef = WeakReference(fragment)
task.callback = {
fragmentRef.get()?.executeAfterFragmentResumed { fragment ->
@ -157,7 +157,7 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor> {
val loader = CursorLoader(context!!)
val loader = CursorLoader(requireContext())
loader.uri = Filters.Subscriptions.CONTENT_URI
loader.projection = Filters.Subscriptions.COLUMNS
return loader
@ -233,7 +233,7 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
cursor.moveToFirst()
while (!cursor.isAfterLast) {
val subscription = indices.newObject(cursor)
subscription.instantiateComponent(context!!)?.deleteLocalData()
subscription.instantiateComponent(requireContext())?.deleteLocalData()
cursor.moveToNext()
}
}
@ -284,7 +284,7 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
class AddUrlSubscriptionDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_add_filters_subscription)
builder.setPositiveButton(R.string.action_add_filters_subscription) { dialog, _ ->
dialog as AlertDialog
@ -293,10 +293,10 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
val subscription = FiltersSubscription()
subscription.name = editName.text.toString()
subscription.setupUrl(editUrl.text.toString())
val component = subscription.instantiateComponent(context!!) ?: return@setPositiveButton
val component = subscription.instantiateComponent(requireContext()) ?: return@setPositiveButton
component.firstAdded()
val vc = ObjectCursor.valuesCreatorFrom(FiltersSubscription::class.java)
context!!.contentResolver.insert(Filters.Subscriptions.CONTENT_URI, vc.create(subscription))
requireContext().contentResolver.insert(Filters.Subscriptions.CONTENT_URI, vc.create(subscription))
}
builder.setNegativeButton(android.R.string.cancel, null)
val dialog = builder.create()

View File

@ -206,7 +206,7 @@ class ExoPlayerPageFragment : MediaViewerFragment(), IBaseFragment<ExoPlayerPage
playerView.setOnSystemUiVisibilityChangeListener {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return@setOnSystemUiVisibilityChangeListener
val visible = MediaViewerActivity.FLAG_SYSTEM_UI_HIDE_BARS !in
activity!!.window.decorView.systemUiVisibility
requireActivity().window.decorView.systemUiVisibility
if (visible) {
playerView.showController()
} else {
@ -327,8 +327,8 @@ class ExoPlayerPageFragment : MediaViewerFragment(), IBaseFragment<ExoPlayerPage
if (playerView.player != null) return
playerView.player = run {
val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory()
val trackSelector = DefaultTrackSelector(context!!, videoTrackSelectionFactory)
val player = SimpleExoPlayer.Builder(context!!)
val trackSelector = DefaultTrackSelector(requireContext(), videoTrackSelectionFactory)
val player = SimpleExoPlayer.Builder(requireContext())
.setTrackSelector(trackSelector)
.build()
if (positionBackup >= 0) {

View File

@ -50,7 +50,7 @@ class ImagePageFragment : SubsampleImageViewerFragment() {
get() = arguments?.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
private val sizedResultCreator: CacheDownloadLoader.ResultCreator by lazy {
return@lazy SizedResultCreator(context!!)
return@lazy SizedResultCreator(requireContext())
}
private var mediaLoadState: Int = 0

View File

@ -85,7 +85,7 @@ class VideoPageFragment : CacheDownloadMediaViewerFragment(), IBaseFragment<Vide
var handler: Handler? = videoViewProgress.handler
if (handler == null) {
handler = Handler(activity!!.mainLooper)
handler = Handler(requireActivity().mainLooper)
}
@ -371,7 +371,7 @@ class VideoPageFragment : CacheDownloadMediaViewerFragment(), IBaseFragment<Vide
override fun getHeight(): Int {
var height = media?.height ?: 0
if (height <= 0) {
height = fragment.view!!.measuredHeight
height = fragment.requireView().measuredHeight
}
if (height <= 0) {
height = 100
@ -382,7 +382,7 @@ class VideoPageFragment : CacheDownloadMediaViewerFragment(), IBaseFragment<Vide
override fun getWidth(): Int {
var width = media?.width ?: 0
if (width <= 0) {
width = fragment.view!!.measuredWidth
width = fragment.requireView().measuredWidth
}
if (width <= 0) {
width = 100

View File

@ -250,7 +250,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<ParcelableMessageConversation?> {
return ConversationInfoLoader(context!!, accountKey, conversationId)
return ConversationInfoLoader(requireContext(), accountKey, conversationId)
}
override fun onLoaderReset(loader: Loader<ParcelableMessageConversation?>) {
@ -299,7 +299,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
private fun performDestroyConversation() {
ProgressDialogFragment.show(childFragmentManager, "leave_conversation_progress")
val weakThis = WeakReference(this)
val task = DestroyConversationTask(context!!, accountKey, conversationId)
val task = DestroyConversationTask(requireContext(), accountKey, conversationId)
task.callback = callback@ { succeed ->
val f = weakThis.get() ?: return@callback
f.dismissDialogThen("leave_conversation_progress") {
@ -315,7 +315,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
private fun performClearMessages() {
ProgressDialogFragment.show(childFragmentManager, "clear_messages_progress")
val weakThis = WeakReference(this)
val task = ClearMessagesTask(context!!, accountKey, conversationId)
val task = ClearMessagesTask(requireContext(), accountKey, conversationId)
task.callback = callback@ { succeed ->
val f = weakThis.get() ?: return@callback
f.dismissDialogThen("clear_messages_progress") {
@ -330,7 +330,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
private fun performAddParticipant(user: ParcelableUser) {
ProgressDialogFragment.show(childFragmentManager, "add_participant_progress")
val weakThis = WeakReference(this)
val task = AddParticipantsTask(context!!, accountKey, conversationId, listOf(user))
val task = AddParticipantsTask(requireContext(), accountKey, conversationId, listOf(user))
task.callback = callback@ { succeed ->
val f = weakThis.get() ?: return@callback
f.dismissDialogThen("add_participant_progress") {
@ -343,7 +343,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
private fun performSetNotificationDisabled(disabled: Boolean) {
ProgressDialogFragment.show(childFragmentManager, "set_notifications_disabled_progress")
val weakThis = WeakReference(this)
val task = SetConversationNotificationDisabledTask(context!!, accountKey, conversationId, disabled)
val task = SetConversationNotificationDisabledTask(requireContext(), accountKey, conversationId, disabled)
task.callback = callback@ { _ ->
val f = weakThis.get() ?: return@callback
f.dismissDialogThen("set_notifications_disabled_progress") {
@ -457,7 +457,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
val fragment = weakThis.get() ?: throw InterruptedException()
val account = AccountUtils.getAccountDetails(AccountManager.get(fragment.context),
accountKey, true) ?: throw MicroBlogException("No account")
val microBlog = account.newMicroBlogInstance(fragment.context!!, cls = MicroBlog::class.java)
val microBlog = account.newMicroBlogInstance(fragment.requireContext(), cls = MicroBlog::class.java)
return@task updateAction(fragment, account, microBlog)
}.then { result ->
val fragment = weakThis.get() ?: throw InterruptedException()
@ -736,7 +736,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val actions = arrayOf(Action(getString(R.string.action_edit_conversation_name), "name"),
Action(getString(R.string.action_edit_conversation_avatar), "avatar"))
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setItems(actions.mapToArray(Action::title)) { _, which ->
val action = actions[which]
(parentFragment as MessageConversationInfoFragment).openEditAction(action.type)
@ -752,7 +752,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
class EditNameDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setView(R.layout.dialog_edit_conversation_name)
builder.setNegativeButton(android.R.string.cancel, null)
builder.setPositiveButton(android.R.string.ok) { dialog, _ ->
@ -768,7 +768,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
class DestroyConversationConfirmDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setMessage(R.string.message_destroy_conversation_confirm)
builder.setPositiveButton(R.string.action_leave_conversation) { _, _ ->
(parentFragment as MessageConversationInfoFragment).performDestroyConversation()
@ -783,7 +783,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
class ClearMessagesConfirmDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setMessage(R.string.message_clear_messages_confirm)
builder.setPositiveButton(R.string.action_clear_messages) { _, _ ->
(parentFragment as MessageConversationInfoFragment).performClearMessages()

View File

@ -207,7 +207,7 @@ class MessageNewConversationFragment : BaseFragment(), LoaderCallbacks<List<Parc
val query = args!!.getString(EXTRA_QUERY)!!
val fromCache = args.getBoolean(EXTRA_FROM_CACHE)
val fromUser = args.getBoolean(EXTRA_FROM_USER)
return CacheUserSearchLoader(context!!, accountKey, query, !fromCache, true, fromUser)
return CacheUserSearchLoader(requireContext(), accountKey, query, !fromCache, true, fromUser)
}
override fun onLoaderReset(loader: Loader<List<ParcelableUser>?>) {

View File

@ -278,7 +278,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment<Messages
}
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableMessage>?> {
return ConversationLoader(context!!, accountKey, conversationId)
return ConversationLoader(requireContext(), accountKey, conversationId)
}
override fun onLoadFinished(loader: Loader<List<ParcelableMessage>?>, data: List<ParcelableMessage>?) {
@ -558,7 +558,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment<Messages
types: IntArray?,
copySrc: Boolean,
deleteSrc: Boolean
) : AbsAddMediaTask<((List<ParcelableMediaUpdate>?) -> Unit)?>(fragment.context!!, sources, types, copySrc, deleteSrc) {
) : AbsAddMediaTask<((List<ParcelableMediaUpdate>?) -> Unit)?>(fragment.requireContext(), sources, types, copySrc, deleteSrc) {
private val fragmentRef = WeakReference(fragment)
@ -581,7 +581,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment<Messages
internal class DeleteMediaTask(
fragment: MessagesConversationFragment,
val media: Array<ParcelableMediaUpdate>
) : AbsDeleteMediaTask<MessagesConversationFragment>(fragment.context!!,
) : AbsDeleteMediaTask<MessagesConversationFragment>(fragment.requireContext(),
media.mapToArray { Uri.parse(it.uri) }) {
init {

View File

@ -74,7 +74,7 @@ class MessagesEntriesFragment : AbsContentListRecyclerViewFragment<MessagesEntri
IFloatingActionButtonFragment {
private val accountKeys: Array<UserKey> by lazy {
Utils.getAccountKeys(context!!, arguments) ?: DataStoreUtils.getActivatedAccountKeys(context!!)
Utils.getAccountKeys(requireContext(), arguments) ?: DataStoreUtils.getActivatedAccountKeys(requireContext())
}
private val errorInfoKey: String = ErrorInfoStore.KEY_DIRECT_MESSAGES
@ -157,7 +157,7 @@ class MessagesEntriesFragment : AbsContentListRecyclerViewFragment<MessagesEntri
override fun triggerRefresh(): Boolean {
super.triggerRefresh()
twitterWrapper.getMessagesAsync(object : GetMessagesTask.RefreshNewTaskParam(context!!) {
twitterWrapper.getMessagesAsync(object : GetMessagesTask.RefreshNewTaskParam(requireContext()) {
override val accountKeys: Array<UserKey> = this@MessagesEntriesFragment.accountKeys
})
return true

View File

@ -35,6 +35,6 @@ class MastodonSearchFragment : ItemsListFragment() {
get() = arguments?.getString(EXTRA_QUERY)!!
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<Any>?> {
return MastodonSearchLoader(context!!, accountKey, query)
return MastodonSearchLoader(requireContext(), accountKey, query)
}
}

View File

@ -46,7 +46,7 @@ abstract class AbsSimpleStatusOperationDialogFragment : BaseDialogFragment(), Di
}
final override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(title)
builder.setMessage(message)
builder.setPositiveButton(android.R.string.ok, this)

View File

@ -68,12 +68,12 @@ abstract class AbsStatusDialogFragment : BaseDialogFragment() {
private lateinit var adapter: DummyItemAdapter
final override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = Builder(context!!)
val builder = Builder(requireContext())
val accountKey = this.accountKey
builder.setupAlertDialog()
adapter = DummyItemAdapter(context!!, requestManager = requestManager)
adapter = DummyItemAdapter(requireContext(), requestManager = requestManager)
adapter.showCardActions = false
adapter.showCardNumbers = false
adapter.showAccountsColor = true

View File

@ -42,7 +42,7 @@ class BlockStatusUsersDialogFragment : BaseDialogFragment() {
private val status: ParcelableStatus get() = arguments?.getParcelable(EXTRA_STATUS)!!
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
val referencedUsers = status.referencedUsers
val nameFirst = preferences[nameFirstKey]
val displayNames = referencedUsers.map {
@ -50,7 +50,7 @@ class BlockStatusUsersDialogFragment : BaseDialogFragment() {
}.toTypedArray()
builder.setTitle(R.string.action_status_block_users)
builder.setItems(displayNames) { _, which ->
CreateUserBlockDialogFragment.show(fragmentManager!!, referencedUsers[which])
CreateUserBlockDialogFragment.show(requireFragmentManager(), referencedUsers[which])
}
val dialog = builder.create()
dialog.applyOnShow { applyTheme() }

View File

@ -42,7 +42,7 @@ class MuteStatusUsersDialogFragment : BaseDialogFragment() {
private val status: ParcelableStatus get() = arguments?.getParcelable(EXTRA_STATUS)!!
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
val referencedUsers = status.referencedUsers
val nameFirst = preferences[nameFirstKey]
val displayNames = referencedUsers.map {
@ -50,7 +50,7 @@ class MuteStatusUsersDialogFragment : BaseDialogFragment() {
}.toTypedArray()
builder.setTitle(R.string.action_status_mute_users)
builder.setItems(displayNames) { _, which ->
CreateUserMuteDialogFragment.show(fragmentManager!!, referencedUsers[which])
CreateUserMuteDialogFragment.show(requireFragmentManager(), referencedUsers[which])
}
val dialog = builder.create()
dialog.onShow { it.applyTheme() }

View File

@ -35,7 +35,7 @@ class PinStatusDialogFragment : AbsSimpleStatusOperationDialogFragment() {
get() = getString(R.string.message_pin_status_confirm)
override fun onPerformAction(status: ParcelableStatus) {
val task = PinStatusTask(context!!, status.account_key, status.id)
val task = PinStatusTask(requireContext(), status.account_key, status.id)
TaskStarter.execute(task)
}

View File

@ -316,7 +316,7 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = activity
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setMessage(R.string.quote_protected_status_warning_message)
builder.setPositiveButton(R.string.send_anyway, this)
builder.setNegativeButton(android.R.string.cancel, null)

View File

@ -372,7 +372,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
val fragmentArgs = arguments
val accountKey = fragmentArgs!!.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
val statusId = fragmentArgs.getString(EXTRA_STATUS_ID)
return ParcelableStatusLoader(activity!!, false, fragmentArgs, accountKey, statusId)
return ParcelableStatusLoader(requireActivity(), false, fragmentArgs, accountKey, statusId)
}
@ -640,7 +640,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
val weakThis = WeakReference(this)
(showProgressDialog("get_language_settings") and task {
val fragment = weakThis.get() ?: throw InterruptedException()
val microBlog = account.newMicroBlogInstance(fragment.context!!, MicroBlog::class.java)
val microBlog = account.newMicroBlogInstance(fragment.requireContext(), MicroBlog::class.java)
return@task Pair(microBlog.accountSettings.language,
microBlog.languages.map { TranslationDestinationDialogFragment.DisplayLanguage(it.name, it.code) })
}).successUi { (_, settings) ->
@ -648,7 +648,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
val fragment = weakThis.get() ?: return@successUi
val df = TranslationDestinationDialogFragment.create(languages, accountLanguage)
df.setTargetFragment(fragment, 0)
df.show(fragment.fragmentManager!!, "translation_destination_settings")
df.show(fragment.requireFragmentManager(), "translation_destination_settings")
}.alwaysUi {
val fragment = weakThis.get() ?: return@alwaysUi
fragment.dismissProgressDialog("get_language_settings")
@ -672,7 +672,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = activity
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(android.R.string.dialog_alert_title)
builder.setMessage(R.string.sensitive_content_warning)
builder.setPositiveButton(android.R.string.ok, this)
@ -684,7 +684,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
}
internal class LoadTranslationTask(fragment: StatusFragment, val status: ParcelableStatus) :
AbsAccountRequestTask<Any?, TranslationResult, Any?>(fragment.context!!, status.account_key) {
AbsAccountRequestTask<Any?, TranslationResult, Any?>(fragment.requireContext(), status.account_key) {
private val weakFragment = WeakReference(fragment)

View File

@ -45,7 +45,7 @@ class TranslationDestinationDialogFragment : BaseDialogFragment() {
private val currentIndex = AtomicInteger(-1)
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
val languages = arguments?.getTypedArray<DisplayLanguage>(EXTRA_LANGUAGES)?.sortedArrayWith(LanguageComparator()) ?: emptyArray()
val selectedLanguage = preferences[translationDestinationKey] ?: arguments?.getString(EXTRA_SELECTED_LANGUAGE)
val selectedIndex = languages.indexOfFirst { selectedLanguage == it.code }

View File

@ -35,7 +35,7 @@ class UnpinStatusDialogFragment : AbsSimpleStatusOperationDialogFragment() {
get() = getString(R.string.message_unpin_status_confirm)
override fun onPerformAction(status: ParcelableStatus) {
val task = UnpinStatusTask(context!!, status.account_key, status.id)
val task = UnpinStatusTask(requireContext(), status.account_key, status.id)
TaskStarter.execute(task)
}

View File

@ -115,7 +115,7 @@ class GroupTimelineFragment : ParcelableStatusesFragment() {
val groupName = args.getString(EXTRA_GROUP_NAME)
val tabPosition = args.getInt(EXTRA_TAB_POSITION, -1)
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
return GroupTimelineLoader(activity!!, accountKey, groupId, groupName, adapterData,
return GroupTimelineLoader(requireActivity(), accountKey, groupId, groupName, adapterData,
savedStatusesFileArgs, tabPosition, fromUser, loadingMore)
}

View File

@ -41,7 +41,7 @@ class MediaStatusesSearchFragment : AbsMediaStatusesFragment() {
val tabPosition = args.getInt(EXTRA_TAB_POSITION, -1)
val makeGap = args.getBoolean(EXTRA_MAKE_GAP, true)
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
return MediaStatusesSearchLoader(activity!!, accountKey, query, adapter.getData(), null, tabPosition,
return MediaStatusesSearchLoader(requireActivity(), accountKey, query, adapter.getData(), null, tabPosition,
fromUser, makeGap, loadingMore)
}

View File

@ -75,12 +75,12 @@ open class StatusesSearchFragment : ParcelableStatusesFragment() {
Loader<List<ParcelableStatus>?> {
refreshing = true
val accountKey = Utils.getAccountKey(context, args)
val query = arguments!!.getString(EXTRA_QUERY)
val local = arguments!!.getBoolean(EXTRA_LOCAL, false)
val tabPosition = arguments!!.getInt(EXTRA_TAB_POSITION, -1)
val query = requireArguments().getString(EXTRA_QUERY)
val local = requireArguments().getBoolean(EXTRA_LOCAL, false)
val tabPosition = requireArguments().getInt(EXTRA_TAB_POSITION, -1)
val makeGap = args.getBoolean(EXTRA_MAKE_GAP, true)
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
return TweetSearchLoader(activity!!, accountKey, query, adapterData, savedStatusesFileArgs,
return TweetSearchLoader(requireActivity(), accountKey, query, adapterData, savedStatusesFileArgs,
tabPosition, fromUser, makeGap, local, loadingMore)
}

View File

@ -90,7 +90,7 @@ class UserFavoritesFragment : ParcelableStatusesFragment() {
override fun notifyFavoriteTask(event: FavoriteTaskEvent) {
if (event.action == FavoriteTaskEvent.Action.DESTROY && event.isSucceeded) {
event.status?.let { status ->
val args = arguments!!
val args = requireArguments()
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
if (status.account_key == userKey) {
removeStatus(event.statusId)

View File

@ -103,7 +103,7 @@ class UserListTimelineFragment : ParcelableStatusesFragment() {
val screenName = args.getString(EXTRA_SCREEN_NAME)
val tabPosition = args.getInt(EXTRA_TAB_POSITION, -1)
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
return UserListTimelineLoader(activity!!, accountKey, listId, userKey, screenName, listName,
return UserListTimelineLoader(requireActivity(), accountKey, listId, userKey, screenName, listName,
adapterData, savedStatusesFileArgs, tabPosition, fromUser, loadingMore, extras)
}

View File

@ -52,7 +52,7 @@ class UserMentionsFragment : StatusesSearchFragment() {
val tabPosition = args.getInt(EXTRA_TAB_POSITION, -1)
val makeGap = args.getBoolean(EXTRA_MAKE_GAP, true)
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
return UserMentionsLoader(activity!!, accountKey, screenName, adapterData,
return UserMentionsLoader(requireActivity(), accountKey, screenName, adapterData,
savedStatusesFileArgs, tabPosition, fromUser, makeGap, false, loadingMore)
}

View File

@ -149,7 +149,7 @@ class UserTimelineFragment : ParcelableStatusesFragment() {
class UserTimelineFilterDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
val values = resources.getStringArray(R.array.values_user_timeline_filter)
val checkedItems = BooleanArray(values.size) {
val filter = preferences[userTimelineFilterKey]

View File

@ -94,9 +94,9 @@ class SyncSettingsFragment : BasePreferenceFragment() {
class DisconnectSyncConfirmDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
val providerInfo = kPreferences[dataSyncProviderInfoKey]!!
val entry = DataSyncProvider.Factory.getProviderEntry(context!!, providerInfo.type)!!
val entry = DataSyncProvider.Factory.getProviderEntry(requireContext(), providerInfo.type)!!
builder.setMessage(getString(R.string.message_sync_disconnect_from_name_confirm, entry.name))
builder.setPositiveButton(R.string.action_sync_disconnect) { _, _ ->
(parentFragment as SyncSettingsFragment).cleanupAndDisconnect()

View File

@ -97,7 +97,7 @@ class ColorPickerPreference(context: Context, attrs: AttributeSet? = null) :
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val preference = preference as ColorPickerPreference
val context = context
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(preference.dialogTitle)
builder.setView(R.layout.cp__dialog_color_picker)
builder.setPositiveButton(android.R.string.ok, this)

View File

@ -91,15 +91,15 @@ class SyncStatusViewController : PremiumDashboardActivity.ExtraFeatureViewContro
class ConnectNetworkStorageSelectionDialogFragment : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val providers = DataSyncProvider.Factory.getSupportedProviders(context!!)
val providers = DataSyncProvider.Factory.getSupportedProviders(requireContext())
val itemNames = providers.mapToArray(SyncProviderEntry::name)
val builder = AlertDialog.Builder(context!!)
val builder = AlertDialog.Builder(requireContext())
builder.setTitle(R.string.title_dialog_sync_connect_to)
builder.setItems(itemNames) { _, which ->
val activity = activity as PremiumDashboardActivity
activity.startActivityForControllerResult(providers[which].authIntent,
arguments!!.getInt(EXTRA_POSITION), REQUEST_CONNECT_NETWORK_STORAGE)
requireArguments().getInt(EXTRA_POSITION), REQUEST_CONNECT_NETWORK_STORAGE)
}
val dialog = builder.create()
dialog.onShow { it.applyTheme() }