Commit 39fc8480 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

gMerge branch 'feature/ui_response' into develop

parents e0531ec9 159bd2a0
package com.biganto.visual.roompark.conductor.dialogs.change_handler
import android.content.pm.ActivityInfo
import android.graphics.Bitmap
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ProgressBar
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.DataSource
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import com.github.chrisbanes.photoview.PhotoView
import com.google.android.material.snackbar.Snackbar
/**
......@@ -33,17 +40,41 @@ class PhotoDialogController : Controller {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val view = inflater.inflate(getLayoutId(), container, false)
val progress = view.findViewById<ProgressBar>(R.id.photo_load_progress_bar)
progress.visibility = View.VISIBLE
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)
.asBitmap()
.load(it)
// .thumbnail(model.resolutionList.lowelest()?.let { thumb ->
// Glide.with(photoPreview).load(thumb.url).diskCacheStrategy(DiskCacheStrategy.ALL)
// .centerCrop()
// })
.diskCacheStrategy(DiskCacheStrategy.ALL)
.addListener(object :RequestListener<Bitmap>{
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Bitmap>?,
isFirstResource: Boolean
): Boolean {
progress.visibility = View.INVISIBLE
Snackbar.make(view,"Ошибка при загрузке!",Snackbar.LENGTH_SHORT)
return false
}
override fun onResourceReady(
resource: Bitmap?,
model: Any?,
target: Target<Bitmap>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
progress.visibility = View.INVISIBLE
return false
}
})
.into(photoView)
}
return view
......
......@@ -28,6 +28,7 @@ class CamListViewHolder(itemView: View) : CommonViewHolder<WebCamModel>(itemView
override fun onViewBound(model: WebCamModel) {
camTitle.text = model.title
camStatus.text = if (model.streams.isNullOrEmpty()) "ОФФЛАЙН" else "ОНЛАЙН"
itemView.isEnabled = !model.streams.isNullOrEmpty()
camStatusIcon.visibility = if (model.streams.isNullOrEmpty()) View.GONE else View.VISIBLE
}
}
package com.biganto.visual.roompark.presentation.screen.web_cam
import android.content.pm.ActivityInfo
import android.net.Uri
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.core.os.bundleOf
import butterknife.BindView
import com.biganto.visual.roompark.R
......@@ -23,7 +25,6 @@ import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
import com.google.android.exoplayer2.ui.PlayerView
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory
import timber.log.Timber
import javax.inject.Inject
......@@ -50,6 +51,10 @@ class WebCamScreenController :
override fun onViewBound(v: View) {
activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
toolBar.setToolbar()
bottomNavigationController.hide()
}
......@@ -77,6 +82,12 @@ class WebCamScreenController :
}
}
override fun handleBack(): Boolean {
activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
return super.handleBack()
}
private fun render(viewState: WebCamScreenViewState.Idle){
}
......@@ -155,19 +166,17 @@ class WebCamScreenController :
playerView.player = player
val sourceUrl = viewState.camList.first{it.index == viewState.selectedCamIndex}.streams
.first().hls
val sourceUrl = viewState.camList.first{it.index == viewState.selectedCamIndex}
.streams
.last().hls
// var rtmpUrl = viewState.camList.first{it.index == viewState.selectedCamIndex}.streams
// .first().rtmp
// rtmpUrl = "rtmp://room-park.ru:1935/cam2-360/stream"
// Timber.d("source url : ${Uri.parse(rtmpUrl)}")
val mediaSource = buildMediaSource(Uri.parse(sourceUrl))
// val mediaSource = buildRtmps(Uri.parse(rtmpUrl))
Timber.d("source url : ${Uri.parse(sourceUrl)}")
Timber.d("mediaSource : $mediaSource")
player.prepare(mediaSource,true,true)
player.playWhenReady = true
Timber.d(" after all: ${player.playbackState}")
// player.seekToDefaultPosition()
}
......
......@@ -9,4 +9,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/photo_load_progress_bar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:layout_gravity="center" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout9"
android:background="#FF000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/webCamPlayerView"
android:background="#FF000000"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
......
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