migrating to Glide
This commit is contained in:
parent
a48efc6b89
commit
719794778d
|
@ -1,20 +1,15 @@
|
|||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Settings specified in this file will override any Gradle settings
|
||||
# configured through the IDE.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx10248m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
org.gradle.jvmargs=-Xmx2048M
|
||||
kotlin.incremental=true
|
||||
org.gradle.jvmargs=-Xmx2048M
|
|
@ -50,6 +50,7 @@ import org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT_KEY
|
|||
import org.mariotaku.twidere.constant.KeyboardShortcutConstants.ACTION_NAVIGATION_BACK
|
||||
import org.mariotaku.twidere.constant.KeyboardShortcutConstants.CONTEXT_TAG_NAVIGATION
|
||||
import org.mariotaku.twidere.constant.newDocumentApiKey
|
||||
import org.mariotaku.twidere.extension.loadProfileImage
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
import org.mariotaku.twidere.model.SuggestionItem
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
@ -263,10 +264,11 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
|||
private val activity: QuickSearchBarActivity
|
||||
) : CursorAdapter(activity, null, 0), OnClickListener {
|
||||
|
||||
private val inflater: LayoutInflater = LayoutInflater.from(activity)
|
||||
private val mediaLoader: MediaLoaderWrapper = activity.mediaLoader
|
||||
private val userColorNameManager: UserColorNameManager = activity.userColorNameManager
|
||||
private val removedPositions: SortableIntList? = SortableIntList()
|
||||
private val requestManager = Glide.with(activity)
|
||||
private val inflater = LayoutInflater.from(activity)
|
||||
private val mediaLoader = activity.mediaLoader
|
||||
private val userColorNameManager = activity.userColorNameManager
|
||||
private val removedPositions = SortableIntList()
|
||||
|
||||
private var indices: SuggestionItem.Indices? = null
|
||||
|
||||
|
@ -319,7 +321,7 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
|||
holder.text2.visibility = View.VISIBLE
|
||||
holder.text2.text = "@${cursor.getString(indices.summary)}"
|
||||
holder.icon.clearColorFilter()
|
||||
mediaLoader.displayProfileImage(holder.icon, cursor.getString(indices.icon))
|
||||
requestManager.loadProfileImage(context, cursor.getString(indices.icon)).into(holder.icon)
|
||||
}
|
||||
VIEW_TYPE_USER_SCREEN_NAME -> {
|
||||
val holder = view.tag as UserViewHolder
|
||||
|
@ -396,7 +398,6 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
|||
}
|
||||
|
||||
private fun getActualPosition(position: Int): Int {
|
||||
if (removedPositions == null) return position
|
||||
var skipped = 0
|
||||
for (i in 0 until removedPositions.size()) {
|
||||
if (position + skipped >= removedPositions.get(i)) {
|
||||
|
@ -408,9 +409,9 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
|||
|
||||
fun addRemovedPositions(positions: IntArray) {
|
||||
for (position in positions) {
|
||||
removedPositions!!.add(getActualPosition(position))
|
||||
removedPositions.add(getActualPosition(position))
|
||||
}
|
||||
removedPositions!!.sort()
|
||||
removedPositions.sort()
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,13 @@ import android.graphics.PorterDuff.Mode
|
|||
import android.support.v4.widget.SimpleCursorAdapter
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.bumptech.glide.RequestManager
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.TwidereConstants.*
|
||||
import org.mariotaku.twidere.constant.displayProfileImageKey
|
||||
import org.mariotaku.twidere.constant.profileImageStyleKey
|
||||
import org.mariotaku.twidere.extension.loadProfileImage
|
||||
import org.mariotaku.twidere.model.SuggestionItem
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Suggestions
|
||||
|
@ -40,7 +42,7 @@ import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
|
|||
import org.mariotaku.twidere.view.ProfileImageView
|
||||
import javax.inject.Inject
|
||||
|
||||
class ComposeAutoCompleteAdapter(context: Context) : SimpleCursorAdapter(context,
|
||||
class ComposeAutoCompleteAdapter(context: Context, val requestManager: RequestManager) : SimpleCursorAdapter(context,
|
||||
R.layout.list_item_auto_complete, null, emptyArray(), intArrayOf(), 0) {
|
||||
|
||||
@Inject
|
||||
|
@ -63,7 +65,7 @@ class ComposeAutoCompleteAdapter(context: Context) : SimpleCursorAdapter(context
|
|||
profileImageStyle = preferences[profileImageStyleKey]
|
||||
}
|
||||
|
||||
override fun bindView(view: View, context: Context?, cursor: Cursor) {
|
||||
override fun bindView(view: View, context: Context, cursor: Cursor) {
|
||||
val indices = this.indices!!
|
||||
val text1 = view.findViewById(android.R.id.text1) as TextView
|
||||
val text2 = view.findViewById(android.R.id.text2) as TextView
|
||||
|
@ -77,7 +79,7 @@ class ComposeAutoCompleteAdapter(context: Context) : SimpleCursorAdapter(context
|
|||
text2.text = String.format("@%s", cursor.getString(indices.summary))
|
||||
if (displayProfileImage) {
|
||||
val profileImageUrl = cursor.getString(indices.icon)
|
||||
mediaLoader.displayProfileImage(icon, profileImageUrl)
|
||||
requestManager.loadProfileImage(context, profileImageUrl).into(icon)
|
||||
} else {
|
||||
//TODO cancel image load
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.support.v4.widget.SimpleCursorAdapter
|
|||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.bumptech.glide.RequestManager
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.sqliteqb.library.Columns
|
||||
import org.mariotaku.sqliteqb.library.Expression
|
||||
|
@ -34,6 +35,7 @@ import org.mariotaku.sqliteqb.library.OrderBy
|
|||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.constant.displayProfileImageKey
|
||||
import org.mariotaku.twidere.constant.profileImageStyleKey
|
||||
import org.mariotaku.twidere.extension.loadProfileImage
|
||||
import org.mariotaku.twidere.model.ParcelableUserCursorIndices
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.CachedUsers
|
||||
|
@ -46,9 +48,10 @@ import org.mariotaku.twidere.view.ProfileImageView
|
|||
import javax.inject.Inject
|
||||
|
||||
|
||||
class UserAutoCompleteAdapter(val context: Context) : SimpleCursorAdapter(context,
|
||||
R.layout.list_item_auto_complete, null, emptyArray(),
|
||||
intArrayOf(), 0) {
|
||||
class UserAutoCompleteAdapter(
|
||||
val context: Context,
|
||||
val requestManager: RequestManager
|
||||
) : SimpleCursorAdapter(context, R.layout.list_item_auto_complete, null, emptyArray(), intArrayOf(), 0) {
|
||||
|
||||
@Inject
|
||||
lateinit var profileImageLoader: MediaLoaderWrapper
|
||||
|
@ -70,7 +73,7 @@ class UserAutoCompleteAdapter(val context: Context) : SimpleCursorAdapter(contex
|
|||
profileImageStyle = preferences[profileImageStyleKey]
|
||||
}
|
||||
|
||||
override fun bindView(view: View, context: Context?, cursor: Cursor) {
|
||||
override fun bindView(view: View, context: Context, cursor: Cursor) {
|
||||
val indices = this.indices!!
|
||||
val text1 = view.findViewById(android.R.id.text1) as TextView
|
||||
val text2 = view.findViewById(android.R.id.text2) as TextView
|
||||
|
@ -83,7 +86,7 @@ class UserAutoCompleteAdapter(val context: Context) : SimpleCursorAdapter(contex
|
|||
text2.text = "@${cursor.getString(indices.screen_name)}"
|
||||
if (displayProfileImage) {
|
||||
val profileImageUrl = cursor.getString(indices.profile_image_url)
|
||||
profileImageLoader.displayProfileImage(icon, profileImageUrl)
|
||||
requestManager.loadProfileImage(context, profileImageUrl, profileImageStyle).into(icon)
|
||||
} else {
|
||||
//TODO cancel image load
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ fun RequestManager.loadProfileImage(context: Context, conversation: ParcelableMe
|
|||
|
||||
fun RequestManager.loadOriginalProfileImage(context: Context, user: ParcelableUser,
|
||||
@ImageShapeStyle shapeStyle: Int = ImageShapeStyle.SHAPE_CIRCLE): DrawableRequestBuilder<String> {
|
||||
val original = user.extras.profile_image_url_original?.takeIf(String::isEmpty)
|
||||
val original = user.extras.profile_image_url_original?.takeUnless(String::isEmpty)
|
||||
?: Utils.getOriginalTwitterProfileImage(user.profile_image_url)
|
||||
return configureLoadProfileImage(context, shapeStyle) { load(original) }
|
||||
}
|
||||
|
|
|
@ -147,6 +147,10 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
|||
hasPrevAccountIndicator.alpha = 0f
|
||||
hasNextAccountIndicator.alpha = 0f
|
||||
|
||||
val profileImageStyle = preferences[profileImageStyleKey]
|
||||
floatingProfileImageSnapshot.style = profileImageStyle
|
||||
accountProfileImageView.style = profileImageStyle
|
||||
|
||||
val menuInflater = SupportMenuInflater(context)
|
||||
menuInflater.inflate(R.menu.action_dashboard_timeline_toggle, accountDashboardMenu.menu)
|
||||
accountDashboardMenu.setOnMenuItemClickListener(OnMenuItemClickListener { item ->
|
||||
|
|
|
@ -41,6 +41,7 @@ import android.text.TextUtils
|
|||
import android.view.*
|
||||
import android.widget.*
|
||||
import android.widget.AbsListView.MultiChoiceModeListener
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.fragment_content_listview.*
|
||||
import org.mariotaku.ktextension.setGroupAvailability
|
||||
import org.mariotaku.sqliteqb.library.Columns
|
||||
|
@ -300,7 +301,7 @@ abstract class BaseFiltersFragment : AbsContentListViewFragment<SimpleCursorAdap
|
|||
if (autoCompleteType == AUTO_COMPLETE_TYPE_SOURCES) {
|
||||
userAutoCompleteAdapter = SourceAutoCompleteAdapter(activity)
|
||||
} else {
|
||||
val adapter = ComposeAutoCompleteAdapter(activity)
|
||||
val adapter = ComposeAutoCompleteAdapter(activity, Glide.with(this))
|
||||
adapter.accountKey = Utils.getDefaultAccountKey(activity)
|
||||
userAutoCompleteAdapter = adapter
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ class FilteredUsersFragment : BaseFiltersFragment() {
|
|||
nameFirst = preferences[nameFirstKey]
|
||||
}
|
||||
|
||||
override fun bindView(view: View, context: Context?, cursor: Cursor) {
|
||||
override fun bindView(view: View, context: Context, cursor: Cursor) {
|
||||
super.bindView(view, context, cursor)
|
||||
val indices = this.indices!!
|
||||
val icon = view.findViewById(android.R.id.icon)
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.support.v4.content.FixedAsyncTaskLoader
|
|||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import org.mariotaku.abstask.library.TaskStarter
|
||||
import org.mariotaku.ktextension.set
|
||||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
|
@ -87,9 +88,9 @@ class ParcelableUserLoader(
|
|||
val values = ParcelableUserValuesCreator.create(user)
|
||||
resolver.insert(CachedUsers.CONTENT_URI, values)
|
||||
ParcelableUserUtils.updateExtraInformation(user, details, userColorNameManager)
|
||||
val response = SingleResponse(user)
|
||||
response.extras.putParcelable(EXTRA_ACCOUNT, details)
|
||||
return response
|
||||
return SingleResponse(user).apply {
|
||||
extras[EXTRA_ACCOUNT] = details
|
||||
}
|
||||
}
|
||||
}
|
||||
val twitter = details.newMicroBlogInstance(context = context, cls = MicroBlog::class.java)
|
||||
|
@ -123,9 +124,9 @@ class ParcelableUserLoader(
|
|||
if (TextUtils.equals(UserKeyUtils.getUserHost(user), user.key.host)) {
|
||||
user.account_key = accountKey
|
||||
user.account_color = details.color
|
||||
val response = SingleResponse(user)
|
||||
response.extras.putParcelable(EXTRA_ACCOUNT, details)
|
||||
return response
|
||||
return SingleResponse(user).apply {
|
||||
extras[EXTRA_ACCOUNT] = details
|
||||
}
|
||||
}
|
||||
cur.moveToNext()
|
||||
}
|
||||
|
@ -148,8 +149,7 @@ class ParcelableUserLoader(
|
|||
twitterUser = twitter.showExternalProfile(profileUrl)
|
||||
} else {
|
||||
val id = userKey?.id
|
||||
twitterUser = TwitterWrapper.tryShowUser(twitter, id, screenName,
|
||||
details.type)
|
||||
twitterUser = TwitterWrapper.tryShowUser(twitter, id, screenName, details.type)
|
||||
}
|
||||
}
|
||||
val cachedUserValues = createCachedUser(twitterUser, profileImageSize)
|
||||
|
@ -157,9 +157,9 @@ class ParcelableUserLoader(
|
|||
val user = ParcelableUserUtils.fromUser(twitterUser, accountKey,
|
||||
profileImageSize = profileImageSize)
|
||||
ParcelableUserUtils.updateExtraInformation(user, details, userColorNameManager)
|
||||
val response = SingleResponse.Companion.getInstance(user)
|
||||
response.extras.putParcelable(EXTRA_ACCOUNT, details)
|
||||
return response
|
||||
return SingleResponse(user).apply {
|
||||
extras[EXTRA_ACCOUNT] = details
|
||||
}
|
||||
} catch (e: MicroBlogException) {
|
||||
Log.w(LOGTAG, e)
|
||||
return SingleResponse(exception = e)
|
||||
|
|
|
@ -20,14 +20,12 @@
|
|||
package org.mariotaku.twidere.util
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.ImageView
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.twidere.constant.mediaPreloadKey
|
||||
import org.mariotaku.twidere.constant.mediaPreloadOnWifiOnlyKey
|
||||
import org.mariotaku.twidere.model.ParcelableActivity
|
||||
import org.mariotaku.twidere.model.ParcelableMedia
|
||||
import org.mariotaku.twidere.model.ParcelableStatus
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.util.getActivityStatus
|
||||
|
||||
class MediaLoaderWrapper {
|
||||
|
@ -39,13 +37,6 @@ class MediaLoaderWrapper {
|
|||
private val shouldPreload: Boolean get() = preloadEnabled && (!preloadOnWifiOnly || !isNetworkMetered)
|
||||
|
||||
|
||||
fun displayOriginalProfileImage(view: ImageView, user: ParcelableUser) {
|
||||
}
|
||||
|
||||
fun displayProfileImage(view: ImageView, url: String?) {
|
||||
}
|
||||
|
||||
|
||||
fun preloadStatus(status: ParcelableStatus) {
|
||||
if (!shouldPreload) return
|
||||
preloadProfileImage(status.user_profile_image_url)
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.text.method.ArrowKeyMovementMethod
|
|||
import android.text.method.MovementMethod
|
||||
import android.util.AttributeSet
|
||||
import android.widget.AdapterView
|
||||
import com.bumptech.glide.Glide
|
||||
import org.mariotaku.chameleon.view.ChameleonMultiAutoCompleteTextView
|
||||
import org.mariotaku.twidere.adapter.ComposeAutoCompleteAdapter
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
|
@ -61,7 +62,7 @@ class ComposeEditText(
|
|||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
if (!isInEditMode && adapter == null) {
|
||||
adapter = ComposeAutoCompleteAdapter(context)
|
||||
adapter = ComposeAutoCompleteAdapter(context, Glide.with(context))
|
||||
}
|
||||
setAdapter(adapter)
|
||||
updateAccountKey()
|
||||
|
|
|
@ -174,7 +174,7 @@
|
|||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
<org.mariotaku.twidere.view.ShapedImageView
|
||||
android:id="@+id/floatingProfileImageSnapshot"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
Loading…
Reference in New Issue