Swipecards icon indicating copy to clipboard operation
Swipecards copied to clipboard

Image loaded, with glide, flickers

Open alexander-ignatow opened this issue 8 years ago • 3 comments

I am using the cards, that have an ImageView with the content loaded from the web/cache with glide.

When the top card is moved, I see the next card with ImageView that has a picture loaded into it.

However, once the top card goes away, adapter gets datasetchanged event and re-inflates all cards' views. That causes the next card to re-load the image and it blinks.

Any ideas how to work around this issue?

alexander-ignatow avatar Dec 15 '16 17:12 alexander-ignatow

Hi, How to add images . Can you please share the code ?

hanisha2128-droid avatar Mar 31 '20 05:03 hanisha2128-droid

Hi, How to add images . Can you please share the code ?

I do it like this. If user has an image uploaded in DB, we get the default method and load this image, orhetwise, we set user's image like default profile image.

switch (card_item.getProfileImageUrl()) {
        case "default":
                Glide.with(convertView.getContext()).load(R.mipmap.ic_launcher).into(image);
        break;
        default:
                Glide.with(convertView.getContext()).load(card_item.getProfileImageUrl()).into(image);
        break;
}

Drewsovsky avatar Mar 31 '20 07:03 Drewsovsky

Hi

I am using this but I did'nt get appropriate result . Can you check this out please .

SwipeCardsAdapter lAdapter;

ArrayList<Integer> ex1

ex1 = new ArrayList<Integer>(); ex1.add(R.drawable.image1); ex1.add(R.drawable.image2); ex1.add(R.drawable.image3); ex1.add(R.drawable.image4);

    lAdapter = new SwipeCardsAdapter(MainActivity.this, ex1);
    Log.d("images", String.valueOf(ex1));
    flingContainer.setAdapter(lAdapter);

    flingContainer.setFlingListener(new SwipeFlingAdapterView.onFlingListener() {
        @Override
        public void removeFirstObjectInAdapter() {
            // this is the simplest way to delete an object from the Adapter (/AdapterView)
            Log.d("LIST", "removed object!");
            ex1.remove(0);
            //al.remove(0);
            //arrayAdapter.notifyDataSetChanged();
            lAdapter.notifyDataSetChanged();
        }
		
		@Override
        public void onAdapterAboutToEmpty(int itemsInAdapter) {
            // Ask for more data here
            ex1.add(itemsInAdapter);
            lAdapter.notifyDataSetChanged();
            Log.d("LIST", "notified");
            i++;
        }

hanisha2128-droid avatar Apr 03 '20 10:04 hanisha2128-droid