{"id":13643657,"url":"https://github.com/TangoAgency/avatar-view","last_synced_at":"2025-04-21T02:30:59.919Z","repository":{"id":146636443,"uuid":"68584436","full_name":"TangoAgency/avatar-view","owner":"TangoAgency","description":"Avatar ImageView with user's name first letter Drawable placeholder","archived":false,"fork":false,"pushed_at":"2018-12-13T13:19:24.000Z","size":1287,"stargazers_count":310,"open_issues_count":19,"forks_count":54,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-09T15:43:20.263Z","etag":null,"topics":["android","android-data-binding","android-library","android-ui","android-view"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TangoAgency.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-09-19T08:19:43.000Z","updated_at":"2024-11-02T04:50:54.000Z","dependencies_parsed_at":"2024-01-14T11:12:16.418Z","dependency_job_id":"6655aba8-700a-407e-8749-4292dcea74df","html_url":"https://github.com/TangoAgency/avatar-view","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangoAgency%2Favatar-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangoAgency%2Favatar-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangoAgency%2Favatar-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangoAgency%2Favatar-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TangoAgency","download_url":"https://codeload.github.com/TangoAgency/avatar-view/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249986044,"owners_count":21356313,"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-data-binding","android-library","android-ui","android-view"],"created_at":"2024-08-02T01:01:50.898Z","updated_at":"2025-04-21T02:30:54.909Z","avatar_url":"https://github.com/TangoAgency.png","language":"Java","funding_links":[],"categories":["ImageView"],"sub_categories":[],"readme":"# Avatar View\n[![Download](https://api.bintray.com/packages/tangoagency/maven/avatar-view/images/download.svg) ](https://bintray.com/tangoagency/maven/avatar-view/_latestVersion)\n[![Build Status](https://travis-ci.org/TangoAgency/avatar-view.svg?branch=master)](https://travis-ci.org/TangoAgency/avatar-view)\n[![Android Arsenal Avatar View](https://img.shields.io/badge/Android%20Arsenal-avatar--view-green.svg?style=true)](https://android-arsenal.com/details/1/4427)\n\nAvatar View library was implemented based on Matt Precious's [Don’t Fear the Canvas][Matt Precious's Lecture] lecture. I decided\nto create this library in order to achieve an ImageView which can smoothly display user's profile image or his username/name initial\nletter (in the case when the image was not provided).\n\nPlease take a look at the examples below:\n\n\n| Simple library presentation | [ExampleActivity][ExampleActivityNoBindings] \u0026 [BindingsExample][ExampleOnBindings]\n|:-:|:-:|\n| ![FirstExample] | ![SecondExample] |\n\n## Usage\n\nThis library can be used in two ways: using [standard Android methods][StandardMethodsPart] and using [Android Data Binding][DataBindingPart].\n\n###Standard:\n\n#### Step 1\n\nAdd gradle dependency:\n```groovy\ndependencies {\n    compile 'agency.tango.android:avatar-view:{latest_release}'\n\n    //if you want to use Picasso for loading images\n    compile 'agency.tango.android:avatar-view-picasso:{latest_release}'\n\n    //if you want to use Glide for loading images\n    compile 'agency.tango.android:avatar-view-glide:{latest_release}'\n}\n```\n\n#### Step 2\n\nAdd to your xml layout file:\n\n```xml\n\u003cagency.tango.android.avatarview.views.AvatarView\n    android:layout_width=\"100dp\"\n    android:layout_height=\"100dp\"\n    app:av_border_color=\"@android:color/white\"\n    app:av_border_width=\"4dp\"\n    app:av_text_size_percentage=\"35\" /\u003e\n```\n\n#### Step 3\n\nAdd to your activity:\n```java\n    AvatarView avatarView;\n    IImageLoader imageLoader;\n\n    @Override\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        avatarView = (AvatarView) findViewById(R.id.avatar_view_example);\n\n        imageLoader = new PicassoLoader();\n        imageLoader.loadImage(avatarView, \"http:/example.com/user/someUserAvatar.png\", \"User Name\");\n    }\n```\nIf you want to use a different library than ```Picasso``` for loading images you have to create a loader which\nextends [ImageLoaderBase][ImageLoaderBase] class. Basically, you have to override one method. Take a look how I have done\nit in [PicassoLoader][PicassoLoader] available in the avatar-view-picasso module.\n\n```ImageLoaderBase``` has two constructors: one with no parameters and second one where you can pass\n```String``` placeholder in order to change the default \"-\". You can also set it directly in\n```AvatarPlaceholder``` constructor. More info about ```AvatarPlaceholder``` [here][AvatarPlaceholderInfo].\n\n\n###Data Binding:\n\n#### Step 1\n\nAdd gradle dependency:\n```groovy\ndependencies {\n    compile 'agency.tango.android:avatar-view:{latest_release}'\n    compile 'agency.tango.android:avatar-view-bindings:{latest_release}'\n\n    //if you want to use Picasso for loading images\n    compile 'agency.tango.android:avatar-view-picasso:{latest_release}'\n\n    //if you want to use Glide for loading images\n    compile 'agency.tango.android:avatar-view-glide:{latest_release}'\n}\n```\n\n#### Step 2\n\nI will show how to edit your xml file based on ```User``` class. Let's see:\n\n```xml\n\u003cdata\u003e\n    \u003cvariable\n        name=\"user\"\n        type=\"User\" /\u003e\n\u003c/data\u003e\n\n\u003cagency.tango.android.avatarview.views.AvatarView\n    android:layout_width=\"100dp\"\n    android:layout_height=\"100dp\"\n    bind:av_border_color=\"@android:color/white\"\n    bind:av_border_width=\"6dp\"\n    bind:av_text_size_percentage=\"40\"\n    bind:avatarUrl=\"@{user.avatarUrl}\"\n    bind:name=\"@{user.name}\" /\u003e\n```\n\n#### Step 3\n\nAdd to your activity:\n\n```java\nprivate ExampleActivityBinding binding;\n\n@Override\nprotected void onCreate(@Nullable Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n\n    binding = DataBindingUtil.setContentView(this, R.layout.example_activity, new ExampleDataComponent());\n    binding.setUser(new User(\"User Name\", \"http:/example.com/user/someUserAvatar.png\"));\n}\n\nprivate static class ExampleDataComponent implements DataBindingComponent {\n    public AvatarViewBindings getAvatarViewBindings() {\n        return new AvatarViewBindings(new PicassoLoader());\n    }\n}\n```\nTake a look at [AvatarViewBindings][AvatarViewBindings] class where ```BindingsAdapter``` is configured\n(```bind:avatarUrl``` and ```bind:name``` for usage in XML). In order to correctly use ```AvatarViewBindings```\nyou have to create class extending ```DataBindingComponent``` and pass it as a third parameter in\n```DataBindingUtil.setContentView()``` method. This is obligatory because ```AvatarViewBindings``` takes an\n[IImageLoader][IImageLoader] parameter in it's constructor. You can find more information about\nthis topic in \u003ca href=\"http://www.slideshare.net/radekpiekarz/deep-dive-into-android-data-binding\"\u003eDeep dive\ninto Android Data Binding\u003c/a\u003e talk.\n\nI have explained [PicassoLoader][PicassoLoader] issue in [step 3][Step3A] in Standard Method part.\n\n####AvatarPlaceholder\n\n[AvatarPlaceholder][AvatarPlaceholder] is a ```Drawable``` which is set as a ```AvatarView``` background when the image\nhasn't been loaded yet. It is a letter on a one-color background (just like in ex. Google, Youtube avatars).\nDefault placeholder ```String``` (displayed when the username is ```null``` or empty) is \"-\". TextSizePercentage value\nsets how big part of the view is taken by the text. Default textSizePercentage is ```33```. You can change\nthose values by passing another ones in ```AvatarPlaceholder``` constructor or not directly by using IImageLoader\nclass methods/constructors.\n\n####Additional information\n\n- Avatar background color is calculated using ```hashCode()``` method called on a given name ```String```.\n- Default border width is ```2dp``` and default border color is ```white```.\n- Placeholder letters are currently always white (in future user will be able to choose a different color).\n- It is recommended to set your default placeholder ```String``` as short as possible (the best would be one letter).\n\n## Getting Help\n\nTo report a specific problem or feature request, [open a new issue on Github](https://github.com/TangoAgency/avatar-view/issues/new).\n\n## Company\n\n[![Facebook](https://github.com/TangoAgency/avatar-view/blob/master/images/facebook.png)](https://www.facebook.com/TangoDigitalAgency)\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;[![Twitter](https://github.com/TangoAgency/avatar-view/blob/master/images/twitter.png)](https://twitter.com/Tango_Agency)\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;[![LinkedIn](https://github.com/TangoAgency/avatar-view/blob/master/images/linkedin.png)](https://www.linkedin.com/company/tango-digital-agency)\n\n[Here](https://github.com/TangoAgency/) you can see open source work developed by Tango Agency.\n\nWhether you're searching for a new partner or trusted team for creating your new great product we are always ready to start work with you. \n\nYou can contact us via contact@tango.agency.\nThanks in advance. \n\n [Matt Precious's Lecture]: \u003chttps://www.youtube.com/watch?v=KH8Ldp39TUk\u003e\n [FirstExample]: \u003chttps://github.com/TangoAgency/avatar-view/blob/master/images/example1.gif\u003e\n [SecondExample]: \u003chttps://github.com/TangoAgency/avatar-view/blob/master/images/example2.gif\u003e\n [PicassoLoader]: \u003chttps://github.com/TangoAgency/avatar-view/blob/master/avatar-view-picasso/src/main/java/agency/tango/android/avatarview/loader/PicassoLoader.java\u003e\n [ImageLoaderBase]: \u003chttps://github.com/TangoAgency/avatar-view/blob/master/avatar-view/src/main/java/agency/tango/android/avatarview/ImageLoaderBase.java\u003e\n [User]:\u003chttps://github.com/TangoAgency/avatar-view/blob/master/example-data-binding/src/main/java/agency/tango/android/avatarview/example/model/User.java\u003e\n [AvatarViewBindings]:\u003chttps://github.com/TangoAgency/avatar-view/blob/master/avatar-view-bindings/src/main/java/agency/tango/android/avatarviewbindings/bindings/AvatarViewBindings.java\u003e\n [ExampleActivityNoBindings]:\u003chttps://github.com/TangoAgency/avatar-view/blob/master/example/src/main/java/agency/tango/android/example/ExampleActivity.java\u003e\n [ExampleOnBindings]:\u003chttps://github.com/TangoAgency/avatar-view/blob/master/example-data-binding/src/main/java/agency/tango/android/avatarview/example/viewmodel/ExampleViewModel.java\u003e\n [Step3A]:\u003chttps://github.com/TangoAgency/avatar-view#step-3\u003e\n [DataBindingPart]:\u003chttps://github.com/TangoAgency/avatar-view#data-binding\u003e\n [StandardMethodsPart]:\u003chttps://github.com/TangoAgency/avatar-view#standard\u003e\n [DataBindingPresentation]:\u003chttp://www.slideshare.net/radekpiekarz/deep-dive-into-android-data-binding\u003e\n [IImageLoader]:\u003chttps://github.com/TangoAgency/avatar-view/blob/master/avatar-view/src/main/java/agency/tango/android/avatarview/IImageLoader.java\u003e\n [AvatarPlaceholder]:\u003chttps://github.com/TangoAgency/avatar-view/blob/master/avatar-view/src/main/java/agency/tango/android/avatarview/AvatarPlaceholder.java\u003e\n [AvatarPlaceholderInfo]:\u003chttps://github.com/TangoAgency/avatar-view#avatar-placeholder\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTangoAgency%2Favatar-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTangoAgency%2Favatar-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTangoAgency%2Favatar-view/lists"}