Code Monkey home page Code Monkey logo

googleprogressbar's Introduction

GoogleProgressBar

This library is not maintained anymore and there will be no further releases

Android library to display different kind of google related animations for the progressBar.

These animations have been finished so far:

FoldingCirclesProgressBar GoogleMusicDicesDrawable NexusRotationCross.gif NexusRotationCross.gif

TODO

  • Different colors for the already existing `GoogleMusicDicesDrawable'. Either the whole dice or his faces.

I also would love to receive your pull requests to create any of the following animations or others that you think fit on this library:

  • NEXUS_CIRCLES:

    Nexus 5 circles boot progress animation (Just the circles bouncing)

  • NEXUS_CROSS:

    Galaxy nexus shinny cross boot animation

Usage

######Dynamically Add a ProgressBar to the xml layout:

     <ProgressBar
            android:id="@+id/google_progress"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="center"/>

Choose from the list of Drawables the one you want to use and place it in your code:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);
        mProgressBar.setIndeterminateDrawable(new your_list_option.Builder(this)
                    .build());
        //...
    }

your_list_option can be replace for:

  • FoldingCirclesDrawable
  • GoogleMusicDicesDrawable
  • NexusRotationCrossDrawable
  • ChromeFloatingCircles

The more custom Drawables finished, the more options in this list.

Attributes depending on the drawable:

######Color

    mProgressBar.setIndeterminateDrawable(new you_list_option.Builder(this)
                                                             .colors(getResources().getIntArray(R.array.colors) //Array of 4 colors
                                                             .build());
  • FoldingCirclesDrawable
  • NexusRotationCrossDrawable
  • ChromeFloatingCirclesDrawable

So far GoogleMusicDicesDrawable doesn't have color options. The animation speed can be modified easily with android:indeterminateDuration in the xml.

If not colors are define the 4 default google colors (red,blue, yellow and green) will be used.

######From XML

When you want to use the GoogleProgresBar from XML you need to add the following view to your layout:

    <com.jpardogo.android.googleprogressbar.library.GoogleProgressBar
            android:id="@+id/google_progress"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="center"
            gpb:type="your_list_option"/>

The require attribute gpb:type will specify the type of ProgressBar to display

your_list_option can be replace for:

  • folding_circles
  • nexus_rotation_cross
  • google_music_dices
  • chrome_floating_circles

The more custom Drawables finished, the more options in this list.

Each type of GoogleProgressBar have different attributes:

Attributes depending on type: ######Color

  • folding_circles
  • nexus_rotation_cross
    • gpb:colors="@array/colors"
      • Optional, If not colors are define the 4 default google colors (red,blue, yellow and green) will be used.
      • It needs to be an array of 4 colors

So far google_music_dices doesn't have color options. The animation speed can be modified easily with android:indeterminateDuration in the xml.

Including in your project

You can either add the library to your application as a library project or add the following dependency to your build.gradle:

Maven Central

dependencies {
    compile 'com.jpardogo.googleprogressbar:library:(latest version)'
}

Proguard

In order to use this library with proguard you need to add this line to your proguard.cfg:

-keep class com.jpardogo.android.googleprogressbar.** { *; }

How to contribute?

  • Pull request to dev branch NO master.

Acknowledgements

Developed By

Javier Pardo de Santayana Gómez - [email protected]

Follow me on Twitter Follow me on Google+ Follow me on LinkedIn
Copyright 2013 Javier Pardo de Santayana Gómez

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.

googleprogressbar's People

Contributors

jpardogo avatar makovkastar avatar mewx avatar romainpiel avatar

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  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

googleprogressbar's Issues

null instead context in fragments

some time in fragment throws exception when i use :

//So i use it like this 
getActivity().findViewById(R.id.google_progress).setVisibility(View.INVISIBLE);

and i know getActivity some time return null instead context but still is problem ! you have any suggest can cover this ?

/**
     * Return the {@link FragmentActivity} this fragment is currently associated with.
     * May return {@code null} if the fragment is associated with a {@link Context}
     * instead.
     */
    final public FragmentActivity getActivity() {
        return mHost == null ? null : (FragmentActivity) mHost.getActivity();
    }

Preview failed, and showed exceptions in Android Studio 1.0

I use GPB in a cardview, and Android Studio 1.0 show me an exception.

The way I use:

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card-view="http://schemas.android.com/apk/res-auto"
    xmlns:gpb="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="140dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:clickable="true"
    android:foreground="?android:attr/selectableItemBackground"
    card-view:cardBackgroundColor="@color/novel_item_white"
    card-view:contentPadding="5dp"
    card-view:cardElevation="2dp"
    card-view:cardMaxElevation="4dp">
        <com.jpardogo.android.googleprogressbar.library.GoogleProgressBar
            android:id="@+id/google_progress"
            android:layout_width="20dp"
            android:layout_height="20dp"
            gpb:type="folding_circles"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true" />
</android.support.v7.widget.CardView>

The exception:

android.content.res.Resources$NotFoundException: Int array resource ID #0x7f050000
    at android.content.res.Resources.getIntArray(Resources.java:522)
    at com.jpardogo.android.googleprogressbar.library.FoldingCirclesDrawable$Builder.initDefaults(FoldingCirclesDrawable.java:256)
    at com.jpardogo.android.googleprogressbar.library.FoldingCirclesDrawable$Builder.<init>(FoldingCirclesDrawable.java:251)
    at com.jpardogo.android.googleprogressbar.library.GoogleProgressBar.buildDrawable(GoogleProgressBar.java:42)
    at com.jpardogo.android.googleprogressbar.library.GoogleProgressBar.<init>(GoogleProgressBar.java:32)
    at com.jpardogo.android.googleprogressbar.library.GoogleProgressBar.<init>(GoogleProgressBar.java:22)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:379)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:99)
    at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:809)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:688)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:677)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
    at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:677)
    at com.android.tools.idea.rendering.RenderService.render(RenderService.java:815)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:646)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:589)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:584)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

gradle compile

I want to know how to make compile like your project
dependencies {
compile 'com.jpardogo.googleprogressbar:library:(latest version)'
}

create Progressbar programmatically

as per your code, you are using progressbar from xml. but how can we create progressbar programmatically with Foldingdrawable.? i tried simple but didnt showing progressbar.

How to make Chrome ProgressBar rotate?

Hi, could you improve the Chrome ProgressBar animation in order to make it rotate clockwise or counterclockwise while switching circles positions? Thank you in advance.

Main manifest has <uses-sdk android:minSdkVersion='8'> but library uses minSdkVersion='11'

I want to reference the library in my project(https://github.com/snowdream/android-widgets).i get the error as follows.
It seems that the minSdkVersion of my project is 8, but your minSdkVersion is 11.
If your library is avaiable for minSdkVersion 8, can you modify it to minSdkVersion 8,thank you.

[/home/snowdream/workspace/git/android-widgets/lib/src/main/AndroidManifest.xml, /home/snowdream/workspace/git/android-widgets/lib/build/exploded-aar/com.jpardogo.googleprogressbar/library/1.0.0/AndroidManifest.xml:2]   
Main manifest has <uses-sdk android:minSdkVersion='8'> but library uses minSdkVersion='11'

Kotlin support

I cann't implement it in my kotlin project, please support this, thanks

Getting null pointer exception while showing progressbar

I am using this library in viewpager i am getting this crash

java.lang.NullPointerException: Attempt to read from null array
at com.jpardogo.android.googleprogressbar.library.ChromeFloatingCirclesDrawable.draw(ChromeFloatingCirclesDrawable.java:189)
at android.widget.ProgressBar.drawTrack(ProgressBar.java:1803)
at android.widget.ProgressBar.onDraw(ProgressBar.java:1770)
at android.view.View.draw(View.java:17503)
at android.view.View.updateDisplayListIfDirty(View.java:16496)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3907)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3887)
at android.view.View.updateDisplayListIfDirty(View.java:16456)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3907)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3887)
at android.view.View.updateDisplayListIfDirty(View.java:16456)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3907)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3887)
at android.view.View.updateDisplayListIfDirty(View.java:16456)

Proguard

If you are using proguard this methods are removed:

  • float getScale() from GoogleMusicDicesDrawable
  • void setScale(float scale) from GoogleMusicDicesDrawable
  • void setRotationAngle(int angle) from NexusRotationCrossDrawable
  • int getRotationAngle() from NexusRotationCrossDrawable

I have to add this line to proguard.cfg:
-keep class com.jpardogo.android.googleprogressbar.** { *; }

Antialias and a couple of comments

Hey,

Good job mate for this library! A couple of comments there:

  • you should set the antialias to the paints, I've tried and it looks better
  • I'm not sure if inheriting from ProgressBar is a good idea. You are doing some extra work in your super.onDraw(canvas) I would actually clone the code from ProgressBar, remove what I don't need and set that as a base class for my custom progress bars.

Good idea anyway!

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.