### Execute Unit Tests with Gradle Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md This command line snippet demonstrates how to run unit tests for the project using Gradle. Executing `./gradlew test` will compile and run all defined unit tests, providing feedback on code correctness. ```shell ./gradlew test ``` -------------------------------- ### Run Static Code Analysis with Gradle Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md This command line snippet shows how to perform static code analysis using Gradle. The `./gradlew check` command runs Checkstyle, PMD, and Lint, generating reports in the `library/build/reports/` directory to identify potential code quality issues. ```shell ./gradlew check ``` -------------------------------- ### Initialize Swipe and Subscribe to Swipe Events with RxJava Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md This code demonstrates the initialization of the `Swipe` object and subscription to its observable events within the `onCreate` method of an Android `Activity`. It uses RxJava's `subscribeOn` for computation and `observeOn` for UI thread updates, displaying swipe events in a `TextView`. ```java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); info = (TextView) findViewById(R.id.info); swipe = new Swipe(); disposable = swipe.observe() .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(swipeEvent -> info.setText(swipeEvent.toString())); } ``` -------------------------------- ### Add Swipe Library Dependency via Maven Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md This XML snippet provides the Maven dependency configuration for including the `swipe-rx2` library in a Java project. Users should add this `` block to their `pom.xml` file to integrate the library. ```xml com.github.pwittchen swipe-rx2 0.3.0 ``` -------------------------------- ### Add Swipe Library Dependency via Gradle Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md This Groovy snippet shows how to add the `swipe-rx2` library as a dependency in a Gradle project. Developers should include this line in their `build.gradle` file, typically within the `dependencies` block, to use the library. ```groovy dependencies { compile 'com.github.pwittchen:swipe-rx2:0.3.0' } ``` -------------------------------- ### Swipe Class Constructor for Threshold Configuration Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md Documents the `Swipe` class constructor that allows configuration of swipe sensitivity thresholds. `swipingThreshold` defines the distance for a 'swiping' event, while `swipedThreshold` defines the distance for a 'swiped' event. Decreasing these values increases sensitivity. ```APIDOC Swipe(int swipingThreshold, int swipedThreshold) swipingThreshold: int - The distance in pixels to trigger a 'swiping' event. Default is 20. swipedThreshold: int - The distance in pixels to trigger a 'swiped' event. Default is 100. ``` -------------------------------- ### Initialize Swipe and Set Listener in Android Activity Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md Initializes the `Swipe` object within the `onCreate` method of an Android Activity. It sets a `SwipeListener` to handle various swipe events (left, right, up, down) for both swiping (in progress) and swiped (completed) states, updating a TextView with the detected event. ```Java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); info = (TextView) findViewById(R.id.info); swipe = new Swipe(); swipe.setListener(new SwipeListener() { @Override public void onSwipingLeft(final MotionEvent event) { info.setText("SWIPING_LEFT"); } @Override public void onSwipedLeft(final MotionEvent event) { info.setText("SWIPED_LEFT"); } @Override public void onSwipingRight(final MotionEvent event) { info.setText("SWIPING_RIGHT"); } @Override public void onSwipedRight(final MotionEvent event) { info.setText("SWIPED_RIGHT"); } @Override public void onSwipingUp(final MotionEvent event) { info.setText("SWIPING_UP"); } @Override public void onSwipedUp(final MotionEvent event) { info.setText("SWIPED_UP"); } @Override public void onSwipingDown(final MotionEvent event) { info.setText("SWIPING_DOWN"); } @Override public void onSwipedDown(final MotionEvent event) { info.setText("SWIPED_DOWN"); } }); } ``` -------------------------------- ### Declare Swipe Instance in Android Activity Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md Declares a private instance of the `Swipe` class within an Android Activity. This instance will be used to manage and detect swipe events. ```Java private Swipe swipe; ``` -------------------------------- ### Dispose RxJava Disposable in Android Activity Lifecycle Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md This code demonstrates the proper disposal of the RxJava `Disposable` object within the `onPause` method of an Android `Activity`. Disposing the subscription prevents memory leaks and ensures resources are released when the activity is no longer active. ```java @Override protected void onPause() { super.onPause(); if (disposable != null && !disposable.isDisposed()) { disposable.dispose(); } } ``` -------------------------------- ### Declare Swipe and Disposable Attributes in Android Activity Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md This snippet shows the declaration of `Swipe` and `Disposable` objects as private attributes within an Android `Activity`. These are essential for managing swipe gesture detection and RxJava subscriptions respectively. ```java private Swipe swipe; private Disposable disposable; ``` -------------------------------- ### Override dispatchTouchEvent for Swipe Gesture Processing Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md This snippet shows how to override the `dispatchTouchEvent` method in an Android `Activity` to pass touch events to the `Swipe` object. This is crucial for the `Swipe` library to process and detect gestures, ensuring the `Activity`'s default touch handling is also maintained. ```java @Override public boolean dispatchTouchEvent(MotionEvent event) { swipe.dispatchTouchEvent(event); return super.dispatchTouchEvent(event); } ``` -------------------------------- ### Override dispatchTouchEvent for Swipe Event Handling Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md Overrides the `dispatchTouchEvent` method in an Android Activity to pass all touch events to the `Swipe` object. This allows the `Swipe` library to process the events and detect swipe gestures. It then calls the superclass method to ensure normal touch event dispatching continues. ```Java @Override public boolean dispatchTouchEvent(MotionEvent event) { swipe.dispatchTouchEvent(event); return super.dispatchTouchEvent(event); } ``` -------------------------------- ### SwipeEvent Enum Definition Source: https://github.com/pwittchen/swipe/blob/RxJava2.x/README.md Defines the `SwipeEvent` enum, which represents various states of a swipe gesture. These values indicate whether a swipe is in progress (SWIPING_*) or completed (SWIPED_*), and in which direction. ```APIDOC public enum SwipeEvent { SWIPING_LEFT, SWIPED_LEFT, SWIPING_RIGHT, SWIPED_RIGHT, SWIPING_UP, SWIPED_UP, SWIPING_DOWN, SWIPED_DOWN } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.