Commit 9f85323d authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

share url

parent f227fe02
......@@ -2,8 +2,6 @@ package com.biganto.visual.roompark.presentation.screen.photo
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Bundle
import android.view.View
import android.view.WindowManager
......@@ -22,9 +20,6 @@ import com.biganto.visual.roompark.data.repository.file.FileModule
import com.biganto.visual.roompark.presentation.screen.photo.util.PhotoPreviewSlider
import com.biganto.visual.roompark.presentation.screen.photo.util.PhotosAdapter
import com.bluelinelabs.conductor.RouterTransaction
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.google.android.material.textview.MaterialTextView
import timber.log.Timber
import java.io.FileOutputStream
......@@ -79,41 +74,19 @@ class PhotoScreenController :
@OnClick(R.id.share_image_button)
fun onShareImage(){
val img = (photoViewPager.adapter as PhotosAdapter)
.getCurrentItem(photoViewPager.currentItem)
.resolutionList
.maxBy { it.resHeight*it.resWidth }
?.url?:""
Timber.d(" sssssssssss $img")
Glide.with(photoViewPager)
.asBitmap()
.load(img)
.into(object :CustomTarget<Bitmap>(){
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
Timber.d(" eeee $img")
val uri = writeFile("${img.hashCode()}.jpg",resource)
Timber.d(" zzz zz zz $uri")
Timber.d(" zzz zz zz ${Uri.parse(uri)}")
val shareIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_STREAM, Uri.parse(uri))
putExtra(Intent.EXTRA_SUBJECT, "subject");
putExtra(Intent.EXTRA_TITLE, "room park");
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
type = "image/jpeg";
}
startActivity(Intent.createChooser(shareIntent, resources?.getText(R.string.share_house_photo)))
}
override fun onLoadCleared(placeholder: Drawable?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
})
val imgUrl =
(photoViewPager.adapter as PhotosAdapter)
.getCurrentItem(photoViewPager.currentItem)
.resolutionList
.maxBy { it.resHeight*it.resWidth }
?.url?:""
val shareIntent = Intent()
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
shareIntent.action = Intent.ACTION_SEND
shareIntent.type = "text/plain"
shareIntent.putExtra(Intent.EXTRA_TEXT, imgUrl)
startActivity(shareIntent)
}
private fun writeFile(fileName: String?, bitmap: Bitmap): String {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment