diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt index 258354b19..a57fde2cf 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt index eca60ca7f..08ea82c6c 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt @@ -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) { _, _ -> diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/InvalidAccountAlertActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/InvalidAccountAlertActivity.kt index 51d90f0b3..b3c48ee0d 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/InvalidAccountAlertActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/InvalidAccountAlertActivity.kt @@ -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) { _, _ -> diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SettingsActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SettingsActivity.kt index 7216b56a1..c0b2863fa 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SettingsActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SettingsActivity.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt index 09f6c1e54..de95a88c3 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt @@ -573,13 +573,13 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, class SignInTypeChooserDialogFragment : BaseDialogFragment(), LoaderManager.LoaderCallbacks> { 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> { - return DefaultAPIConfigLoader(context!!) + return DefaultAPIConfigLoader(requireContext()) } override fun onLoaderReset(loader: Loader>) { @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/TrendsLocationSelectorActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/TrendsLocationSelectorActivity.kt index 976364e32..0b904299e 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/TrendsLocationSelectorActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/TrendsLocationSelectorActivity.kt @@ -93,7 +93,7 @@ class TrendsLocationSelectorActivity : BaseActivity() { private val list: Array 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, _ -> diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/StatusDetailsAdapter.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/StatusDetailsAdapter.kt index 693423eac..4961d3906 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/StatusDetailsAdapter.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/StatusDetailsAdapter.kt @@ -51,7 +51,7 @@ import org.mariotaku.twidere.view.holder.status.DetailStatusViewHolder class StatusDetailsAdapter( val fragment: StatusFragment -) : LoadMoreSupportAdapter(fragment.context!!, fragment.requestManager), +) : LoadMoreSupportAdapter(fragment.requireContext(), fragment.requestManager), IStatusesAdapter>, IItemCountsAdapter { override val twidereLinkify: TwidereLinkify diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/APIEditorDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/APIEditorDialogFragment.kt index 2a9132c74..ae6d81f37 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/APIEditorDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/APIEditorDialogFragment.kt @@ -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 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> { - return DefaultAPIConfigLoader(context!!) + return DefaultAPIConfigLoader(requireContext()) } override fun onLoadFinished(loader: Loader>, data: List) { @@ -189,7 +189,7 @@ class APIEditorDialogFragment : BaseDialogFragment() { private class AccountTypeSpinnerAdapter( fragment: APIEditorDialogFragment - ) : BaseArrayAdapter(fragment.context!!, R.layout.support_simple_spinner_dropdown_item, + ) : BaseArrayAdapter(fragment.requireContext(), R.layout.support_simple_spinner_dropdown_item, requestManager = fragment.requestManager) { init { add(AccountType.TWITTER) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsActivitiesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsActivitiesFragment.kt index ac0ef2730..cd5d4bc6d 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsActivitiesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsActivitiesFragment.kt @@ -185,7 +185,7 @@ abstract class AbsActivitiesFragment protected constructor() : override fun onCreateLoader(id: Int, args: Bundle?): Loader> { 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() { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsContentListViewFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsContentListViewFragment.kt index 96e9d0cba..bcca505a2 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsContentListViewFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsContentListViewFragment.kt @@ -129,12 +129,12 @@ abstract class AbsContentListViewFragment : 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() diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsContentRecyclerViewFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsContentRecyclerViewFragment.kt index 2da1262b4..a2d466535 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsContentRecyclerViewFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsContentRecyclerViewFragment.kt @@ -182,13 +182,13 @@ abstract class AbsContentRecyclerViewFragment?> { 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?>, data: List?) { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsStatusesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsStatusesFragment.kt index c05c0a967..55cc8e1e4 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsStatusesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsStatusesFragment.kt @@ -239,7 +239,7 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment?> { 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 return MenuUtils.handleStatusClick(activity!!, this, fragmentManager!!, + else -> return MenuUtils.handleStatusClick(requireActivity(), this, requireFragmentManager(), preferences, userColorNameManager, twitterWrapper, status, item) } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt index a8d981b07..2baa1577b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt @@ -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 } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsUserMuteBlockDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsUserMuteBlockDialogFragment.kt index ad7a2550e..313347bc0 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsUserMuteBlockDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsUserMuteBlockDialogFragment.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt index 5d97ab4ed..db5848565 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt @@ -259,7 +259,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks, } override fun onCreateLoader(id: Int, args: Bundle?): Loader { - return AccountsInfoLoader(activity!!, accountsAdapter.accounts == null) + return AccountsInfoLoader(requireActivity(), accountsAdapter.accounts == null) } @@ -538,10 +538,10 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks, } 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, } 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 diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt index ab35857b5..052d6953c 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt @@ -60,7 +60,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks
  • @@ -158,7 +158,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks
  • > { - return AccountDetailsLoader(context!!) + return AccountDetailsLoader(requireContext()) } override fun onLoaderReset(loader: Loader>) { @@ -227,7 +227,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks
  • ? = null override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - val builder = AlertDialog.Builder(context!!) + val builder = AlertDialog.Builder(requireContext()) filterItems = filterItemsInfo val entries = arrayOfNulls(filterItems!!.size) val nameFirst = preferences[nameFirstKey] diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseDialogFragment.kt index 14a33c6e9..6e6b72863 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseDialogFragment.kt @@ -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() { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseFragment.kt index dd2930912..06953601e 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseFragment.kt @@ -102,7 +102,7 @@ open class BaseFragment : Fragment(), IBaseFragment { 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() { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseWebViewFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseWebViewFragment.kt index ec93e57b0..14ad0d0ad 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseWebViewFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/BaseWebViewFragment.kt @@ -48,7 +48,7 @@ open class BaseWebViewFragment : BaseFragment() { protected fun createWebViewClient(): WebViewClient { - return DefaultWebViewClient(activity!!) + return DefaultWebViewClient(requireActivity()) } /** diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ColorPickerDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ColorPickerDialogFragment.kt index 7783736d5..aa62fa2e8 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ColorPickerDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ColorPickerDialogFragment.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CreateUserListDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CreateUserListDialogFragment.kt index ace3fe233..7086fbaa5 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CreateUserListDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CreateUserListDialogFragment.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CursorActivitiesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CursorActivitiesFragment.kt index cff0549e7..c824d0d08 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CursorActivitiesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CursorActivitiesFragment.kt @@ -59,7 +59,7 @@ import org.mariotaku.twidere.util.Utils abstract class CursorActivitiesFragment : AbsActivitiesFragment() { override val accountKeys: Array - get() = Utils.getAccountKeys(context!!, arguments) ?: DataStoreUtils.getActivatedAccountKeys(context!!) + get() = Utils.getAccountKeys(requireContext(), arguments) ?: DataStoreUtils.getActivatedAccountKeys(requireContext()) abstract val contentUri: Uri diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CursorStatusesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CursorStatusesFragment.kt index 52311562e..0fae563f0 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CursorStatusesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CursorStatusesFragment.kt @@ -70,7 +70,7 @@ abstract class CursorStatusesFragment : AbsStatusesFragment() { get() = false override val accountKeys: Array - get() = Utils.getAccountKeys(context!!, arguments) ?: DataStoreUtils.getActivatedAccountKeys(context!!) + get() = Utils.getAccountKeys(requireContext(), arguments) ?: DataStoreUtils.getActivatedAccountKeys(requireContext()) abstract val errorInfoKey: String abstract val isFilterEnabled: Boolean diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CustomTabsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CustomTabsFragment.kt index 1bc4678fb..097c55387 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CustomTabsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/CustomTabsFragment.kt @@ -93,7 +93,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks, 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, MultiChoice } override fun onCreateLoader(id: Int, args: Bundle?): Loader { - 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, 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, 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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DateTimePickerDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DateTimePickerDialogFragment.kt index 279a8e056..18db4ef16 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DateTimePickerDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DateTimePickerDialogFragment.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DeleteUserListMembersDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DeleteUserListMembersDialogFragment.kt index afc2b1666..273c1c2e0 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DeleteUserListMembersDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DeleteUserListMembersDialogFragment.kt @@ -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() diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyFriendshipDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyFriendshipDialogFragment.kt index 4157cb1fe..ebb6e17cc 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyFriendshipDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyFriendshipDialogFragment.kt @@ -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)) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroySavedSearchDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroySavedSearchDialogFragment.kt index d5f9fa4d7..895e4e50b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroySavedSearchDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroySavedSearchDialogFragment.kt @@ -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)) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyUserListDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyUserListDialogFragment.kt index 1409d68f1..73c08ca6e 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyUserListDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyUserListDialogFragment.kt @@ -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)) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyUserListSubscriptionDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyUserListSubscriptionDialogFragment.kt index a0c51fcf9..182e062d1 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyUserListSubscriptionDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/DestroyUserListSubscriptionDialogFragment.kt @@ -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)) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/EditAltTextDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/EditAltTextDialogFragment.kt index f80d76ecb..c05ede01a 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/EditAltTextDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/EditAltTextDialogFragment.kt @@ -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 } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/EditUserListDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/EditUserListDialogFragment.kt index ca89f7605..75226fdbc 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/EditUserListDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/EditUserListDialogFragment.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExtensionsListFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExtensionsListFragment.kt index df3ec1f1c..28b50c5d7 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExtensionsListFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExtensionsListFragment.kt @@ -57,11 +57,11 @@ class ExtensionsListFragment : AbsContentListViewFragment(), } override fun onCreateAdapter(context: Context, requestManager: RequestManager): ExtensionsAdapter { - return ExtensionsAdapter(activity!!, requestManager) + return ExtensionsAdapter(requireActivity(), requestManager) } override fun onCreateLoader(id: Int, args: Bundle?): Loader> { - return ExtensionsListLoader(activity!!) + return ExtensionsListLoader(requireActivity()) } override fun onLoadFinished(loader: Loader>, data: List) { @@ -128,7 +128,7 @@ class ExtensionsListFragment : AbsContentListViewFragment(), 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 diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExtraFeaturesIntroductionDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExtraFeaturesIntroductionDialogFragment.kt index ae8508b55..e540e3651 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExtraFeaturesIntroductionDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ExtraFeaturesIntroductionDialogFragment.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/GroupFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/GroupFragment.kt index 91bf87764..492d90c8d 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/GroupFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/GroupFragment.kt @@ -53,7 +53,7 @@ class GroupFragment : AbsToolbarTabPagesFragment(), LoaderCallbacks?> { - return ItemsLoader(context!!, arguments!!) + return ItemsLoader(requireContext(), requireArguments()) } final override fun onLoadFinished(loader: Loader?>, data: List?) { @@ -176,7 +176,7 @@ open class ItemsListFragment : AbsContentListRecyclerViewFragment?> { 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?>) { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ParcelableUserListsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ParcelableUserListsFragment.kt index 0feac0981..ba8754e7f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ParcelableUserListsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ParcelableUserListsFragment.kt @@ -137,7 +137,7 @@ abstract class ParcelableUserListsFragment : AbsContentListRecyclerViewFragment< override fun onCreateLoader(id: Int, args: Bundle?): Loader> { 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>) { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ParcelableUsersFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ParcelableUsersFragment.kt index 075a55568..6784a1126 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ParcelableUsersFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ParcelableUsersFragment.kt @@ -124,7 +124,7 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment?> { 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) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/PermissionRequestDialog.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/PermissionRequestDialog.kt index a058065ed..e82845268 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/PermissionRequestDialog.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/PermissionRequestDialog.kt @@ -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) } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/PhishingLinkWarningDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/PhishingLinkWarningDialogFragment.kt index 464d94dda..e7c8bab2f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/PhishingLinkWarningDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/PhishingLinkWarningDialogFragment.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SavedSearchesListFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SavedSearchesListFragment.kt index b483dca28..76549415b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SavedSearchesListFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SavedSearchesListFragment.kt @@ -75,7 +75,7 @@ class SavedSearchesListFragment : AbsContentListViewFragment?> { - return SavedSearchesLoader(activity!!, accountKey) + return SavedSearchesLoader(requireActivity(), accountKey) } override fun onItemLongClick(view: AdapterView<*>, child: View, position: Int, id: Long): Boolean { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SensitiveContentWarningDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SensitiveContentWarningDialogFragment.kt index a0907a50a..f5c7178be 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SensitiveContentWarningDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SensitiveContentWarningDialogFragment.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SetUserNicknameDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SetUserNicknameDialogFragment.kt index 4f8eb43e6..4376dfb5b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SetUserNicknameDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/SetUserNicknameDialogFragment.kt @@ -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()) { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ThemedPreferenceDialogFragmentCompat.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ThemedPreferenceDialogFragmentCompat.kt index 1329328aa..f9e6babba 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ThemedPreferenceDialogFragmentCompat.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/ThemedPreferenceDialogFragmentCompat.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/TrendsSuggestionsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/TrendsSuggestionsFragment.kt index 87ce0ae8b..31a22e5b8 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/TrendsSuggestionsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/TrendsSuggestionsFragment.kt @@ -73,7 +73,7 @@ class TrendsSuggestionsFragment : AbsContentListViewFragment(), L } override fun onCreateAdapter(context: Context, requestManager: RequestManager): TrendsAdapter { - return TrendsAdapter(activity!!) + return TrendsAdapter(requireActivity()) } override fun onCreateLoader(id: Int, args: Bundle?): Loader { @@ -81,7 +81,7 @@ class TrendsSuggestionsFragment : AbsContentListViewFragment(), 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) { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt index 9b759e679..a4c016260 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserFragment.kt @@ -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() 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(EXTRA_USER_LISTS) - val userKey = arguments!!.getParcelable(EXTRA_USER_KEY)!! - val accountKey = arguments!!.getParcelable(EXTRA_ACCOUNT_KEY)!! - val builder = AlertDialog.Builder(context!!) + val lists = requireArguments().getTypedArray(EXTRA_USER_LISTS) + val userKey = requireArguments().getParcelable(EXTRA_USER_KEY)!! + val accountKey = requireArguments().getParcelable(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 diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListFragment.kt index 77b1561c9..7b865a83f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListFragment.kt @@ -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(EXTRA_USER_LIST)!! - val builder = AlertDialog.Builder(context!!) + val userList = requireArguments().getParcelable(EXTRA_USER_LIST)!! + val builder = AlertDialog.Builder(requireContext()) builder.setTitle(userList.name) builder.setMessage(userList.description) builder.setPositiveButton(android.R.string.ok, null) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListMembershipsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListMembershipsFragment.kt index f59cfcd9e..c59648800 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListMembershipsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListMembershipsFragment.kt @@ -34,7 +34,7 @@ class UserListMembershipsFragment : ParcelableUserListsFragment() { val accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY) val userKey = args.getParcelable(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) } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListSubscriptionsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListSubscriptionsFragment.kt index ad3246989..9a1ef7dee 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListSubscriptionsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListSubscriptionsFragment.kt @@ -33,7 +33,7 @@ class UserListSubscriptionsFragment : ParcelableUserListsFragment() { val accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY) val userKey = args.getParcelable(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) } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListsOwnershipsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListsOwnershipsFragment.kt index bdad370c1..5e3e7c25a 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListsOwnershipsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserListsOwnershipsFragment.kt @@ -47,7 +47,7 @@ class UserListsOwnershipsFragment : ParcelableUserListsFragment() { val accountKey = args.getParcelable(EXTRA_ACCOUNT_KEY) val userKey = args.getParcelable(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)) } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserProfileEditorFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserProfileEditorFragment.kt index 988e61675..4d6e20150 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserProfileEditorFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserProfileEditorFragment.kt @@ -132,7 +132,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener, override fun onCreateLoader(id: Int, args: Bundle?): Loader> { 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>, @@ -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, - 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(fragment.context!!, accountKey, imageUri, deleteImage) { + ) : UpdateProfileBannerImageTask(fragment.requireContext(), accountKey, imageUri, deleteImage) { init { callback = fragment @@ -513,7 +513,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener, imageUri: Uri, tile: Boolean, deleteImage: Boolean - ) : UpdateProfileBackgroundImageTask(fragment.context!!, accountKey, imageUri, + ) : UpdateProfileBackgroundImageTask(fragment.requireContext(), accountKey, imageUri, tile, deleteImage) { init { @@ -538,7 +538,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener, accountKey: UserKey, imageUri: Uri, deleteImage: Boolean - ) : UpdateProfileImageTask(fragment.context!!, accountKey, imageUri, deleteImage) { + ) : UpdateProfileImageTask(fragment.requireContext(), accountKey, imageUri, deleteImage) { init { callback = fragment diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserQrDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserQrDialogFragment.kt index 5c127cb02..78870607b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserQrDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/UserQrDialogFragment.kt @@ -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() } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/drafts/DraftsListFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/drafts/DraftsListFragment.kt index 1a874a2f0..572d6634c 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/drafts/DraftsListFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/drafts/DraftsListFragment.kt @@ -111,7 +111,7 @@ class DraftsListFragment : AbsContentListViewFragment(), 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(), 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?) { @@ -289,7 +289,7 @@ class DraftsListFragment : AbsContentListViewFragment(), 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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/AddEditItemFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/AddEditItemFragment.kt index 0ce37e5e9..cf5d579a8 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/AddEditItemFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/AddEditItemFragment.kt @@ -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) } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/BaseFiltersFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/BaseFiltersFragment.kt index 1c8b79746..b5ca06376 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/BaseFiltersFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/BaseFiltersFragment.kt @@ -179,7 +179,7 @@ abstract class BaseFiltersFragment : AbsContentListViewFragment { 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, data: Cursor?) { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/BaseFiltersImportFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/BaseFiltersImportFragment.kt index e8fc94cc8..87988005a 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/BaseFiltersImportFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/BaseFiltersImportFragment.kt @@ -130,7 +130,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment?> { 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?>) { @@ -189,7 +189,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment 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 { - 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") } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/FiltersSubscriptionsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/FiltersSubscriptionsFragment.kt index 3f24856d1..fffad9752 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/FiltersSubscriptionsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/FiltersSubscriptionsFragment.kt @@ -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 { - 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() diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExoPlayerPageFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExoPlayerPageFragment.kt index 4ea334cf4..8c544df5f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExoPlayerPageFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExoPlayerPageFragment.kt @@ -206,7 +206,7 @@ class ExoPlayerPageFragment : MediaViewerFragment(), IBaseFragment= 0) { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ImagePageFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ImagePageFragment.kt index 4e9da0c53..8e82518b8 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ImagePageFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ImagePageFragment.kt @@ -50,7 +50,7 @@ class ImagePageFragment : SubsampleImageViewerFragment() { get() = arguments?.getParcelable(EXTRA_ACCOUNT_KEY) private val sizedResultCreator: CacheDownloadLoader.ResultCreator by lazy { - return@lazy SizedResultCreator(context!!) + return@lazy SizedResultCreator(requireContext()) } private var mediaLoadState: Int = 0 diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/VideoPageFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/VideoPageFragment.kt index 8edb7e955..c2073eed0 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/VideoPageFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/VideoPageFragment.kt @@ -85,7 +85,7 @@ class VideoPageFragment : CacheDownloadMediaViewerFragment(), IBaseFragment { - return ConversationInfoLoader(context!!, accountKey, conversationId) + return ConversationInfoLoader(requireContext(), accountKey, conversationId) } override fun onLoaderReset(loader: Loader) { @@ -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() diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageNewConversationFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageNewConversationFragment.kt index 25480b318..bcfe87c1f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageNewConversationFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageNewConversationFragment.kt @@ -207,7 +207,7 @@ class MessageNewConversationFragment : BaseFragment(), LoaderCallbacks?>) { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesConversationFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesConversationFragment.kt index a00710cc2..b39a1d6f3 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesConversationFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesConversationFragment.kt @@ -278,7 +278,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment?> { - return ConversationLoader(context!!, accountKey, conversationId) + return ConversationLoader(requireContext(), accountKey, conversationId) } override fun onLoadFinished(loader: Loader?>, data: List?) { @@ -558,7 +558,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment?) -> Unit)?>(fragment.context!!, sources, types, copySrc, deleteSrc) { + ) : AbsAddMediaTask<((List?) -> Unit)?>(fragment.requireContext(), sources, types, copySrc, deleteSrc) { private val fragmentRef = WeakReference(fragment) @@ -581,7 +581,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment - ) : AbsDeleteMediaTask(fragment.context!!, + ) : AbsDeleteMediaTask(fragment.requireContext(), media.mapToArray { Uri.parse(it.uri) }) { init { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesEntriesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesEntriesFragment.kt index 84ce6f35c..fa171ce09 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesEntriesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesEntriesFragment.kt @@ -74,7 +74,7 @@ class MessagesEntriesFragment : AbsContentListRecyclerViewFragment 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 = this@MessagesEntriesFragment.accountKeys }) return true diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/search/MastodonSearchFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/search/MastodonSearchFragment.kt index 5379df352..da50fc738 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/search/MastodonSearchFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/search/MastodonSearchFragment.kt @@ -35,6 +35,6 @@ class MastodonSearchFragment : ItemsListFragment() { get() = arguments?.getString(EXTRA_QUERY)!! override fun onCreateLoader(id: Int, args: Bundle?): Loader?> { - return MastodonSearchLoader(context!!, accountKey, query) + return MastodonSearchLoader(requireContext(), accountKey, query) } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/AbsSimpleStatusOperationDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/AbsSimpleStatusOperationDialogFragment.kt index 4eee5bed0..84851c11c 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/AbsSimpleStatusOperationDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/AbsSimpleStatusOperationDialogFragment.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/AbsStatusDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/AbsStatusDialogFragment.kt index 4ad04e48c..b42de4699 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/AbsStatusDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/AbsStatusDialogFragment.kt @@ -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 diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/BlockStatusUsersDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/BlockStatusUsersDialogFragment.kt index 4a2cd6d4a..7bea40eca 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/BlockStatusUsersDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/BlockStatusUsersDialogFragment.kt @@ -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() } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/MuteStatusUsersDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/MuteStatusUsersDialogFragment.kt index 1dad27ccc..d93d6306c 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/MuteStatusUsersDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/MuteStatusUsersDialogFragment.kt @@ -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() } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/PinStatusDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/PinStatusDialogFragment.kt index 6ae94d09b..57bb93c1f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/PinStatusDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/PinStatusDialogFragment.kt @@ -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) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/RetweetQuoteDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/RetweetQuoteDialogFragment.kt index 3e0848743..5dbb1f463 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/RetweetQuoteDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/RetweetQuoteDialogFragment.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/StatusFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/StatusFragment.kt index 6eaa4319b..0cb6202d1 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/StatusFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/StatusFragment.kt @@ -372,7 +372,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks(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 @@ -648,7 +648,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks(fragment.context!!, status.account_key) { + AbsAccountRequestTask(fragment.requireContext(), status.account_key) { private val weakFragment = WeakReference(fragment) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/TranslationDestinationDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/TranslationDestinationDialogFragment.kt index 4e4585f87..36ea0e0d5 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/TranslationDestinationDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/TranslationDestinationDialogFragment.kt @@ -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(EXTRA_LANGUAGES)?.sortedArrayWith(LanguageComparator()) ?: emptyArray() val selectedLanguage = preferences[translationDestinationKey] ?: arguments?.getString(EXTRA_SELECTED_LANGUAGE) val selectedIndex = languages.indexOfFirst { selectedLanguage == it.code } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/UnpinStatusDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/UnpinStatusDialogFragment.kt index 49171f021..977c7d521 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/UnpinStatusDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/UnpinStatusDialogFragment.kt @@ -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) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/GroupTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/GroupTimelineFragment.kt index 1afee2421..194e07459 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/GroupTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/GroupTimelineFragment.kt @@ -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) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/MediaStatusesSearchFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/MediaStatusesSearchFragment.kt index d1a9d1767..6f556dea1 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/MediaStatusesSearchFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/MediaStatusesSearchFragment.kt @@ -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) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/StatusesSearchFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/StatusesSearchFragment.kt index 90dc609df..83e9accb2 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/StatusesSearchFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/StatusesSearchFragment.kt @@ -75,12 +75,12 @@ open class StatusesSearchFragment : ParcelableStatusesFragment() { Loader?> { 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) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserFavoritesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserFavoritesFragment.kt index 4e3429493..a114cc50e 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserFavoritesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserFavoritesFragment.kt @@ -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(EXTRA_USER_KEY) if (status.account_key == userKey) { removeStatus(event.statusId) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserListTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserListTimelineFragment.kt index 65073c1ba..33cd8ee27 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserListTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserListTimelineFragment.kt @@ -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) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserMentionsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserMentionsFragment.kt index cdae7b07b..2219ecba7 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserMentionsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserMentionsFragment.kt @@ -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) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserTimelineFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserTimelineFragment.kt index 0d1d93969..23cc6ac54 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserTimelineFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/statuses/UserTimelineFragment.kt @@ -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] diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/sync/SyncSettingsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/sync/SyncSettingsFragment.kt index 771293b5e..7466f1a0b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/sync/SyncSettingsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/sync/SyncSettingsFragment.kt @@ -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() diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/preference/ColorPickerPreference.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/preference/ColorPickerPreference.kt index 23ecc79c3..7eef95167 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/preference/ColorPickerPreference.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/preference/ColorPickerPreference.kt @@ -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) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/controller/premium/SyncStatusViewController.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/controller/premium/SyncStatusViewController.kt index 8441e3ecb..c3ea7d867 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/controller/premium/SyncStatusViewController.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/controller/premium/SyncStatusViewController.kt @@ -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() }