Skip to content

Commit

Permalink
fix: #281
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Dec 20, 2021
1 parent 6139b39 commit b9ff045
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected void onInit(@NonNull Context context) {

@Override
protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) {
super.onAttributeSet(context, attrs);
setFirstVisible(provider.firstLevelVisible());
setThirdVisible(provider.thirdLevelVisible());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

Expand Down Expand Up @@ -69,11 +70,13 @@ protected int provideLayoutRes() {
return R.layout.wheel_picker_linkage;
}

@CallSuper
@Override
protected List<WheelView> provideWheelViews() {
return Arrays.asList(firstWheelView, secondWheelView, thirdWheelView);
}

@CallSuper
@Override
protected void onInit(@NonNull Context context) {
firstWheelView = findViewById(R.id.wheel_picker_linkage_first_wheel);
Expand All @@ -85,6 +88,7 @@ protected void onInit(@NonNull Context context) {
loadingView = findViewById(R.id.wheel_picker_linkage_loading);
}

@CallSuper
@Override
protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LinkageWheelLayout);
Expand All @@ -97,6 +101,7 @@ protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet a
setLabel(firstLabel, secondLabel, thirdLabel);
}

@CallSuper
@Override
public void onWheelSelected(WheelView view, int position) {
int id = view.getId();
Expand All @@ -122,6 +127,7 @@ public void onWheelSelected(WheelView view, int position) {
}
}

@CallSuper
@Override
public void onWheelScrollStateChanged(WheelView view, @ScrollState int state) {
int id = view.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public NumberWheelLayout(Context context, AttributeSet attrs, int defStyleAttr,

@Override
protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) {
super.onAttributeSet(context, attrs);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NumberWheelLayout);
float minNumber = typedArray.getFloat(R.styleable.NumberWheelLayout_wheel_minNumber, 0);
float maxNumber = typedArray.getFloat(R.styleable.NumberWheelLayout_wheel_maxNumber, 10);
Expand All @@ -70,6 +71,7 @@ protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet a

@Override
public void onWheelSelected(WheelView view, int position) {
super.onWheelSelected(view, position);
if (onNumberSelectedListener != null) {
Object item = getWheelView().getItem(position);
onNumberSelectedListener.onNumberSelected(position, (Number) item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.util.AttributeSet;
import android.widget.TextView;

import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

Expand Down Expand Up @@ -61,24 +62,28 @@ protected int provideLayoutRes() {
return R.layout.wheel_picker_option;
}

@CallSuper
@Override
protected List<WheelView> provideWheelViews() {
return Collections.singletonList(wheelView);
}

@CallSuper
@Override
protected void onInit(@NonNull Context context) {
wheelView = findViewById(R.id.wheel_picker_option_wheel);
labelView = findViewById(R.id.wheel_picker_option_label);
}

@CallSuper
@Override
protected void onAttributeSet(@NonNull Context context, @Nullable AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.OptionWheelLayout);
labelView.setText(typedArray.getString(R.styleable.OptionWheelLayout_wheel_label));
typedArray.recycle();
}

@CallSuper
@Override
public void onWheelSelected(WheelView view, int position) {
if (onOptionSelectedListener != null) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_picker_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
app:wheel_label=""
app:wheel_maxNumber="30"
app:wheel_maxNumber="50"
app:wheel_minNumber="10"
app:wheel_stepNumber="5"
app:wheel_visibleItemCount="7" />
Expand Down

0 comments on commit b9ff045

Please sign in to comment.