fixed some compatibility issues on older devices
fixing memory leaks
This commit is contained in:
parent
b017e520ac
commit
9dc4f72bb4
|
@ -1 +1 @@
|
|||
15f7574581e9c47b544d23522843710a35ae7e9f
|
||||
050d282caf0af4439fc71a67b474d237cf8bbe8b
|
||||
|
|
|
@ -374,7 +374,7 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator, C
|
|||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (mIsCurrent) {
|
||||
final int width = canvas.getWidth(), height = canvas.getHeight();
|
||||
final int width = getWidth(), height = getHeight();
|
||||
canvas.drawRect(0, height - mStripHeight, width, height, mStripPaint);
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
|
|
|
@ -28,7 +28,6 @@ import android.widget.AdapterView
|
|||
import android.widget.AdapterView.OnItemClickListener
|
||||
import android.widget.ListView
|
||||
import android.widget.Toast
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.activity_account_selector.*
|
||||
import org.mariotaku.ktextension.getNullableTypedArrayExtra
|
||||
import org.mariotaku.twidere.R
|
||||
|
@ -87,7 +86,7 @@ class AccountSelectorActivity : BaseActivity(), OnItemClickListener {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_account_selector)
|
||||
DataStoreUtils.prepareDatabase(this)
|
||||
adapter = AccountDetailsAdapter(this, Glide.with(this)).apply {
|
||||
adapter = AccountDetailsAdapter(this, requestManager).apply {
|
||||
switchEnabled = !isSingleSelection
|
||||
sortEnabled = false
|
||||
val am = AccountManager.get(context)
|
||||
|
|
|
@ -43,6 +43,8 @@ import android.view.KeyEvent
|
|||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import com.squareup.otto.Bus
|
||||
import nl.komponents.kovenant.Promise
|
||||
import org.mariotaku.chameleon.Chameleon
|
||||
|
@ -120,6 +122,9 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity<BaseActivity>, IThe
|
|||
@Inject
|
||||
lateinit var taskServiceRunner: TaskServiceRunner
|
||||
|
||||
lateinit var requestManager: RequestManager
|
||||
private set
|
||||
|
||||
protected val statusScheduleProvider: StatusScheduleProvider?
|
||||
get() = statusScheduleProviderFactory.newInstance(this)
|
||||
|
||||
|
@ -152,7 +157,7 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity<BaseActivity>, IThe
|
|||
|
||||
private var isNightBackup: Int = TwilightManagerAccessor.UNSPECIFIED
|
||||
|
||||
private val actionHelper = IBaseActivity.ActionHelper(this)
|
||||
private val actionHelper = IBaseActivity.ActionHelper<BaseActivity>()
|
||||
|
||||
private val themePreferences by lazy {
|
||||
getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||
|
@ -249,11 +254,27 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity<BaseActivity>, IThe
|
|||
}
|
||||
onApplyNavigationStyle(themeNavigationStyle, themeColor)
|
||||
super.onCreate(savedInstanceState)
|
||||
requestManager = Glide.with(this)
|
||||
ActivitySupport.setTaskDescription(this, TaskDescriptionCompat(title.toString(), null,
|
||||
ColorUtils.setAlphaComponent(overrideTheme.colorToolbar, 0xFF)))
|
||||
GeneralComponent.get(this).inject(this)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
requestManager.onStart()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
requestManager.onStop()
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
requestManager.onDestroy()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val adapter = NfcAdapter.getDefaultAdapter(this)
|
||||
|
@ -322,11 +343,11 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity<BaseActivity>, IThe
|
|||
|
||||
override fun onResumeFragments() {
|
||||
super.onResumeFragments()
|
||||
actionHelper.dispatchOnResumeFragments()
|
||||
actionHelper.dispatchOnResumeFragments(this)
|
||||
}
|
||||
|
||||
override fun executeAfterFragmentResumed(useHandler: Boolean, action: (BaseActivity) -> Unit): Promise<Unit, Exception> {
|
||||
return actionHelper.executeAfterFragmentResumed(useHandler, action)
|
||||
return actionHelper.executeAfterFragmentResumed(this, useHandler, action)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.attoparser.ParseException
|
|||
import org.mariotaku.ktextension.dismissDialogFragment
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.TwidereConstants.*
|
||||
import org.mariotaku.twidere.extension.applyDefault
|
||||
import org.mariotaku.twidere.extension.onShow
|
||||
import org.mariotaku.twidere.fragment.BaseDialogFragment
|
||||
import org.mariotaku.twidere.util.OAuthPasswordAuthenticator
|
||||
|
@ -285,12 +286,5 @@ class BrowserSignInActivity : BaseActivity() {
|
|||
private const val INJECT_CONTENT = "javascript:window.injector.processHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');"
|
||||
private const val TAG_BROWSER_WINDOW = "browser_window"
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
private fun WebSettings.applyDefault() {
|
||||
loadsImagesAutomatically = true
|
||||
javaScriptEnabled = true
|
||||
blockNetworkImage = false
|
||||
saveFormData = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
|||
bottomMenuAnimator = ViewAnimator()
|
||||
bottomMenuAnimator.setupViews()
|
||||
|
||||
mediaPreviewAdapter = MediaPreviewAdapter(this, Glide.with(this))
|
||||
mediaPreviewAdapter = MediaPreviewAdapter(this, requestManager)
|
||||
mediaPreviewAdapter.listener = object : MediaPreviewAdapter.Listener {
|
||||
override fun onEditClick(position: Int, holder: MediaPreviewViewHolder) {
|
||||
attachedMediaPreview.showContextMenuForChild(holder.itemView)
|
||||
|
@ -872,7 +872,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
|||
} else {
|
||||
accountProfileImage.clearColorFilter()
|
||||
accountProfileImage.scaleType = ImageView.ScaleType.CENTER_CROP
|
||||
Glide.with(this).loadProfileImage(this, single, accountProfileImage.style)
|
||||
requestManager.loadProfileImage(this, single, accountProfileImage.style)
|
||||
.into(accountProfileImage)
|
||||
}
|
||||
|
||||
|
@ -1947,7 +1947,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
|||
|
||||
private class AccountIconsAdapter(
|
||||
private val activity: ComposeActivity
|
||||
) : BaseRecyclerViewAdapter<AccountIconViewHolder>(activity, Glide.with(activity)) {
|
||||
) : BaseRecyclerViewAdapter<AccountIconViewHolder>(activity, activity.requestManager) {
|
||||
private val inflater: LayoutInflater = activity.layoutInflater
|
||||
private val selection: MutableMap<UserKey, Boolean> = HashMap()
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import android.view.View
|
|||
import android.widget.Toast
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.Priority
|
||||
import com.bumptech.glide.RequestManager
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import nl.komponents.kovenant.Promise
|
||||
import org.mariotaku.chameleon.Chameleon
|
||||
|
@ -72,9 +73,19 @@ import javax.inject.Inject
|
|||
|
||||
open class MainActivity : ChameleonActivity(), IBaseActivity<MainActivity> {
|
||||
|
||||
@Inject
|
||||
lateinit var restHttpClient: RestHttpClient
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferences
|
||||
|
||||
@Inject
|
||||
lateinit var jsonCache: JsonCache
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private val launchLaterRunnable: Runnable = Runnable { launchMain() }
|
||||
private val actionHelper = IBaseActivity.ActionHelper(this)
|
||||
|
||||
private val actionHelper = IBaseActivity.ActionHelper<MainActivity>()
|
||||
|
||||
private var isNightBackup: Int = TwilightManagerAccessor.UNSPECIFIED
|
||||
|
||||
|
@ -86,14 +97,7 @@ open class MainActivity : ChameleonActivity(), IBaseActivity<MainActivity> {
|
|||
return@lazy ThemeUtils.getUserTheme(this, themePreferences)
|
||||
}
|
||||
|
||||
@Inject
|
||||
lateinit var restHttpClient: RestHttpClient
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: SharedPreferences
|
||||
|
||||
@Inject
|
||||
lateinit var jsonCache: JsonCache
|
||||
private lateinit var requestManager: RequestManager
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
|
@ -107,6 +111,7 @@ open class MainActivity : ChameleonActivity(), IBaseActivity<MainActivity> {
|
|||
}
|
||||
super.onCreate(savedInstanceState)
|
||||
GeneralComponent.get(this).inject(this)
|
||||
requestManager = Glide.with(this)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
if (!preferences[promotionsEnabledKey]) {
|
||||
|
@ -168,6 +173,21 @@ open class MainActivity : ChameleonActivity(), IBaseActivity<MainActivity> {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
requestManager.onStart()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
requestManager.onStop()
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
requestManager.onDestroy()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
actionHelper.dispatchOnPause()
|
||||
super.onPause()
|
||||
|
@ -180,11 +200,11 @@ open class MainActivity : ChameleonActivity(), IBaseActivity<MainActivity> {
|
|||
|
||||
override fun onResumeFragments() {
|
||||
super.onResumeFragments()
|
||||
actionHelper.dispatchOnResumeFragments()
|
||||
actionHelper.dispatchOnResumeFragments(this)
|
||||
}
|
||||
|
||||
override fun executeAfterFragmentResumed(useHandler: Boolean, action: (MainActivity) -> Unit): Promise<Unit, Exception> {
|
||||
return actionHelper.executeAfterFragmentResumed(useHandler, action)
|
||||
return actionHelper.executeAfterFragmentResumed(this, useHandler, action)
|
||||
}
|
||||
|
||||
override fun getOverrideTheme(): Chameleon.Theme? {
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.mariotaku.mediaviewer.library.*
|
|||
import org.mariotaku.mediaviewer.library.subsampleimageview.SubsampleImageViewerFragment.EXTRA_MEDIA_URI
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.TwidereConstants.*
|
||||
import org.mariotaku.twidere.activity.iface.IBaseActivity
|
||||
import org.mariotaku.twidere.activity.iface.IControlBarActivity.ControlBarShowHideHelper
|
||||
import org.mariotaku.twidere.annotation.CacheFileType
|
||||
import org.mariotaku.twidere.extension.addSystemUiVisibility
|
||||
|
@ -97,13 +96,14 @@ class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeClos
|
|||
return@lazy intent.getNullableTypedArrayExtra<ParcelableMedia>(EXTRA_MEDIA) ?: emptyArray()
|
||||
}
|
||||
|
||||
private val currentFragment: MediaViewerFragment? get() {
|
||||
val viewPager = findViewPager()
|
||||
val adapter = viewPager.adapter
|
||||
val currentItem = viewPager.currentItem
|
||||
if (currentItem < 0 || currentItem >= adapter.count) return null
|
||||
return adapter.instantiateItem(viewPager, currentItem) as? MediaViewerFragment
|
||||
}
|
||||
private val currentFragment: MediaViewerFragment?
|
||||
get() {
|
||||
val viewPager = findViewPager()
|
||||
val adapter = viewPager.adapter
|
||||
val currentItem = viewPager.currentItem
|
||||
if (currentItem < 0 || currentItem >= adapter.count) return null
|
||||
return adapter.instantiateItem(viewPager, currentItem) as? MediaViewerFragment
|
||||
}
|
||||
|
||||
override val shouldApplyWindowBackground: Boolean = false
|
||||
|
||||
|
@ -120,6 +120,7 @@ class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeClos
|
|||
}
|
||||
return 0f
|
||||
}
|
||||
@SuppressLint("RestrictedApi")
|
||||
set(offset) {
|
||||
val actionBar = supportActionBar
|
||||
if (actionBar != null && !hideOffsetNotSupported) {
|
||||
|
@ -461,50 +462,7 @@ class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeClos
|
|||
val f = adapter.instantiateItem(viewPager, shareMediaPosition) as? MediaViewerFragment ?: return
|
||||
val fileInfo = f.cacheFileInfo() ?: return
|
||||
val destination = ShareProvider.getFilesDir(this) ?: return
|
||||
val task = object : SaveFileTask(this@MediaViewerActivity, destination, fileInfo) {
|
||||
private val PROGRESS_FRAGMENT_TAG = "progress"
|
||||
|
||||
override fun dismissProgress() {
|
||||
val activity = context as IBaseActivity<*>
|
||||
activity.executeAfterFragmentResumed { activity ->
|
||||
val fm = activity.supportFragmentManager
|
||||
val fragment = fm.findFragmentByTag(PROGRESS_FRAGMENT_TAG) as? DialogFragment
|
||||
fragment?.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun showProgress() {
|
||||
val activity = context as IBaseActivity<*>
|
||||
activity.executeAfterFragmentResumed { activity ->
|
||||
val fragment = ProgressDialogFragment()
|
||||
fragment.isCancelable = false
|
||||
fragment.show(activity.supportFragmentManager, PROGRESS_FRAGMENT_TAG)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFileSaved(savedFile: File, mimeType: String?) {
|
||||
val activity = context as MediaViewerActivity
|
||||
|
||||
val fileUri = ShareProvider.getUriForFile(activity, AUTHORITY_TWIDERE_SHARE,
|
||||
savedFile)
|
||||
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
intent.setDataAndType(fileUri, mimeType)
|
||||
intent.putExtra(Intent.EXTRA_STREAM, fileUri)
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION)
|
||||
}
|
||||
activity.processShareIntent(intent)
|
||||
startActivityForResult(Intent.createChooser(intent, activity.getString(R.string.action_share)),
|
||||
REQUEST_SHARE_MEDIA)
|
||||
}
|
||||
|
||||
override fun onFileSaveFailed() {
|
||||
val activity = context as MediaViewerActivity
|
||||
Toast.makeText(activity, R.string.message_toast_error_occurred, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
val task = SaveMediaTask(this, destination, fileInfo)
|
||||
task.execute()
|
||||
}
|
||||
|
||||
|
@ -550,6 +508,53 @@ class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeClos
|
|||
}
|
||||
}
|
||||
|
||||
class SaveMediaTask(activity: MediaViewerActivity, destination: File, fileInfo: FileInfo) :
|
||||
SaveFileTask(activity, destination, fileInfo) {
|
||||
private val PROGRESS_FRAGMENT_TAG = "progress"
|
||||
|
||||
override fun dismissProgress() {
|
||||
val activity = context as? MediaViewerActivity ?: return
|
||||
|
||||
activity.executeAfterFragmentResumed {
|
||||
val fm = it.supportFragmentManager
|
||||
val fragment = fm.findFragmentByTag(PROGRESS_FRAGMENT_TAG) as? DialogFragment
|
||||
fragment?.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun showProgress() {
|
||||
val activity = context as? MediaViewerActivity ?: return
|
||||
|
||||
activity.executeAfterFragmentResumed {
|
||||
val fragment = ProgressDialogFragment()
|
||||
fragment.isCancelable = false
|
||||
fragment.show(it.supportFragmentManager, PROGRESS_FRAGMENT_TAG)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFileSaved(savedFile: File, mimeType: String?) {
|
||||
val activity = context as? MediaViewerActivity ?: return
|
||||
|
||||
val fileUri = ShareProvider.getUriForFile(activity, AUTHORITY_TWIDERE_SHARE,
|
||||
savedFile)
|
||||
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
intent.setDataAndType(fileUri, mimeType)
|
||||
intent.putExtra(Intent.EXTRA_STREAM, fileUri)
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION)
|
||||
}
|
||||
activity.processShareIntent(intent)
|
||||
activity.startActivityForResult(Intent.createChooser(intent, activity.getString(R.string.action_share)),
|
||||
REQUEST_SHARE_MEDIA)
|
||||
}
|
||||
|
||||
override fun onFileSaveFailed() {
|
||||
val activity = context as? MediaViewerActivity ?: return
|
||||
Toast.makeText(activity, R.string.message_toast_error_occurred, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
companion object {
|
||||
|
||||
private val REQUEST_SHARE_MEDIA = 201
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.view.*
|
|||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import kotlinx.android.synthetic.main.activity_premium_dashboard.*
|
||||
import kotlinx.android.synthetic.main.card_item_extra_feature.view.*
|
||||
|
@ -48,7 +47,7 @@ class PremiumDashboardActivity : BaseActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_premium_dashboard)
|
||||
adapter = ControllersAdapter(this, Glide.with(this))
|
||||
adapter = ControllersAdapter(this, requestManager)
|
||||
recyclerView.adapter = adapter
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
if (extraFeaturesService.isSupported()) {
|
||||
|
|
|
@ -94,7 +94,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
|||
val am = AccountManager.get(this)
|
||||
val accounts = AccountUtils.getAllAccountDetails(am, AccountUtils.getAccounts(am), true).toList()
|
||||
val accountsSpinnerAdapter = AccountsSpinnerAdapter(this, R.layout.spinner_item_account_icon,
|
||||
requestManager = Glide.with(this))
|
||||
requestManager = requestManager)
|
||||
accountsSpinnerAdapter.setDropDownViewResource(R.layout.list_item_simple_user)
|
||||
accountsSpinnerAdapter.addAll(accounts)
|
||||
accountSpinner.adapter = accountsSpinnerAdapter
|
||||
|
@ -357,7 +357,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
|||
|
||||
private val profileImageStyle = activity.preferences[profileImageStyleKey]
|
||||
private val profileImageSize = activity.getString(R.string.profile_image_size)
|
||||
private val requestManager = Glide.with(activity)
|
||||
private val requestManager = activity.requestManager
|
||||
private val inflater = LayoutInflater.from(activity)
|
||||
private val userColorNameManager = activity.userColorNameManager
|
||||
private val removedPositions = SortableIntList()
|
||||
|
|
|
@ -574,9 +574,9 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
|||
val builder = AlertDialog.Builder(context)
|
||||
builder.setView(R.layout.dialog_expandable_list)
|
||||
val dialog = builder.create()
|
||||
dialog.onShow { dialog ->
|
||||
dialog.applyTheme()
|
||||
val listView = dialog.expandableList
|
||||
dialog.onShow {
|
||||
it.applyTheme()
|
||||
val listView = it.expandableList
|
||||
val adapter = LoginTypeAdapter(context)
|
||||
listView.setAdapter(adapter)
|
||||
listView.setOnGroupClickListener { _, _, groupPosition, _ ->
|
||||
|
@ -822,7 +822,6 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
|||
val apiUser = twitter.verifyCredentials()
|
||||
var color = analyseUserProfileColor(apiUser)
|
||||
val (type, extras) = SignInActivity.detectAccountType(twitter, apiUser, apiConfig.type)
|
||||
val userId = apiUser.id
|
||||
val accountKey = apiUser.key
|
||||
val user = apiUser.toParcelable(accountKey, type, profileImageSize = profileImageSize)
|
||||
val am = AccountManager.get(context)
|
||||
|
@ -913,7 +912,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
|||
verificationCallback, userAgent)
|
||||
val accessToken = authenticator.getOAuthAccessToken(username, password)
|
||||
val userId = accessToken.userId
|
||||
return getOAuthSignInResponse(activity, accessToken, userId, Credentials.Type.OAUTH)
|
||||
return getOAuthSignInResponse(activity, accessToken, Credentials.Type.OAUTH)
|
||||
}
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
|
@ -936,7 +935,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
|||
accountType = apiConfig.type, cls = MicroBlog::class.java)
|
||||
return@run microBlog.verifyCredentials().id
|
||||
}
|
||||
return getOAuthSignInResponse(activity, accessToken, userId, Credentials.Type.XAUTH)
|
||||
return getOAuthSignInResponse(activity, accessToken, Credentials.Type.XAUTH)
|
||||
}
|
||||
|
||||
@Throws(MicroBlogException::class, OAuthPasswordAuthenticator.AuthenticationException::class)
|
||||
|
@ -960,7 +959,6 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
|||
throw e
|
||||
}
|
||||
|
||||
val userId = apiUser.id!!
|
||||
var color = analyseUserProfileColor(apiUser)
|
||||
val (type, extras) = SignInActivity.detectAccountType(twitter, apiUser, apiConfig.type)
|
||||
val accountKey = apiUser.key
|
||||
|
@ -990,7 +988,6 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
|||
val twitter = newMicroBlogInstance(activity, endpoint = endpoint, auth = auth,
|
||||
accountType = apiConfig.type, cls = MicroBlog::class.java)
|
||||
val apiUser = twitter.verifyCredentials()
|
||||
val userId = apiUser.id!!
|
||||
var color = analyseUserProfileColor(apiUser)
|
||||
val (type, extras) = SignInActivity.detectAccountType(twitter, apiUser, apiConfig.type)
|
||||
val accountKey = apiUser.key
|
||||
|
@ -1010,7 +1007,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
|||
|
||||
@Throws(MicroBlogException::class)
|
||||
private fun getOAuthSignInResponse(activity: SignInActivity, accessToken: OAuthToken,
|
||||
userId: String, @Credentials.Type authType: String): SignInResponse {
|
||||
@Credentials.Type authType: String): SignInResponse {
|
||||
val auth = apiConfig.getOAuthAuthorization(accessToken) ?:
|
||||
throw MicroBlogException("Invalid OAuth credential")
|
||||
val endpoint = MicroBlogAPIFactory.getOAuthRestEndpoint(apiUrlFormat,
|
||||
|
|
|
@ -69,20 +69,20 @@ class TrendsLocationSelectorActivity : BaseActivity() {
|
|||
return@task map.pack()
|
||||
}.successUi { result ->
|
||||
val activity = weakThis.get() ?: return@successUi
|
||||
activity.executeAfterFragmentResumed { activity ->
|
||||
activity.executeAfterFragmentResumed {
|
||||
val df = TrendsLocationDialogFragment()
|
||||
df.arguments = Bundle {
|
||||
this[EXTRA_DATA] = result
|
||||
}
|
||||
df.show(activity.supportFragmentManager, "trends_location_selector")
|
||||
df.show(it.supportFragmentManager, "trends_location_selector")
|
||||
}
|
||||
}.failUi {
|
||||
val activity = weakThis.get() ?: return@failUi
|
||||
activity.finish()
|
||||
}.alwaysUi {
|
||||
val activity = weakThis.get() ?: return@alwaysUi
|
||||
activity.executeAfterFragmentResumed { activity ->
|
||||
val fm = activity.supportFragmentManager
|
||||
activity.executeAfterFragmentResumed {
|
||||
val fm = it.supportFragmentManager
|
||||
val df = fm.findFragmentByTag(PROGRESS_FRAGMENT_TAG) as? DialogFragment
|
||||
df?.dismiss()
|
||||
}
|
||||
|
@ -98,9 +98,9 @@ class TrendsLocationSelectorActivity : BaseActivity() {
|
|||
selectorBuilder.setView(R.layout.dialog_expandable_list)
|
||||
selectorBuilder.setNegativeButton(android.R.string.cancel, null)
|
||||
val dialog = selectorBuilder.create()
|
||||
dialog.onShow { dialog ->
|
||||
dialog.applyTheme()
|
||||
val listView = dialog.expandableList
|
||||
dialog.onShow {
|
||||
it.applyTheme()
|
||||
val listView = it.expandableList
|
||||
val adapter = ExpandableTrendLocationsListAdapter(context)
|
||||
adapter.data = list
|
||||
listView.setAdapter(adapter)
|
||||
|
@ -111,7 +111,7 @@ class TrendsLocationSelectorActivity : BaseActivity() {
|
|||
dismiss()
|
||||
return@OnGroupClickListener true
|
||||
}
|
||||
false
|
||||
return@OnGroupClickListener false
|
||||
})
|
||||
listView.setOnChildClickListener { _, _, groupPosition, childPosition, _ ->
|
||||
val child = adapter.getChild(groupPosition, childPosition)
|
||||
|
|
|
@ -85,7 +85,7 @@ class UserListSelectorActivity : BaseActivity(),
|
|||
}
|
||||
setContentView(R.layout.activity_user_list_selector)
|
||||
|
||||
adapter = SimpleParcelableUserListsAdapter(this, Glide.with(this))
|
||||
adapter = SimpleParcelableUserListsAdapter(this, requestManager)
|
||||
adapter.loadMoreSupportedPosition = ILoadMoreSupportAdapter.END
|
||||
listView.addFooterView(layoutInflater.inflate(R.layout.simple_list_item_activated_1,
|
||||
listView, false).apply {
|
||||
|
|
|
@ -29,7 +29,6 @@ import android.view.View
|
|||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.OnItemClickListener
|
||||
import android.widget.ListView
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.activity_user_selector.*
|
||||
import kotlinx.android.synthetic.main.layout_list_with_empty_view.*
|
||||
import org.mariotaku.ktextension.Bundle
|
||||
|
@ -90,7 +89,7 @@ class UserSelectorActivity : BaseActivity(), OnItemClickListener, LoaderManager.
|
|||
if (savedInstanceState == null) {
|
||||
editScreenName.setText(intent.getStringExtra(EXTRA_SCREEN_NAME))
|
||||
}
|
||||
adapter = SimpleParcelableUsersAdapter(this, requestManager = Glide.with(this))
|
||||
adapter = SimpleParcelableUsersAdapter(this, requestManager = requestManager)
|
||||
listView.adapter = adapter
|
||||
listView.onItemClickListener = this
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ interface IBaseActivity<out A : FragmentActivity> {
|
|||
|
||||
fun executeAfterFragmentResumed(useHandler: Boolean = false, action: (A) -> Unit): Promise<Unit, Exception>
|
||||
|
||||
class ActionHelper<out A : FragmentActivity>(private val activity: A) {
|
||||
class ActionHelper<A : FragmentActivity> {
|
||||
|
||||
private var fragmentResumed: Boolean = false
|
||||
private val actionQueue = LinkedList<ExecuteInfo<A>>()
|
||||
|
@ -43,33 +43,32 @@ interface IBaseActivity<out A : FragmentActivity> {
|
|||
fragmentResumed = false
|
||||
}
|
||||
|
||||
fun dispatchOnResumeFragments() {
|
||||
fun dispatchOnResumeFragments(activity: A) {
|
||||
fragmentResumed = true
|
||||
executePending()
|
||||
executePending(activity)
|
||||
}
|
||||
|
||||
|
||||
private fun executePending() {
|
||||
private fun executePending(activity: A) {
|
||||
if (!fragmentResumed) return
|
||||
var info: ExecuteInfo<A>?
|
||||
do {
|
||||
val cur = actionQueue.poll()
|
||||
cur?.let { cur ->
|
||||
if (cur.useHandler) {
|
||||
handler.post { cur.invoke(activity) }
|
||||
info = actionQueue.poll()
|
||||
info?.let { i ->
|
||||
if (i.useHandler) {
|
||||
handler.post { i.invoke(activity) }
|
||||
} else {
|
||||
cur.invoke(activity)
|
||||
i.invoke(activity)
|
||||
}
|
||||
}
|
||||
info = cur
|
||||
} while (info != null)
|
||||
}
|
||||
|
||||
fun executeAfterFragmentResumed(useHandler: Boolean = false, action: (A) -> Unit)
|
||||
fun executeAfterFragmentResumed(activity: A, useHandler: Boolean = false, action: (A) -> Unit)
|
||||
: Promise<Unit, Exception> {
|
||||
val info = ExecuteInfo(action, useHandler)
|
||||
actionQueue.add(info)
|
||||
executePending()
|
||||
executePending(activity)
|
||||
return info.promise
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.Space
|
||||
import android.widget.TextView
|
||||
import com.bumptech.glide.Glide
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.contains
|
||||
import org.mariotaku.microblog.library.twitter.model.TranslationResult
|
||||
|
@ -51,7 +50,7 @@ import org.mariotaku.twidere.view.holder.status.DetailStatusViewHolder
|
|||
|
||||
class StatusDetailsAdapter(
|
||||
val fragment: StatusFragment
|
||||
) : LoadMoreSupportAdapter<RecyclerView.ViewHolder>(fragment.context, Glide.with(fragment)),
|
||||
) : LoadMoreSupportAdapter<RecyclerView.ViewHolder>(fragment.context, fragment.requestManager),
|
||||
IStatusesAdapter<List<ParcelableStatus>>, IItemCountsAdapter {
|
||||
|
||||
override val twidereLinkify: TwidereLinkify
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.extension
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.webkit.WebSettings
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/9/3.
|
||||
*/
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
fun WebSettings.applyDefault() {
|
||||
loadsImagesAutomatically = true
|
||||
javaScriptEnabled = true
|
||||
blockNetworkImage = false
|
||||
saveFormData = true
|
||||
}
|
|
@ -190,7 +190,7 @@ class APIEditorDialogFragment : BaseDialogFragment() {
|
|||
private class AccountTypeSpinnerAdapter(
|
||||
fragment: APIEditorDialogFragment
|
||||
) : BaseArrayAdapter<String>(fragment.context, R.layout.support_simple_spinner_dropdown_item,
|
||||
requestManager = Glide.with(fragment)) {
|
||||
requestManager = fragment.requestManager) {
|
||||
init {
|
||||
add(AccountType.TWITTER)
|
||||
add(AccountType.FANFOU)
|
||||
|
|
|
@ -33,7 +33,6 @@ import android.support.v7.widget.LinearLayoutManager
|
|||
import android.support.v7.widget.RecyclerView
|
||||
import android.support.v7.widget.RecyclerView.OnScrollListener
|
||||
import android.view.*
|
||||
import com.bumptech.glide.Glide
|
||||
import com.squareup.otto.Subscribe
|
||||
import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
|
||||
import org.mariotaku.kpreferences.get
|
||||
|
@ -55,6 +54,7 @@ import org.mariotaku.twidere.constant.displaySensitiveContentsKey
|
|||
import org.mariotaku.twidere.constant.newDocumentApiKey
|
||||
import org.mariotaku.twidere.constant.readFromBottomKey
|
||||
import org.mariotaku.twidere.constant.rememberPositionKey
|
||||
import org.mariotaku.twidere.extension.model.activityStatus
|
||||
import org.mariotaku.twidere.extension.model.getAccountType
|
||||
import org.mariotaku.twidere.loader.iface.IExtendedLoader
|
||||
import org.mariotaku.twidere.model.*
|
||||
|
@ -62,7 +62,6 @@ import org.mariotaku.twidere.model.analyzer.Share
|
|||
import org.mariotaku.twidere.model.event.StatusListChangedEvent
|
||||
import org.mariotaku.twidere.model.pagination.SinceMaxPagination
|
||||
import org.mariotaku.twidere.model.util.AccountUtils
|
||||
import org.mariotaku.twidere.extension.model.activityStatus
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Activities
|
||||
import org.mariotaku.twidere.util.*
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback
|
||||
|
@ -104,7 +103,8 @@ abstract class AbsActivitiesFragment protected constructor() :
|
|||
registerForContextMenu(recyclerView)
|
||||
navigationHelper = RecyclerViewNavigationHelper(recyclerView, layoutManager, adapter,
|
||||
this)
|
||||
pauseOnScrollListener = PauseRecyclerViewOnScrollListener(false, false, Glide.with(this))
|
||||
pauseOnScrollListener = PauseRecyclerViewOnScrollListener(false, false,
|
||||
requestManager)
|
||||
|
||||
val loaderArgs = Bundle(arguments)
|
||||
loaderArgs.putBoolean(EXTRA_FROM_USER, true)
|
||||
|
@ -212,8 +212,8 @@ abstract class AbsActivitiesFragment protected constructor() :
|
|||
val readFromBottom = preferences[readFromBottomKey]
|
||||
val firstLoad = adapterData.isNullOrEmpty()
|
||||
|
||||
var lastReadId: Long = -1
|
||||
var lastReadViewTop: Int = 0
|
||||
var lastReadId = -1L
|
||||
var lastReadViewTop = 0
|
||||
var loadMore = false
|
||||
var wasAtTop = false
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.support.v4.widget.SwipeRefreshLayout
|
|||
import android.support.v7.widget.RecyclerView
|
||||
import android.support.v7.widget.RecyclerView.ItemDecoration
|
||||
import android.view.*
|
||||
import com.bumptech.glide.RequestManager
|
||||
import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
|
||||
import kotlinx.android.synthetic.main.layout_content_fragment_common.*
|
||||
import org.mariotaku.twidere.R
|
||||
|
@ -186,7 +187,7 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
|||
R.color.bg_refresh_progress_color_light, R.color.bg_refresh_progress_color_dark)
|
||||
swipeLayout.setOnRefreshListener(this)
|
||||
swipeLayout.setProgressBackgroundColorSchemeResource(colorRes)
|
||||
adapter = onCreateAdapter(context)
|
||||
adapter = onCreateAdapter(context, requestManager)
|
||||
layoutManager = onCreateLayoutManager(context)
|
||||
scrollListener = RecyclerViewScrollHandler(this, RecyclerViewScrollHandler.RecyclerViewCallback(recyclerView))
|
||||
|
||||
|
@ -271,8 +272,7 @@ abstract class AbsContentRecyclerViewFragment<A : LoadMoreSupportAdapter<Recycle
|
|||
return false
|
||||
}
|
||||
|
||||
protected abstract fun onCreateAdapter(context: Context): A
|
||||
|
||||
protected abstract fun onCreateAdapter(context: Context, requestManager: RequestManager): A
|
||||
|
||||
protected open fun onCreateItemDecoration(context: Context, recyclerView: RecyclerView,
|
||||
layoutManager: L): ItemDecoration? {
|
||||
|
|
|
@ -25,7 +25,7 @@ import android.support.v4.app.LoaderManager.LoaderCallbacks
|
|||
import android.support.v4.app.hasRunningLoadersSafe
|
||||
import android.support.v4.content.Loader
|
||||
import android.support.v7.widget.StaggeredGridLayoutManager
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import org.mariotaku.twidere.adapter.StaggeredGridParcelableStatusesAdapter
|
||||
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_FROM_USER
|
||||
|
@ -81,8 +81,8 @@ abstract class AbsMediaStatusesFragment : AbsContentRecyclerViewFragment<Stagger
|
|||
layoutManager.scrollToPositionWithOffset(position, offset)
|
||||
}
|
||||
|
||||
override final fun onCreateAdapter(context: Context): StaggeredGridParcelableStatusesAdapter {
|
||||
return StaggeredGridParcelableStatusesAdapter(context, Glide.with(this))
|
||||
override final fun onCreateAdapter(context: Context, requestManager: RequestManager): StaggeredGridParcelableStatusesAdapter {
|
||||
return StaggeredGridParcelableStatusesAdapter(context, requestManager)
|
||||
}
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle): Loader<List<ParcelableStatus>?> {
|
||||
|
|
|
@ -34,7 +34,6 @@ import android.support.v7.widget.LinearLayoutManager
|
|||
import android.support.v7.widget.RecyclerView
|
||||
import android.support.v7.widget.RecyclerView.OnScrollListener
|
||||
import android.view.*
|
||||
import com.bumptech.glide.Glide
|
||||
import com.squareup.otto.Subscribe
|
||||
import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
|
||||
import org.mariotaku.kpreferences.get
|
||||
|
@ -147,7 +146,8 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
|
|||
adapter.statusClickListener = this
|
||||
registerForContextMenu(recyclerView)
|
||||
navigationHelper = RecyclerViewNavigationHelper(recyclerView, layoutManager, adapter, this)
|
||||
pauseOnScrollListener = PauseRecyclerViewOnScrollListener(false, false, Glide.with(this))
|
||||
pauseOnScrollListener = PauseRecyclerViewOnScrollListener(false, false,
|
||||
requestManager)
|
||||
|
||||
if (shouldInitLoader) {
|
||||
initLoaderIfNeeded()
|
||||
|
|
|
@ -51,7 +51,6 @@ import android.view.*
|
|||
import android.view.View.OnClickListener
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.widget.ImageView
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.header_drawer_account_selector.view.*
|
||||
import org.mariotaku.chameleon.Chameleon
|
||||
import org.mariotaku.kpreferences.get
|
||||
|
@ -123,7 +122,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
|||
@SuppressLint("RestrictedApi")
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
accountsAdapter = AccountSelectorAdapter(layoutInflater, preferences, Glide.with(this)).also {
|
||||
accountsAdapter = AccountSelectorAdapter(layoutInflater, preferences, requestManager).also {
|
||||
it.listener = this
|
||||
}
|
||||
accountsSelector.adapter = accountsAdapter
|
||||
|
@ -475,7 +474,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
|||
clickedColors = clickedImageView.borderColors
|
||||
val oldSelectedAccount = accountsAdapter.selectedAccount ?: return
|
||||
val profileImageStyle = preferences[profileImageStyleKey]
|
||||
Glide.with(this@AccountsDashboardFragment).loadProfileImage(context, oldSelectedAccount,
|
||||
requestManager.loadProfileImage(context, oldSelectedAccount,
|
||||
profileImageStyle, clickedImageView.cornerRadius, clickedImageView.cornerRadiusRatio)
|
||||
.into(clickedImageView).onLoadStarted(profileDrawable)
|
||||
//TODO complete border color
|
||||
|
@ -537,7 +536,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
|||
ColorDrawable(Chameleon.getOverrideTheme(activity, activity).colorPrimary)
|
||||
}
|
||||
|
||||
Glide.with(this).loadProfileBanner(context, account.user, width).fallback(fallbackBanner)
|
||||
requestManager.loadProfileBanner(context, account.user, width).fallback(fallbackBanner)
|
||||
.into(bannerView)
|
||||
}
|
||||
|
||||
|
@ -546,7 +545,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
|||
val account = accountsAdapter.selectedAccount ?: return
|
||||
accountProfileNameView.spannable = account.user.name
|
||||
accountProfileScreenNameView.spannable = "@${account.user.screen_name}"
|
||||
Glide.with(this).loadProfileImage(context, account, preferences[profileImageStyleKey],
|
||||
requestManager.loadProfileImage(context, account, preferences[profileImageStyleKey],
|
||||
accountProfileImageView.cornerRadius, accountProfileImageView.cornerRadiusRatio,
|
||||
ProfileImageSize.REASONABLY_SMALL).placeholder(profileImageSnapshot).into(accountProfileImageView)
|
||||
//TODO complete border color
|
||||
|
|
|
@ -17,7 +17,6 @@ import android.view.*
|
|||
import android.view.ContextMenu.ContextMenuInfo
|
||||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.layout_draggable_list_with_empty_view.*
|
||||
import nl.komponents.kovenant.task
|
||||
import org.mariotaku.kpreferences.get
|
||||
|
@ -61,7 +60,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
|||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
val am = AccountManager.get(context)
|
||||
adapter = AccountDetailsAdapter(context, Glide.with(this)).apply {
|
||||
adapter = AccountDetailsAdapter(context, requestManager).apply {
|
||||
sortEnabled = true
|
||||
switchEnabled = true
|
||||
accountToggleListener = { pos, checked ->
|
||||
|
|
|
@ -21,7 +21,10 @@ package org.mariotaku.twidere.fragment
|
|||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.DialogFragment
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import com.squareup.otto.Bus
|
||||
import com.twitter.Validator
|
||||
import okhttp3.Dns
|
||||
|
@ -58,15 +61,34 @@ open class BaseDialogFragment : DialogFragment() {
|
|||
@Inject
|
||||
lateinit var restHttpClient: RestHttpClient
|
||||
|
||||
override fun onAttach(context: Context?) {
|
||||
super.onAttach(context)
|
||||
GeneralComponent.get(context!!).inject(this)
|
||||
lateinit var requestManager: RequestManager
|
||||
private set
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
requestManager = Glide.with(this)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
requestManager.onStart()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
requestManager.onStop()
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
requestManager.onDestroy()
|
||||
extraFeaturesService.release()
|
||||
super.onDestroy()
|
||||
DebugModeUtils.watchReferenceLeak(this)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context?) {
|
||||
super.onAttach(context)
|
||||
GeneralComponent.get(context!!).inject(this)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ import android.content.SharedPreferences
|
|||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.text.BidiFormatter
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import com.squareup.otto.Bus
|
||||
import com.twitter.Validator
|
||||
import nl.komponents.kovenant.Promise
|
||||
|
@ -84,6 +86,9 @@ open class BaseFragment : Fragment(), IBaseFragment<BaseFragment> {
|
|||
@Inject
|
||||
lateinit var externalThemeManager: ExternalThemeManager
|
||||
|
||||
lateinit var requestManager: RequestManager
|
||||
private set
|
||||
|
||||
protected val statusScheduleProvider: StatusScheduleProvider?
|
||||
get() = statusScheduleProviderFactory.newInstance(context)
|
||||
|
||||
|
@ -93,26 +98,26 @@ open class BaseFragment : Fragment(), IBaseFragment<BaseFragment> {
|
|||
protected val gifShareProvider: GifShareProvider?
|
||||
get() = gifShareProviderFactory.newInstance(context)
|
||||
|
||||
private val actionHelper = IBaseFragment.ActionHelper(this)
|
||||
private val actionHelper = IBaseFragment.ActionHelper<BaseFragment>()
|
||||
|
||||
override fun onViewStateRestored(savedInstanceState: Bundle?) {
|
||||
super.onViewStateRestored(savedInstanceState)
|
||||
requestApplyInsets()
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
requestManager = Glide.with(this)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
GeneralComponent.get(context).inject(this)
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
requestManager.onStart()
|
||||
}
|
||||
|
||||
override fun executeAfterFragmentResumed(useHandler: Boolean, action: (BaseFragment) -> Unit)
|
||||
: Promise<Unit, Exception> {
|
||||
return actionHelper.executeAfterFragmentResumed(useHandler, action)
|
||||
override fun onStop() {
|
||||
requestManager.onStop()
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
actionHelper.dispatchOnResumeFragments()
|
||||
actionHelper.dispatchOnResumeFragments(this)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
@ -121,9 +126,25 @@ open class BaseFragment : Fragment(), IBaseFragment<BaseFragment> {
|
|||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
requestManager.onDestroy()
|
||||
extraFeaturesService.release()
|
||||
super.onDestroy()
|
||||
DebugModeUtils.watchReferenceLeak(this)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
GeneralComponent.get(context).inject(this)
|
||||
}
|
||||
|
||||
override fun onViewStateRestored(savedInstanceState: Bundle?) {
|
||||
super.onViewStateRestored(savedInstanceState)
|
||||
requestApplyInsets()
|
||||
}
|
||||
|
||||
override fun executeAfterFragmentResumed(useHandler: Boolean, action: (BaseFragment) -> Unit)
|
||||
: Promise<Unit, Exception> {
|
||||
return actionHelper.executeAfterFragmentResumed(this, useHandler, action)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat(), IBaseFragmen
|
|||
@Inject
|
||||
lateinit var bus: Bus
|
||||
|
||||
private val actionHelper = IBaseFragment.ActionHelper(this)
|
||||
private val actionHelper = IBaseFragment.ActionHelper<BasePreferenceFragment>()
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
if (savedInstanceState != null) {
|
||||
|
@ -63,6 +63,16 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat(), IBaseFragmen
|
|||
super.onActivityCreated(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
actionHelper.dispatchOnPause()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
actionHelper.dispatchOnResumeFragments(this)
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
GeneralComponent.get(context).inject(this)
|
||||
|
@ -122,7 +132,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat(), IBaseFragmen
|
|||
|
||||
override fun executeAfterFragmentResumed(useHandler: Boolean, action: (BasePreferenceFragment) -> Unit)
|
||||
: Promise<Unit, Exception> {
|
||||
return actionHelper.executeAfterFragmentResumed(useHandler, action)
|
||||
return actionHelper.executeAfterFragmentResumed(this, useHandler, action)
|
||||
}
|
||||
|
||||
override fun onApplySystemWindowInsets(insets: Rect) {
|
||||
|
|
|
@ -28,7 +28,7 @@ import android.os.Bundle
|
|||
import android.os.Handler
|
||||
import android.support.v4.content.Loader
|
||||
import android.widget.Toast
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import com.squareup.otto.Subscribe
|
||||
import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
|
||||
import org.mariotaku.ktextension.*
|
||||
|
@ -144,8 +144,8 @@ abstract class CursorStatusesFragment : AbsStatusesFragment() {
|
|||
return data.isNotNullOrEmpty()
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): ListParcelableStatusesAdapter {
|
||||
return ListParcelableStatusesAdapter(context, Glide.with(this))
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): ListParcelableStatusesAdapter {
|
||||
return ListParcelableStatusesAdapter(context, requestManager)
|
||||
}
|
||||
|
||||
override fun onLoaderReset(loader: Loader<List<ParcelableStatus>?>) {
|
||||
|
|
|
@ -272,7 +272,7 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
|
|||
val positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE)
|
||||
|
||||
val iconsAdapter = TabIconsAdapter(context)
|
||||
val accountsAdapter = AccountsSpinnerAdapter(context, requestManager = Glide.with(this))
|
||||
val accountsAdapter = AccountsSpinnerAdapter(context, requestManager = requestManager)
|
||||
iconSpinner.adapter = iconsAdapter
|
||||
accountSpinner.adapter = accountsAdapter
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ import android.widget.AbsListView.MultiChoiceModeListener
|
|||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.OnItemClickListener
|
||||
import android.widget.ListView
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.fragment_drafts.*
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.setItemAvailability
|
||||
|
@ -72,7 +71,7 @@ class DraftsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, OnItemClickList
|
|||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
adapter = DraftsAdapter(activity, Glide.with(this)).apply {
|
||||
adapter = DraftsAdapter(activity, requestManager).apply {
|
||||
textSize = preferences[textSizeKey].toFloat()
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ import android.view.MenuItem
|
|||
import android.view.View
|
||||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.fragment_content_listview.*
|
||||
import org.mariotaku.ktextension.isNullOrEmpty
|
||||
import org.mariotaku.ktextension.setItemAvailability
|
||||
|
@ -57,7 +56,7 @@ class ExtensionsListFragment : AbsContentListViewFragment<ExtensionsAdapter>(),
|
|||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): ExtensionsAdapter {
|
||||
return ExtensionsAdapter(activity, Glide.with(this))
|
||||
return ExtensionsAdapter(activity, requestManager)
|
||||
}
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ExtensionInfo>> {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.mariotaku.twidere.fragment
|
||||
|
||||
import android.content.Context
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import org.mariotaku.microblog.library.twitter.model.Activity
|
||||
import org.mariotaku.sqliteqb.library.Expression
|
||||
import org.mariotaku.twidere.TwidereConstants.NOTIFICATION_ID_INTERACTIONS_TIMELINE
|
||||
|
@ -50,8 +50,8 @@ class InteractionsTimelineFragment : CursorActivitiesFragment() {
|
|||
override val timelineSyncTag: String?
|
||||
get() = getTimelineSyncTag(accountKeys)
|
||||
|
||||
override fun onCreateAdapter(context: Context): ParcelableActivitiesAdapter {
|
||||
val adapter = ParcelableActivitiesAdapter(context, Glide.with(this))
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): ParcelableActivitiesAdapter {
|
||||
val adapter = ParcelableActivitiesAdapter(context, requestManager)
|
||||
val extras: InteractionsTabExtras? = arguments.getParcelable(EXTRA_EXTRAS)
|
||||
if (extras != null) {
|
||||
adapter.followingOnly = extras.isMyFollowingOnly
|
||||
|
|
|
@ -12,7 +12,7 @@ import android.view.ContextMenu
|
|||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.twidere.R
|
||||
|
@ -61,8 +61,8 @@ open class ItemsListFragment : AbsContentListRecyclerViewFragment<VariousItemsAd
|
|||
}
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): VariousItemsAdapter {
|
||||
val adapter = VariousItemsAdapter(context, Glide.with(this))
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): VariousItemsAdapter {
|
||||
val adapter = VariousItemsAdapter(context, requestManager)
|
||||
val dummyItemAdapter = adapter.dummyAdapter
|
||||
dummyItemAdapter.statusClickListener = object : IStatusViewHolder.StatusClickListener {
|
||||
override fun onStatusClick(holder: IStatusViewHolder, position: Int) {
|
||||
|
|
|
@ -26,7 +26,7 @@ import android.support.v4.app.hasRunningLoadersSafe
|
|||
import android.support.v4.content.Loader
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.KeyEvent
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
|
||||
import org.mariotaku.twidere.adapter.ParcelableGroupsAdapter
|
||||
import org.mariotaku.twidere.adapter.iface.IGroupsAdapter.GroupAdapterListener
|
||||
|
@ -64,8 +64,8 @@ abstract class ParcelableGroupsFragment : AbsContentListRecyclerViewFragment<Par
|
|||
super.refreshing = value
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): ParcelableGroupsAdapter {
|
||||
return ParcelableGroupsAdapter(context, Glide.with(this))
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): ParcelableGroupsAdapter {
|
||||
return ParcelableGroupsAdapter(context, this.requestManager)
|
||||
}
|
||||
|
||||
override fun setupRecyclerView(context: Context, recyclerView: RecyclerView) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import android.os.Bundle
|
|||
import android.support.v4.app.hasRunningLoadersSafe
|
||||
import android.support.v4.content.Loader
|
||||
import android.text.TextUtils
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import com.squareup.otto.Subscribe
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.TwidereConstants.*
|
||||
|
@ -128,8 +128,8 @@ abstract class ParcelableStatusesFragment : AbsStatusesFragment() {
|
|||
return ParcelableStatusesBusCallback()
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): ListParcelableStatusesAdapter {
|
||||
return ListParcelableStatusesAdapter(context, Glide.with(this))
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): ListParcelableStatusesAdapter {
|
||||
return ListParcelableStatusesAdapter(context, this.requestManager)
|
||||
}
|
||||
|
||||
override fun onStatusesLoaded(loader: Loader<List<ParcelableStatus>?>, data: List<ParcelableStatus>?) {
|
||||
|
|
|
@ -26,7 +26,7 @@ import android.support.v4.app.hasRunningLoadersSafe
|
|||
import android.support.v4.content.Loader
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.KeyEvent
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
|
||||
import org.mariotaku.ktextension.set
|
||||
import org.mariotaku.twidere.adapter.ParcelableUserListsAdapter
|
||||
|
@ -69,8 +69,8 @@ abstract class ParcelableUserListsFragment : AbsContentListRecyclerViewFragment<
|
|||
super.refreshing = value
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): ParcelableUserListsAdapter {
|
||||
return ParcelableUserListsAdapter(context, Glide.with(this))
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): ParcelableUserListsAdapter {
|
||||
return ParcelableUserListsAdapter(context, this.requestManager)
|
||||
}
|
||||
|
||||
override fun setupRecyclerView(context: Context, recyclerView: RecyclerView) {
|
||||
|
|
|
@ -28,7 +28,7 @@ import android.support.v4.content.Loader
|
|||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.KeyEvent
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import com.squareup.otto.Subscribe
|
||||
import kotlinx.android.synthetic.main.fragment_content_recyclerview.*
|
||||
import org.mariotaku.commons.parcel.ParcelUtils
|
||||
|
@ -167,8 +167,8 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<Parc
|
|||
loaderManager.restartLoader(0, loaderArgs, this)
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): ParcelableUsersAdapter {
|
||||
val adapter = ParcelableUsersAdapter(context, Glide.with(this))
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): ParcelableUsersAdapter {
|
||||
val adapter = ParcelableUsersAdapter(context, this.requestManager)
|
||||
adapter.simpleLayout = simpleLayout
|
||||
adapter.showFollow = showFollow
|
||||
val accountType = arguments.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)?.let { key ->
|
||||
|
|
|
@ -73,7 +73,6 @@ import android.view.View.OnTouchListener
|
|||
import android.view.animation.AnimationUtils
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.bumptech.glide.Glide
|
||||
import com.squareup.otto.Subscribe
|
||||
import kotlinx.android.synthetic.main.fragment_user.*
|
||||
import kotlinx.android.synthetic.main.fragment_user.view.*
|
||||
|
@ -502,7 +501,6 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
|||
}
|
||||
val defWidth = resources.displayMetrics.widthPixels
|
||||
val width = if (bannerWidth > 0) bannerWidth else defWidth
|
||||
val requestManager = Glide.with(this)
|
||||
requestManager.loadProfileBanner(context, user, width).into(profileBanner)
|
||||
requestManager.loadOriginalProfileImage(context, user, profileImage.style,
|
||||
profileImage.cornerRadius, profileImage.cornerRadiusRatio)
|
||||
|
|
|
@ -33,7 +33,6 @@ import android.text.TextUtils.isEmpty
|
|||
import android.view.*
|
||||
import android.view.View.OnClickListener
|
||||
import android.widget.Toast
|
||||
import com.bumptech.glide.Glide
|
||||
import com.twitter.Validator
|
||||
import kotlinx.android.synthetic.main.fragment_user_profile_editor.*
|
||||
import nl.komponents.kovenant.combine.and
|
||||
|
@ -278,7 +277,6 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
|
|||
editLocation.setText(user.location)
|
||||
editUrl.setText(if (isEmpty(user.url_expanded)) user.url else user.url_expanded)
|
||||
|
||||
val requestManager = Glide.with(this)
|
||||
requestManager.loadProfileImage(context, user, 0).into(profileImage)
|
||||
requestManager.loadProfileBanner(context, user, resources.displayMetrics.widthPixels)
|
||||
.into(profileBanner)
|
||||
|
|
|
@ -65,7 +65,6 @@ import org.mariotaku.twidere.model.FiltersData
|
|||
import org.mariotaku.twidere.model.util.AccountUtils
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Filters
|
||||
import org.mariotaku.twidere.text.style.EmojiSpan
|
||||
import org.mariotaku.twidere.util.DataStoreUtils
|
||||
import org.mariotaku.twidere.util.ParseUtils
|
||||
import org.mariotaku.twidere.util.ThemeUtils
|
||||
|
||||
|
@ -279,8 +278,6 @@ abstract class BaseFiltersFragment : AbsContentListViewFragment<SimpleCursorAdap
|
|||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val activity = activity
|
||||
val context = activity
|
||||
val builder = AlertDialog.Builder(context)
|
||||
builder.setView(R.layout.dialog_auto_complete_textview)
|
||||
|
||||
|
@ -304,7 +301,7 @@ abstract class BaseFiltersFragment : AbsContentListViewFragment<SimpleCursorAdap
|
|||
if (autoCompleteType == AUTO_COMPLETE_TYPE_SOURCES) {
|
||||
userAutoCompleteAdapter = SourceAutoCompleteAdapter(activity)
|
||||
} else {
|
||||
val adapter = ComposeAutoCompleteAdapter(activity, Glide.with(this))
|
||||
val adapter = ComposeAutoCompleteAdapter(activity, requestManager)
|
||||
val am = AccountManager.get(activity)
|
||||
adapter.account = AccountUtils.getDefaultAccountDetails(activity, am, false)
|
||||
userAutoCompleteAdapter = adapter
|
||||
|
|
|
@ -14,7 +14,7 @@ import android.view.MenuInflater
|
|||
import android.view.MenuItem
|
||||
import android.widget.CheckBox
|
||||
import android.widget.Toast
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import kotlinx.android.synthetic.main.dialog_block_mute_filter_user_confirm.*
|
||||
import nl.komponents.kovenant.combine.and
|
||||
import nl.komponents.kovenant.task
|
||||
|
@ -168,7 +168,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Se
|
|||
val cursorLoader = loader as AbsRequestUsersLoader
|
||||
nextPagination = cursorLoader.nextPagination
|
||||
prevPagination = cursorLoader.prevPagination
|
||||
activity.supportInvalidateOptionsMenu()
|
||||
activity.invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
override fun onLoadMoreContents(@IndicatorPosition position: Long) {
|
||||
|
@ -182,8 +182,8 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Se
|
|||
loaderManager.restartLoader(0, loaderArgs, this)
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): SelectableUsersAdapter {
|
||||
val adapter = SelectableUsersAdapter(context, Glide.with(this))
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): SelectableUsersAdapter {
|
||||
val adapter = SelectableUsersAdapter(context, this.requestManager)
|
||||
adapter.itemCheckedListener = listener@ { _, _ ->
|
||||
if (!extraFeaturesService.isEnabled(ExtraFeaturesService.FEATURE_FILTERS_IMPORT)) {
|
||||
ExtraFeaturesIntroductionDialogFragment.show(fragmentManager,
|
||||
|
@ -198,7 +198,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Se
|
|||
} else {
|
||||
null
|
||||
}
|
||||
activity.supportInvalidateOptionsMenu()
|
||||
activity.invalidateOptionsMenu()
|
||||
return@listener true
|
||||
}
|
||||
return adapter
|
||||
|
@ -249,10 +249,10 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Se
|
|||
builder.setPositiveButton(android.R.string.ok, this)
|
||||
builder.setNegativeButton(android.R.string.cancel, null)
|
||||
val dialog = builder.create()
|
||||
dialog.onShow { dialog ->
|
||||
dialog.applyTheme()
|
||||
val confirmMessageView = dialog.confirmMessage
|
||||
val filterEverywhereHelp = dialog.filterEverywhereHelp
|
||||
dialog.onShow {
|
||||
it.applyTheme()
|
||||
val confirmMessageView = it.confirmMessage
|
||||
val filterEverywhereHelp = it.filterEverywhereHelp
|
||||
filterEverywhereHelp.setOnClickListener {
|
||||
MessageDialogFragment.show(childFragmentManager, title = getString(R.string.filter_everywhere),
|
||||
message = getString(R.string.filter_everywhere_description), tag = "filter_everywhere_help")
|
||||
|
|
|
@ -72,7 +72,7 @@ interface IBaseFragment<out F : Fragment> {
|
|||
|
||||
fun executeAfterFragmentResumed(useHandler: Boolean = false, action: (F) -> Unit): Promise<Unit, Exception>
|
||||
|
||||
class ActionHelper<out F : Fragment>(private val fragment: F) {
|
||||
class ActionHelper<F : Fragment> {
|
||||
|
||||
private val handler: Handler = Handler(Looper.getMainLooper())
|
||||
|
||||
|
@ -83,32 +83,31 @@ interface IBaseFragment<out F : Fragment> {
|
|||
fragmentResumed = false
|
||||
}
|
||||
|
||||
fun dispatchOnResumeFragments() {
|
||||
fun dispatchOnResumeFragments(fragment: F) {
|
||||
fragmentResumed = true
|
||||
executePending()
|
||||
executePending(fragment)
|
||||
}
|
||||
|
||||
private fun executePending() {
|
||||
private fun executePending(fragment: F) {
|
||||
if (!fragmentResumed) return
|
||||
var info: ExecuteInfo<F>?
|
||||
do {
|
||||
val cur = actionQueue.poll()
|
||||
cur?.let { cur ->
|
||||
if (cur.useHandler) {
|
||||
handler.post { cur.invoke(fragment) }
|
||||
info = actionQueue.poll()
|
||||
info?.let { i ->
|
||||
if (i.useHandler) {
|
||||
handler.post { i.invoke(fragment) }
|
||||
} else {
|
||||
cur.invoke(fragment)
|
||||
i.invoke(fragment)
|
||||
}
|
||||
}
|
||||
info = cur
|
||||
} while (info != null)
|
||||
}
|
||||
|
||||
fun executeAfterFragmentResumed(useHandler: Boolean = false, action: (F) -> Unit)
|
||||
fun executeAfterFragmentResumed(fragment: F, useHandler: Boolean = false, action: (F) -> Unit)
|
||||
: Promise<Unit, Exception> {
|
||||
val info = ExecuteInfo(action, useHandler)
|
||||
actionQueue.add(info)
|
||||
executePending()
|
||||
executePending(fragment)
|
||||
return info.promise
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ import android.support.v7.widget.Toolbar
|
|||
import android.view.*
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.EditText
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import kotlinx.android.synthetic.main.activity_home_content.view.*
|
||||
import kotlinx.android.synthetic.main.fragment_messages_conversation_info.*
|
||||
|
@ -133,7 +132,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
|
|||
}
|
||||
val theme = Chameleon.getOverrideTheme(context, activity)
|
||||
|
||||
adapter = ConversationInfoAdapter(context, Glide.with(this))
|
||||
adapter = ConversationInfoAdapter(context, requestManager)
|
||||
adapter.listener = object : ConversationInfoAdapter.Listener {
|
||||
override fun onUserClick(position: Int) {
|
||||
val user = adapter.getUser(position) ?: return
|
||||
|
@ -267,10 +266,10 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
|
|||
val name = data.getTitle(context, userColorNameManager, preferences[nameFirstKey]).first
|
||||
val summary = data.getSubtitle(context)
|
||||
|
||||
val requestManager = Glide.with(this)
|
||||
@ImageShapeStyle val profileImageStyle = preferences[profileImageStyleKey]
|
||||
requestManager.loadProfileImage(context, data, profileImageStyle).into(conversationAvatar)
|
||||
requestManager.loadProfileImage(context, data, profileImageStyle, size = ProfileImageSize.REASONABLY_SMALL).into(appBarIcon)
|
||||
requestManager.loadProfileImage(context, data, profileImageStyle, 0f,
|
||||
0f, ProfileImageSize.REASONABLY_SMALL).into(appBarIcon)
|
||||
appBarTitle.spannable = name
|
||||
conversationTitle.spannable = name
|
||||
if (summary != null) {
|
||||
|
|
|
@ -35,7 +35,6 @@ import android.text.SpannableStringBuilder
|
|||
import android.text.TextUtils
|
||||
import android.text.style.ReplacementSpan
|
||||
import android.view.*
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.fragment_messages_conversation_new.*
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.*
|
||||
|
@ -99,7 +98,7 @@ class MessageNewConversationFragment : BaseFragment(), LoaderCallbacks<List<Parc
|
|||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
usersAdapter = SelectableUsersAdapter(context, Glide.with(this))
|
||||
usersAdapter = SelectableUsersAdapter(context, requestManager)
|
||||
recyclerView.adapter = usersAdapter
|
||||
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import android.support.v7.widget.LinearLayoutManager
|
|||
import android.support.v7.widget.RecyclerView
|
||||
import android.support.v7.widget.Toolbar
|
||||
import android.view.*
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import com.squareup.otto.Subscribe
|
||||
import kotlinx.android.synthetic.main.activity_premium_dashboard.*
|
||||
import kotlinx.android.synthetic.main.fragment_messages_conversation.*
|
||||
|
@ -142,7 +142,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment<Messages
|
|||
return recyclerView.showContextMenuForChild(holder.itemView)
|
||||
}
|
||||
}
|
||||
mediaPreviewAdapter = MediaPreviewAdapter(context, Glide.with(this))
|
||||
mediaPreviewAdapter = MediaPreviewAdapter(context, requestManager)
|
||||
|
||||
mediaPreviewAdapter.listener = object : MediaPreviewAdapter.Listener {
|
||||
override fun onRemoveClick(position: Int, holder: MediaPreviewViewHolder) {
|
||||
|
@ -300,8 +300,8 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment<Messages
|
|||
adapter.setData(null, null)
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): MessagesConversationAdapter {
|
||||
return MessagesConversationAdapter(context, Glide.with(this))
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): MessagesConversationAdapter {
|
||||
return MessagesConversationAdapter(context, this.requestManager)
|
||||
}
|
||||
|
||||
override fun onCreateLayoutManager(context: Context): LinearLayoutManager {
|
||||
|
@ -447,9 +447,9 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment<Messages
|
|||
private fun openMediaPicker() {
|
||||
val builder = ThemedMediaPickerActivity.withThemed(context)
|
||||
builder.pickSources(arrayOf(MediaPickerActivity.SOURCE_CAMERA,
|
||||
MediaPickerActivity.SOURCE_CAMCORDER,
|
||||
MediaPickerActivity.SOURCE_GALLERY,
|
||||
MediaPickerActivity.SOURCE_CLIPBOARD))
|
||||
MediaPickerActivity.SOURCE_CAMCORDER,
|
||||
MediaPickerActivity.SOURCE_GALLERY,
|
||||
MediaPickerActivity.SOURCE_CLIPBOARD))
|
||||
if (gifShareProvider != null) {
|
||||
builder.addEntry(getString(R.string.action_add_gif), "gif", RESULT_SEARCH_GIF)
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ class MessagesConversationFragment : AbsContentListRecyclerViewFragment<Messages
|
|||
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(conversationTitle, null,
|
||||
null, stateIcon, null)
|
||||
|
||||
Glide.with(this).loadProfileImage(context, conversation, preferences[profileImageStyleKey])
|
||||
requestManager.loadProfileImage(context, conversation, preferences[profileImageStyleKey])
|
||||
.into(conversationAvatar)
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import android.view.ContextMenu
|
|||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestManager
|
||||
import com.squareup.otto.Subscribe
|
||||
import kotlinx.android.synthetic.main.activity_premium_dashboard.*
|
||||
import org.mariotaku.abstask.library.TaskStarter
|
||||
|
@ -134,8 +134,8 @@ class MessagesEntriesFragment : AbsContentListRecyclerViewFragment<MessagesEntri
|
|||
showContentOrError()
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): MessagesEntriesAdapter {
|
||||
return MessagesEntriesAdapter(context, Glide.with(this))
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): MessagesEntriesAdapter {
|
||||
return MessagesEntriesAdapter(context, this.requestManager)
|
||||
}
|
||||
|
||||
override fun triggerRefresh(): Boolean {
|
||||
|
|
|
@ -29,7 +29,6 @@ import android.support.v7.app.AlertDialog
|
|||
import android.support.v7.app.AlertDialog.Builder
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import com.bumptech.glide.Glide
|
||||
import nl.komponents.kovenant.Promise
|
||||
import nl.komponents.kovenant.combine.and
|
||||
import nl.komponents.kovenant.task
|
||||
|
@ -74,7 +73,7 @@ abstract class AbsStatusDialogFragment : BaseDialogFragment() {
|
|||
|
||||
builder.setupAlertDialog()
|
||||
|
||||
adapter = DummyItemAdapter(context, requestManager = Glide.with(this))
|
||||
adapter = DummyItemAdapter(context, requestManager = requestManager)
|
||||
adapter.showCardActions = false
|
||||
adapter.showAccountsColor = true
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.mariotaku.twidere.fragment.users
|
|||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import com.bumptech.glide.RequestManager
|
||||
import org.mariotaku.twidere.TwidereConstants.USER_TYPE_FANFOU_COM
|
||||
import org.mariotaku.twidere.adapter.ParcelableUsersAdapter
|
||||
import org.mariotaku.twidere.adapter.iface.IUsersAdapter
|
||||
|
@ -43,8 +44,8 @@ class IncomingFriendshipsFragment : ParcelableUsersFragment(), IUsersAdapter.Req
|
|||
return IncomingFriendshipsLoader(context, accountKey, adapter.getData(), fromUser)
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): ParcelableUsersAdapter {
|
||||
val adapter = super.onCreateAdapter(context)
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): ParcelableUsersAdapter {
|
||||
val adapter = super.onCreateAdapter(context, requestManager)
|
||||
val accountKey = arguments.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY) ?: return adapter
|
||||
if (USER_TYPE_FANFOU_COM == accountKey.host) {
|
||||
adapter.requestClickListener = this
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.users
|
|||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import com.bumptech.glide.RequestManager
|
||||
import org.mariotaku.twidere.adapter.ParcelableUsersAdapter
|
||||
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT_KEY
|
||||
|
@ -39,8 +40,8 @@ class StatusFavoritersListFragment : ParcelableUsersFragment() {
|
|||
return StatusFavoritersLoader(context, accountKey, statusId, adapter.getData(), false)
|
||||
}
|
||||
|
||||
override fun onCreateAdapter(context: Context): ParcelableUsersAdapter {
|
||||
return super.onCreateAdapter(context).apply {
|
||||
override fun onCreateAdapter(context: Context, requestManager: RequestManager): ParcelableUsersAdapter {
|
||||
return super.onCreateAdapter(context, requestManager).apply {
|
||||
loadMoreSupportedPosition = ILoadMoreSupportAdapter.NONE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.content.Intent
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.layout_extra_config_user.view.*
|
||||
import kotlinx.android.synthetic.main.list_item_simple_user.view.*
|
||||
import org.mariotaku.twidere.R
|
||||
|
@ -51,7 +50,7 @@ class UserExtraConfiguration(key: String) : TabConfiguration.ExtraConfiguration(
|
|||
fragment.startExtraConfigurationActivityForResult(this@UserExtraConfiguration, intent, 1)
|
||||
}
|
||||
hintView = view.selectUserHint
|
||||
val adapter = DummyItemAdapter(context, requestManager = Glide.with(fragment))
|
||||
val adapter = DummyItemAdapter(context, requestManager = fragment.requestManager)
|
||||
adapter.updateOptions()
|
||||
viewHolder = SimpleUserViewHolder(view.listItem, adapter)
|
||||
|
||||
|
|
|
@ -25,10 +25,6 @@ import android.text.TextPaint
|
|||
import android.text.TextUtils
|
||||
import android.text.style.ReplacementSpan
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/3/26.
|
||||
*/
|
||||
|
||||
class NonBreakEllipseSpan : ReplacementSpan() {
|
||||
override fun getSize(paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?): Int {
|
||||
return 1
|
||||
|
|
|
@ -85,7 +85,7 @@ class TintedStatusFrameLayout(context: Context, attrs: AttributeSet? = null) :
|
|||
|
||||
override fun dispatchDraw(canvas: Canvas) {
|
||||
super.dispatchDraw(canvas)
|
||||
canvas.drawRect(0f, 0f, canvas.width.toFloat(), statusBarHeight.toFloat(), colorPaint)
|
||||
canvas.drawRect(0f, 0f, width.toFloat(), statusBarHeight.toFloat(), colorPaint)
|
||||
}
|
||||
|
||||
override fun isPostApplyTheme(): Boolean {
|
||||
|
|
|
@ -88,7 +88,7 @@ class TintedStatusRelativeLayout(context: Context, attrs: AttributeSet? = null)
|
|||
|
||||
override fun dispatchDraw(canvas: Canvas) {
|
||||
super.dispatchDraw(canvas)
|
||||
canvas.drawRect(0f, 0f, canvas.width.toFloat(), statusBarHeight.toFloat(), colorPaint)
|
||||
canvas.drawRect(0f, 0f, width.toFloat(), statusBarHeight.toFloat(), colorPaint)
|
||||
}
|
||||
|
||||
override fun isPostApplyTheme(): Boolean {
|
||||
|
|
|
@ -503,7 +503,7 @@ class DetailStatusViewHolder(
|
|||
private class CountsUsersAdapter(
|
||||
private val fragment: StatusFragment,
|
||||
private val statusAdapter: StatusDetailsAdapter
|
||||
) : BaseRecyclerViewAdapter<RecyclerView.ViewHolder>(statusAdapter.context, Glide.with(fragment)) {
|
||||
) : BaseRecyclerViewAdapter<RecyclerView.ViewHolder>(statusAdapter.context, fragment.requestManager) {
|
||||
|
||||
private val inflater = LayoutInflater.from(statusAdapter.context)
|
||||
|
||||
|
|
Loading…
Reference in New Issue