AndroidImageSlider icon indicating copy to clipboard operation
AndroidImageSlider copied to clipboard

Disable caching

Open mayank250004 opened this issue 9 years ago • 2 comments

how to disable caching in slider so images can not saved in cache??

mayank250004 avatar May 10 '16 08:05 mayank250004

----I use this methode in fragment to clear memory cache and disc cache ------

with demo example:

    HashMap<String,String> url_maps = new HashMap<String, String>();
    url_maps.put("Hannibal", "http://static2.hypable.com/wp-content/uploads/2013/12/hannibal-season-2-release-date.jpg");
    url_maps.put("Big Bang Theory", "http://tvfiles.alphacoders.com/100/hdclearart-10.png");
    url_maps.put("House of Cards", "http://cdn3.nflximg.net/images/3093/2043093.jpg");
    url_maps.put("Game of Thrones", "http://images.boomsbeat.com/data/images/full/19640/game-of-thrones-season-4-jpg.jpg");

    HashMap<String,Integer> file_maps = new HashMap<String, Integer>();
    file_maps.put("Hannibal",R.drawable.hannibal);
    file_maps.put("Big Bang Theory",R.drawable.bigbang);
    file_maps.put("House of Cards",R.drawable.house);
    file_maps.put("Game of Thrones", R.drawable.game_of_thrones);

add this

// to clear diskcache and memory cache deleteDirectoryTree(getContext().getCacheDir()); PicassoTools.clearCache(Picasso.with(getContext()));

-----then add---

public void deleteDirectoryTree(File fileOrDirectory) {
    if (fileOrDirectory.isDirectory()) {
        for (File child : fileOrDirectory.listFiles()) {
            deleteDirectoryTree(child);
        }
    }

    fileOrDirectory.delete();
}

----next, add new package ---

package com.squareup.picasso;

/**

  • Created by fms on 16/07/2016. */ public class PicassoTools {

    public static void clearCache (Picasso p) { p.cache.clear(); } }

andrew73545 avatar Jul 16 '16 01:07 andrew73545

onCreate(savedInstanceState){
     ...
     deleteDirectoryTree(getContext().getCacheDir());
}
public void deleteDirectoryTree(File fileOrDirectory) {
    if (fileOrDirectory.isDirectory()) {
        for (File child : fileOrDirectory.listFiles()) {
            deleteDirectoryTree(child);
        }
    }

    fileOrDirectory.delete();
}

using this on current activity that using slider will solve the issue.. thank u...

vai21 avatar Jan 02 '19 13:01 vai21