How to convert this

Post your questions and help other users.

Moderator: Martin

Post Reply
gilanxcheetz
Posts: 18
Joined: 08 Nov 2018 15:10
Contact:

How to convert this

Post by gilanxcheetz » 20 Mar 2020 16:31

anyone help me please, how to convert this https://indodax.com/api/tickers into a message dialog with format like this:

BTC-IDR
Last: Rp. 107,082,000
High: Rp. 112,503,000
Low: Rp. 95,880,000

TEN-IDR
Last: Rp. 316
High: Rp. 346
Low: Rp. 292

bla bla bla also another coin
.
im so blind in this :(
From: Redmi 5 Plus (Vince)

Micky Micky
Posts: 179
Joined: 16 Oct 2019 17:38

Re: How to convert this

Post by Micky Micky » 20 Mar 2020 20:36

Hello

This should get you going. You can see the structure and amend as required.

http://automagic4android.com/flow.php?i ... cf57e0c20f

Hope this helps

Micky
Crude but it works.

gilanxcheetz
Posts: 18
Joined: 08 Nov 2018 15:10
Contact:

Re: How to convert this

Post by gilanxcheetz » 21 Mar 2020 00:47

thank you very much :D i get it



[edited]
but how to add map with less script, this script just for 2 Coin :(
i want to add more coin but so many script
Attachments
flow_Refresher.xml
flow file
(13.11 KiB) Downloaded 817 times
Screenshot_Automagic_Premium_20200321-101013.png
adding into map manually
Screenshot_Automagic_Premium_20200321-101013.png (247.71 KiB) Viewed 17567 times
From: Redmi 5 Plus (Vince)

gilanxcheetz
Posts: 18
Joined: 08 Nov 2018 15:10
Contact:

Re: How to convert this

Post by gilanxcheetz » 21 Mar 2020 04:10

Micky Micky wrote:
20 Mar 2020 20:36
Hello

This should get you going. You can see the structure and amend as required.

http://automagic4android.com/flow.php?i ... cf57e0c20f

Hope this helps

Micky
can you help me to make it more less script to adding new map?
From: Redmi 5 Plus (Vince)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How to convert this

Post by Desmanto » 21 Mar 2020 16:30

@gilanxcheetz : Use loop. If you dig on the js variable in the debug dialog, change value, you can tap the "tickers" and see all the coins map. Loop upon this and store in other list or you can directly create the text to show. I prefer to create a temporary list or map to store the converstion first, because you can do another preprocessing before showing it, or doing some filter.

Code: Select all

js = fromJSON(response);

t = js["tickers"];

tickers = newMap();
for(i in getMapKeys(t))
  tickers[i] = newList(t[i]["last"], t[i]["high"], t[i]["low"]);
//tickers contains map | coin name : Last, High, Low

show = "";
for(i in getMapKeys(tickers))
  show = show +
"{toUpperCase(i)}\n" + 
"Last : Rp. {tickers[i][0],numberformat,#,##0.##}\n" +
"High : Rp. {tickers[i][1],numberformat,#,##0.#}\n" +
"Low : Rp. {tickers[i][2],numberformat,#,##0.##}\n\n";


//this part use the favourite, save the keyword in the fav list
fav = newList("btc_idr", "ten_idr");
showfav = "";
for(i in fav)
  showfav = showfav +
"{toUpperCase(i)}\n" + 
"Last : Rp. {tickers[i][0],numberformat,#,##0.##}\n" +
"High : Rp. {tickers[i][1],numberformat,#,##0.#}\n" +
"Low : Rp. {tickers[i][2],numberformat,#,##0.##}\n\n";
As you can see above, first I create newmap tickers. Loop upon the js and store all the needed info into this newMap.
Then loop against the new map and put the info on the {show}.

Using temporary map, we can filter out for only some coins. As shown in the favourite part.
You can also use the remove, to show every coin except the ones you don't need. You can also do some calculation and don't include the coin which have value lower than 0. But I will leave that to you first.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

gilanxcheetz
Posts: 18
Joined: 08 Nov 2018 15:10
Contact:

Re: How to convert this

Post by gilanxcheetz » 21 Mar 2020 19:56

Desmanto wrote:
21 Mar 2020 16:30
@gilanxcheetz : Use loop. If you dig on the js variable in the debug dialog, change value, you can tap the "tickers" and see all the coins map. Loop upon this and store in other list or you can directly create the text to show. I prefer to create a temporary list or map to store the converstion first, because you can do another preprocessing before showing it, or doing some filter.

Using temporary map, we can filter out for only some coins. As shown in the favourite part.
You can also use the remove, to show every coin except the ones you don't need. You can also do some calculation and don't include the coin which have value lower than 0. But I will leave that to you first.
wow.. awesome :D
thank youu !1!1!

i'll try to adding new fetature, CRUD on 'favorites' coin
mkasih bnyak :v
From: Redmi 5 Plus (Vince)

Post Reply