I just install dev-labs-bg /fullscreen-video-view from GitHub and I want to set thumbnail, but the library method use only images from drawable.
val thumbnailResId = R.drawable.video_thumbnail
fullscreenVideoView.videoUrl(videoUrl)
.thumbnail(thumbnailResId)
How I can use image from URL to load into that method.Any clue or this is not postible
It's not supported. I've checked the newest API by myself and can confirm that no method that supports Bitmap or Drawable exists. Here is the snippet from the documentation as a confirmation:
This feature supports loading only drawables from the Android project. Source: https://github.com/dev-labs-bg/fullscreen-video-view#add-thumbnail
Related
I'm using Fresco library to display images in my Android app. I'd like to display some images (jpg or png) that I have set with public grants.
When I was doing quick tests, I just took any image from internet to set a URL, but when using the real ones that I need to use, I have the following url https://drive.google.com/uc?export=view&id=<>, but as it is a redirect and, once redirected, new url is not the image itself, Fresco is unable to display it.
I have tried Picasso as an alternative library, but with out any success.
I have also tried the download url for both libraries (https://drive.google.com/uc?export=download&id=<>). But no result.
Anybody knows how could it be possible to get this images? Or the only solution is to download it (using the second url) processing the object received store a bitmap of it and displaying it?
For downloading it, what should i use and how? retrofit?
Thanks in advance.
Fresco supports different network stacks. For example, you can use OkHttp with Fresco, which should follow redirects or modify the default one to allow redirects - or write your own based on them.
Guide for OkHttp: http://frescolib.org/docs/using-other-network-layers.html
Related GitHub issue: https://github.com/facebook/fresco/issues/61
I found a solution for this problem (but could be only applicable if you use Google Cloud or Google Script).
It consists on creating a doGet() service with the following code inside:
var file = DriveApp.getFileById(fileId)
return Utilities.base64Encode(file.getBlob().getBytes());
and use that base64 value in your app. With this format, Fresco can do the magic
It is not an immediate solution, and requires to do somework in other platform that is not your Android app, but it works perfectly.
Are you sure that there is no problems with your URLs?
Picasso works with direct URLs like: https://kudago.com/media/images/place/06/66/06662fda6309ce1ee9116d13bd1c66d5.jpg
Then you can download your image like:
Picasso.with(this)
.load(url)
.noFade()
.placeholder(R.drawable.placeholder_grey) //if you want to use a stub
.into(imageView, new com.squareup.picasso.Callback() {
#Override
public void onSuccess() {
//here you can operate with image after it is downloaded
}
#Override
public void onError() {
}
});
Hope it will help you.
I am using holder to set images from Parse to my image view, below is following code
holder.rank.setText(worldpopulationlist.get(position).getRank());
holder.country.setText(worldpopulationlist.get(position).getCountry());
holder.population.setText(worldpopulationlist.get(position).getPopulation());
holder.flag.setImageResource(Integer.parseInt(worldpopulationlist.get(position).getFlag()));
And below is the error given by android studio
java.lang.NumberFormatException: Invalid int: "http://listview123.herokuapp.com/parse/files/hlkhlkhyuiyemnbbmbackguyweuiyqw/10ad83c5546b993c18be84402e0f2bff_android_1.png"
You can't just say "here is the url of the image, do something"
You have to download the image and set is as the wanted resource.
For a guide look here
Or if you want to use an external library you could, like Azmat said, use Picasso
Picasso.with(context).load(imageURL).into(myImageView);
You can use Picasso to load images from link
Picasso.with(context).load(worldpopulationlist.get(position).getFlag()).into(holder.flag);
p.s: this code works if your worldpopulationlist.get(position).getFlag() returns link for file.
I don't think it's duplicating 'cause all the answers I've found were made several years ago. So, I load bitmap from URL and then do it this way:
currentView.setBackground(new BitmapDrawable(result));
...where "result" is Bitmap.
But "BitmapDrawable" is deprecated and it doesn't work from API 22 or 21.
Are there some other way of converting Bitmap to Drawable or loading drawable from URL instead of Bitmap?
As the documentation tells you - don't use the deprecated
new BitmapDrawable(result)
Instead use the API 18 version
new BitmapDrawable(getActivity().getResources(), result)
Assuming you're supporting API 18+, otherwise you need to handle both version depending on the runtime API.
Use Glide to load image from URL, Glide is a fast and efficient open source media management and image loading framework for Android that wraps media decoding, memory and disk caching, and resource pooling into a simple and easy to use interface.
Glide takes care of making scrolling any list of images as smooth as possible and also receive, resize and display remote image.
For more information refer here
Add below dependencies in build.gradle:
dependencies {
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.android.support:support-v4:19.1.0'
}
Eg project https://github.com/chrisbanes/cheesesquare
Eg usage:
#Override
public void onCreate(Bundle savedInstanceState) {
...
ImageView imageView = (ImageView) findViewById(R.id.my_image_view);
Glide.with(this).load("http://goo.gl/gEgYUd").into(imageView);
}
In the load method just pass the URL of the image and in into just pass the view, in you case currentview.
For your scenario:
Glide.with(this).load("http://goo.gl/gEgYUd").into(currentView);
A very strange behaviour, while writing code for showing GIF image in image-view.
what i am doing is
InputStream is = this.getResources().openRawResource(R.drawable.logo);
logo is gif image that is in the drawable folder.
when I write that line of code in Eclipse , image loads successfully but when I import that code on Android Studio What I am seeing is an error on R.drawable.logo
and the error is
Expected Resource of type raw
supplying the wrong type of resource identifier. For Example when calling Resources.getString(int id), You should be passing R.string.something not R.drawable.something
one code runs on Eclipse not on Android Studio
I am sure that no problem with the imports.
After doing some R&D i have found a work-around for that
and that is instead of creating drawable folder and put that image into it
create assets folder in main/src/assests and paste that image and then open Input steam.
InputStream is = context.getAssets().open("logo.gif");
that worked for me but sill dont know the answer why
InputStream is = this.getResources().openRawResource(R.drawable.logo);
was not working.
you can try using ion https://github.com/koush/ion#load-an-image-into-an-imageview is a nice library for load images and support gif from local store , resorces or from Url.
Simple solution is using Glide library
compile 'com.github.bumptech.glide:glide:4.3.1'
And Load your ImageView
Glide.with(YourActivity.this).load(R.drawable.your_gif).into(yourImageView);
I want to load an image which is located at the url "http://www.Karnatakatourism.org/mm/slide/chickmaglur_home.jpg" onto the imageview in Android.
Can anyone help me with the code to do the same?
You can use android query lib. http://code.google.com/p/android-query/wiki/ImageLoading
You just need to write
aq.id(R.id.imageview_profilee).image("your path");
You can use this one...
There many libs to do this, You can use Picasso.
Here an example of usage:
Picasso.with(context).load("http://www.karnatakatourism.org/mm/slide/chickmaglur_home.jpg").into(imageView);
Or you can use Universal Image Loader class
in which you can use by this one.
imageLoader.displayImage("http://www.karnatakatourism.org/mm/slide/chickmaglur_home.jpg", imageView, options);