Android Question [B4X] SimpleMediaManager (SMM) - REQUEST_ZOOMIMAGEVIEW

Hi
When I Use REQUEST_ZOOMIMAGEVIEW With SimpleMediaManager like this :
Ex:
MediaManager.SetMediaWithExtra(Panel1, "https://image.link", "", CreateMap(MediaManager.REQUEST_ZOOMIMAGEVIEW: True))
And I Use image format ".png"...
I needs background color black but in realese background is white
After When i use REQUEST_BACKGROUND for change color but not work
any Idea?
 
Solution
Change to:
B4X:
Private Sub SetZoomImageViewMedia(Panel As B4XView, Url As String, BackgroundColor As Int)
    MediaManager.SetMediaWithExtra(Panel, Url, "", CreateMap(MediaManager.REQUEST_CALLBACK: Me, MediaManager.REQUEST_ZOOMIMAGEVIEW: True, _
        MediaManager.REQUEST_BACKGROUND: BackgroundColor))
    Wait For (Panel) SMM_MediaReady (Success As Boolean, Media As SMMedia)
    If Success Then
        Dim zv As ZoomImageView = Panel.GetView(0).Tag
        zv.pnlBackground.Color = BackgroundColor
        zv.mBase.Color = BackgroundColor
    End If
End Sub
Thanks now is worked!
šŸ‘

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
1. Add SMM_ZOOM to build configuration (Ctrl + B)
2. Add reference to ZoomImageView v1.05+: https://www.b4x.com/android/forum/t...-zoomable-pannable-image-view.119987/#content
3. Add REQUEST_ZOOMIMAGEVIEW to the relevant requests:

Did you added SMM_ZOOM to the buildconfiguration?
Yes I added!
I dont't have problem use SimpleMediaManager

Main:
Dim extra_1 As Map = CreateMap(MediaManager.REQUEST_BACKGROUND: xui.Color_Yellow)
MediaManager.SetMediaWithExtra(Pane1, "https://bayanbox.ir/view/6340604828595145875/AdminProfile.png","",extra_1)

Dim extra_2 As Map = CreateMap(MediaManager.REQUEST_ZOOMIMAGEVIEW: True, MediaManager.REQUEST_BACKGROUND: xui.Color_Yellow)
MediaManager.SetMediaWithExtra(Pane2, "https://bayanbox.ir/view/6340604828595145875/AdminProfile.png", "", extra_2)

I say When I use REQUEST_ZOOMIMAGEVIEW my background is white however i add REQUEST_BACKGROUND why not work? how i can do?
 

Attachments

  • 1653364182432.png
    1653364182432.png
    77.1 KB · Views: 157
Upvote 0
It happens because ZoomImageView also has a background color. You can use this code:
B4X:
Private Sub SetZoomImageViewMedia(Panel As B4XView, Url As String, BackgroundColor As Int)
    MediaManager.SetMediaWithExtra(Panel, Url, "", CreateMap(MediaManager.REQUEST_CALLBACK: Me, MediaManager.REQUEST_ZOOMIMAGEVIEW: True, _
        MediaManager.REQUEST_BACKGROUND: BackgroundColor))
    Wait For (Panel) SMM_MediaReady (Success As Boolean, Media As SMMedia)
    Dim zv As ZoomImageView = Panel.GetView(0).Tag
    zv.pnlBackground.Color = BackgroundColor
End Sub
Work in B4x :)
Is it possible to run it in the B4A? Because I Get This Error

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
java.lang.RuntimeException: java.lang.RuntimeException: Method: getBA not found in: b4a.example.main
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1719)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
Caused by: java.lang.RuntimeException: Method: getBA not found in: b4a.example.main
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:139)
at b4a.example.smmviews$ResumableSub_AddMedia.resume(smmviews.java:312)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1717)
... 7 more
 
Upvote 0
It doesn't look related to this code.
you say here
I think problem this here:
1. The callback (Me in this case) must be a class, such as a B4XPages page.
when i use you cod in b4xpage worked! but in activity b4a test and not run How I can use this cod in "Class" ?
 
Upvote 0
It happens because ZoomImageView also has a background color. You can use this code:
B4X:
Private Sub SetZoomImageViewMedia(Panel As B4XView, Url As String, BackgroundColor As Int)
    MediaManager.SetMediaWithExtra(Panel, Url, "", CreateMap(MediaManager.REQUEST_CALLBACK: Me, MediaManager.REQUEST_ZOOMIMAGEVIEW: True, _
        MediaManager.REQUEST_BACKGROUND: BackgroundColor))
    Wait For (Panel) SMM_MediaReady (Success As Boolean, Media As SMMedia)
    Dim zv As ZoomImageView = Panel.GetView(0).Tag
    zv.pnlBackground.Color = BackgroundColor
End Sub
Something is wrong!
Part of Background is not black?
How I can Do?
Screenshot_20220525-102646.png
 
Upvote 0
Tested in B4J with this code:
B4X:
    SetZoomImageViewMedia(Pane1, "https://b4x-4c17.kxcdn.com/android/forum/data/avatars/m/116/116084.jpg?1653399474", xui.Color_Red)
All the background is red. If you see different behavior in B4A then please create a small B4XPages project with the code and upload it.
 

Attachments

  • SMM_background.zip
    10.4 KB · Views: 146
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Change to:
B4X:
Private Sub SetZoomImageViewMedia(Panel As B4XView, Url As String, BackgroundColor As Int)
    MediaManager.SetMediaWithExtra(Panel, Url, "", CreateMap(MediaManager.REQUEST_CALLBACK: Me, MediaManager.REQUEST_ZOOMIMAGEVIEW: True, _
        MediaManager.REQUEST_BACKGROUND: BackgroundColor))
    Wait For (Panel) SMM_MediaReady (Success As Boolean, Media As SMMedia)
    If Success Then
        Dim zv As ZoomImageView = Panel.GetView(0).Tag
        zv.pnlBackground.Color = BackgroundColor
        zv.mBase.Color = BackgroundColor
    End If
End Sub
 
Upvote 0
Change to:
B4X:
Private Sub SetZoomImageViewMedia(Panel As B4XView, Url As String, BackgroundColor As Int)
    MediaManager.SetMediaWithExtra(Panel, Url, "", CreateMap(MediaManager.REQUEST_CALLBACK: Me, MediaManager.REQUEST_ZOOMIMAGEVIEW: True, _
        MediaManager.REQUEST_BACKGROUND: BackgroundColor))
    Wait For (Panel) SMM_MediaReady (Success As Boolean, Media As SMMedia)
    If Success Then
        Dim zv As ZoomImageView = Panel.GetView(0).Tag
        zv.pnlBackground.Color = BackgroundColor
        zv.mBase.Color = BackgroundColor
    End If
End Sub
Thanks now is worked!
šŸ‘
 
Upvote 0
Solution
Top