public interface

DifferentialMotionFlingTarget

 androidx.core.view.DifferentialMotionFlingTarget

Gradle dependencies

compile group: 'androidx.core', name: 'core', version: '1.15.0-alpha02'

  • groupId: androidx.core
  • artifactId: core
  • version: 1.15.0-alpha02

Artifact androidx.core:core:1.15.0-alpha02 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.core:core com.android.support:support-compat

Overview

Represents an entity that may be flung by a differential motion or an entity that initiates fling on a target View.

Summary

Methods
public floatgetScaledScrollFactor()

Returns the scaled scroll factor to be used for differential motions.

public booleanstartDifferentialMotionFling(float velocity)

Start flinging on the target View by a given velocity.

public voidstopDifferentialMotionFling()

Stop any ongoing fling on the target View that is caused by a differential motion.

Methods

public boolean startDifferentialMotionFling(float velocity)

Start flinging on the target View by a given velocity.

Parameters:

velocity: the fling velocity, in pixels/second.

Returns:

true if fling was successfully initiated, false otherwise.

public void stopDifferentialMotionFling()

Stop any ongoing fling on the target View that is caused by a differential motion.

public float getScaledScrollFactor()

Returns the scaled scroll factor to be used for differential motions. This is the value that the raw MotionEvent values should be multiplied with to get pixels.

This usually is one of the values provided by ViewConfigurationCompat. It is up to the client to choose and provide any value as per its internal configuration.

See also: ViewConfigurationCompat.getScaledHorizontalScrollFactor(ViewConfiguration, Context), ViewConfigurationCompat.getScaledVerticalScrollFactor(ViewConfiguration, Context)

Source

/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.core.view;

import android.content.Context;
import android.view.MotionEvent;
import android.view.ViewConfiguration;

/**
 * Represents an entity that may be flung by a differential motion or an entity that initiates
 * fling on a target View.
 */
public interface DifferentialMotionFlingTarget {
    /**
     * Start flinging on the target View by a given velocity.
     *
     * @param velocity the fling velocity, in pixels/second.
     * @return {@code true} if fling was successfully initiated, {@code false} otherwise.
     */
    boolean startDifferentialMotionFling(float velocity);

    /** Stop any ongoing fling on the target View that is caused by a differential motion. */
    void stopDifferentialMotionFling();

    /**
     * Returns the scaled scroll factor to be used for differential motions. This is the
     * value that the raw {@link MotionEvent} values should be multiplied with to get pixels.
     *
     * <p>This usually is one of the values provided by {@link ViewConfigurationCompat}. It is
     * up to the client to choose and provide any value as per its internal configuration.
     *
     * @see ViewConfigurationCompat#getScaledHorizontalScrollFactor(ViewConfiguration, Context)
     * @see ViewConfigurationCompat#getScaledVerticalScrollFactor(ViewConfiguration, Context)
     */
    float getScaledScrollFactor();
}