GithubHelp home page GithubHelp logo

akashjaindev / imagelettericon Goto Github PK

View Code? Open in Web Editor NEW
212.0 10.0 56.0 554 KB

Material letter icon with circle background. Also supports for image for user contact.

License: Apache License 2.0

Java 100.00%

imagelettericon's Introduction

ImageLetterIcon

Material letter icon with circle background. Also supports for image for user contact.

Android Arsenal

Download

Square Initials Square Initials Alternate Initial Square Image Alternate Initial Circular Image Gradle


dependencies {
    compile 'com.github.akashandroid90:imageletter:1.8@aar'
}

ChangeLog

bug fixes

vector drawable support

Usage

Declare in XML (see xml attributes below for customization):

<com.github.akashandroid90.imageletter.MaterialLetterIcon
    android:layout_width="@dimen/letter_icon_size"
    android:layout_height="@dimen/letter_icon_size" />

Or static initializer (see xml attributes below for customization):

MaterialLetterIcon icon = new MaterialLetterIcon.Builder(context) //
            .shapeColor(getResources().getColor(R.color.circle_color))
            .setShapeType(MaterialLetterIcon.SHAPE_CIRCLE)
            .letter("S")
            .letterColor(getResources().getColor(R.color.letter_color))
            .letterSize(26)
            .lettersNumber(1)
            .letterTypeface(yourTypeface)
            .initials(false)
            .initialsNumber(2)
            .create();

Configure using xml attributes or setters in code:

app:shape_color="@color/black"      // shape color
app:shape_type="circle"             // shape type
app:letter=""                       // letter or string to get first letter from
app:letter_color="@color/white"     // letter color
app:letter_size="26"                // letter size SP
app:letters_number="1"              // number of letters to get from string
app:initials="false"                // turn on initials mode
app:initials_number="2"             // number of initials to be showed
app:corner_radius="1dp"             // radius of image to make at corner
app:is_oval="true"                  // to make a circular image
app:border_width="1dp"              // border width around the image
app:border_color="@color/black"     //border color around image

Donations

This project needs you! If you would like to support this project's further development, the creator of this project or the continuous maintenance of this project, feel free to donate. Your donation is highly appreciated (and I love food, coffee and beer). Thank you!

PayPal

  • Donate $5: Thank's for creating this project, here's a coffee (or some beer) for you!
  • Donate $10: Wow, I am stunned. Let me take you to the movies!
  • Donate $15: I really appreciate your work, let's grab some lunch!
  • Donate $25: That's some awesome stuff you did right there, dinner is on me!
  • Donate $50: I really really want to support this project, great job!
  • Donate $100: You are the man! This project saved me hours (if not days) of struggle and hard work, simply awesome!
  • Donate $2799: Go buddy, buy Macbook Pro for yourself! Of course, you can also choose what you want to donate, all donations are awesome!

Developed By

Akash Jain

imagelettericon's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imagelettericon's Issues

Using Picasso or setImageResource with MaterialLetterIcon

Hi,

I have the following use case:

  • I have a list of contacts
  • to add a contact, a "friend request" is sent
  • in the adapter, I am using the viewHolder pattern

The flow:

  • if a contact was added, but it hasn't been approved yet (the friend request is not accepted), I am displaying a local image using imageView.setImageResource()
  • if the contact was added and was approved, I am loading it's picture from an url, using Picasso
  • if the contact was added and was approved, but it has no profile picture (no url), I am showing 2 letters from it's name (imageView.setLetter(name))

I am using the same ImageView for all 3 cases. The ImageView is a MaterialLetterIcon.

The problem:

  • the issue is related to view recycling. As I mentioned, I am using a viewHolder pattern and thus, I have to handle the if flow. For example: if url exists, then load into picasso, else, picasso needs a default placeholder and the letters need to be drawn. Setting a default placeholder or image resource doesn't work combined with the setLetter implementation. It sets the default placeholder but the letters are not drawn any more.

Example:

  • After the list is loaded correctly (following the flow), when I background and foreground the app or scroll the list, the contacts that have the letter images have the resource image.

Solutions:

  • I tried setting a null or transparent drawable on the first else (friend request accepted)
  • in some cases, I only need the last 2 if's from the flow. I used 2 different imageViews, more exactly, an ImageView for Picasso, and the MaterialLetterIcon for the name, and I was handling their visibillity. This solution seems to work, but using 3 different imageViews for this case seems a bit overkill. Most likely there will be more if's added to the flow..

Version of lib:

  • 1.2

What solution / approach do you suggest?

Thank you.

Questions: image inside, outline, elevation, rounded corners ?

  1. Is it possible to put an image inside the MaterialLetterIcon , that won't be shaped, meaning show as it is?
    This is useful in cases that there are no letters or images available for the item. Can also be useful for the case of loading the image, yet not having any letter to show during this time.

  2. Is it possible to add a border (AKA outline/stroke) around the shape, including color and width?

  3. Is it possible to add elevation to the MaterialLetterIcon ?
    I know that it's possible to add a rounded one using this:

    public static void setOvalElevationToView(final View view) {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
            view.setOutlineProvider(new ViewOutlineProvider() {
                @TargetApi(VERSION_CODES.LOLLIPOP)
                @Override
                public void getOutline(View view, Outline outline) {
                    final int size = view.getWidth();
                    outline.setOval(0, 0, size, size);
                }
            });
    }

But it's only from Lollipop, and only for rounded ones

  1. Is it possible to use rounded corners, instead of only square/circle shapes?

Remove library appcompat-v7 dependency

https://github.com/akashandroid90/ImageLetterIcon/blob/master/imageletter/build.gradle has a dependency on appcompat-v7. However, I do not see anything in the code that requires this dependency โ€” you do not seem to have any import statements pulling in appcompat-v7 classes, nor are you referencing any appcompat-v7 resources.

If you remove this dependency, it will simplify the use of this library by projects that are not using appcompat-v7 or, for various reasons, want a version different than the one that your Gradle file requests.

Thanks!

View changed to letter

I am using material letter for coordinatorlayout with animation. Now I have also avatar image which is displayed if image is available. Now When I am animating it with corodrinator layout , it is changing to letter view. There should be some way with that once Image is loaded, it should not change to letter icon.

update the readme and version indicator to v1.14

On the release's page, the latest stable release is v1.2
In the readme it is v1.8
v1.8 is broken for support libs 26> because attr/tint is duplicated. I searched issues and saw you stated there exists v1.14 but nowhere is any mention about this.

v1.14 is working, so please update readme and project description.

Some developers including myself, actively using this library.

Check the maven dependency

In your readme you are indicating to use:

dependencies {
    compile 'com.imageletter:ImageLetterIcon:1.0'
}

Checking the pom file in jcenter it seems to be:

compile 'com.github.akashandroid90:image-letter-icon:1.0'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.