Created
April 14, 2018 20:21
-
-
Save YuriDenison/2be7fa1e4a526b67c209dce659ba331b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FrescoSphericalPanoramaView(context: Context, attrs: AttributeSet) : SphericalPanoramaView(context: Context, attrs: AttributeSet) { | |
private val multiDraweeHolder: MultiDraweeHolder<GenericDraweeHierarchy> = MultiDraweeHolder() | |
fun bindTo(tileUris: List<Uri>) = post { | |
multiDraweeHolder.clear() | |
val imagesSetter = getImagesSetter(...) | |
tileUris.forEachIndexed { index, uri -> | |
val holder = DraweeHolder.create(GenericDraweeHierarchyBuilder(resources).build(), context) | |
val imageRequest = ImageRequestBuilder.newBuilderWithSource(uri) | |
.setPostprocessor(object : BasePostprocessor() { | |
override fun process(bitmap: Bitmap) { | |
imagesSetter.setImageToSector(index, bitmap) | |
} | |
}) | |
.build() | |
holder.controller = Fresco.newDraweeControllerBuilder() | |
.setOldController(holder.controller) | |
.setImageRequest(imageRequest) | |
.build() | |
holder.topLevelDrawable.callback = this | |
multiDraweeHolder.add(holder) | |
} | |
} | |
@SuppressLint("MissingSuperCall") | |
override fun verifyDrawable(who: Drawable): Boolean = multiDraweeHolder.verifyDrawable(who) | |
public override fun onDetachedFromWindow() { | |
super.onDetachedFromWindow() | |
multiDraweeHolder.onDetach() | |
} | |
override fun onStartTemporaryDetach() { | |
super.onStartTemporaryDetach() | |
multiDraweeHolder.onDetach() | |
} | |
public override fun onAttachedToWindow() { | |
super.onAttachedToWindow() | |
multiDraweeHolder.onAttach() | |
} | |
override fun onFinishTemporaryDetach() { | |
super.onFinishTemporaryDetach() | |
multiDraweeHolder.onAttach() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment