Skip to content

Commit

Permalink
Merge pull request #21 from kuassivi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
FranRiadigos committed Oct 26, 2015
2 parents 54e9fba + 223e516 commit 95d6291
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 66 deletions.
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ ProgressProfileView

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

It works on Marshmallow.
It also works on Marshmallow.

![Portrait][1]

You can customize the Component as you wish.

![Ring Samples][2]

**You can also Preview the result on Android Studio!**

![Android Studio Preview][2]
![Android Studio Preview][3]

Background
----------
Expand All @@ -28,15 +32,15 @@ How to:
If you are working with gradle, add the dependency to your build.gradle file:
```groovy
dependencies{
compile 'com.kuassivi.view:progressprofile:1.0.4'
compile 'com.kuassivi.view:progressprofile:1.0.5'
}
```
If you are working with maven, do it into your pom.xml
```xml
<dependency>
<groupId>com.kuassivi.view</groupId>
<artifactId>progressprofile</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
<type>aar</type>
</dependency>
```
Expand All @@ -54,7 +58,8 @@ Add the **ProgressProfileView** component in some place on the layout.
android:src="@drawable/my_avatar"
app:progress="42"
app:progressRingSize="10dp"
app:progressRingCap="ROUND"/>
app:progressRingCap="ROUND"
app:progressRingOutline="true"/>
```

>Get the object on your activity or fragment.
Expand Down Expand Up @@ -88,16 +93,17 @@ profile.getAnimator().addUpdateListener(new AnimatorUpdateListener());
profile.getAnimator().setInterpolator(new AccelerateDecelerateInterpolator());
```

>If you are loading images from Glide, consider to implement a custom ViewTarget like this one
>If you are loading images with Glide or Picasso, do it as usual
```java
// Using Glide as usual
Glide.with(this)
.load("http://your/server/path")
.placeholder(R.drawable.ic_icon_user_default)
.fitCenter() // Fit and center the bitmap
.into(profile);
```

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

Expand All @@ -108,6 +114,7 @@ Features:
* `app:backgroundRingColor="@color/my_color"` - Set the color of the background ring (it can be an hex color as well)
* `app:progressRingColor="@color/my_color"` - Set the color of the progress ring (it can be an hex color as well)
* `app:progressRingCap="BUTT"` - Set the cap style of the progress ring (Possible values: BUTT, ROUND, SQUARE)
* `app:progressRingOutline="true"` - Set the ring as an Outline based on the padding of the ImageView, by default is `false`.

License
-------
Expand All @@ -127,4 +134,5 @@ See the License for the specific language governing permissions and
limitations under the License.

[1]: ./art/portrait.gif
[2]: ./art/android-studio-preview.png
[2]: ./art/ring-samples.png
[3]: ./art/android-studio-preview.png
Binary file modified art/portrait.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/ring-samples.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.kuassivi.progressprofile"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.1"
}
buildTypes {
release {
Expand All @@ -21,7 +21,7 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile project(':progressprofile')
}
6 changes: 3 additions & 3 deletions example/example.iml
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="glide-3.6.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="glide-3.6.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="module" module-name="progressprofile" exported="" />
</component>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.animation.ValueAnimator;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -20,27 +21,33 @@ protected void onCreate(Bundle savedInstanceState) {

final TextView percentage = (TextView) findViewById(R.id.percentage);

ProgressProfileView profile = (ProgressProfileView) findViewById(R.id.profile);
final ProgressProfileView profile = (ProgressProfileView) findViewById(R.id.profile);
profile.getAnimator().setInterpolator(new AccelerateDecelerateInterpolator());
profile.setProgress(38.5f);
profile.setProgress(0);

// Using Glide as usual
Glide.with(this)
.load("http://lorempixel.com/500/500/people/1")
.placeholder(R.drawable.ic_icon_user_default)
.fitCenter() // Fit and center the bitmap
.into(profile);

// Show the current percentage animated
profile.getAnimator().addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
new Handler().postDelayed(new Runnable() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int absValue = Float.valueOf(animation.getAnimatedValue().toString()).intValue();
percentage.setText("Completed: " + absValue + "%");
}
});
public void run() {
profile.setProgress(38.5f);
// Using Glide as usual
Glide.with(MainActivity.this)
.load("http://lorempixel.com/500/500/people/1")
.placeholder(R.drawable.ic_icon_user_default)
.fitCenter() // Fit and center the bitmap
.into(profile);

profile.startAnimation();
// Show the current percentage animated
profile.getAnimator().addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int absValue = Float.valueOf(animation.getAnimatedValue().toString()).intValue();
percentage.setText("Completed: " + absValue + "%");
}
});

profile.startAnimation();
}
}, 2000);
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions example/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
android:adjustViewBounds="true"
android:layout_centerInParent="true"
android:layout_margin="50dp"
tools:src="@drawable/ic_icon_user_default"
android:src="@drawable/ic_icon_user_default"
app:progress="42"
app:progressRingSize="10dp"
app:progressRingCap="ROUND"/>
app:progressRingCap="ROUND"
app:progressRingOutline="true"/>

<TextView
android:id="@+id/percentage"
Expand Down
151 changes: 151 additions & 0 deletions example/src/main/res/layout/example_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
tools:text="- adjustViewBounds=&quot;true&quot;\n- progressRingCap=&quot;ROUND&quot;\n- progressRingOutline=&quot;false&quot;"
android:textSize="12sp"
android:textStyle="bold"
android:layout_marginBottom="10dp"/>

<com.kuassivi.view.ProgressProfileView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
tools:src="@drawable/ic_icon_user_default"
app:progress="12"
app:progressRingSize="15dp"
app:progressRingCap="ROUND"
app:progressRingOutline="false"/>

</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
tools:text="- adjustViewBounds=&quot;true&quot;\n- progressRingCap=&quot;BUTT&quot;\n- progressRingOutline=&quot;true&quot;"
android:textSize="12sp"
android:textStyle="bold"
android:layout_marginBottom="10dp"/>

<com.kuassivi.view.ProgressProfileView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
tools:src="@drawable/ic_icon_user_default"
app:progress="22"
app:progressRingSize="20dp"
app:progressRingCap="BUTT"
app:progressRingOutline="true"/>

</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
tools:text="- adjustViewBounds=&quot;true&quot;\n- progressRingCap=&quot;BUTT&quot;\n- progressRingOutline=&quot;true&quot;"
android:textSize="12sp"
android:textStyle="bold"
android:layout_marginBottom="10dp"/>

<com.kuassivi.view.ProgressProfileView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
tools:src="@drawable/ic_icon_user_default"
app:progress="32"
app:backgroundRingSize="20dp"
app:progressRingSize="5dp"
app:progressRingCap="BUTT"
app:progressRingOutline="true"
app:backgroundRingColor="#79b35c88"
app:progressRingColor="#FFB35C88"/>

</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="5dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
tools:text="- adjustViewBounds=&quot;true&quot;\n- progressRingCap=&quot;ROUND&quot;\n- progressRingOutline=&quot;false&quot;"
android:textSize="12sp"
android:textStyle="bold"
android:layout_marginBottom="10dp"/>

<com.kuassivi.view.ProgressProfileView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
tools:src="@drawable/ic_icon_user_default"
app:progress="37"
app:progressRingSize="20dp"
app:backgroundRingSize="5dp"
app:progressRingCap="ROUND"
app:progressRingOutline="false"
app:backgroundRingColor="#353362ee"
app:progressRingColor="#FF3362EE"/>

</LinearLayout>

</LinearLayout>

</LinearLayout>
4 changes: 2 additions & 2 deletions progressprofile/progressprofile.iml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
</component>
</module>
Loading

0 comments on commit 95d6291

Please sign in to comment.