react-native-slider icon indicating copy to clipboard operation
react-native-slider copied to clipboard

onSlidingComplete is not working on Android

Open EJohnF opened this issue 7 years ago • 8 comments

Environment

System: OS: macOS 10.14.6 CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz Memory: 22.35 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.16.0 - /usr/local/bin/node Yarn: 1.19.0 - /usr/local/bin/yarn npm: 6.11.3 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3 Android SDK: API Levels: 28, 29 Build Tools: 28.0.3, 29.0.1 IDEs: Android Studio: 3.4 AI-183.6156.11.34.5692245 Xcode: 10.3/10G8 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.5 => 0.60.5 npmGlobalPackages: react-native-cli: 2.0.1

react-native-slider version 2.0.2

Description

The same code works as expected on iOS ('on sliding complete' is logged in console) but not on android Although currentValue is correctly changed on Android as well as on iOS

Reproducible Demo

const [currentValue, setCurrentValue] = useState();
<Slider
        style={{ width: screenWidth - 48, height: 40 }}
        minimumTrackTintColor={theme.colors.pinkButton}
        maximumTrackTintColor={theme.colors.grayIcon}
        value={currentValue}
        onValueChange={setCurrentValue}
        onSlidingComplete={value => {
          console.log('on sliding complete')
        }}
      />

EJohnF avatar Oct 24 '19 08:10 EJohnF

Please try version 2.0.7 it seems to work correctly on example app. I'm closing this issue, if it still occurs on the latest version, please let me know, I'll reopen that issue :)

michalchudziak avatar Nov 26 '19 12:11 michalchudziak

This is still occurring for me on Android with version 2.0.7

Findiglay avatar Dec 02 '19 15:12 Findiglay

Same for me, any workarounds to make it works?

LRNZ09 avatar Dec 02 '19 17:12 LRNZ09

This is still occurring for me on Android with version 2.0.9

hezhii avatar Apr 23 '20 10:04 hezhii

using version 2.0.9 and still occurring

teodora-techpods avatar Apr 28 '20 12:04 teodora-techpods

This issue is still occurring on Android, and on iOS emulator the onSliderComplete function is not always called as well. Why isn't this issue in opened state?

aurelianv avatar Oct 14 '20 22:10 aurelianv

onSlidingComplete is not working even with version 3.0.3 on Android. Please open this issue and kindly fix it.

tarangill avatar Oct 17 '20 22:10 tarangill

To run onSlidingComlete in android please do the following changes in << ReactSliderManager.java >> as given below :-

1. Comment this line -->>

ReactSlidingCompleteEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRNCSliderSlidingComplete"), in the getExportedCustomDirectEventTypeConstants() method like given below

 @Override
  public Map getExportedCustomDirectEventTypeConstants() {
    return MapBuilder.of(
        // ======= Comment below line============ 
        //   ReactSlidingCompleteEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRNCSliderSlidingComplete"),
            ReactSlidingStartEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRNCSliderSlidingStart"));
  }

2. Add the given below method

  @Override
  public Map getExportedCustomBubblingEventTypeConstants() {
       return MapBuilder.builder()
               .put(
                       ReactSlidingCompleteEvent.EVENT_NAME ,
                        MapBuilder.of(
                              "phasedRegistrationNames",
                              MapBuilder.of("bubbled", "onRNCSliderSlidingComplete")))
              .build();
  }

Now when event is fired from native code is work properly @michalchudziak

veeru03 avatar Oct 19 '20 08:10 veeru03