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 ...@@ -2,8 +2,6 @@ package com.biganto.visual.roompark.presentation.screen.photo
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
...@@ -22,9 +20,6 @@ import com.biganto.visual.roompark.data.repository.file.FileModule ...@@ -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.PhotoPreviewSlider
import com.biganto.visual.roompark.presentation.screen.photo.util.PhotosAdapter import com.biganto.visual.roompark.presentation.screen.photo.util.PhotosAdapter
import com.bluelinelabs.conductor.RouterTransaction 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 com.google.android.material.textview.MaterialTextView
import timber.log.Timber import timber.log.Timber
import java.io.FileOutputStream import java.io.FileOutputStream
...@@ -79,41 +74,19 @@ class PhotoScreenController : ...@@ -79,41 +74,19 @@ class PhotoScreenController :
@OnClick(R.id.share_image_button) @OnClick(R.id.share_image_button)
fun onShareImage(){ fun onShareImage(){
val imgUrl =
val img = (photoViewPager.adapter as PhotosAdapter) (photoViewPager.adapter as PhotosAdapter)
.getCurrentItem(photoViewPager.currentItem) .getCurrentItem(photoViewPager.currentItem)
.resolutionList .resolutionList
.maxBy { it.resHeight*it.resWidth } .maxBy { it.resHeight*it.resWidth }
?.url?:"" ?.url?:""
Timber.d(" sssssssssss $img") val shareIntent = Intent()
Glide.with(photoViewPager) shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.asBitmap() shareIntent.action = Intent.ACTION_SEND
.load(img) shareIntent.type = "text/plain"
.into(object :CustomTarget<Bitmap>(){ shareIntent.putExtra(Intent.EXTRA_TEXT, imgUrl)
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) { startActivity(shareIntent)
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.
}
})
} }
private fun writeFile(fileName: String?, bitmap: Bitmap): String { 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