how to create gridview by using JSON images in android - android

I want to create grid view using JSON.JSON contain image urls.I am reading number of tutorials but i not getting what am want.JSON contain many images(more than 100).please help me how can i solve this issu

I can recommend a different way that works like a charm: Android Query.
You can download jar from here
AQuery androidAQuery = new AQuery(this);
As an example:
androidAQuery.id(YOUR IMAGEVIEW).image(YOUR IMAGE TO LOAD, true, true); // true, true means image caching in file and in sdcard, if you want to show images fast then keep this true.
It's very fast and accurate, and using this you can find many more features like animation when loading, getting a bitmap (if needed), etc.

Related

How to show SVG string as an Image in Xamarin?

So the simple idea is that I have SVG data as a string that I fetch from Internet.
I would like to show that as an icon in my app. Is there any way I can do this?
I have seen countless examples where SVG data is in a file located in the app's directory that is then showed but this is not what I am looking for. I literally have the data in XML format after http request and I only need to transform that to a Image or something else visible on the screen.
I have been trying to find a solution to this for hours now, so I would really appreciate some help :S
Android doesn't support svg with ImageView directly,you could display SVG with some commonly used third-party controls.
Like FFImageLoading.
Add Xamarin.FFImageLoading.Svg nuget package to platform project. Use ImageService with svg data resolver for displaying svg images.
For Android:
<ImageView
android:id="#+id/image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
then use like:
var svgString = #"<svg><rect width=""30"" height=""30"" style=""fill:blue"" /></svg>";
ImageView imageView = FindViewById<ImageView>(Resource.Id.image_view);
ImageService.Instance
.LoadString(svgString)
.LoadingPlaceholder(placeHolderPath)
.WithCustomDataResolver(new SvgDataResolver(64, 0, true))
.WithCustomLoadingPlaceholderDataResolver(new SvgDataResolver(64, 0, true))
.Into(imageView);

How to reduce the time for video thumbnail

So I am displaying video files from specific folder when the folder is selected but in the video list I am showing file name with the video thumbnail and that's where the problem starts i am using this way to get the thumb
Bitmap bmThumbnail = ThumbnailUtils.
extractThumbnail(ThumbnailUtils.createVideoThumbnail(info.getFilename(),
MediaStore.Video.Thumbnails.MINI_KIND), 60, 60);
if(bmThumbnail != null) {
imageView.setImageBitmap(bmThumbnail);}
and even if I don't set the bitmap or not the process is taking way too much time to open the new fragment whereas just displaying the name is smooth if I call the following bitmap it takes around 6-7 sec to display the list. The following thing are happening in the adapter as I test the app in adapter then recycler view
so I would like to know what is the best way to do it .
For using image loader i need the url which is not there as i am getting the album art using the file url but it will not produce the album art url directly.
Dealing with images and videos like that takes time. Particularly when dealing with a large group of them. It's unlikely you can speed up the operation but you can make it so your application doesn't have to wait for it by sending it to the background. I recommend Kotlin coroutines if you are up for converting to Kotlin. Otherwise I recommend making a thumbnail work manager
public class VideoThumbnailWorker extends Worker {
}

Android OutOfMemory

What is my Problem (KISS)?
After showing the 3rd Image in Detail my App crashes cause OutOfMemory
Background information about my App:
I made an offline Supermarket. All products are shown in a ListView.
All Images I use are stored as String (Uri from every Image) in a sqlite Database by SugarORM.
The ListView element got a ArrayAdapter where the Information for each Item in the ListView is set.
Like this:
ImageView imageView = (ImageView) rowView.findViewById(R.id.productimage);
Handler handler = new Handler();
handler.post(new Runnable() {
#Override
public void run() {
imageView.setImageURI(productList.get(position).getPictureUri());
handler.removeCallbacks(this);
}
});
My Intention was, to load the Images in the Background to Click on it, even before the Image is loaded (But it did'nt work for me :/ The Image is Shown, but I cant click on any other View Element while Loading the Image).
The "getPictureUri" gets the URI from the Picture that the Admin has choosen for the product with the following Code:
Intent pickPhoto = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(pickPhoto,1);
AndroidManifest.xml
android:hardwareAccelerated="false"
android:largeHeap="true"
I extend only from "AppCompatActivity" (Needed for Toolbar). Meaning of this: I don't use "Activity" even once.
Could anyone give me a good advice, how to clear the cached Images (I think this might be the Problem) and besides, maybe one of you got the Time to help me with my "Image Async Loading while you are able to move freely in your app" Problem.
Using setImageUri() is rather intensive on memory, especially when trying to load large bitmaps from a local resource. Instead, use tried and true solutions like Picasso or Glide for any/all image loading tasks. The libraries will work offline, can definitely load images from URIs pointing to a local resource and would most likely solve all your memory issues with image loading.

How to load image from SD card using Picasso library

i need to load images from the Sd card into gridview.
For efficiency i'm using Picasso Library
Picasso.with(activity).load(images.get(position).getDataPath())
.resize(96, 96).centerCrop().into(viewHolder.image);
I used the following code in the adapter. unfortunately m unable to see any images
so please can any one help.
Note
And also can anyone suggest any efficient image loading library to load the images from the sd card.
Requirement
I dont to load the image every time when scrolling. If it is already loaded dont load the image on scrolling
To load the file you need to convert it to a uri first
Uri uri = Uri.fromFile(new File(images.get(position).getDataPath()));
Picasso.with(activity).load(uri)
.resize(96, 96).centerCrop().into(viewHolder.image);
Requirement I dont to load the image every time when scrolling. If it
is already loaded dont load the image on scrolling
Picasso is excellent for this
In Picasso version 2.5.2, you need to pass a File as argument to load method, so the image can be loaded as:
Picasso.with(context).load(new File(images.get(position).getDataPath()))
.resize(96, 96).centerCrop().into(viewHolder.image);
I didn't want to create a new File because if the path was already obtained from an existing file, there is no need for a new object (want to see the already existing picture in the device).
According to Picasso docs you have to do something like this:
file:///android_asset/DvpvklR.png
So I used to have:
/storage/sdcard/Pictures/findyoursport/yoursport_1482358052384.jpeg
Prepending: file:// did the trick

do i need to load jpg file for flex air mobile projects like as3?

In a typical as3 or flex project, after loading xml file, i load jpg files (thumbnails etc) manually, so i can use them in sprites / movie clips etc..
currently i am working on air mobile project. and i am attempting to load some thumnails(jpg) file to list view (spark) and using custom item renderer.
itemrenderer has an spark image component in it. and its data property is set to Image object.
i can check that image files do exists in file application directory.
do i need to load all those thumbnails in memory. then use them?
image object will autoload source file object?? once assigned?
do i have to tell it explicitly to load file object? what events should i use to amke sure , image file object is loaded.?
any ideas?
thanks in advance.
Spark images are really easy to work with. All you need is a url.
<s:Image source="http://someimagesite.com/someimage.png" width="100%" height="100%" />
You can also use bitmap data or even embed directly into the source tag.
[Embed(source="image.png")] private var myImage:Class
mySparkImage.source = new myImage() as BitmapData;
<s:Image source="#Embed('image.png')" />
Take a look:
http://help.adobe.com/en_US/flex/using/WSc5cd04c102ae3e97-33ad5caa12c719dc7c8-8000.html

Categories

Resources