This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Library and sample updated to v1.4.1
- Loading branch information
Showing
20 changed files
with
2,548 additions
and
1,976 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Linq; | ||
|
||
using Android.App; | ||
using Android.Views; | ||
|
||
namespace MaterialProgressBar.Sample | ||
{ | ||
public static class ActivityExtensions | ||
{ | ||
public static T[] BindViews<T>(this Activity activity, params int[] ids) | ||
where T : View | ||
{ | ||
return ids.Select(id => activity.FindViewById<T>(id)).ToArray(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System; | ||
using Android.Widget; | ||
using Android.Animation; | ||
using Android.Views.Animations; | ||
|
||
namespace MaterialProgressBar.Sample | ||
{ | ||
static class Animators | ||
{ | ||
class DeterminateCircularPrimaryProgressAnimatorListener : Java.Lang.Object, ValueAnimator.IAnimatorUpdateListener | ||
{ | ||
ValueAnimator animator; | ||
ProgressBar[] progressBars; | ||
|
||
public DeterminateCircularPrimaryProgressAnimatorListener(ValueAnimator animator, ProgressBar[] progressBars) | ||
{ | ||
this.animator = animator; | ||
this.progressBars = progressBars; | ||
} | ||
|
||
public void OnAnimationUpdate(ValueAnimator animation) | ||
{ | ||
int value = (int)animator.AnimatedValue; | ||
|
||
foreach (var progressBar in progressBars) | ||
{ | ||
progressBar.Progress = value; | ||
} | ||
} | ||
} | ||
|
||
public static ValueAnimator MakeDeterminateCircularPrimaryProgressAnimator(ProgressBar[] progressBars) | ||
{ | ||
ValueAnimator animator = ValueAnimator.OfInt(0, 150); | ||
animator.SetDuration(6000); | ||
animator.SetInterpolator(new LinearInterpolator()); | ||
animator.RepeatCount = ValueAnimator.Infinite; | ||
|
||
animator.AddUpdateListener(new DeterminateCircularPrimaryProgressAnimatorListener(animator, progressBars)); | ||
|
||
return animator; | ||
} | ||
|
||
class DeterminateCircularPrimaryAndSecondaryProgressAnimatorListener : Java.Lang.Object, ValueAnimator.IAnimatorUpdateListener | ||
{ | ||
ValueAnimator animator; | ||
ProgressBar[] progressBars; | ||
|
||
public DeterminateCircularPrimaryAndSecondaryProgressAnimatorListener(ValueAnimator animator, ProgressBar[] progressBars) | ||
{ | ||
this.animator = animator; | ||
this.progressBars = progressBars; | ||
} | ||
|
||
public void OnAnimationUpdate(ValueAnimator animation) | ||
{ | ||
int value = (int)Math.Round(1.25f * (int)animator.AnimatedValue); | ||
|
||
foreach (var progressBar in progressBars) | ||
{ | ||
progressBar.SecondaryProgress = value; | ||
} | ||
} | ||
} | ||
|
||
public static ValueAnimator MakeDeterminateCircularPrimaryAndSecondaryProgressAnimator(ProgressBar[] progressBars) | ||
{ | ||
ValueAnimator animator = MakeDeterminateCircularPrimaryProgressAnimator(progressBars); | ||
|
||
animator.AddUpdateListener(new DeterminateCircularPrimaryAndSecondaryProgressAnimatorListener(animator, progressBars)); | ||
|
||
return animator; | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
MaterialProgressBar.Sample/DeterminateCircularSampleActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using Android.Animation; | ||
using Android.App; | ||
using Android.Content.PM; | ||
using Android.OS; | ||
using Android.Support.V7.App; | ||
using Android.Views; | ||
using Android.Widget; | ||
|
||
namespace MaterialProgressBar.Sample | ||
{ | ||
[Activity(Label = "@string/determinate_circular_title", LaunchMode = LaunchMode.SingleTop)] | ||
[MetaData("android.support.PARENT_ACTIVITY", Value = "MaterialProgressBarSample.MainActivity")] | ||
public class DeterminateCircularSampleActivity : AppCompatActivity | ||
{ | ||
ProgressBar[] mPrimaryProgressBars; | ||
ProgressBar[] mPrimaryAndSecondaryProgressBars; | ||
|
||
ValueAnimator mPrimaryProgressAnimator; | ||
ValueAnimator mPrimaryAndSecondaryProgressAnimator; | ||
|
||
protected override void OnCreate(Bundle savedInstanceState) | ||
{ | ||
base.OnCreate(savedInstanceState); | ||
|
||
SetContentView(Resource.Layout.determinate_circular_sample_activity); | ||
|
||
mPrimaryProgressBars = this.BindViews<ProgressBar>(Resource.Id.normal_progress, | ||
Resource.Id.tinted_normal_progress, | ||
Resource.Id.dynamic_progress, | ||
Resource.Id.tinted_dynamic_progress); | ||
|
||
mPrimaryAndSecondaryProgressBars = this.BindViews<ProgressBar>(Resource.Id.normal_secondary_progress, | ||
Resource.Id.normal_background_progress, | ||
Resource.Id.tinted_normal_secondary_progress, | ||
Resource.Id.tinted_normal_background_progress, | ||
Resource.Id.dynamic_secondary_progress, | ||
Resource.Id.dynamic_background_progress, | ||
Resource.Id.tinted_dynamic_secondary_progress, | ||
Resource.Id.tinted_dynamic_background_progress); | ||
|
||
SupportActionBar.SetDisplayHomeAsUpEnabled(true); | ||
|
||
mPrimaryProgressAnimator = Animators.MakeDeterminateCircularPrimaryProgressAnimator(mPrimaryProgressBars); | ||
mPrimaryAndSecondaryProgressAnimator = Animators.MakeDeterminateCircularPrimaryAndSecondaryProgressAnimator(mPrimaryAndSecondaryProgressBars); | ||
} | ||
|
||
public override void OnAttachedToWindow() | ||
{ | ||
base.OnAttachedToWindow(); | ||
|
||
mPrimaryProgressAnimator.Start(); | ||
mPrimaryAndSecondaryProgressAnimator.Start(); | ||
} | ||
|
||
public override void OnDetachedFromWindow() | ||
{ | ||
base.OnDetachedFromWindow(); | ||
|
||
mPrimaryProgressAnimator.End(); | ||
mPrimaryAndSecondaryProgressAnimator.End(); | ||
} | ||
|
||
public override bool OnOptionsItemSelected(IMenuItem item) | ||
{ | ||
switch (item.ItemId) | ||
{ | ||
case Android.Resource.Id.Home: | ||
AppUtils.NavigateUp(this); | ||
return true; | ||
default: | ||
return base.OnOptionsItemSelected(item); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.