{"id":18660361,"url":"https://github.com/patrick-doyle/crossbow","last_synced_at":"2025-07-11T04:04:20.200Z","repository":{"id":13601457,"uuid":"16294381","full_name":"patrick-doyle/CrossBow","owner":"patrick-doyle","description":"Wrapper Around the Volley library from Google to make it easier to manage and handle image loading","archived":false,"fork":false,"pushed_at":"2015-12-08T19:57:58.000Z","size":4040,"stargazers_count":143,"open_issues_count":1,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-11T22:06:42.245Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patrick-doyle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-27T22:02:00.000Z","updated_at":"2025-01-18T19:41:42.000Z","dependencies_parsed_at":"2022-09-10T12:41:48.520Z","dependency_job_id":null,"html_url":"https://github.com/patrick-doyle/CrossBow","commit_stats":null,"previous_names":["twistedequations/crossbow"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/patrick-doyle/CrossBow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-doyle%2FCrossBow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-doyle%2FCrossBow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-doyle%2FCrossBow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-doyle%2FCrossBow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrick-doyle","download_url":"https://codeload.github.com/patrick-doyle/CrossBow/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrick-doyle%2FCrossBow/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264726769,"owners_count":23654494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T07:43:25.607Z","updated_at":"2025-07-11T04:04:20.183Z","avatar_url":"https://github.com/patrick-doyle.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Crossbow\n===========\n[ ![Download](https://api.bintray.com/packages/twistedequations/maven/crossbow-wear-receiver/images/download.svg) ](https://bintray.com/twistedequations/maven/crossbow-wear-receiver/_latestVersion)\n\nContents\n--------\n[ Changelog](readme/changes.md)  \n[ Crossbow Wear](readme/crossbow-wear.md)  \n[ Crossbow Gson](readme/gson-requests.md)  \n\nCurrent Version Number - 0.8.9.5\n\nAll Crossbow Libraries\n\n######Base Crossbow Library\n```groovy\n   compile 'com.twistedequations.crossbow:crossbow:0.8.9.5'\n```\n\n######Crossbow Wear\n```groovy\n   compile 'com.twistedequations.crossbow:crossbow-wear:0.8.9.5'\n```\n\n######Crossbow Wear Receiver\n```groovy\n   compile 'com.twistedequations.crossbow:crossbow-wear-receiver:0.8.9.5'\n```\n\n######Crossbow Gson\n```groovy\n   compile 'com.twistedequations.crossbow:crossbow-gson:0.8.9.5'\n```\n\nExtension to the Volley library adding an easy to use wrapper around Volley. Supports android 2.3\nand up on phones and 4.3 and up for the wear module\n\nAlso provides an easy Picasso https://square.github.io/picasso/ inspired image loading\nsystem based on the ImageLoader.\n\nCrossbow does not modify the Volley library in any way so if you already use Volley then\nthis library can replace it with no changes to your code.\n\nCrossbow will use OkHttp if it finds it in the project. You can force the use a custom OkHttpClient\nby using a custom CrossbowComponents or by extending the DefaultCrossbowComponents.\n\nGetting Started\n------\nCrossbow is hosted on jcenter\n```groovy\nbuildscript {\n    repositories {\n        jcenter()\n    }\n}\n```\nAdd the Crossbow dependency to your build.gradle in your wear project\n```groovy\ndependencies {\n    compile 'com.twistedequations.crossbow:crossbow:0.8.9.5'\n}\n```\n\nCrossbow does all the heavy setup lifting for you including setting up the Request\nQueue, Image Caches, Image Loaders and Http Clients.\n\nA default Crossbow singleton can be obtained using\n\n```java\nCrossBow.get(Context context);\n```\n\nHttp Requests\n------\n\nAdding a request to the queue is easy and simple.\n```java\nStringRequest request = new StringRequest(\"http://www.url.com\", new Response.Listener\u003cString\u003e() {\n    @Override\n    public void onResponse(String response) {\n        //Handle response\n    }\n}, new Response.ErrorListener() {\n    @Override\n    public void onErrorResponse(VolleyError error) {\n        //Error handling\n    }\n});\n\nCrossbow.get(context).async(request);\n```\n\nThis will execute the request asynchronously and the callbacks will be invoked when the request has finished on the main thread.\n\nIf you want to execute a request synchronously then use the sync method. The callbacks will not be invoked and it is safe to pass\nnull for the callbacks. \n\n```java\nGsonGetRequest\u003cList\u003cRepo\u003e\u003e requestRepos = new  GsonGetRequest\u003cList\u003cRepo\u003e\u003e(\"https://api.github.com/users/twistedequations/repos\", null, null){};\nSyncResponse\u003cList\u003cRepo\u003e\u003e response = Crossbow.get(context).sync(requestRepos);\n```\n\nIf you need to get a reference to the RequestQueue then simply use \n```java\nRequestQueue requestQueue = Crossbow.get(context).getRequestQueue();\n```\n\nIf you wish you can write a CustomRequest by extending thr Request class to handle any custom parsing,\nheaders etc that the library does not support directly.\n\nImage Loading\n------\nCrossbow also has rich image loading api based in volleys image loader.\nCrossbow sets up an ImageLoader and a Memory Cache for the decoded and scaled bitmaps. Using this is\nvery easy using the Crossbow.loadImage().\n\n```java\nCrossbow.get(context).loadImage().source(\"https://i.imgur.com/5mObncZ.jpg\").into(imageView).load();\n```\n\nThe bitmaps are automatically scaled down to the size of the ImageView if the image is larger than\nthe ImageView to reduce memory usage and improve cache performance.\n\nCrossbowImage also supports placeholders\n```java\nCrossbow.get(context)\n    .loadImage()\n    .placeHolder(R.drawable.placeHolder)\n    .error(R.drawable.errorImage)\n    .source(\"https://i.imgur.com/5mObncZ.jpg\")\n    .into(imageView);\n```\n\nfading\n```java\nCrossbow.get(context)\n    .loadImage()\n    .fade(200)\n    .source(\"https://i.imgur.com/5mObncZ.jpg\")\n    .into(imageView);\n```\n\nand separate scaling for placeholders drawables, error drawables and the loaded image.\n```java\nCrossbow.get(context)\n    .loadImage()\n    .scale(ImageView.ScaleType.CENTER_CROP)\n    .placeholderScale(ImageView.ScaleType.CENTER)\n    .placeHolder(R.drawable.placeHolder)\n    .source(\"https://i.imgur.com/5mObncZ.jpg\")\n    .into(imageView);\n```\n\nCrossbow can load from http/https network urls, File Uri, File paths and drawable resource ids.\n```java\nCrossbow.get(context)\n    .loadImage()\n    .scale(ImageView.ScaleType.CENTER_CROP)\n    .placeholderScale(ImageView.ScaleType.CENTER)\n    .placeHolder(R.drawable.placeHolder)\n    .source(\"/path/to/file/image.png\")\n    .into(imageView);\n```\n\nCrossbow will automatically detect ImageView reuse and cancel the old requests so it safe to\nuse in adapters.\n\n```java\n@Override\npublic View getView(int position, View convertView, ViewGroup parent) {\n    ImageView imageView = new ImageView(context);\n    Crossbow.from(context).loadImage().url(\"https://i.imgur.com/5mObncZ.jpg\").into(imageView);\n    return imageView;\n}\n```\n\nIf you need custom network image loading/handing then you can use the standard Volley ImageLoader. This\nshares the same Threads, Cache and ImageLoader that CrossbowImage uses.\nGetting a reference to the ImageLoader uses the same method as the RequestQueue.\n\n```java\nImageLoader imageLoader = Crossbow.from(this).getImageLoader();\n\nimageLoader.get(\"https://i.imgur.com/5mObncZ.jpg\", new ImageLoader.ImageListener() {\n    @Override\n    public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {\n        \n    }\n\n    @Override\n    public void onErrorResponse(VolleyError error) {\n\n    }\n});\n```\n\nFile image loading is done with the FileImageLoader\n\n```java\nFileImageLaoder imageLoader = Crossbow.from(this).getImageLoader();\n\nimageLoader.get(\"https://i.imgur.com/5mObncZ.jpg\", new ImageLoader.ImageListener() {\n    @Override\n    public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {\n\n    }\n\n    @Override\n    public void onErrorResponse(VolleyError error) {\n\n    }\n});\n```\nUsing Custom Volley Components\n------\n\nIf you want to use your own components you can implement CrossbowComponents or its simpler subclass\nDefaultCrossbowComponents which has hooks to override the default components. If you wanted to use a\ncustom network of a different OkHttpClient\n\n```java\npublic class CustomCrossbowBuilder extends DefaultCrossbowComponents {\n\n    @Override\n    public Network onCreateNetwork(HttpStack httpStack) {\n        return new CustomNetwork(httpStack);\n    }\n\n    @Override\n    public OkHttpClient onCreateHttpClient() {\n        return new CustomOkHttpClient();\n    }\n}\n```\nAnd register it using in the application class\n```java\nCrossbow.initialize(context, components);\n```\nor any where before calling\n```java\nCrossbow.get(context);\n```\nfor the first time.\n\nIf you want to manage the crossbow singleton yourself you can use\n```java\nCrossbow crossbow = new Crossbow(crossbow, components);\n```\nand store it manually in the application for a singleton wrapper.\n\nNote:\nIf you use dagger2 you can extend the CrossbowComponents interface and annotate it with a module to\nuse dependency injection\n\n## License\n\n```\nCopyright 2015 Patrick Doyle\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrick-doyle%2Fcrossbow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrick-doyle%2Fcrossbow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrick-doyle%2Fcrossbow/lists"}