Code Monkey home page Code Monkey logo

progressprofileview's Introduction

ProgressProfileView

Hex.pm Platform Android Arsenal

Android custom view to load an avatar or profile image with a progress indicator.

Portrait        Ring Samples        Gradient Samples

Preview also on Android Studio!

Android Studio Preview

Background

ProgressProfileView inherits from ImageView, so you can set any xml attributes as usual.

Measured both on landscape and portrait.

No need to crop to rounded images!

ProgressProfileView will clip proportionally all images loaded.

Remember to set android:scaleType="centerCrop" and android:adjustViewBounds="true"

Dependency

Latest stable version: Latest Version Bintray Version Maven Central

If you are working with gradle, add the dependency to your build.gradle file:

dependencies{
    compile 'com.kuassivi.view:progressprofile:?.?.?'
}

If you are working with maven, do it into your pom.xml

<dependency>
    <groupId>com.kuassivi.view</groupId>
    <artifactId>progressprofile</artifactId>
    <version>?.?.?</version>
    <type>aar</type>
</dependency>

How to:

Add the ProgressProfileView component in the layout.
Set your preferred ImageView attributes on it.

<com.kuassivi.view.ProgressProfileView
        android:id="@+id/profile"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        android:adjustViewBounds="true"
        android:src="@drawable/my_avatar"
        app:progress="42"
        app:progressRingSize="10dp"
        app:progressRingCorner="ROUND"
        app:progressRingOutline="true"/>

Get the object on your activity or fragment.

ProgressProfileView profile = (ProgressProfileView) findViewById(R.id.profile);

Set your desired progress.

profile.setProgress(59.5f);

To animate the ring, call #startAnimation()

profile.startAnimation();

If you need to handle the progress animation update or listen to the end of the animation, just get the ObjectAnimator calling the getAnimator() method from your ProgressProfileView object.

profile.getAnimator().addListener(new AnimatorListener());
profile.getAnimator().addUpdateListener(new AnimatorUpdateListener());
profile.getAnimator().setInterpolator(new AccelerateDecelerateInterpolator());

If you are loading images with Glide or Picasso, do it as usual

// Using Glide as usual
Glide.with(this)
    .load("http://your/server/path")
    .placeholder(R.drawable.ic_icon_user_default)
    .into(profile);

Be careful when using fitCenter() method of Glide, Picasso, or any other similar kind of method, because it will re-scale the bitmap, and the Progress Profile component will loose its original bounds!

Features:

  • `app:max="100"` - Max value for progress indicator
    
  • `app:progress="50"` - Current progress value
    
  • `app:backgroundRingSize="20dp"` - The size of the background ring (not set, means use the same as the <i>progressRingSize</i>)
    
  • `app:progressRingSize="20dp"` - The size of the progress ring
    
  • `app:backgroundRingColor="@color/my_color"` - The color of the background ring (it can be an hex color as well)
    
  • `app:progressRingColor="@color/my_color"` - The color of the progress ring (it can be an hex color as well)
    
  • `app:progressGradient="@array/colors"` - An array of colors for a gradient ring (you must provide an array resource reference) [#23](https://github.com/kuassivi/ProgressProfileView/issues/23)
    
  • `app:joinGradient="true"` - Enabling this you get a gradient smooth on the ring corners
    
  • `app:gradientFactor="1.0"` - Adjust the gradient factor of the ring
    
  • `app:progressRingOutline="true"` - Sets the ring as an Outline based on the padding of the ImageView, by default is `false`.
    
  • `app:progressRingCorner="ROUND"` - Sets the corner style of the progress ring (by default is RECT)
    

License

Copyright 2015 Francisco Gonzalez-Armijo Riádigos

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

progressprofileview's People

Contributors

franriadigos avatar

Watchers

James Cloos avatar

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.