GithubHelp home page GithubHelp logo

nageshkulkarni / android-doubleprogressbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from septiyanandika/android-doubleprogressbar

0.0 1.0 0.0 112 KB

An Android Widget to show a double progress bar

Home Page: http://simaomata.com

License: Other

android-doubleprogressbar's Introduction

Android Double Progress Bar

Purpose

While developing an Android App I needed a widget to show two progress bars at the same time. One to show the overall progress and another to show the intermediate progress.

I first tried to extend the ProgressBar class included with the Android SDK which didn't work out because of the fields in ProgressBar are defined as private.

I then used the code in ProgressDialog.java directly, extending AlertDialog and overriding setSecondaryProgress so it updates the second progress bar instead of drawing another bar behind the primary progress bar.

Example

The following screenshot illustrates how this widget looks using the included example project.

DoubleProgressBatExample

How to use

The usage is actually pretty simple:

  1. Copy DoubleProgressBar.java to your classpath

  2. Copy the included res/layout/alert_dialog_double_progress.xml file to your res/layout folder.

  3. Adjust package com.simaomata; to match your package.

  4. Create a new DoubleProgress bar as needed.

     progressDialog = new DoubleProgressDialog(this);
     progressDialog.setMessage("Double progress test");
     progressDialog.setCancelable(true);
     progressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialogInterface, int i) {
             dialogInterface.cancel();
         }
     });
     progressDialog.show();
    
  5. Set primary and secondary progress using the appropriate methods, always using progress values ranging from 0 to 100.

     progressDialog.setProgress(64);
     progressDialog.setSecondaryProgress(32);
    

Drawbacks and future improvements

There are some rough edges,

  • Only tested under Android SDK API Level 2.1
  • Only tested when directly feeding the calculated percentage to setProgress and setSecondaryProgess, withouth using setMax.

Contributions

Clearly, there is room for improvement. If you find yourself using this widget, please send me a pull request.

LICENSE

This widget is based on the ProgressDialog.java file included with the Android SDK, so it's licensed under an Apache Licensed.

Copyright 2010 Simão Mata

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.

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.