Hello,
I have a problem. I use http job to get the currency rates from my database like USD,EUR,CAD etc.. httpjob is executed every 30 seconds and with every jobdone i have to change the labels according to updated values.
The jobdone code is like this :
in this example , I initialize the labels at application start with this code :
because if i initialize it with every jobdone , the prices are not changing and labels are not updated , i dont know why. If i initialize like in this example there is no problem . BUT if i add one of the panel that consists the labels to another scrollview also ( please search for "look here" in the code , i add pdoviz panel to another scrollview also) the newly added labels in the panel that added to new scrollview are without any problem but the same labels in the first scrollview is gone . How can i fix this problem ?
TY
I have a problem. I use http job to get the currency rates from my database like USD,EUR,CAD etc.. httpjob is executed every 30 seconds and with every jobdone i have to change the labels according to updated values.
The jobdone code is like this :
B4X:
For i = 0 To 46
If i=0 Then
Log(txt.IndexOf("Rate Symbol"))
bas=txt.IndexOf("Rate Symbol")
Log(txt.IndexOf("/Rate"))
son=txt.IndexOf("/Rate")
son=son+6
Bitt=son
ilkyeni=txt.SubString2(bas-1,Bitt)
LogColor(ilkyeni,Colors.Blue)
yeni = ilkyeni.SubString2(ilkyeni.IndexOf($"""$$)+1,ilkyeni.IndexOf(">")-1)
LogColor(yeni,Colors.Magenta)
deger1=ilkyeni.SubString2(ilkyeni.IndexOf("<Bid>")+5,ilkyeni.IndexOf("</Bid>")-1)
'Log(deger1)
deger2=ilkyeni.SubString2(ilkyeni.IndexOf("<Ask>")+5,ilkyeni.IndexOf("</Ask>")-1)
'Log(deger2)
deger3=NumberFormat((deger1+deger2)/2,1,5)
Log(deger3)
degisim = ilkyeni.SubString2(ilkyeni.IndexOf("<Direction>")+11,ilkyeni.IndexOf("</Direction>"))
az = ilkyeni.SubString2(ilkyeni.IndexOf("<Low>")+5,ilkyeni.IndexOf("</Low>"))
LogColor(az,Colors.Blue)
cok = ilkyeni.SubString2(ilkyeni.IndexOf("<High>")+6,ilkyeni.IndexOf("</High>"))
LogColor(cok,Colors.blue)
Log(degisim)
Else
bas=txt.IndexOf2("Rate Symbol",son)
son=txt.IndexOf2("/Rate",son+6)
ilkyeni=txt.SubString2(bas-1,son)
LogColor(ilkyeni,Colors.black)
yeni = ilkyeni.SubString2(ilkyeni.IndexOf($"""$$)+1,ilkyeni.IndexOf(">")-1)
LogColor(yeni,Colors.Magenta)
deger1=ilkyeni.SubString2(ilkyeni.IndexOf("<Bid>")+5,ilkyeni.IndexOf("</Bid>")-1)
'Log(deger1)
deger2=ilkyeni.SubString2(ilkyeni.IndexOf("<Ask>")+5,ilkyeni.IndexOf("</Ask>")-1)
'Log(deger2)
deger3=NumberFormat((deger1+deger2)/2,1,5)
Log(deger3)
degisim = ilkyeni.SubString2(ilkyeni.IndexOf("<Direction>")+11,ilkyeni.IndexOf("</Direction>"))
az = ilkyeni.SubString2(ilkyeni.IndexOf("<Low>")+5,ilkyeni.IndexOf("</Low>"))
LogColor(az,Colors.Blue)
cok = ilkyeni.SubString2(ilkyeni.IndexOf("<High>")+6,ilkyeni.IndexOf("</High>"))
LogColor(cok,Colors.blue)
Log(degisim)
End If
' Dim semboldoviz(38) As Label
' Dim degisimdoviz(38) As ImageView
' Dim fiyatdoviz(38) As Label
pdoviz(i).Initialize("pdoviz")
pdoviz(i).Color=Colors.Transparent
pdoviz(i).SetBorder(0,Colors.Transparent,0)
If i=0 Then
pdoviz(i).Color=Colors.RGB(64,64,64)
Else
If pdoviz(i-1).Color = Colors.RGB(64,64,64) Then
pdoviz(i).Color=Colors.RGB(50,50,50)
Else
pdoviz(i).Color=Colors.RGB(64,64,64)
End If
End If
semboldoviz(i).Initialize("semboldoviz")
semboldoviz(i).TextColor=Colors.RGB(255,227,116)
semboldoviz(i).Text=yeni
semboldoviz(i).Font=Font.CreateNew2("HelveticaNeue-Bold",15)
' fiyatdoviz(i).Initialize("fiyatdoviz")
fiyatdoviz(i).TextColor=Colors.white
' LogColor(deger3&"/"&fiyatdoviz(i).text,Colors.Cyan)
timeryaksondur.enabled=True
lbluyari.TextColor=Colors.white
lbluyari.Color=Colors.RGB(7,255,3)
lbluyari2.TextColor=Colors.white
lbluyari2.Color=Colors.RGB(7,255,3)
lbluyari3.TextColor=Colors.white
lbluyari3.Color=Colors.RGB(7,255,3)
' degisimdoviz(i).Initialize("degisimdoviz")
If degisim="0" Then
degisimdoviz(i).Bitmap=LoadBitmap(File.DirAssets, "nokta.png")
degisimdoviz(i).Visible=True
Log("a1")
else if degisim="-1" Then
degisimdoviz(i).Bitmap=LoadBitmap(File.DirAssets, "Down-52.png")
degisimdoviz(i).Visible=True
Log("a2")
else if degisim="1" Then
degisimdoviz(i).Bitmap=LoadBitmap(File.DirAssets, "Up-52.png")
degisimdoviz(i).Visible=True
Log("a3")
Else
Log("a4")
End If
fiyatdoviz(i).Text=deger3
fiyatdoviz(i).Font=Font.CreateNew2("HelveticaNeue-Bold",15)
' dovizlow(i).Initialize("dovizlow")
dovizlow(i).TextColor=Colors.RGB(208,208,208)
dovizlow(i).Text="Low: " & az
dovizlow(i).Font=Font.CreateNew2("HelveticaNeue-Bold",13)
Log(semboldoviz(i).Text & dovizlow(i).text)
' dovizhigh(i).Initialize("dovizhigh")
dovizhigh(i).TextColor=Colors.RGB(208,208,208)
dovizhigh(i).Text="High: " & cok
dovizhigh(i).Font=Font.CreateNew2("HelveticaNeue-Bold",13)
If ilksefer= True Then ' if first time
listsecenekler.Add(yeni)
If i<=36 Then
ScrollView1.Panel.AddView(pdoviz(i),0dip,i*50dip,en,50dip)
pdoviz(i).AddView(semboldoviz(i),60dip,0,100dip,30dip)
pdoviz(i).AddView(fiyatdoviz(i),180dip,0,100dip,30dip)
pdoviz(i).AddView(dovizlow(i),60dip,20dip,100dip,30dip)
pdoviz(i).AddView(dovizhigh(i),180dip,20dip,100dip,30dip)
pdoviz(i).AddView(degisimdoviz(i),10dip,10dip,30dip,30dip)
Else
ScrollView2.Panel.AddView(pdoviz(i),0dip,(i-37)*50dip,en,50dip)
pdoviz(i).AddView(semboldoviz(i),60dip,0,100dip,30dip)
pdoviz(i).AddView(fiyatdoviz(i),180dip,0,100dip,30dip)
pdoviz(i).AddView(dovizlow(i),60dip,20dip,100dip,30dip)
pdoviz(i).AddView(dovizhigh(i),180dip,20dip,100dip,30dip)
pdoviz(i).AddView(degisimdoviz(i),10dip,10dip,30dip,30dip)
End If
Else ' look here
For t=0 To kvs.ListKeys.Size-1
If kvs.ListKeys.Get(t)=semboldoviz(i).text Then
ScrollView3.Panel.AddView(pdoviz(i),0dip,(t)*50dip,en,50dip)
pdoviz(i).AddView(semboldoviz(i),60dip,0,100dip,30dip)
pdoviz(i).AddView(fiyatdoviz(i),180dip,0,100dip,30dip)
pdoviz(i).AddView(dovizlow(i),60dip,20dip,100dip,30dip)
pdoviz(i).AddView(dovizhigh(i),180dip,20dip,100dip,30dip)
pdoviz(i).AddView(degisimdoviz(i),10dip,10dip,30dip,30dip)
imgsil(i).Initialize("imgsil")
imgsil(i).Bitmap=LoadBitmap(File.DirAssets, "Minus-48.png")
imgsil(i).Tag=semboldoviz(i).text
pdoviz(i).AddView(imgsil(i),en-60dip,13dip,20dip,20dip)
Else
End If
Next
ScrollView3.ContentWidth=ScrollView3.Width
ScrollView3.ContentHeight=50dip*kvs.ListKeys.Size-1
End If
Next
in this example , I initialize the labels at application start with this code :
B4X:
For i=0 To 69
fiyatdoviz(i).Initialize("fiyatdoviz")
dovizlow(i).Initialize("dovizlow")
dovizhigh(i).Initialize("dovizhigh")
degisimdoviz(i).Initialize("degisimdoviz")
Next
because if i initialize it with every jobdone , the prices are not changing and labels are not updated , i dont know why. If i initialize like in this example there is no problem . BUT if i add one of the panel that consists the labels to another scrollview also ( please search for "look here" in the code , i add pdoviz panel to another scrollview also) the newly added labels in the panel that added to new scrollview are without any problem but the same labels in the first scrollview is gone . How can i fix this problem ?
TY