Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
e74f9910
Commit
e74f9910
authored
Mar 13, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added callback for photo on load and failded; progressbar;
parent
e0531ec9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
4 deletions
+44
-4
PhotoDialogController.kt
...conductor/dialogs/change_handler/PhotoDialogController.kt
+35
-4
photo_viewer.xml
app/src/main/res/layout/photo_viewer.xml
+9
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/change_handler/PhotoDialogController.kt
View file @
e74f9910
package
com.biganto.visual.roompark.conductor.dialogs.change_handler
package
com.biganto.visual.roompark.conductor.dialogs.change_handler
import
android.content.pm.ActivityInfo
import
android.content.pm.ActivityInfo
import
android.graphics.Bitmap
import
android.os.Bundle
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.ProgressBar
import
androidx.annotation.LayoutRes
import
androidx.annotation.LayoutRes
import
androidx.core.os.bundleOf
import
androidx.core.os.bundleOf
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
com.bluelinelabs.conductor.Controller
import
com.bluelinelabs.conductor.Controller
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.DataSource
import
com.bumptech.glide.load.engine.DiskCacheStrategy
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.github.chrisbanes.photoview.PhotoView
import
com.google.android.material.snackbar.Snackbar
/**
/**
...
@@ -33,17 +40,41 @@ class PhotoDialogController : Controller {
...
@@ -33,17 +40,41 @@ class PhotoDialogController : Controller {
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
):
View
{
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
):
View
{
val
view
=
inflater
.
inflate
(
getLayoutId
(),
container
,
false
)
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
activity
?.
requestedOrientation
=
ActivityInfo
.
SCREEN_ORIENTATION_USER_LANDSCAPE
args
.
getString
(
PHOTO_URL_KEY
)
?.
let
{
args
.
getString
(
PHOTO_URL_KEY
)
?.
let
{
val
photoView
=
view
.
findViewById
<
PhotoView
>(
R
.
id
.
photo_frame
)
val
photoView
=
view
.
findViewById
<
PhotoView
>(
R
.
id
.
photo_frame
)
Glide
.
with
(
photoView
)
Glide
.
with
(
photoView
)
.
asBitmap
()
.
load
(
it
)
.
load
(
it
)
// .thumbnail(model.resolutionList.lowelest()?.let { thumb ->
// Glide.with(photoPreview).load(thumb.url).diskCacheStrategy(DiskCacheStrategy.ALL)
// .centerCrop()
// })
.
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
.
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
)
.
into
(
photoView
)
}
}
return
view
return
view
...
...
app/src/main/res/layout/photo_viewer.xml
View file @
e74f9910
...
@@ -9,4 +9,13 @@
...
@@ -9,4 +9,13 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"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>
</RelativeLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment