左晓为主开发手持机充值管理机
zuoxiao
2025-02-28 765d5165b18938eaefbd5b3af00e8775bfb1a91f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.bigkoo.pickerview.adapter;
 
 
import com.contrarywind.adapter.WheelAdapter;
 
/**
 * Numeric Wheel adapter.
 */
public class NumericWheelAdapter implements WheelAdapter {
    
    private int minValue;
    private int maxValue;
 
    /**
     * Constructor
     * @param minValue the wheel min value
     * @param maxValue the wheel max value
     */
    public NumericWheelAdapter(int minValue, int maxValue) {
        this.minValue = minValue;
        this.maxValue = maxValue;
    }
 
    @Override
    public Object getItem(int index) {
        if (index >= 0 && index < getItemsCount()) {
            int value = minValue + index;
            return value;
        }
        return 0;
    }
 
    @Override
    public int getItemsCount() {
        return maxValue - minValue + 1;
    }
    
    @Override
    public int indexOf(Object o){
        try {
            return (int)o - minValue;
        } catch (Exception e) {
            return -1;
        }
 
    }
}