package com.akexorcist.roundcornerprogressbar.example;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.akexorcist.roundcornerprogressbar.IconRoundCornerProgressBar;
import com.akexorcist.roundcornerprogressbar.RoundCornerProgressBar;


public class MainActivity extends Activity implements View.OnClickListener {

    private IconRoundCornerProgressBar progressOne;
    private RoundCornerProgressBar progressTwo;
    private TextView textProgressOne;
    private TextView textProgressTwo;
    private Button btnProgressOneDecrease;
    private Button btnProgressOneIncrease;
    private Button btnProgressTwoDecrease;
    private Button btnProgressTwoIncrease;

    private int progress1 = 5;
    private int progress2 = 5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        progressOne = (IconRoundCornerProgressBar) findViewById(R.id.progress_one);
        progressOne.setProgressColor(getResources().getColor(R.color.custom_progress_blue_progress));
        progressOne.setHeaderColor(getResources().getColor(R.color.custom_progress_blue_header));
        progressOne.setBackgroundColor(getResources().getColor(R.color.custom_progress_background));
        textProgressOne = (TextView) findViewById(R.id.text_progress_one);
        btnProgressOneDecrease = (Button) findViewById(R.id.button_progress_one_decrease);
        btnProgressOneDecrease.setOnClickListener(this);
        btnProgressOneIncrease = (Button) findViewById(R.id.button_progress_one_increase);
        btnProgressOneIncrease.setOnClickListener(this);
        updateProgressOne();

        progressTwo = (RoundCornerProgressBar) findViewById(R.id.progress_two);
        progressTwo.setBackgroundColor(getResources().getColor(R.color.custom_progress_background));
        textProgressTwo = (TextView) findViewById(R.id.text_progress_two);
        btnProgressTwoDecrease = (Button) findViewById(R.id.button_progress_two_decrease);
        btnProgressTwoDecrease.setOnClickListener(this);
        btnProgressTwoIncrease = (Button) findViewById(R.id.button_progress_two_increase);
        btnProgressTwoIncrease.setOnClickListener(this);
        updateProgressTwo();
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch (id) {
            case R.id.button_progress_one_decrease:
                progress1 = (progress1 > 0) ? progress1 - 1 : progress1;
                updateProgressOne();
                break;
            case R.id.button_progress_one_increase:
                progress1 = (progress1 < progressOne.getMax()) ? progress1 + 1 : progress1;
                updateProgressOne();
                break;
            case R.id.button_progress_two_decrease:
                progress2 = (progress2 > 0) ? progress2 - 1 : progress2;
                updateProgressTwo();
                break;
            case R.id.button_progress_two_increase:
                progress2 = (progress2 < progressTwo.getMax()) ? progress2 + 1 : progress2;
                updateProgressTwo();
                break;
        }
    }

    private void updateProgressOne() {
        progressOne.setProgress(progress1);
        textProgressOne.setText("" + progress1);
    }

    private void updateProgressTwo() {
        progressTwo.setProgress(progress2);
        textProgressTwo.setText("" + progress2);
        updateProgressTwoColor();
    }

    private void updateProgressTwoColor() {
        if(progress2 <= 3) {
            progressTwo.setProgressColor(getResources().getColor(R.color.custom_progress_red_progress));
        } else if(progress2 > 3 && progress2 <= 6) {
            progressTwo.setProgressColor(getResources().getColor(R.color.custom_progress_orange_progress));
        } else if(progress2 > 6) {
            progressTwo.setProgressColor(getResources().getColor(R.color.custom_progress_green_progress));
        }
    }
}

@@ -1,8 +1,559 @@
+/*%0ACopyright 2015 Akexorcist%0ALicensed under the Apache License, Version 2.0 (the %22License%22);%0Ayou may not use this file except in compliance with the License.%0AYou may obtain a copy of the License at%0Ahttp://www.apache.org/licenses/LICENSE-2.0%0AUnless required by applicable law or agreed to in writing, software%0Adistributed under the License is distributed on an %22AS IS%22 BASIS,%0AWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0ASee the License for the specific language governing permissions and%0Alimitations under the License.%0A*/%0A%0A
 package 

Update MainActivity.java