Commit e0531ec9 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

Merge branch 'feature/photo_impr' into develop

parents 008819d4 bfc2a9e6
package com.biganto.visual.androidplayer.conductor.dialogs
package com.biganto.visual.roompark.conductor.dialogs
import android.os.Bundle
import android.view.LayoutInflater
......@@ -15,9 +15,9 @@ import com.bluelinelabs.conductor.Controller
* Created by Vladislav Bogdashkin on 09.04.2019.
*/
const val ALERT_DIALOG_MESSAGE_KEY = "BIGANTO_ALERT_MESSAGE"
const val ALERT_DIALOG_BUTTON_TEXT_KEY = "BIGANTO_ALERT_OK_BUTTON_TEXT"
const val ALERT_DIALOG_BUTTON_CANCEL_TEXT_KEY = "BIGANTO_ALERT_CANCEL_BUTTON_TEXT"
internal const val ALERT_DIALOG_MESSAGE_KEY = "BIGANTO_ALERT_MESSAGE"
internal const val ALERT_DIALOG_BUTTON_TEXT_KEY = "BIGANTO_ALERT_OK_BUTTON_TEXT"
internal const val ALERT_DIALOG_BUTTON_CANCEL_TEXT_KEY = "BIGANTO_ALERT_CANCEL_BUTTON_TEXT"
fun formBundle(message:String): Bundle {
val b = Bundle()
......@@ -40,6 +40,8 @@ fun formBundle(message:String,buttonText:String,cancelButtonText:String): Bundle
return b
}
open class AlertDialogController : Controller {
constructor():super()
......
package com.biganto.visual.roompark.conductor.dialogs
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import com.biganto.visual.roompark.conductor.dialogs.change_handler.PhotoDialogController
import com.biganto.visual.roompark.domain.model.PhotoResolutionModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.RouterTransaction
import com.google.android.material.textview.MaterialTextView
import io.reactivex.disposables.CompositeDisposable
import timber.log.Timber
/**
* Created by Vladislav Bogdashkin on 09.04.2019.
*/
internal const val PHOTOS_KEY = "CHHOSE_PHOTO_LIST_KEY"
private fun formBundle(photos: ArrayList<PhotoResolutionModel>): Bundle {
val b = Bundle()
b.putParcelableArrayList(PHOTOS_KEY,photos)
return b
}
class ChooseResolutionDialogController : Controller {
constructor(args: Bundle) : super(args)
constructor(photos: ArrayList<PhotoResolutionModel>) : super(formBundle(photos))
lateinit var recyclerView : RecyclerView
private val detachDisposable = CompositeDisposable()
override fun onDetach(view: View) {
detachDisposable.clear()
super.onDetach(view)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val view = inflater.inflate(getLayoutId(), container, false)
recyclerView = view.findViewById(R.id.photoSizesRecyclerView)
recyclerView.layoutManager =
LinearLayoutManager(activity, RecyclerView.VERTICAL, false)
recyclerView.adapter = PhotoSizeAdapter()
recyclerView.itemAnimator = null
recyclerView.addItemDecoration(
DividerItemDecoration(activity,DividerItemDecoration.VERTICAL)
)
args.getParcelableArrayList<PhotoResolutionModel>(PHOTOS_KEY)?.let {
(recyclerView.adapter as PhotoSizeAdapter).setItems(it)
}
detachDisposable.add(
(recyclerView.adapter as PhotoSizeAdapter).onItemClicked.subscribe {
Timber.d("gonna shit : $it")
router.replaceTopController(RouterTransaction.with(PhotoDialogController(it.url))
.popChangeHandler(DialogChangeHandler())
.pushChangeHandler(DialogChangeHandler())
)
})
view.findViewById<View>(R.id.cancel_button).setOnClickListener { handleBack() }
return view
}
@LayoutRes
fun getLayoutId() = R.layout.choose_size_modal_screen
override fun handleBack(): Boolean {
return router.popCurrentController()
}
}
internal class PhotoSizeAdapter:CommonRecyclerAdapter<PhotoSizeViewHolder,PhotoResolutionModel>(){
override val vhKlazz = PhotoSizeViewHolder::class
override fun getVhLayout(): Int = R.layout.choose_size_viewholder
}
internal class PhotoSizeViewHolder(itemView: View) :CommonViewHolder<PhotoResolutionModel>(itemView){
@BindView(R.id.size_text)
lateinit var textView : MaterialTextView
override fun onViewBound(model: PhotoResolutionModel) {
Timber.d("resname: ${model.resName}")
textView.text = "${model.resWidth}x${model.resHeight}"
}
}
package com.biganto.visual.roompark.conductor.dialogs
import android.os.Bundle
import com.biganto.visual.androidplayer.conductor.dialogs.AlertDialogController
/**
* Created by Vladislav Bogdashkin on 09.04.2019.
......
......@@ -3,7 +3,6 @@ package com.biganto.visual.roompark.conductor.dialogs
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import com.biganto.visual.androidplayer.conductor.dialogs.AlertDialogController
import timber.log.Timber
......
package com.biganto.visual.roompark.conductor.dialogs.change_handler
import android.content.pm.ActivityInfo
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
import com.biganto.visual.roompark.R
import com.bluelinelabs.conductor.Controller
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.github.chrisbanes.photoview.PhotoView
/**
* Created by Vladislav Bogdashkin on 09.04.2019.
*/
internal const val PHOTO_URL_KEY = "CHHOSE_PHOTO_LIST_KEY"
class PhotoDialogController : Controller {
constructor(args: Bundle) : super(args)
constructor(photoUrl: String) : super(bundleOf(PHOTO_URL_KEY to photoUrl))
lateinit var recyclerView : RecyclerView
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val view = inflater.inflate(getLayoutId(), container, false)
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
args.getString(PHOTO_URL_KEY)?.let {
val photoView = view.findViewById<PhotoView>(R.id.photo_frame)
Glide.with(photoView)
.load(it)
// .thumbnail(model.resolutionList.lowelest()?.let { thumb ->
// Glide.with(photoPreview).load(thumb.url).diskCacheStrategy(DiskCacheStrategy.ALL)
// .centerCrop()
// })
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(photoView)
}
return view
}
@LayoutRes
fun getLayoutId() = R.layout.photo_viewer
override fun handleBack(): Boolean {
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
return router.popCurrentController()
}
}
package com.biganto.visual.roompark.domain.model
import android.os.Parcel
import android.os.Parcelable
import com.biganto.visual.roompark.data.repository.db.requrey.model.GalleryPhotoEntity
import com.biganto.visual.roompark.data.repository.db.requrey.model.ImageAlbumEntity
import timber.log.Timber
......@@ -44,9 +46,8 @@ data class PhotoModel(
val description:String?,
val sort:Int,
val resolutionList:List<PhotoResolutionModel>
){
fun optimalResolution(width:Int,height:Int) =
fun optimalResolution(width:Int, height:Int) =
resolutionList
.asSequence()
.filter { it.resWidth >= width || it.resWidth >= height }
......@@ -54,7 +55,6 @@ data class PhotoModel(
.onEach { Timber.d("res filtered: ${it.resWidth} / ${it.resHeight}") }
.minBy { it.resHeight * it.resWidth }
?: resolutionList.maxBy { it.resHeight * it.resWidth }!!
}
data class PhotoResolutionModel(
......@@ -62,7 +62,35 @@ data class PhotoResolutionModel(
val url:String,
val resWidth:Int,
val resHeight:Int
)
) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readString(),
parcel.readString(),
parcel.readInt(),
parcel.readInt()
)
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(resName)
parcel.writeString(url)
parcel.writeInt(resWidth)
parcel.writeInt(resHeight)
}
override fun describeContents(): Int {
return 0
}
companion object CREATOR : Parcelable.Creator<PhotoResolutionModel> {
override fun createFromParcel(parcel: Parcel): PhotoResolutionModel {
return PhotoResolutionModel(parcel)
}
override fun newArray(size: Int): Array<PhotoResolutionModel?> {
return arrayOfNulls(size)
}
}
}
fun fromEntity(entity: ImageAlbumEntity):AlbumPreviewModel =
......
......@@ -13,6 +13,7 @@ import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.domain.model.PhotoModel
import com.biganto.visual.roompark.presentation.screen.albums.util.AlbumListAdapter
......@@ -20,8 +21,6 @@ import com.biganto.visual.roompark.presentation.screen.albums.util.AlbumsHeaderA
import com.biganto.visual.roompark.presentation.screen.photo.PhotoScreenController
import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.target.Target
......@@ -151,8 +150,8 @@ class AlbumsScreenController :
private fun render(viewState: AlbumsScreenViewState.PhotoSelected){
router.pushController(RouterTransaction.with(PhotoScreenController(viewState.photoId))
.pushChangeHandler(VerticalChangeHandler())
.popChangeHandler(FadeChangeHandler(false))
.pushChangeHandler(DialogChangeHandler())
.popChangeHandler(DialogChangeHandler())
)
}
......
......@@ -84,8 +84,9 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
@BindView(R.id.photo_preview_imageview) lateinit var photoPreview: RoundedImageView
override fun onViewBound(model: PhotoModel) {
model.resolutionList.lowelest()?.let {
model.resolutionList.lowlest()?.let {
Glide.with(itemView)
.asBitmap()
.load(it.url)
.centerCrop()
.fitCenter()
......@@ -93,5 +94,5 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
}}
}
fun List<PhotoResolutionModel>.lowelest() =
fun List<PhotoResolutionModel>.lowlest() =
this.minBy { it.resWidth * it.resHeight }
\ No newline at end of file
......@@ -2,15 +2,21 @@ package com.biganto.visual.roompark.presentation.screen.photo
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import android.widget.ImageView
import androidx.core.os.bundleOf
import androidx.viewpager2.widget.ViewPager2
import butterknife.BindView
import butterknife.OnClick
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.conductor.dialogs.ChooseResolutionDialogController
import com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
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.google.android.material.textview.MaterialTextView
import timber.log.Timber
import javax.inject.Inject
......@@ -42,6 +48,30 @@ class PhotoScreenController :
@BindView(R.id.photosPreviewSlider)
lateinit var slider: PhotoPreviewSlider
@BindView(R.id.choose_size_button)
lateinit var chooseSizeButton : ImageView
@OnClick(R.id.choose_size_button)
fun onSwitchSize(){
router.pushController(RouterTransaction.with(ChooseResolutionDialogController(ArrayList(
(photoViewPager.adapter as PhotosAdapter)
.getItem(photoViewPager.currentItem).resolutionList
)
)).pushChangeHandler(DialogChangeHandler())
.popChangeHandler(DialogChangeHandler())
)
}
override fun onAttach(view: View) {
// tempSystemUiFlag = activity?.window?.decorView?.systemUiVisibility
super.onAttach(view)
}
private var tempSystemUiFlag : Int? = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
override fun onDetach(view: View) {
// activity?.window?.decorView?.systemUiVisibility = tempSystemUiFlag?:View.SYSTEM_UI_FLAG_LAYOUT_STABLE
super.onDetach(view)
}
private fun bindRecycler() {
photoViewPager.isNestedScrollingEnabled = false
......@@ -65,6 +95,9 @@ class PhotoScreenController :
toolBar.setToolbar()
bottomNavigationController.hide()
bindRecycler()
// activity?.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
}
override fun injectDependencies() {
......@@ -129,7 +162,12 @@ class PhotoScreenController :
// (photoViewPager.adapter as PhotoViewerAdapter).setItems(arrayListOf(viewState.model))
}
override fun handleBack(): Boolean {router.popController(this); return true}
override fun handleBack(): Boolean {
activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
// activity?.window?.decorView?.systemUiVisibility = tempSystemUiFlag?:View.SYSTEM_UI_FLAG_LAYOUT_STABLE
router.popController(this)
return true
}
override fun getLayoutId(): Int = R.layout.photo_view_screen
......
......@@ -28,9 +28,10 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() {
val ret = list.map { it.resolutionList.lowelest()?.url?: error("No res urls!")}.toList()
Timber.d("$ret")
return ret
}
fun getItem(index:Int) = list[index]
fun indexById(id:Int):Int = list.indexOfFirst { it.photoId == id }
......@@ -71,7 +72,9 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
.load(photo.url)
.thumbnail(model.resolutionList.lowelest()?.let { thumb ->
Glide.with(photoPreview).load(thumb.url).diskCacheStrategy(DiskCacheStrategy.ALL)
.centerCrop()
})
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(photoPreview)
}
......
......@@ -25,8 +25,10 @@
style="@style/Header_TextView.Main_Header"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:paddingStart="16dp"
android:text="ОТКРЫТЬ\nВ ДРУГОМ РАЗМЕРЕ"
android:textAlignment="center"
android:textAlignment="viewStart"
app:layout_constraintBottom_toTopOf="@+id/include4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
......@@ -35,26 +37,32 @@
android:id="@+id/include4"
layout="@layout/horizontal_divider"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/recyclerView"
android:layout_height="1dp"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toTopOf="@+id/photoSizesRecyclerView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:id="@+id/photoSizesRecyclerView"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/materialTextView"
android:background="@color/colorPrimary"
android:paddingStart="16dp"
app:layout_constraintBottom_toTopOf="@+id/cancel_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/materialTextView"
android:id="@+id/cancel_button"
style="@style/Default_TextView.Cancel_Text"
android:layout_width="0dp"
android:layout_height="144dp"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:clickable="true"
android:gravity="center"
android:paddingBottom="44dp"
android:paddingTop="32dp"
android:paddingBottom="64dp"
android:text="ОТМЕНА"
android:textAlignment="gravity"
app:layout_constraintBottom_toBottomOf="parent"
......
......@@ -7,14 +7,15 @@
android:layout_height="wrap_content">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/textView12"
android:id="@+id/size_text"
style="@style/Default_TextView.Accent_Text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:includeFontPadding="false"
android:text="1080x1920"
android:textAlignment="viewStart"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imageView6"
app:layout_constraintStart_toStartOf="parent"
......@@ -24,8 +25,9 @@
android:id="@+id/imageView6"
android:layout_width="16dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@+id/textView12"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="@+id/size_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView12"
app:layout_constraintTop_toTopOf="@+id/size_text"
app:srcCompat="@drawable/ic_favorites" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -60,7 +60,7 @@
app:srcCompat="@drawable/iic_full_view" />
<ImageView
android:id="@+id/change_size_button"
android:id="@+id/choose_size_button"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="16dp"
......@@ -82,7 +82,7 @@
android:orientation="horizontal"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/change_size_button"
app:layout_constraintEnd_toStartOf="@+id/choose_size_button"
app:layout_constraintStart_toEndOf="@+id/show_full_button"
app:layout_constraintTop_toTopOf="@+id/guideline2"
app:layout_constraintVertical_bias="0.0" />
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000">
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/photo_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
\ No newline at end of file
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