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

add dialog

parent 781aa274
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.RecyclerView
import butterknife.BindView
import com.biganto.visual.roompark.R
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.google.android.material.textview.MaterialTextView
/**
* 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
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val view = inflater.inflate(getLayoutId(), container, false)
recyclerView = view.findViewById(R.id.photoSizesRecyclerView)
recyclerView.adapter = PhotoSizeAdapter()
args.getParcelableArrayList<PhotoResolutionModel>(PHOTOS_KEY)?.let {
(recyclerView.adapter as PhotoSizeAdapter).setItems(it)
}
return view
}
@LayoutRes
fun getLayoutId() = R.layout.choose_size_modal_screen
var dismissActionDelegate = {
router.popCurrentController()
Unit
// args.putParcelableArrayList("sdsd", arrayListOf<PhotoModel>())
}
}
private class PhotoSizeAdapter:CommonRecyclerAdapter<PhotoSizeViewHolder,PhotoResolutionModel>(){
override val vhKlazz = PhotoSizeViewHolder::class
override fun getVhLayout(): Int = R.layout.choose_size_viewholder
}
private class PhotoSizeViewHolder(itemView: View) :CommonViewHolder<PhotoResolutionModel>(itemView){
@BindView(R.id.size_text)
lateinit var textView : MaterialTextView
override fun onViewBound(model: PhotoResolutionModel) {
textView.text = model.resName
}
}
\ No newline at end of file
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.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 =
......
......@@ -35,13 +35,13 @@
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"
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"
......
......@@ -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
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