{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/fresco/issues/280","labels_url":"https://api.github.com/repos/facebook/fresco/issues/280/labels{/name}","comments_url":"https://api.github.com/repos/facebook/fresco/issues/280/comments","events_url":"https://api.github.com/repos/facebook/fresco/issues/280/events","html_url":"https://github.com/facebook/fresco/issues/280","id":77463415,"number":280,"title":"not found cache file","user":{"login":"tqzym","id":5967427,"avatar_url":"https://avatars.githubusercontent.com/u/5967427?v=3","gravatar_id":"","url":"https://api.github.com/users/tqzym","html_url":"https://github.com/tqzym","followers_url":"https://api.github.com/users/tqzym/followers","following_url":"https://api.github.com/users/tqzym/following{/other_user}","gists_url":"https://api.github.com/users/tqzym/gists{/gist_id}","starred_url":"https://api.github.com/users/tqzym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tqzym/subscriptions","organizations_url":"https://api.github.com/users/tqzym/orgs","repos_url":"https://api.github.com/users/tqzym/repos","events_url":"https://api.github.com/users/tqzym/events{/privacy}","received_events_url":"https://api.github.com/users/tqzym/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/fresco/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-05-18T02:20:11Z","updated_at":"2015-05-20T08:22:05Z","closed_at":null,"body":"    int MAX_MEMORY_CACHE_SIZE = 5*1024*1024;\r\n    private void initFresco(){\r\n        \r\n        int maxHeapSize = (int) Runtime.getRuntime().maxMemory();\r\n        int use = ((maxHeapSize/4)/1024/1024);\r\n        android.util.Log.d(TAG,\"use M:\"+use);\r\n        \r\n        String diskCachePath = Environment.getExternalStorageDirectory() + \"/haha/\";\r\n        File diskCacheDir = new File(diskCachePath);\r\n        \r\n        ImagePipelineConfig.Builder builder = ImagePipelineConfig.newBuilder(this);\r\n        final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(\r\n                MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache\r\n                Integer.MAX_VALUE,                     // Max entries in the cache\r\n                MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue\r\n                Integer.MAX_VALUE,                     // Max length of eviction queue\r\n                Integer.MAX_VALUE);                    // Max cache entry size\r\n        builder.setBitmapMemoryCacheParamsSupplier(\r\n                    new Supplier<MemoryCacheParams>() {\r\n                      public MemoryCacheParams get() {\r\n                        return bitmapCacheParams;\r\n                      }\r\n                    })\r\n                .setMainDiskCacheConfig(\r\n                    DiskCacheConfig.newBuilder()\r\n                        .setBaseDirectoryPath(diskCacheDir)\r\n                        .setBaseDirectoryName(\"tqtest\")\r\n                        .setMaxCacheSize(40 * ByteConstants.MB)\r\n                        .build());\r\n        ImagePipelineConfig config = builder.build();\r\n        Fresco.initialize(this,config);\r\n\r\nat \"Environment.getExternalStorageDirectory() + \"/haha/tqtest\" ， not found cache file ??\r\n    "},"comment":{"url":"https://api.github.com/repos/facebook/fresco/issues/comments/103806002","html_url":"https://github.com/facebook/fresco/issues/280#issuecomment-103806002","issue_url":"https://api.github.com/repos/facebook/fresco/issues/280","id":103806002,"user":{"login":"tqzym","id":5967427,"avatar_url":"https://avatars.githubusercontent.com/u/5967427?v=3","gravatar_id":"","url":"https://api.github.com/users/tqzym","html_url":"https://github.com/tqzym","followers_url":"https://api.github.com/users/tqzym/followers","following_url":"https://api.github.com/users/tqzym/following{/other_user}","gists_url":"https://api.github.com/users/tqzym/gists{/gist_id}","starred_url":"https://api.github.com/users/tqzym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tqzym/subscriptions","organizations_url":"https://api.github.com/users/tqzym/orgs","repos_url":"https://api.github.com/users/tqzym/repos","events_url":"https://api.github.com/users/tqzym/events{/privacy}","received_events_url":"https://api.github.com/users/tqzym/received_events","type":"User","site_admin":false},"created_at":"2015-05-20T08:22:05Z","updated_at":"2015-05-20T08:22:05Z","body":"below is all code: \r\npackage tq.test;\r\n\r\nimport java.io.File;\r\nimport java.util.ArrayList;\r\n\r\nimport android.app.Activity;\r\nimport android.content.ContentResolver;\r\nimport android.database.Cursor;\r\nimport android.net.Uri;\r\nimport android.os.Bundle;\r\nimport android.os.Environment;\r\nimport android.provider.MediaStore;\r\nimport android.util.DisplayMetrics;\r\nimport android.view.View;\r\nimport android.view.ViewGroup;\r\nimport android.widget.AbsListView.LayoutParams;\r\nimport android.widget.BaseAdapter;\r\nimport android.widget.GridView;\r\n\r\nimport com.example.test.R;\r\nimport com.facebook.cache.disk.DiskCacheConfig;\r\nimport com.facebook.common.internal.Supplier;\r\nimport com.facebook.common.util.ByteConstants;\r\nimport com.facebook.drawee.backends.pipeline.Fresco;\r\nimport com.facebook.drawee.view.SimpleDraweeView;\r\nimport com.facebook.imagepipeline.cache.MemoryCacheParams;\r\nimport com.facebook.imagepipeline.core.ImagePipelineConfig;\r\n\r\npublic class MainActivity extends Activity{\r\n    \r\n    String TAG = \"tq\";\r\n    ArrayList<String> data;\r\n    public String[] STORE_IMAGES = {\r\n        MediaStore.Images.Media._ID,\r\n        MediaStore.Images.Media.DATA\r\n    };\r\n    \r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n        initFresco();\r\n        initData();\r\n        initView();\r\n    }\r\n    \r\n    \r\n    int MAX_MEMORY_CACHE_SIZE = 5*1024*1024;\r\n    private void initFresco(){\r\n        \r\n        int maxHeapSize = (int) Runtime.getRuntime().maxMemory();\r\n        int use = ((maxHeapSize/4)/1024/1024);\r\n        android.util.Log.d(TAG,\"use M:\"+use);\r\n        \r\n        String diskCachePath = Environment.getExternalStorageDirectory() + \"/haha/\";\r\n        File diskCacheDir = new File(diskCachePath);\r\n        \r\n        ImagePipelineConfig.Builder builder = ImagePipelineConfig.newBuilder(this);\r\n        final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(\r\n                MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache\r\n                Integer.MAX_VALUE,                     // Max entries in the cache\r\n                MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue\r\n                Integer.MAX_VALUE,                     // Max length of eviction queue\r\n                Integer.MAX_VALUE);                    // Max cache entry size\r\n        builder\r\n//        .setBitmapMemoryCacheParamsSupplier(\r\n//                    new Supplier<MemoryCacheParams>() {\r\n//                      public MemoryCacheParams get() {\r\n//                        return bitmapCacheParams;\r\n//                      }\r\n//                    })\r\n                .setMainDiskCacheConfig(\r\n                    DiskCacheConfig.newBuilder()\r\n                    \t.setBaseDirectoryName(\"tqtest\")\r\n                        .setBaseDirectoryPath(diskCacheDir)\r\n//                        .setMaxCacheSize(40 * ByteConstants.MB)\r\n                        .setMaxCacheSize(40 * 1024)\r\n                        .build());\r\n        ImagePipelineConfig config = builder.build();\r\n        Fresco.initialize(this,config);\r\n    }\r\n    \r\n    private void initView(){\r\n        \r\n        DisplayMetrics displayMetrics = new DisplayMetrics();\r\n        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);\r\n        double space = 6 * displayMetrics.density +0.5;\r\n        columnWidth = (int) ((displayMetrics.widthPixels - space * 5 ) / 4);\r\n        GridView gv = (GridView) findViewById(R.id.gv_show);\r\n        int s = (int)space;\r\n        gv.setHorizontalSpacing(6);\r\n        gv.setVerticalSpacing(6);\r\n        gv.setColumnWidth(columnWidth);\r\n        \r\n        MAdapter adapter = new MAdapter();\r\n        gv.setAdapter(adapter);\r\n        \r\n    }\r\n    private void initData(){\r\n        \r\n        data = new ArrayList<String>();\r\n        ContentResolver contentResolver = getContentResolver();\r\n        Cursor cursor = contentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,\r\n                STORE_IMAGES, null, null, \"date_modified desc\");\r\n        if(null != cursor ){\r\n            for(cursor.moveToFirst();cursor.moveToNext();){\r\n                String path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));\r\n                data.add(path);\r\n            }\r\n        }\r\n        cursor.close();\r\n    }\r\n    \r\n    int columnWidth;\r\n    \r\n    class MAdapter extends BaseAdapter{\r\n\r\n        @Override\r\n        public int getCount() {\r\n            // TODO Auto-generated method stub\r\n            return data.size();\r\n        }\r\n\r\n        @Override\r\n        public String getItem(int position) {\r\n            // TODO Auto-generated method stub\r\n            return data.get(position);\r\n        }\r\n\r\n        @Override\r\n        public long getItemId(int position) {\r\n            // TODO Auto-generated method stub\r\n            return position;\r\n        }\r\n\r\n        @Override\r\n        public View getView(int position, View convertView, ViewGroup parent) {\r\n            // TODO Auto-generated method stub\r\n            SimpleDraweeView v = new SimpleDraweeView(getApplicationContext());\r\n            LayoutParams params = new LayoutParams(columnWidth, columnWidth);\r\n            v.setLayoutParams(params);\r\n            v.setImageURI(Uri.parse(\"file://\"+getItem(position))); \r\n            return v;\r\n        }\r\n    }\r\n    \r\n}\r\n"}}