package id.gits.basosample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import java.util.Date;

import id.gits.baso.BasoProgressView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    BasoProgressView mBasoProgressView;

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

        mBasoProgressView = (BasoProgressView) findViewById(R.id.baso_ProgressView);
        findViewById(R.id.baso_btnStart).setOnClickListener(this);
        findViewById(R.id.baso_btnStopAndError).setOnClickListener(this);
        findViewById(R.id.baso_btnStopAndErrorNoImage).setOnClickListener(this);
        findViewById(R.id.baso_btnStopAndGone).setOnClickListener(this);

        mBasoProgressView.setOnButtonClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mBasoProgressView.startProgress();
            }
        });


    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.baso_btnStart) {
            mBasoProgressView.startProgress();
        } else if (v.getId() == R.id.baso_btnStopAndError) {
            mBasoProgressView.setFinishedImageResource(R.drawable.baso_sample_error);
            mBasoProgressView.stopAndError("Error: " + new Date().getTime());
        } else if (v.getId() == R.id.baso_btnStopAndErrorNoImage) {
            mBasoProgressView.setFinishedImageDrawable(null);
            mBasoProgressView.stopAndError("Error: " + new Date().getTime());
        } else if (v.getId() == R.id.baso_btnStopAndGone) {
            mBasoProgressView.stopAndGone();
        }
    }
}

@@ -128,32 +128,8 @@
 w;%0A%0A
-import java.util.Date;%0A%0A
 impo
@@ -1392,49 +1392,9 @@
 stop
-AndError(%22Error: %22 + new Date().getTime()
+(
 );%0A 
@@ -1570,39 +1570,27 @@
 or(%22
-Error: %22 + new Date().getTime()
+Something happened%22
 );%0A 

change text sample