Android Open Source - MaterialLoadingProgressBar Main Activity






From Project

Back to project page MaterialLoadingProgressBar.

License

The source code is released under:

Apache License

If you think the Android project MaterialLoadingProgressBar listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lsjwzh.materialloadingprogressbardemo;
//  www . j  a  v  a  2s .  c o m
import android.os.Handler;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;


public class MainActivity extends ActionBarActivity {
    int progress = 0;
    private Handler handler;
    CircleProgressBar progress1;
    CircleProgressBar progress2;
    CircleProgressBar progressWithArrow;
    CircleProgressBar progressWithoutBg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        progress1 = (CircleProgressBar) findViewById(R.id.progress1);
        progress2 = (CircleProgressBar) findViewById(R.id.progress2);
        progressWithArrow = (CircleProgressBar) findViewById(R.id.progressWithArrow);
        progressWithoutBg = (CircleProgressBar) findViewById(R.id.progressWithoutBg);


//        progress1.setColorSchemeResources(android.R.color.holo_blue_bright);
        progress2.setColorSchemeResources(android.R.color.holo_green_light);

        progressWithArrow.setColorSchemeResources(android.R.color.holo_orange_light);
        progressWithoutBg.setColorSchemeResources(android.R.color.holo_red_light);

        handler = new Handler();
        for (int i = 0; i < 10; i++) {
            final int finalI = i;
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    if(finalI *10>=90){
                        progress2.setVisibility(View.INVISIBLE);
                    }else {
                        progress2.setProgress(finalI * 10);
                    }
                }
            },1000*(i+1));
        }

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}




Java Source Code List

com.lsjwzh.materialloadingprogressbardemo.ApplicationTest.java
com.lsjwzh.materialloadingprogressbardemo.MainActivity.java
com.lsjwzh.widget.ApplicationTest.java
com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar.java
com.lsjwzh.widget.materialloadingprogressbar.MaterialProgressDrawable.java