Skip to content

Commit

Permalink
Update sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
anton46 committed Jul 1, 2015
1 parent 3154732 commit 379b214
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 62 deletions.
93 changes: 60 additions & 33 deletions app/src/main/java/anton46/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,78 @@

import com.anton46.stepsview.StepsView;

import android.graphics.Color;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;


public class MainActivity extends AppCompatActivity {

private final String[] steps = {"Step 1", "Step 2", "Step 3", "Step 4"};

private final String[] steps1 = {"Step 1", "Step 2", "Step 3"};

private final String[] steps2 = {"Step 1", "Step 2", "Step 3", "Step 4", "Step 5"};

private StepsView mStepsView;
private final String[] views = {"View 1", "View 2", "View 3", "View 4", "View 5", "View 6",
"View 7", "View 8", "View 9", "View 10", "View 11", "View 12"};

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

mStepsView = (StepsView) findViewById(R.id.stepsView0);
mStepsView.setLabels(steps)
.setColorIndicator(Color.GREEN)
.setBarColor(Color.GRAY)
.setLabelColor(Color.BLUE)
.setCompletedPosition(0);

mStepsView = (StepsView) findViewById(R.id.stepsView1);
mStepsView.setLabels(steps)
.setColorIndicator(getResources().getColor(R.color.blue))
.setBarColor(Color.DKGRAY)
.setLabelColor(Color.GRAY)
.setCompletedPosition(1);

mStepsView = (StepsView) findViewById(R.id.stepsView2);
mStepsView.setLabels(steps1)
.setColorIndicator(getResources().getColor(R.color.red))
.setCompletedPosition(2);

mStepsView = (StepsView) findViewById(R.id.stepsView3);
mStepsView.setLabels(steps2)
.setColorIndicator(getResources().getColor(R.color.orange))
.setLabelColor(getResources().getColor(R.color.orange))
.setCompletedPosition(3);
ListView mListView = (ListView) findViewById(R.id.list);

MyAdapter adapter = new MyAdapter(this, 0);
adapter.addAll(views);

mListView.setAdapter(adapter);

}

public static class MyAdapter extends ArrayAdapter<String> {

private final String[] labels = {"Step 1", "Step 2", "Step 3", "Step 4", "Step 5"};

public MyAdapter(Context context, int resource) {
super(context, resource);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.row, null);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}

holder.mLabel.setText(getItem(position));

holder.mStepsView.setCompletedPosition(position % labels.length)
.setLabels(labels)
.setBarColorIndicator(
getContext().getResources().getColor(R.color.material_blue_grey_800))
.setProgressColorIndicator(getContext().getResources().getColor(R.color.orange))
.setLabelColorIndicator(getContext().getResources().getColor(R.color.orange))
.drawView();

return convertView;
}

static class ViewHolder {

TextView mLabel;
StepsView mStepsView;

public ViewHolder(View view) {
mLabel = (TextView) view.findViewById(R.id.label);
mStepsView = (StepsView) view.findViewById(R.id.stepsView);
}
}
}

}
}
32 changes: 3 additions & 29 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,9 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<com.anton46.stepsview.StepsView
android:id="@+id/stepsView0"
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" />


<com.anton46.stepsview.StepsView
android:id="@+id/stepsView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" />


<com.anton46.stepsview.StepsView
android:id="@+id/stepsView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" />


<com.anton46.stepsview.StepsView
android:id="@+id/stepsView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" />
android:layout_height="match_parent"/>

</LinearLayout>
20 changes: 20 additions & 0 deletions app/src/main/res/layout/row.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StepsView 1"/>

<com.anton46.stepsview.StepsView
android:id="@+id/stepsView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" />

</LinearLayout>

0 comments on commit 379b214

Please sign in to comment.