filter json results into image path - android

Hello i am using MIT App Inventor 2 to make an app that runs on an old (spare) android phone to display the folder.jpg of currently playing movie (later on I also want to do that with music).
I can't filter the path to use, for example this is the result of the json:
{"id":"VideoGetItem","jsonrpc":"2.0","result":{"item":{"id":1,"label":"2012","thumbnail":"image://F%3a%5cMovies%5c2012%5cfolder.jpg/","type":"movie"}}}
I want to keep: image://F%3a%5cMovies%5c2012%5cfolder.jpg which is the dvd cover (and maybe the label: 2012 which is the title of the movie).
I tried various options like making a list but then I still get text with lot of params between '()'
Can someone help me with this?
Thanks

Use the JSON decode block together with the lookup in pairs block. As you can see, it helps to use Do it...

I have something that is doing it for me for starters.
I see a flaw but that's in Kodi(.tv) itself (I am not a fan of the library system in kodi, so I put a folder.jpg in every drawer of a movie, but sometimes kodi doesn't display it and presents me with a video preview of the movie, I have to sort that out with kodi developers)
For now I am glad I have it working,
solution picture

Related

Render image using srcset property in React Native

I am having following JSON feed from one of my Wordpress blog, and I would like to render images within the content of the blog as the JSON feed shows.
There is only one image in the feed, however you will notice one tag and within that a few srcset as well. For some reason is giving a relative URL which is no good for me to render an image outside of the Wordpress blog, however I could use the property of tag which is srcset which is providing an absolute path to the image.
Could someone suggest me how I can ignore the src of the tag and rather should be able to use srcset? The platform I am using is React Native.
<p>Can you spare a few minutes to look at some terrible and completely ridiculous life tips? Well then you’ve come to the right place!</p>\n<p>Some of them come from a sub-Reddit called /r/ShittyLifeProTips, and while they won’t actually help you to achieve much, they are at least useful when it comes to making us laugh. From using ketchup as a bookmark, to saving yourself precious time by adding toothpaste to meals, these “pro” life tips are sure to put a smile on your face while completely failing to help you in any practical way.</p>\n<p>P.S.: These tips are a joke and may be dangerous, don’t try them yourself!</p>\n<p><strong>#1 Use a toilet seat to put your plate on while watching TV</strong></p>\n<p><img class=\"alignnone size-medium wp-image-2098\" src=\"/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV-284x300.jpg\" alt=\"\" width=\"284\" height=\"300\" srcset=\"https://vinth.azurewebsites.net/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV-284x300.jpg 284w, https://vinth.azurewebsites.net/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV-545x575.jpg 545w, https://vinth.azurewebsites.net/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV.jpg 605w\" sizes=\"(max-width: 284px) 100vw, 284px\" /></p>\n<p> </p>\n

How to present parsed JSON in readable format to users?

So I have JSON, I parsed in and it's sitting there. From my code below it looks like I have put everything into an ArrayList but then what? I mean for example I need the "title" of each JSON object to be an onClick on the first page, is that possible?
Essentially my onPostExceute() is empty/not doing much. Eventually I need to separate each object into it's own page via the onlicks I'm mentioning, but I think I can do that by separating the JSONObjects...? guess I'll come to that when I can.
If I want to separate things should I even be using an ArrayList? It's just what I used for a server test I ran with different code.
Would really appreciate some help. Basically stuck at the last hurdle is how I perceive it. Maybe I'm wrong though. The logs see that the JSON is showing up as one big chunk.
Edit: Removed my code, this is more of a theory question. ListView being the best thing to go with.
yes you can make spearate arraylist for them..and can store them in diferent listviews...on google click you can open new listview showing id and link for google ..and same you can do for microsoft and your other trem.And using onItemClick is a gud option,you can easily get the index of item clicked//

Smartway to implement media in Android

I am working on an Android app, where media(audio/video/images) could be stored either internally/externally. I would be facing the following scenarios
Case I
Setting dynamically images from the random value broadcasted by the app.
Right now, I am managing it as
if(rowData.strName.equals("football")){
imageView.setImageResource(R.drawable.football);
}else if(rowData.strName.equals("chess")){
imageView.setImageResource(R.drawable.chess);
Problem As of now, I am having few records so managing else if loop in not big headache, but later it could turn out to be one.
Case II
Downloading a media from internet, saving it in external storage and loading it on an imageview as an when required
Problem Incase, the image has already been downloaded(app keeps track of downloaded image), the user ejects the card, then I plan to use
try{
}catch(FileNotFoundException e){
imageView.setImageResource(R.drawable.no_media);//media from the app
}
Case III
I will be having a listView of a category.Each Category contains certain sub-category names,their images(inbuilt & to be downloaded externally) & their description.Each sub-category has sub records with each record having its own one or image(inbuilt & to be downloaded externally),description and media files(both audio and video).
I am confused on what Collection class shall I use for this case and how to begin with? For data that is to be retrieved from the server(online), I plan to use XMLParsing. Please suggest me the best way to achieve the problem.
Wow! This is really three questions. If only I could get three times the rep :)
Case I
Use a Map to store and retrieve stuff. Saves you writing lots of if/else statements.
Map<String,Integer> drawableMap = new HashMap<String,Integer>();
drawableMap.put("football", R.drawable.football);
// Then later to retrieve...
imageView.setImageResource(drawableMap.get("football"));
Case II
OK, this seems fine. Though for most of my image loading I use existing libraries like Universal Image Loader or Volley. These may do what you need, I'm not sure.
Case III
I would take an OO approach and model the data appropriately. You don't have to choose "a" Collection class to use. Create a Category class. Create a SubCategory class. Have the Category class "have" SubCategories, etc. Take it from there.
XML parsing is fine, I'm not sure what you're expecting to be suggested. You may also like to consider JSON, a popular data format.

Save images inside webview Android SDK

Im making a simple app for some friends to use on there android phone that shows my website with images. Im using a webview to show the website inside the app. I want the users, to be able to save the actual image. Either by Hold down on the image or actually clicking a button. Been looking around on googles docs ands cant seem to find anything for this.
I haven't actually played around with this yet, but from the docs it appears you have at least two (non-deprecated) options:
getHitTestResult()
requestImageRef(Message msg)
According to the documentation you can use the first option to test for IMAGE_TYPE as result, and a url to the image is provided as well:
If a HTML::img tag is found, the HitTestResult type is set to
IMAGE_TYPE and the url is set in the "extra" field.
The second option will give you a similar result:
Request the url of the image last touched by the user. msg will be
sent to its target with a String representing the url as its object.
Not sure if these options are compatible with a 'long click' too though.
Alternatively, how did you have in mind to link clicking a button to a specific image? Depending on your solution for this, you may also be able to simply capture all loaded image resources using onLoadResource(WebView view, String url), build a list of image references and download the one that button click refers too.

Trying to pull API into LinearLayout Android APP

I am a beginner of Android apps and am using Eclipse. I have found some larger samples of pulling APIs but I cannot find a simple one to get started with. I simply want to pull from an XML file on the web (by using an API KEY) and throw it in a LinearLayout (Vertical). I can then go from there, anyone know of any? Below is a sample of my XML:
<xmldata>
<Products>
<ProductCode>ITI-GR12</ProductCode>
<ProductName>Granada 9-3/4" Narrow Rim Platter</ProductName>
<ProductPrice>64.4000</ProductPrice>
</Products>
</xmldata>
I am assuming you are looking for mechanisms which help you to parse XML and extract data from it...Voila here is a link to get you started with different ways of doing it...
http://www.ibm.com/developerworks/opensource/library/x-android/
Good luck!
your question is not easy as you will have quite a lot of programming to achieve what you want.
Here are the steps :
read your data using sax
fill a data structure of your own (build a
class, data members will be filled by
previous parsing)
build an activity, use a layout you define to
show all UI fields you think you need
to display your data
fill the content of each view using the data
structure you filled on step 2.
If you are a beginner, I suggest you first understand steps 3 and 4, having fun with UIs, then try to understand how you could download your file, parse it and fill some data class to provide content for the views.
Regards,
Stéphane

Categories

Resources