Thumb and image

Prosg

Active Member
Licensed User
Longtime User
Hello,

i have some imageview (background come from internet).
url : mywebsite/thumb/image.jpg

but i want to see them in big size (url : mywebsite/bigSize/image.jpg

Here is the code

B4X:
Sub img_Click
   Dim iv As ImageView
   iv = Sender
   Dim bd As BitmapDrawable
   bd = iv.Background
   Activity2.bmp = bd.Bitmap
   StartActivity(Activity2)
End Sub

How can i do to send in Activity2 the BigSize and not the thumb ?

i try to find with iv the name of the jpg... and after use httputils but i don't have succes to have this name

if i use : iv.bitmap it's not image.jpg but android.graphics.bitmap@4285b10
 
Last edited:

Prosg

Active Member
Licensed User
Longtime User
B4X:
Sub ImageUrlDone (Url As String)
   ivs(ImageIndex).Bitmap = HttpUtils.GetBitmap(Url)
   ivs(ImageIndex).Gravity = Gravity.FILL
   ivs(ImageIndex).tag = Url
   ImageIndex = ImageIndex + 1
   'The SuccessfulUrls map holds all the successful links. We are removing this link from the list
   'to avoid dealing with this link again in ImagesJobDone
   HttpUtils.SuccessfulUrls.Remove(Url)
End Sub

I use the .tag to remember the url

so after i do this :

B4X:
Sub img_Click
   Dim iv As ImageView
   iv = Sender
   'Remplacement de l'url
   Dim myUrl As String = iv.Tag
   myUrl = myUrl.Replace ("thumb", "images")
   
   Activity2.bmp = HttpUtils.GetBitmap(myUrl) <==ERROR
   
   'Dim bd As BitmapDrawable
   'bd = iv.Background
   'Activity2.bmp = bd.Bitmap
   'StartActivity(Activity2)
End Sub

i know what is the url but i don't have success to load the new image (bigSize) in activity2

it's a black screen, the picture are not load or not load as background

it want a bitmapdrawable and i have a bitmap (HttpUtils.GetBitmap(myUrl))
 
Last edited:
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
I just understand i use httputils instead of httpUtils2 :)

I change all think and now the problem is :

ImagesJobDone return 9 ImageView of Thumbnail(small size)

B4X:
Sub ImagesJobDone (Job As HttpJob)
   If Job.Success = True Then
      ivs(ImageIndex).Bitmap = Job.GetBitmap
      ivs(ImageIndex).Gravity = Gravity.FILL
   End If
   ImageIndex = ImageIndex + 1
   If ImageIndex = 9 Then
      ProgressDialogHide
   End If
End Sub

Folder of Thumbnail: /mywebsite/thumb/image1.jpg
Folder of real size : /mywebsite/images/image1.jpg

I need to load real size images when i use Sub img_Click (replace the folder thumb by images in the url so i have to load the new image but i need to know what is the name of the image i have in sender)

B4X:
Sub img_Click
   Dim iv As ImageView
   iv = Sender
   If iv.Background Is BitmapDrawable Then
      'It will be ColorDrawable when there is no image.
      Dim bd As BitmapDrawable
      bd = iv.Background
      Dim bmp As Bitmap
      bmp = bd.Bitmap
      CallSubDelayed2(Activity2, "ShowImage", bmp)
   End If
End Sub

I think it's more easy to understand my problem now :)

ivs(ImageIndex).Tag = job. ???????? how can i have the url of the job in imagesJobDone
 
Last edited:
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
Ok i have succes to the end of my job

Have a look :

B4X:
Sub JobDone(Job As HttpJob)
   Select Job.JobName
      Case "Main page"
         HandleMainPage(Job)
      Case "ImageJob"
         ImagesJobDone(Job)         
      Case "realSizeJob"
         realSizeJobDone(Job)
   End Select
   Job.Release
End Sub


Sub realSizeJobDone(Job As HttpJob)
   Dim dBmp As BitmapDrawable
   dBmp.Initialize(Job.GetBitmap)
   Dim bmp As Bitmap
   bmp = dBmp.Bitmap
   CallSubDelayed2(Activity2, "ShowImage", bmp)
End Sub

Sub img_Click

   Dim iv As ImageView
   iv = Sender
   
   Dim tempUrl As String = iv.tag
   tempUrl = tempUrl.Replace("thumb", "images")
   
   Dim realSizeJob As HttpJob
   realSizeJob.Initialize ("realSizeJob", Me)
   realSizeJob.Download(tempUrl)
   
'   If iv.Background Is BitmapDrawable Then
'      'It will be ColorDrawable when there is no image.
'      Dim bd As BitmapDrawable
'      bd = iv.Background
'      Dim bmp As Bitmap
'      bmp = bd.Bitmap
'      CallSubDelayed2(Activity2, "ShowImage", bmp)
'   End If
End Sub

My last need is to pass the url of the image in .Tag

B4X:
Sub ImagesJobDone (Job As HttpJob)
   If Job.Success = True Then
      ivs(ImageIndex).Bitmap = Job.GetBitmap
      ivs(ImageIndex).Gravity = Gravity.FILL
      ivs(ImageIndex).Tag = "http://myWebSite/thumb/image1.jpg"
   End If
   ImageIndex = ImageIndex + 1
   If ImageIndex = 9 Then
      ProgressDialogHide
   End If
End Sub

i try this :

Dim ImageJob As HttpJob
ImageJob.Initialize("ImageJob", Me)
'ImageJob.Download(m.Group(1))
ImageJob.Download2(m.Group(1), Array As String("tagUrl", m.Group(1)))

but how to retrieve it in ?
ivs(ImageIndex).Tag = Job.?????
 
Last edited:
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
thx i edit the class and all work

thx a lot :)

sometimes i have this error : how can we debug it cause it's java ?

B4X:
Sub ImagesJobDone (Job As HttpJob)
Log("Begin : " & ImageIndex )
   If Job.Success = True Then
      ivs(ImageIndex).Bitmap = Job.GetBitmap
      ivs(ImageIndex).Gravity = Gravity.FILL
      ivs(ImageIndex).Tag = Job.myParam
   End If
Log("End : " & ImageIndex )
   ImageIndex = ImageIndex + 1

      ProgressDialogHide
End Sub

here is the log

Begin : 0


End : 0


Begin : 1


End : 1
Begin : 2


End : 2
Begin : 3
End : 3


Begin : 4


End : 4
Begin : 5


End : 5
Begin : 6
End : 6
Begin : 7
End : 7
Begin : 8


End : 8
Begin : 9


main_imagesjobdone (java line: 508)


java.lang.ArrayIndexOutOfBoundsException: length=9; index=9
at mangawallpaper.yukie.main._imagesjobdone(main.java:508)
at mangawallpaper.yukie.main._jobdone(main.java:591)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at anywheresoftware.b4a.keywords.Common$4.run(Common.java:884)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ArrayIndexOutOfBoundsException: length=9; index=9

As it begin at 0 => 9 doesn't exist :eek:

why sometimes it check 9


i resolve with that :

If Job.Success = True and imageIndex <= 8 Then

but i don't understand why 9 :(
 
Last edited:
Upvote 0
Top