Browse Source

Fix android native wheel stop glitch

master
Henning Hall 5 years ago
committed by GitHub
parent
commit
437b317054
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions
  1. +1
    -2
      README.md
  2. +7
    -2
      android/src/main/java/com/henninghall/date_picker/pickers/AndroidNative.java

+ 1
- 2
README.md View File

@ -1,5 +1,4 @@
# React Native Date Picker [![npm](https://img.shields.io/npm/v/react-native-date-picker.svg)](https://www.npmjs.com/package/react-native-date-picker) [![npm](https://img.shields.io/npm/dm/react-native-date-picker.svg)](https://www.npmjs.com/package/react-native-date-picker)
# React Native Date Picker [![npm](https://img.shields.io/npm/v/react-native-date-picker.svg)](https://www.npmjs.com/package/react-native-date-picker) [![Build status](https://img.shields.io/github/workflow/status/henninghall/react-native-date-picker/Android:%20build%20&%20test?label=tests)](https://github.com/henninghall/react-native-date-picker/actions) [![npm](https://img.shields.io/npm/dm/react-native-date-picker.svg)](https://www.npmjs.com/package/react-native-date-picker)
This is a React Native Date Picker with following main features:

+ 7
- 2
android/src/main/java/com/henninghall/date_picker/pickers/AndroidNative.java View File

@ -1,7 +1,6 @@
package com.henninghall.date_picker.pickers;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Paint;
import android.os.Handler;
import android.util.AttributeSet;
@ -174,7 +173,13 @@ public class AndroidNative extends NumberPicker implements Picker {
public void onScrollStateChange(NumberPicker numberPicker, int state) {
boolean stoppedScrolling = previousState != SCROLL_STATE_IDLE && state == SCROLL_STATE_IDLE;
if (stoppedScrolling) {
listener.onValueChange();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
listener.onValueChange();
}
// the delay make sure the wheel has stopped before sending the value change event
}, 500);
}
previousState = state;
}

Loading…
Cancel
Save