Android Question "Like" Whatsapp Keyboard

Discussion in 'Android Questions' started by jotaele, Jun 17, 2015.

  1. jotaele

    jotaele Member Licensed User

    This is a PREVIEW ALFA version of a Whatsapp "Like" keyboard.

    Screenshots:

    Screenshot 1

    Screenshot 2

    Requiere this libraries:

    -msEmoji (by DonManfred): http://www.b4x.com/android/forum/threads/msemoji-v1-0-0.53787/#content
    -FontAwesome (by NJDude): http://www.b4x.com/android/forum/threads/fontawesome.53990/
    -IME (by Erel): http://www.b4x.com/android/forum/th...-keyboard-with-the-ime-library.14832/#content

    You can DONATE them if you find this usefull.

    The question is that the load of the grid of icons is very slow, and I tried:

    -Reduce the size of the picteres
    -Use an ImageView instead EmojiViewText
    -Reflection

    But its slow load. If anyone can contribute to speed the load, it might be a good keyboard.

    SOURCE CODE - Click Here (> 4Mb)

    And this is the part that load the images in a ScrollView

    Code:
    Sub PrecargaScrollView (ScrollViewTmp As ScrollView, Lista As List)

       
    Dim now As Long
       now = 
    DateTime.Now
       
    Log("TIEMPO INICIO 1: " & DateTime.Time(now))

       
    Dim NumeroIconosFila As Int
       NumeroIconosFila = (
    100%x) / 45dip
      
       
    Dim NumeroFilas As Int
       NumeroFilas = (Lista.Size / NumeroIconosFila)

       ScrollViewTmp.Initialize(
    40dip * NumeroFilas)

       
    Dim i As Int = 0
      
       
    For x = 1 To NumeroFilas '+1 Falta retocar para que la última fila, si tiene 3 iconos p.ej., funcions.
      
         
    For y = 1 To NumeroIconosFila

             EmojiTextView1.Initialize(
    "EmojiTextView1")
           EmojiTextView1.Text = Lista.Get(i) & 
    " "

           BotonTransparente.Initialize(
    "BotonTransparente")
           BotonTransparente.Color = 
    Colors.Transparent

           BotonTransparente.Tag = Lista.Get(i)
           ScrollViewTmp.Color = 
    Colors.White
           ScrollViewTmp.Panel.AddView(BotonTransparente, 
    45dip*(y-1) + 5dip40dip * (x-1) + 5dip40dip40dip)
           ScrollViewTmp.Panel.AddView(EmojiTextView1, 
    45dip*(y-1) + 5dip40dip * (x-1) + 5dip40dip40dip)
          
           EmojiTextView1.Height = 
    40dip : EmojiTextView1.Width = 40dip
           BotonTransparente.Width = 
    40dip : BotonTransparente.Height = 40dip
          
           
    '''

    '       Imagen.Initialize("Imagen")
    '       Dim Cad As String = Lista.Get(i)
    '       ScrollViewTmp.Color = Colors.White
    '       Imagen.Bitmap = CreateScaledBitmap(LoadBitmap(File.DirAssets, "imagenes/" & Cad.SubString2(1, Cad.Length -1) & ".png"), 35, 35, True)
    '       ScrollViewTmp.Panel.AddView(Imagen, 45dip*(y-1) + 5dip, 40dip * (x-1) + 5dip, 40dip, 40dip)
    '       Imagen.Tag = Lista.Get(i)
          
           
    '''
          
           i = i + 
    1
          
         
    Next

       
    Next

       now = 
    DateTime.Now
       
    Log("TIEMPO FINAL 1: " & DateTime.Time(now))

    End Sub

    Thanks
     
    KZero, MarcoRome and DonManfred like this.
  2. thedesolatesoul

    thedesolatesoul Expert Licensed User

    What is the size of the list and how long does it take to load them?
    What device are you testing on?
     
  3. jotaele

    jotaele Member Licensed User

    I attached the source code in the post.

    The list is about 900 elements ( 5 lists of 200 elements, aprox)

    The total size of the images to load is about 4 Mb

    I am testing in a Galaxy S5 Mini. Its a good device. ;)

    The load time in this device is about 4 seconds. I know that are a lot of images, but when you open whatsapp, the load time is instantaneous.
     
  4. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Your source is in a language unfortunately I cannot follow with both comments and variable names not meaning anything to me.
    I think you are loading too many images, 900 elements wont show at the same time. But again it should not be that slow.
     
    lemonisdead likes this.
  5. Peter Simpson

    Peter Simpson Well-Known Member Licensed User

    Hello @jotaele, on my N5 it takes about 1.7 seconds to load. You could always try the threading library.
     
    lemonisdead likes this.
  6. DonManfred

    DonManfred Expert Licensed User

    Whatsapp does load the icons in a recycle-grid-view. It does not load 900 images
     
    KZero and LucaMs like this.
  7. jotaele

    jotaele Member Licensed User

    TDS, I has only one comment in all the code and it's a bug. All is B4A. ;)
     
  8. jotaele

    jotaele Member Licensed User

    I think that this is not the way. Threading must process all the images and I think that no accelerate the execution.
     
  9. jotaele

    jotaele Member Licensed User

    Interesting.

    I will use this TDS library of this thread with and XmlLayoutBuilder for not repeat the resources.

    MSDynamicGridView : http://www.b4x.com/android/forum/threads/msdynamicgridview-library.49331/#content

    XmlLayoutBuilder: http://www.b4x.com/android/forum/threads/xmllayoutbuilder-load-xml-layouts.33762/


    Is the correct way?

    I am autoresponding.

    Yes, is the correct way. The keyboard loads very fast if I put the images in the MSDynamicGridView

    Thanks to @thedesolatesoul
     
    Last edited: Jun 20, 2015
  10. Prosg

    Prosg Active Member Licensed User

    i want to test but

    unknow member

    Code:
    EmojiEditText1.SelectionStart
     
Loading...