kandi background
Explore Kits

Android-Universal-Image-Loader | flexible library for loading, caching and displaying images | Computer Vision library

 by   nostra13 Java Version: Current License: Apache-2.0

 by   nostra13 Java Version: Current License: Apache-2.0

Download this library from

kandi X-RAY | Android-Universal-Image-Loader Summary

Android-Universal-Image-Loader is a Java library typically used in Telecommunications, Media, Media, Entertainment, Artificial Intelligence, Computer Vision applications. Android-Universal-Image-Loader has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.
The great ancestor of modern image-loading libraries :) UIL aims to provide a powerful, flexible and highly customizable instrument for image loading, caching and displaying. It provides a lot of configuration options and good control over the image loading and caching process.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • Android-Universal-Image-Loader has a medium active ecosystem.
  • It has 16815 star(s) with 6276 fork(s). There are 1371 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 439 open issues and 773 have been closed. On average issues are closed in 488 days. There are 1 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of Android-Universal-Image-Loader is current.
This Library - Support
Best in #Computer Vision
Average in #Computer Vision
This Library - Support
Best in #Computer Vision
Average in #Computer Vision

quality kandi Quality

  • Android-Universal-Image-Loader has 0 bugs and 0 code smells.
This Library - Quality
Best in #Computer Vision
Average in #Computer Vision
This Library - Quality
Best in #Computer Vision
Average in #Computer Vision

securitySecurity

  • Android-Universal-Image-Loader has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • Android-Universal-Image-Loader code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
This Library - Security
Best in #Computer Vision
Average in #Computer Vision
This Library - Security
Best in #Computer Vision
Average in #Computer Vision

license License

  • Android-Universal-Image-Loader is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
This Library - License
Best in #Computer Vision
Average in #Computer Vision
This Library - License
Best in #Computer Vision
Average in #Computer Vision

buildReuse

  • Android-Universal-Image-Loader releases are not available. You will need to build from source code and install.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • It has 7521 lines of code, 794 functions and 106 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
This Library - Reuse
Best in #Computer Vision
Average in #Computer Vision
This Library - Reuse
Best in #Computer Vision
Average in #Computer Vision
Top functions reviewed by kandi - BETA

kandi has reviewed Android-Universal-Image-Loader and discovered the below as its top functions. This is intended to give you an instant insight into Android-Universal-Image-Loader implemented functionality, and help decide if they suit your requirements.

  • Round bitmap corners .
  • Completes the edit .
  • Read a line from the buffer .
  • Tries to load a bitmap .
  • Compute image size based on aspect ratio .
  • Consider the exact scale and orientation
  • Copy test image onto SD card .
  • Removes all bits from the map .
  • Get an image from the network .
  • Returns a string representation of this collection .

Android-Universal-Image-Loader Key Features

Multi-thread image loading (async or sync)

Wide customization of ImageLoader's configuration (thread executors, downloader, decoder, memory and disk cache, display image options, etc.)

Many customization options for every display image call (stub images, caching switch, decoding options, Bitmap processing and displaying, etc.)

Image caching in memory and/or on disk (device's file system or SD card)

Listening loading process (including downloading progress)

Dependency

copy iconCopydownload iconDownload
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

Acceptable URIs examples

copy iconCopydownload iconDownload
"http://site.com/image.png" // from Web
"file:///mnt/sdcard/image.png" // from SD card
"file:///mnt/sdcard/video.mp4" // from SD card (video thumbnail)
"content://media/external/images/media/13" // from content provider
"content://media/external/video/media/13" // from content provider (video thumbnail)
"assets://image.png" // from assets
"drawable://" + R.drawable.img // from drawables (non-9patch images)

Simple

copy iconCopydownload iconDownload
ImageLoader imageLoader = ImageLoader.getInstance(); // Get singleton instance

Complete

copy iconCopydownload iconDownload
// Load image, decode it to Bitmap and display Bitmap in ImageView (or any other view 
//	which implements ImageAware interface)
imageLoader.displayImage(imageUri, imageView, options, new ImageLoadingListener() {
	@Override
	public void onLoadingStarted(String imageUri, View view) {
		...
	}
	@Override
	public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
		...
	}
	@Override
	public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
		...
	}
	@Override
	public void onLoadingCancelled(String imageUri, View view) {
		...
	}
}, new ImageLoadingProgressListener() {
	@Override
	public void onProgressUpdate(String imageUri, View view, int current, int total) {
		...
	}
});

License

copy iconCopydownload iconDownload
Copyright 2011-2015 Sergey Tarasevich

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Loading Images from URL Is Producing Unexpected Results

copy iconCopydownload iconDownload
private val viewModelScope = CoroutineScope(Dispatchers.Main)

private fun initWikiService() {
    retrofit = Retrofit.Builder()
        .baseUrl("https://en.wikipedia.org/")
        .addConverterFactory(GsonConverterFactory.create())
        .build()
    wikiService = retrofit?.create(WikiService::class.java)
}

private fun initList() {
    viewModelScope.launch {
        val wikiPages = getWikiPages()
        adapter?.items = wikiPages
    }
}
private val viewModelScope = CoroutineScope(Dispatchers.Main + viewModelJob)

private suspend fun getWikiPages(): ArrayList<Item> {
    val newItems = ArrayList<Item>()

    withContext(IO) {
        ArtistData.artists.map { artist ->
            async { wikiService?.getWikiData(artist) }
        }.awaitAll().forEach { response ->
            val pages = response?.body()?.query?.pages
            pages?.let {
                for (page in pages) {
                    val value = page.value
                    val id = value.pageid?.toLong() ?: value.title.hashCode().toLong()
                    val title = value.title ?: "Unknown"
                    val url = value.thumbnail?.source
                    newItems.add(Item(id, title, url))
                }
            }
        }
    }
    return newItems
}
    fun onBind(item: Item) {
        if (item.url != null) {
            Picasso.get()
                .load(item.url)
                .resize(dimension, dimension)
                .centerCrop()
                .error(R.drawable.ic_baseline_broken_image_24)
                .into(pictureView)
        } else {
            pictureView.setImageResource(R.drawable.ic_baseline_image_24)
        }
    }
init {
    hasStableIds()
}

override fun getItemId(position: Int): Long = items[position].id
interface WikiService {
    @GET("/w/api.php?action=query&prop=pageimages&format=json&pithumbsize=250")
    suspend fun getWikiData(@Query("titles") band: String): Response<WikipediaResponse?>
}
-----------------------
private val viewModelScope = CoroutineScope(Dispatchers.Main)

private fun initWikiService() {
    retrofit = Retrofit.Builder()
        .baseUrl("https://en.wikipedia.org/")
        .addConverterFactory(GsonConverterFactory.create())
        .build()
    wikiService = retrofit?.create(WikiService::class.java)
}

private fun initList() {
    viewModelScope.launch {
        val wikiPages = getWikiPages()
        adapter?.items = wikiPages
    }
}
private val viewModelScope = CoroutineScope(Dispatchers.Main + viewModelJob)

private suspend fun getWikiPages(): ArrayList<Item> {
    val newItems = ArrayList<Item>()

    withContext(IO) {
        ArtistData.artists.map { artist ->
            async { wikiService?.getWikiData(artist) }
        }.awaitAll().forEach { response ->
            val pages = response?.body()?.query?.pages
            pages?.let {
                for (page in pages) {
                    val value = page.value
                    val id = value.pageid?.toLong() ?: value.title.hashCode().toLong()
                    val title = value.title ?: "Unknown"
                    val url = value.thumbnail?.source
                    newItems.add(Item(id, title, url))
                }
            }
        }
    }
    return newItems
}
    fun onBind(item: Item) {
        if (item.url != null) {
            Picasso.get()
                .load(item.url)
                .resize(dimension, dimension)
                .centerCrop()
                .error(R.drawable.ic_baseline_broken_image_24)
                .into(pictureView)
        } else {
            pictureView.setImageResource(R.drawable.ic_baseline_image_24)
        }
    }
init {
    hasStableIds()
}

override fun getItemId(position: Int): Long = items[position].id
interface WikiService {
    @GET("/w/api.php?action=query&prop=pageimages&format=json&pithumbsize=250")
    suspend fun getWikiData(@Query("titles") band: String): Response<WikipediaResponse?>
}
-----------------------
private val viewModelScope = CoroutineScope(Dispatchers.Main)

private fun initWikiService() {
    retrofit = Retrofit.Builder()
        .baseUrl("https://en.wikipedia.org/")
        .addConverterFactory(GsonConverterFactory.create())
        .build()
    wikiService = retrofit?.create(WikiService::class.java)
}

private fun initList() {
    viewModelScope.launch {
        val wikiPages = getWikiPages()
        adapter?.items = wikiPages
    }
}
private val viewModelScope = CoroutineScope(Dispatchers.Main + viewModelJob)

private suspend fun getWikiPages(): ArrayList<Item> {
    val newItems = ArrayList<Item>()

    withContext(IO) {
        ArtistData.artists.map { artist ->
            async { wikiService?.getWikiData(artist) }
        }.awaitAll().forEach { response ->
            val pages = response?.body()?.query?.pages
            pages?.let {
                for (page in pages) {
                    val value = page.value
                    val id = value.pageid?.toLong() ?: value.title.hashCode().toLong()
                    val title = value.title ?: "Unknown"
                    val url = value.thumbnail?.source
                    newItems.add(Item(id, title, url))
                }
            }
        }
    }
    return newItems
}
    fun onBind(item: Item) {
        if (item.url != null) {
            Picasso.get()
                .load(item.url)
                .resize(dimension, dimension)
                .centerCrop()
                .error(R.drawable.ic_baseline_broken_image_24)
                .into(pictureView)
        } else {
            pictureView.setImageResource(R.drawable.ic_baseline_image_24)
        }
    }
init {
    hasStableIds()
}

override fun getItemId(position: Int): Long = items[position].id
interface WikiService {
    @GET("/w/api.php?action=query&prop=pageimages&format=json&pithumbsize=250")
    suspend fun getWikiData(@Query("titles") band: String): Response<WikipediaResponse?>
}
-----------------------
private val viewModelScope = CoroutineScope(Dispatchers.Main)

private fun initWikiService() {
    retrofit = Retrofit.Builder()
        .baseUrl("https://en.wikipedia.org/")
        .addConverterFactory(GsonConverterFactory.create())
        .build()
    wikiService = retrofit?.create(WikiService::class.java)
}

private fun initList() {
    viewModelScope.launch {
        val wikiPages = getWikiPages()
        adapter?.items = wikiPages
    }
}
private val viewModelScope = CoroutineScope(Dispatchers.Main + viewModelJob)

private suspend fun getWikiPages(): ArrayList<Item> {
    val newItems = ArrayList<Item>()

    withContext(IO) {
        ArtistData.artists.map { artist ->
            async { wikiService?.getWikiData(artist) }
        }.awaitAll().forEach { response ->
            val pages = response?.body()?.query?.pages
            pages?.let {
                for (page in pages) {
                    val value = page.value
                    val id = value.pageid?.toLong() ?: value.title.hashCode().toLong()
                    val title = value.title ?: "Unknown"
                    val url = value.thumbnail?.source
                    newItems.add(Item(id, title, url))
                }
            }
        }
    }
    return newItems
}
    fun onBind(item: Item) {
        if (item.url != null) {
            Picasso.get()
                .load(item.url)
                .resize(dimension, dimension)
                .centerCrop()
                .error(R.drawable.ic_baseline_broken_image_24)
                .into(pictureView)
        } else {
            pictureView.setImageResource(R.drawable.ic_baseline_image_24)
        }
    }
init {
    hasStableIds()
}

override fun getItemId(position: Int): Long = items[position].id
interface WikiService {
    @GET("/w/api.php?action=query&prop=pageimages&format=json&pithumbsize=250")
    suspend fun getWikiData(@Query("titles") band: String): Response<WikipediaResponse?>
}

Community Discussions

Trending Discussions on Android-Universal-Image-Loader
  • Loading Images from URL Is Producing Unexpected Results
  • Outdated version of GitHub project loading in Android Studio
Trending Discussions on Android-Universal-Image-Loader

QUESTION

Loading Images from URL Is Producing Unexpected Results

Asked 2020-Oct-22 at 13:42

I am loading images from Wikipedia into a Grid view. For the most part this is working correctly. Because there could possible be up to 200 or more images being loaded I am try to run it in a new thread. I see a definite delay when scrolling from my Album tab to the Artist tab that is loading the images. I am also see some lag as images are still getting load while scrolling up and down the list. Also when I scroll back to the top of the list place holders that previously occupied by the default image because I am unable to get an image from Wikipedia are now occupied by images from another artist.

When I scroll back to the song list and then back to the artist list the view is reset but it still has a lot of delay when going into the artist tab.

This image is what the screen looks like when first entering the Artist tab.

enter image description here

This image is what the screen looks like after scrolling to the bottom of the list and back to the top.

enter image description here

As you can see the <unknow. and AJR have had their default image replaced.

Here is my code that I am calling to load the images from Wikipedia.

@Override
public void onBindViewHolder(@NonNull ARV holder, int position) {

    Artist artist = artistList.get(position);
    if(artist!=null) {
        holder.artistName.setText(artist.artistName);
        String bandName = artist.artistName;
        bandName = bandName.replace(' ','_');
        try {
            String imageUrl = cutImg(getUrlSource("https://en.wikipedia.org/w/api.php?action=query&titles="+bandName+"&prop=pageimages&format=json&pithumbsize=250"));
            URL url = new URL(imageUrl);
            ImageLoader.getInstance().displayImage(imageUrl, holder.artistImage,
                    new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnLoading(R.drawable.album)
                            .resetViewBeforeLoading(true).build());
        } catch (IOException e) {
            e.printStackTrace();
        }

        /*ImageLoader.getInstance().displayImage(getCoverArtPath(context,artist.id),holder.artistImage,
                new DisplayImageOptions.Builder().cacheInMemory(true).showImageOnLoading(R.drawable.album)
                        .resetViewBeforeLoading(false).build());*/
        }
}

private StringBuilder getUrlSource(String site) throws IOException {
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    URL localUrl = null;
    localUrl = new URL(site);
    URLConnection conn = localUrl.openConnection();
    BufferedReader reader = new BufferedReader(
            new InputStreamReader(conn.getInputStream()));
    String line = "";
    String html;
    StringBuilder ma = new StringBuilder();
    while ((line = reader.readLine()) != null) {
        ma.append(line);
        Log.i(ContentValues.TAG, "StringBuilder " + ma);
    }
    Log.i(ContentValues.TAG, "Final StringBuilder " + ma);
    return ma;
}

public static String cutImg(StringBuilder split){
    int start=split.indexOf("\"source\":")+new String("\"source\":\"").length();
    split.delete(0, start);
    split.delete(split.indexOf("\""), split.length());
    Log.i(ContentValues.TAG, "StringBuilder " + split);
    return split.toString();
}

Here is the code that is call the Artist Fragment.

public class ArtistFragment extends Fragment {

    int spanCount = 3; // 2 columns
    int spacing = 20; // 20px
    boolean includeEdge = true;

    private RecyclerView recyclerView;
    private ArtistAdapter adapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_artist, container, false);
        recyclerView = view.findViewById(R.id.artistFragment);
        recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 3));

        Thread t = new Thread()
        {
            public void run()
            {
                // put whatever code you want to run inside the thread here.
                new LoadData().execute("");
            }
        };

        t.start();
        return view;
    }

    public class LoadData extends AsyncTask<String, Void, String> {

        @Override
        protected String doInBackground(String... strings) {
            if(getActivity()!=null) {
                adapter=new ArtistAdapter(getActivity(),new ArtistLoader().artistList(getActivity()));
            }
            return "Executed";
        }

        @Override
        protected void onPostExecute(String s) {
            recyclerView.setAdapter(adapter);
            if(getActivity()!=null) {
                recyclerView.addItemDecoration(new GridSpacingItemDecoration(spanCount, spacing, includeEdge));
            }
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }
    }
}

I have also tried this using Picasso using the following code:

 bandName = artist.artistName;
    bandName = bandName.replace(' ','_');
    try {
           String imageUrl = cutImg(getUrlSource("https://en.wikipedia.org/w/api.php?action=query&titles="+bandName+"&prop=pageimages&format=json&pithumbsize=250"));
                    URL url = new URL(imageUrl);
                    Picasso.get().load(imageUrl).placeholder(R.drawable.album)
                            .error(R.drawable.artistdefault).into(holder.artistImage);
                } catch (IOException e) {
                    e.printStackTrace();
                }

The results are pretty much the same as when I used Android-Universal-Image-Loader. I have been try for several days to fix this, I have tried several different examples that I found on Stack overflow but none of them seem to resolve the issues I am seeing. I am hoping that someone will be able to identify what I am doing incorrectly. Thanks in advance.

ArtistFragmentconverted to Kotlin

class ArtistFragment : Fragment() {
var spanCount = 3 // 2 columns
var spacing = 20 // 20px
var includeEdge = true

var retrofit: Retrofit? = null
var wikiService: WikiService? = null
var adapter: ArtistAdapter? = null

private var recyclerView: RecyclerView? = null

private var viewModelJob = Job()
private val viewModelScope = CoroutineScope(Dispatchers.Main + viewModelJob)

private var progress_view: ProgressBar? = null

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                          savedInstanceState: Bundle?): View? {
    val view = inflater.inflate(R.layout.fragment_artist, container, false)
    recyclerView = view.findViewById(R.id.artistFragment)
    recyclerView?.setLayoutManager(GridLayoutManager(activity, 3))
    progress_view = view.findViewById(R.id.progress_view)
    initWikiService()
    initList()
    //LoadData().execute("")
    return view
}

override fun onDestroy() {
    super.onDestroy()
    viewModelJob.cancel()
}

private fun initList() {
    recyclerView!!.addItemDecoration(GridSpacingItemDecoration(spanCount, spacing, includeEdge))
    adapter = ArtistAdapter(this)
    adapter?.items = ArrayList()
    adapter?.listener = this
    recyclerView?.adapter = adapter

    viewModelScope.launch {
        progress_view.visibility = View.VISIBLE
        val wikiPages = getWikiPages()
        adapter?.items = wikiPages
        progress_view?.visibility = View.GONE
    }
}

private suspend fun getWikiPages(): ArrayList<Artist> {
    val newItems = ArrayList<Artist>()

    withContext(Dispatchers.IO) {
        ArtistData.artists.map { artist ->

            async { wikiService?.getWikiData(artist) }
        }.awaitAll().forEach { response ->
            val pages = response?.body()?.query?.pages
            pages?.let {
                for (page in pages) {
                    val value = page.value
                    val id = value.pageid?.toLong() ?: value.title.hashCode().toLong()
                    val title = value.title ?: "Unknown"
                    val url = value.thumbnail?.source
                    newItems.add(Artist(id, title, albumCount = 0, songCount = 0, artistUrl = url!!))
                }
            }
        }
    }
    return newItems
}

private fun initWikiService() {
    retrofit = Retrofit.Builder()
            .baseUrl("https://en.wikipedia.org/")
            .addConverterFactory(GsonConverterFactory.create())
            .build()
    wikiService = retrofit?.create(WikiService::class.java)
}

I believe I have resolved most of the issues I was previously seeing I am now down to the following problems:

Artist.item.map { artist -> - Not sure how this should be called, Unresolved reference: item

}.awaitAll().forEach { response -> = forEach is telling me Overload resolution ambiguity. All these functions match. public inline fun Iterable<TypeVariable(T)>.forEach(action: (TypeVariable(T)) → Unit): Unit defined in kotlin.collections public inline fun <K, V> Map<out TypeVariable(K), TypeVariable(V)>.forEach(action: (Map.Entry<TypeVariable(K), TypeVariable(V)>) → Unit): Unit defined in kotlin.collections

newItems.add(Artist(id, title, url)) - I know that the variables for the Artist Model need to go here, but when I put them there they are unresolved.

I have reworked the ArtistAdapter not sure if it is correct though.

class ArtistAdapter(private val context: ArtistFragment, private val artistList: List<Artist>?) : RecyclerView.Adapter<ArtistAdapter.ARV>() {

private var dimension: Int = 64

init {
    val density = context.resources.displayMetrics.density
    dimension = (density * 64).toInt()
    hasStableIds()
}

var items: MutableList<Artist> = ArrayList()
    set(value) {
        field = value
        notifyDataSetChanged()
    }

var listener: Listener? = null

interface Listener {
    fun onItemClicked(item: Artist)
    abstract fun ArtistAdapter(context: ArtistFragment): ArtistAdapter
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ARV {
    return ARV(LayoutInflater.from(parent.context).inflate(R.layout.artist_gride_item, parent,
            false))
}

override fun onBindViewHolder(holder: ARV, position: Int) {
    holder.onBind(getItem(position))
}

private fun getItem(position: Int): Artist = items[position]

override fun getItemId(position: Int): Long = items[position].id

override fun getItemCount(): Int {
    return artistList?.size ?: 0
}

inner class ARV(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener {

    private val artistNameView: TextView = itemView.findViewById(R.id.artistName)
    private val artistAlbumArtView: SquareCellView = itemView.findViewById(R.id.artistAlbumArt)

    fun onBind(item: Artist) {
        artistNameView.text=item.artistName

        if(item.artistURL!=null) {
            Picasso.get()
                        .load(item.artistURL)
                        .resize(dimension, dimension)
                        .centerCrop()
                        .error(R.drawable.artistdefualt)
                        .into(artistAlbumArtView)
        } else {
            artistAlbumArtView.setImageResource(R.drawable.artistdefualt)
        }
        itemView.setOnClickListener(this)
    }

    override fun onClick(view: View) {
        val artistId = artistList!![bindingAdapterPosition].id
        val fragmentManager = (context as AppCompatActivity).supportFragmentManager
        val transaction = fragmentManager.beginTransaction()
        val fragment: Fragment
        transaction.setCustomAnimations(R.anim.layout_fad_in, R.anim.layout_fad_out,
                R.anim.layout_fad_in, R.anim.layout_fad_out)
        fragment = ArtistDetailsFragment.newInstance(artistId)
        transaction.hide(context.supportFragmentManager
                .findFragmentById(R.id.main_container)!!)
        transaction.add(R.id.main_container, fragment)
        transaction.addToBackStack(null).commit()
    }
}

}

Logcat Snippet

java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or it

    s super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.art/javalib/core-oj.jar)
            at okhttp3.internal.Util.<clinit>(Util.java:87)
            at okhttp3.internal.Util.skipLeadingAsciiWhitespace(Util.java:321)
            at okhttp3.HttpUrl$Builder.parse(HttpUrl.java:1313)
            at okhttp3.HttpUrl.get(HttpUrl.java:917)
            at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:506)
            at com.rvogl.androidaudioplayer.fragments.ArtistFragment.initWikiService(ArtistFragment.kt:103)
            at com.rvogl.androidaudioplayer.fragments.ArtistFragment.onCreateView(ArtistFragment.kt:43)

ANSWER

Answered 2020-Oct-14 at 16:46

It looks to me as a known bug with Picasso. Try to load default image manually so it won't be replaced with cached one.

Update 14.10.20: I think the main problem is that you load network content in adapter in rather ineffective way. I suggest to form a list of all urls at first, leaving only image load in adapter.

Also reccomend you to use rerofit2 for network calls and something for async work instead of AsyncTask: rxJava, courutines, flow etc.

I created a sample project to load data async using retrofit2+coroutines.

In activity:

private val viewModelScope = CoroutineScope(Dispatchers.Main)

private fun initWikiService() {
    retrofit = Retrofit.Builder()
        .baseUrl("https://en.wikipedia.org/")
        .addConverterFactory(GsonConverterFactory.create())
        .build()
    wikiService = retrofit?.create(WikiService::class.java)
}

private fun initList() {
    viewModelScope.launch {
        val wikiPages = getWikiPages()
        adapter?.items = wikiPages
    }
}
private val viewModelScope = CoroutineScope(Dispatchers.Main + viewModelJob)

private suspend fun getWikiPages(): ArrayList<Item> {
    val newItems = ArrayList<Item>()

    withContext(IO) {
        ArtistData.artists.map { artist ->
            async { wikiService?.getWikiData(artist) }
        }.awaitAll().forEach { response ->
            val pages = response?.body()?.query?.pages
            pages?.let {
                for (page in pages) {
                    val value = page.value
                    val id = value.pageid?.toLong() ?: value.title.hashCode().toLong()
                    val title = value.title ?: "Unknown"
                    val url = value.thumbnail?.source
                    newItems.add(Item(id, title, url))
                }
            }
        }
    }
    return newItems
}

In viewHolder:

    fun onBind(item: Item) {
        if (item.url != null) {
            Picasso.get()
                .load(item.url)
                .resize(dimension, dimension)
                .centerCrop()
                .error(R.drawable.ic_baseline_broken_image_24)
                .into(pictureView)
        } else {
            pictureView.setImageResource(R.drawable.ic_baseline_image_24)
        }
    }

In adapter: add hasStableIds() to constructor and override getItemId method:

init {
    hasStableIds()
}

override fun getItemId(position: Int): Long = items[position].id

Retrofit Service:

interface WikiService {
    @GET("/w/api.php?action=query&prop=pageimages&format=json&pithumbsize=250")
    suspend fun getWikiData(@Query("titles") band: String): Response<WikipediaResponse?>
}

Source https://stackoverflow.com/questions/64337695

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install Android-Universal-Image-Loader

You can download it from GitHub, Maven.
You can use Android-Universal-Image-Loader like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the Android-Universal-Image-Loader component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Try Top Libraries by nostra13
Compare Computer Vision Libraries with Highest Support
Compare Computer Vision Libraries with Highest Security
Compare Computer Vision Libraries with Permissive License
Compare Computer Vision Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.