{"id":17552396,"url":"https://github.com/saschpe/android-utils","last_synced_at":"2025-03-29T07:44:07.409Z","repository":{"id":136456566,"uuid":"75477066","full_name":"saschpe/android-utils","owner":"saschpe","description":"My often used Android classes","archived":false,"fork":false,"pushed_at":"2018-10-09T19:03:58.000Z","size":330,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T21:43:34.245Z","etag":null,"topics":["android","android-library","androidutils","appcompat","gradle","java","recyclerview","recyclerview-adapter","recyclerview-item-decoration","travis-ci"],"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/saschpe.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-03T14:01:08.000Z","updated_at":"2018-10-09T19:03:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"e506f2a3-26fc-4cc2-90b5-384ff6bcae1c","html_url":"https://github.com/saschpe/android-utils","commit_stats":{"total_commits":86,"total_committers":1,"mean_commits":86.0,"dds":0.0,"last_synced_commit":"a46b9dd11af65269ed5ce6b57392fc46fda98b88"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saschpe%2Fandroid-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saschpe%2Fandroid-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saschpe%2Fandroid-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saschpe%2Fandroid-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saschpe","download_url":"https://codeload.github.com/saschpe/android-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246156029,"owners_count":20732359,"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":["android","android-library","androidutils","appcompat","gradle","java","recyclerview","recyclerview-adapter","recyclerview-item-decoration","travis-ci"],"created_at":"2024-10-21T05:04:15.109Z","updated_at":"2025-03-29T07:44:07.392Z","avatar_url":"https://github.com/saschpe.png","language":"Java","readme":"# Android Utils\n[![Download](https://api.bintray.com/packages/saschpe/maven/android-utils/images/download.svg)](https://bintray.com/saschpe/maven/android-utils/_latestVersion)\n[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)\n[![Build Status](https://travis-ci.org/saschpe/android-utils.svg?branch=master)](https://travis-ci.org/saschpe/android-utils)\n\u003ca href=\"http://www.methodscount.com/?lib=saschpe.android%3Autils%3A2.0.0\"\u003e\u003cimg src=\"https://img.shields.io/badge/Methods and size-core: 156 | deps: 21569 | 27 KB-e91e63.svg\"/\u003e\u003c/a\u003e\n\nThis library collects a range of Android classes that I often use in projects.\n\n# Usage\nAvoid adding padding to recycler view item XML files and use item decoration\ninstead. The class *SpacesItemDecoration* can be used to add space between\nitems. It can be used several times to provide different values for *HORIZONTAL*\nand *VERTICAL* orientations.\n\n```java\nRecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);\nrecyclerView.addItemDecoration(new SpacesItemDecoration(16, SpacesItemDecoration.VERTICAL));\n```\n\nThe *DisplayHelper* class provides a range of functions for screen measurement\nand to find suitable layout managers for RecyclerView based on the screen width:\n\n```java\nrecyclerView.setLayoutManager(DisplayHelper.getSuitableLayoutManager(this));\n```\n\nArray-based adapters are the most common recycler view adapters. Avoid\nre-inventing the whell and subclass from *ArrayAdapter*:\n\n```java\npublic final class MyArrayAdapter extends ArrayAdapter\u003cThing, MyArrayAdapter.MyViewHolder\u003e {\n    public MyArrayAdapter(List\u003cThing\u003e objects) {\n        super(objects);\n        // ...\n    }\n    \n    static final class MyViewHolder extends RecyclerView.ViewHolder {\n        // ...\n    }\n}\n \npublic final class MainActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        List\u003cThing\u003e things = new ArrayList\u003c\u003e();\n        \n        MyAdapter adapter = new Adapter(things);\n        \n        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);\n        recyclerView.setAdapter(adapter);\n    }\n}\n```\n\nThe recycler view library does not provide Cursor-based adapters. Use\n*CursorRecyclerAdapter* to directly display database data:\n\n```java\npublic final class EventAdapter extends CursorRecyclerAdapter\u003cEventAdapter.EventViewHolder\u003e {\n    public EventAdapter(@NonNull Context context) {\n        // ...\n        Cursor cursor = context.getContentResolver()\n                .query(eventsUri, PROJECTION, SELECTION, selectionArgs,\n                        CalendarContract.Instances.DTSTART + \" ASC\");\n    \n        init(cursor); // See base class\n    }\n    \n    @Override\n    public EventViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {\n        // ...\n        return new EventViewHolder(v);\n    }\n    \n    @Override\n    public void onBindViewHolderCursor(final EventViewHolder holder, final Cursor cursor) {\n        // ...\n    }\n    \n    static class EventViewHolder extends RecyclerView.ViewHolder {\n        // ...\n    }\n}\n```\n\n\nThe Android SDK does not provide a PreferenceActivity that is based on\nAppCompat. To avoid using the old and deprecated PreferenceActivity or rolling\nyour own, subclass from *AppCompatPreferenceActivity* instead:\n\n```java\npublic final class SettingsActivity extends AppCompatPreferenceActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        final ActionBar actionBar = getSupportActionBar();\n        if (actionBar != null) {\n            actionBar.setDisplayHomeAsUpEnabled(true);\n        }\n    }\n    // ...\n}\n```\n\n# Download\n```groovy\ncompile 'saschpe.android:utils:2.0.0'\n```\n\nSnapshots of the development version are available in [Sonatype's `snapshots` repository][snap].\n\n# In use by\n* [Alpha+ Player](https://play.google.com/store/apps/details?id=saschpe.alphaplus)\n* [Birthday Calendar](https://play.google.com/store/apps/details?id=saschpe.contactevents) - Open Source on [Github](https://github.com/saschpe/BirthdayCalendar/)\n* [Planning Poker](https://play.google.com/store/apps/details?id=saschpe.poker) - Open Source on [Github](https://github.com/saschpe/PlanningPoker)\n\n# License\n\n    Copyright 2016 Sascha Peilicke\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n\n [snap]: https://oss.sonatype.org/content/repositories/snapshots/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaschpe%2Fandroid-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaschpe%2Fandroid-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaschpe%2Fandroid-utils/lists"}