Skip to content
This repository was archived by the owner on Aug 22, 2020. It is now read-only.

Commit 6a0094e

Browse files
committed
VerticalStepperView: Finish (Except animation)
Signed-off-by: Fung <fython@163.com>
1 parent 51daa09 commit 6a0094e

17 files changed

Lines changed: 387 additions & 73 deletions

demo/src/main/java/moe/feng/common/stepperview/demo/MainActivity.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
import android.os.Bundle;
1010
import android.support.v7.widget.Toolbar;
1111
import android.view.MenuItem;
12+
import moe.feng.common.stepperview.demo.fragment.VerticalStepperAdapterDemoFragment;
1213
import moe.feng.common.stepperview.demo.fragment.VerticalStepperDemoFragment;
1314

1415
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
1516

1617
private DrawerLayout mDrawerLayout;
1718
private NavigationView mNavigationView;
1819

19-
private Fragment mVerticalStepperDemoFragment = new VerticalStepperDemoFragment();
20+
private Fragment mVerticalStepperDemoFragment = new VerticalStepperDemoFragment(),
21+
mVerticalStepperAdapterDemoFragment = new VerticalStepperAdapterDemoFragment();
2022

2123
@Override
2224
protected void onCreate(Bundle savedInstanceState) {
@@ -62,6 +64,10 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
6264
getSupportFragmentManager().beginTransaction()
6365
.replace(R.id.container, mVerticalStepperDemoFragment).commit();
6466
return true;
67+
case R.id.item_vertical_stepper_adapter:
68+
getSupportFragmentManager().beginTransaction()
69+
.replace(R.id.container, mVerticalStepperAdapterDemoFragment).commit();
70+
return true;
6571
default:
6672
return false;
6773
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package moe.feng.common.stepperview.demo.fragment;
2+
3+
import android.content.Context;
4+
import android.os.Bundle;
5+
import android.support.design.widget.Snackbar;
6+
import android.support.v4.app.Fragment;
7+
import android.view.LayoutInflater;
8+
import android.view.View;
9+
import android.view.ViewGroup;
10+
import android.widget.TextView;
11+
import moe.feng.common.stepperview.IStepperViewAdapter;
12+
import moe.feng.common.stepperview.VerticalStepperItemView;
13+
import moe.feng.common.stepperview.VerticalStepperView;
14+
import moe.feng.common.stepperview.demo.R;
15+
16+
public class VerticalStepperAdapterDemoFragment extends Fragment implements IStepperViewAdapter {
17+
18+
private VerticalStepperView mVerticalStepperView;
19+
20+
@Override
21+
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
22+
return inflater.inflate(R.layout.fragment_vertical_stepper_adapter, parent, false);
23+
}
24+
25+
@Override
26+
public void onViewCreated(View view, Bundle savedInstanceState) {
27+
mVerticalStepperView = view.findViewById(R.id.vertical_stepper_view);
28+
mVerticalStepperView.setViewAdapter(this);
29+
}
30+
31+
@Override
32+
public String getTitle(int index) {
33+
return "Step " + index;
34+
}
35+
36+
@Override
37+
public String getSummary(int index) {
38+
switch (index) {
39+
case 0:
40+
return "Summarized if needed";
41+
case 2:
42+
return "Last step";
43+
default:
44+
return null;
45+
}
46+
}
47+
48+
@Override
49+
public int size() {
50+
return 3;
51+
}
52+
53+
@Override
54+
public View onCreateCustomView(int index, Context context, VerticalStepperItemView parent) {
55+
View inflateView = LayoutInflater.from(context).inflate(R.layout.vertical_stepper_sample_item, parent, false);
56+
TextView contentView = inflateView.findViewById(R.id.item_content);
57+
contentView.setText(
58+
index == 0 ? R.string.content_step_0 : (index == 1 ? R.string.content_step_1 : R.string.content_step_2)
59+
);
60+
inflateView.findViewById(R.id.button_next).setOnClickListener(new View.OnClickListener() {
61+
@Override
62+
public void onClick(View view) {
63+
if (!mVerticalStepperView.nextStep()) {
64+
Snackbar.make(mVerticalStepperView, "Finish", Snackbar.LENGTH_LONG).show();
65+
}
66+
}
67+
});
68+
inflateView.findViewById(R.id.button_prev).setOnClickListener(new View.OnClickListener() {
69+
@Override
70+
public void onClick(View view) {
71+
mVerticalStepperView.prevStep();
72+
}
73+
});
74+
return inflateView;
75+
}
76+
77+
@Override
78+
public void onShow(int index) {
79+
80+
}
81+
82+
@Override
83+
public void onHide(int index) {
84+
85+
}
86+
87+
}

demo/src/main/res/layout/fragment_vertical_stepper.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
android:layout_width="wrap_content"
3131
android:layout_height="wrap_content"
3232
android:layout_marginTop="12dp"
33-
android:text="This is the first step. Click OK button to next step.\n\nTest Message."/>
33+
android:text="@string/content_step_0"/>
3434

3535
<LinearLayout
3636
android:layout_width="wrap_content"
@@ -75,7 +75,7 @@
7575
android:layout_width="wrap_content"
7676
android:layout_height="wrap_content"
7777
android:layout_marginTop="12dp"
78-
android:text="This is the second step. Click OK button to next step or Cancel button to previous step.\n\nThe summary text of each step is optional. If you haven\'t set, summary view won\'t be displayed."/>
78+
android:text="@string/content_step_1"/>
7979

8080
<LinearLayout
8181
android:layout_width="wrap_content"
@@ -123,7 +123,7 @@
123123
android:layout_width="wrap_content"
124124
android:layout_height="wrap_content"
125125
android:layout_marginTop="12dp"
126-
android:text="This is the last step. You can finish steps now."/>
126+
android:text="@string/content_step_2"/>
127127

128128
<LinearLayout
129129
android:layout_width="wrap_content"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:orientation="vertical"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
8+
<moe.feng.common.stepperview.VerticalStepperView
9+
android:id="@+id/vertical_stepper_view"
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
app:step_done_icon="@drawable/ic_done_white_16dp"
13+
app:step_animation_duration="@android:integer/config_mediumAnimTime"/>
14+
15+
</LinearLayout>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:orientation="vertical">
7+
8+
<TextView
9+
android:id="@+id/item_content"
10+
android:layout_width="wrap_content"
11+
android:layout_height="wrap_content"
12+
android:layout_marginTop="12dp"/>
13+
14+
<LinearLayout
15+
android:layout_width="wrap_content"
16+
android:layout_height="wrap_content"
17+
android:layout_marginTop="16dp"
18+
android:orientation="horizontal">
19+
20+
<Button
21+
android:id="@+id/button_next"
22+
android:layout_width="wrap_content"
23+
android:layout_height="wrap_content"
24+
android:backgroundTint="@color/material_blue_500"
25+
android:textColor="@android:color/white"
26+
android:text="@android:string/ok"/>
27+
28+
<Button
29+
android:id="@+id/button_prev"
30+
android:layout_width="wrap_content"
31+
android:layout_height="wrap_content"
32+
android:layout_marginStart="8dp"
33+
android:text="@android:string/cancel"/>
34+
35+
</LinearLayout>
36+
37+
</LinearLayout>

demo/src/main/res/menu/navigation_main.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
android:icon="@drawable/ic_format_list_bulleted_black_24dp"
99
android:checked="true"/>
1010

11+
<item android:id="@+id/item_vertical_stepper_adapter"
12+
android:title="@string/item_vertical_stepper_adapter"
13+
android:icon="@drawable/ic_format_list_bulleted_black_24dp"/>
14+
1115
</group>
1216

1317
</menu>

demo/src/main/res/values/strings.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
<string name="app_name">StepperView Demo</string>
44

55
<!-- Navigation Menu -->
6-
<string name="item_vertical_stepper">Vertical Stepper</string>
6+
<string name="item_vertical_stepper">Vertical Stepper (Item View)</string>
7+
<string name="item_vertical_stepper_adapter">Vertical Stepper (With Adapter)</string>
8+
9+
<!-- Vertical Stepper View Sample Item -->
10+
<string name="content_step_0">This is the first step. Click OK button to next step.\n\nTest Message.</string>
11+
<string name="content_step_1">This is the second step. Click OK button to next step or Cancel button to previous step.\n\nThe summary text of each step is optional. If you haven\'t set, summary view won\'t be displayed.</string>
12+
<string name="content_step_2">This is the last step. You can finish steps now.</string>
713

814
</resources>

library/build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 26
5-
buildToolsVersion "26.0.1"
4+
compileSdkVersion rootProject.ext.targetSdkVersion
5+
buildToolsVersion rootProject.ext.buildToolsVersion
66

77
defaultConfig {
8-
minSdkVersion 21
9-
targetSdkVersion 26
10-
versionCode 1
11-
versionName "1.0"
8+
minSdkVersion rootProject.ext.minSdkVersion
9+
targetSdkVersion rootProject.ext.targetSdkVersion
10+
versionCode rootProject.ext.versionCode
11+
versionName rootProject.ext.versionName
1212

1313
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14-
1514
}
1615
buildTypes {
1716
release {
@@ -26,6 +25,7 @@ dependencies {
2625
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2726
exclude group: 'com.android.support', module: 'support-annotations'
2827
})
29-
compile 'com.android.support:appcompat-v7:26.+'
28+
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
29+
compile "com.android.support:recyclerview-v7:$supportLibraryVersion"
3030
testCompile 'junit:junit:4.12'
3131
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
package moe.feng.common.stepperview;
22

3+
import android.graphics.drawable.Drawable;
4+
import android.support.annotation.ColorInt;
5+
36
interface IStepperView {
47

58
IStepperViewAdapter getViewAdapter();
9+
int getCurrentStep();
10+
11+
@ColorInt int getNormalColor();
12+
@ColorInt int getActivatedColor();
13+
int getAnimationDuration();
14+
Drawable getDoneIcon();
615

716
}

library/src/main/java/moe/feng/common/stepperview/IStepperViewAdapter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package moe.feng.common.stepperview;
22

33
import android.content.Context;
4+
import android.view.View;
45
import android.view.ViewGroup;
56

6-
interface IStepperViewAdapter {
7+
public interface IStepperViewAdapter {
78

89
String getTitle(int index);
910

11+
String getSummary(int index);
12+
1013
int size();
1114

12-
void onCreateView(int index, Context context, ViewGroup parent);
15+
View onCreateCustomView(int index, Context context, VerticalStepperItemView parent);
1316

1417
void onShow(int index);
1518

0 commit comments

Comments
 (0)