code style improvements
This commit is contained in:
parent
539f141d86
commit
e3251bc72b
|
@ -45,9 +45,6 @@ import org.mariotaku.twidere.model.util.TabArgumentsFieldConverter;
|
|||
import org.mariotaku.twidere.model.util.TabExtrasFieldConverter;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Tabs;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/3/6.
|
||||
*/
|
||||
@ParcelablePlease(allFields = false)
|
||||
@CursorObject(valuesCreator = true, tableInfo = true)
|
||||
@JsonObject
|
||||
|
|
|
@ -34,9 +34,6 @@ import org.mariotaku.twidere.model.UserKey;
|
|||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/3/6.
|
||||
*/
|
||||
@JsonObject
|
||||
public class TabArguments implements TwidereConstants {
|
||||
@JsonField(name = "account_id")
|
||||
|
|
|
@ -31,9 +31,6 @@ import org.mariotaku.twidere.annotation.CustomTabType;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/3/6.
|
||||
*/
|
||||
@JsonObject
|
||||
public abstract class TabExtras implements Parcelable {
|
||||
@CallSuper
|
||||
|
|
|
@ -22,10 +22,14 @@ package org.mariotaku.ktextension
|
|||
import java.lang.ref.WeakReference
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class WeakDelegate<T> {
|
||||
class WeakDelegate<T>(obj: T?) {
|
||||
|
||||
private var weakRef: WeakReference<T>? = null
|
||||
|
||||
init {
|
||||
weakRef = if (obj != null) WeakReference(obj) else null
|
||||
}
|
||||
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): T? {
|
||||
return weakRef?.get()
|
||||
}
|
||||
|
@ -35,4 +39,4 @@ class WeakDelegate<T> {
|
|||
}
|
||||
}
|
||||
|
||||
fun <T> weak(): WeakDelegate<T> = WeakDelegate()
|
||||
fun <T> weak(obj: T? = null): WeakDelegate<T> = WeakDelegate(obj)
|
|
@ -108,7 +108,6 @@ import org.mariotaku.twidere.view.ShapedImageView
|
|||
import org.mariotaku.twidere.view.helper.SimpleItemTouchHelperCallback
|
||||
import org.mariotaku.twidere.view.holder.compose.MediaPreviewViewHolder
|
||||
import java.io.IOException
|
||||
import java.lang.ref.WeakReference
|
||||
import java.text.Normalizer
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
@ -1920,11 +1919,10 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
|||
|
||||
private class ComposeLocationListener(activity: ComposeActivity) : LocationListener {
|
||||
|
||||
private val activityRef = WeakReference(activity)
|
||||
private val activity by weak(activity)
|
||||
|
||||
override fun onLocationChanged(location: Location) {
|
||||
val activity = activityRef.get() ?: return
|
||||
activity.setRecentLocation(ParcelableLocationUtils.fromLocation(location))
|
||||
activity?.setRecentLocation(ParcelableLocationUtils.fromLocation(location))
|
||||
}
|
||||
|
||||
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {
|
||||
|
|
|
@ -30,8 +30,8 @@ import com.bumptech.glide.RequestManager
|
|||
import com.bumptech.glide.request.animation.GlideAnimation
|
||||
import com.bumptech.glide.request.target.BaseTarget
|
||||
import com.bumptech.glide.request.target.SizeReadyCallback
|
||||
import org.mariotaku.ktextension.weak
|
||||
import org.mariotaku.twidere.R
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
class CustomEmojiSpan(
|
||||
val uri: String,
|
||||
|
@ -79,14 +79,7 @@ class CustomEmojiSpan(
|
|||
val textSize: Int
|
||||
) : BaseTarget<Bitmap>() {
|
||||
|
||||
var drawable: Drawable?
|
||||
get() = drawableRef?.get()
|
||||
private set(value) {
|
||||
drawableRef = if (value != null) WeakReference(value) else null
|
||||
textView.invalidate()
|
||||
}
|
||||
|
||||
private var drawableRef: WeakReference<Drawable>? = null
|
||||
var drawable: Drawable? by weak()
|
||||
|
||||
override fun onResourceReady(resource: Bitmap, glideAnimation: GlideAnimation<in Bitmap>) {
|
||||
drawable = BitmapDrawable(textView.resources, resource)
|
||||
|
|
Loading…
Reference in New Issue