public class

GuidedActionDiffCallback

extends DiffCallback<GuidedAction>

 java.lang.Object

androidx.leanback.widget.DiffCallback<GuidedAction>

↳androidx.leanback.widget.GuidedActionDiffCallback

Gradle dependencies

compile group: 'androidx.leanback', name: 'leanback', version: '1.2.0-alpha02'

  • groupId: androidx.leanback
  • artifactId: leanback
  • version: 1.2.0-alpha02

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

Androidx artifact mapping:

androidx.leanback:leanback com.android.support:leanback-v17

Androidx class mapping:

androidx.leanback.widget.GuidedActionDiffCallback android.support.v17.leanback.widget.GuidedActionDiffCallback

Overview

DiffCallback used for GuidedActions, see GuidedStepSupportFragment.setActionsDiffCallback(DiffCallback).

Summary

Constructors
publicGuidedActionDiffCallback()

Methods
public abstract booleanareContentsTheSame(java.lang.Object oldItem, java.lang.Object newItem)

Called to decide whether two items have the same data.

public abstract booleanareItemsTheSame(java.lang.Object oldItem, java.lang.Object newItem)

Called to decide whether two objects represent the same item.

public static GuidedActionDiffCallbackgetInstance()

Returns the singleton GuidedActionDiffCallback.

from DiffCallback<Value>getChangePayload
from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public GuidedActionDiffCallback()

Methods

public static GuidedActionDiffCallback getInstance()

Returns the singleton GuidedActionDiffCallback.

Returns:

The singleton GuidedActionDiffCallback.

public abstract boolean areItemsTheSame(java.lang.Object oldItem, java.lang.Object newItem)

Called to decide whether two objects represent the same item.

Parameters:

oldItem: The item in the old list.
newItem: The item in the new list.

Returns:

True if the two items represent the same object or false if they are different.

See also:

public abstract boolean areContentsTheSame(java.lang.Object oldItem, java.lang.Object newItem)

Called to decide whether two items have the same data. This information is used to detect if the contents of an item have changed.

Parameters:

oldItem: The item in the old list.
newItem: The item in the new list.

Returns:

True if the contents of the items are the same or false if they are different.

See also:

Source

/*
 * Copyright 2017 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.leanback.widget;

import android.text.TextUtils;

import androidx.annotation.NonNull;

/**
 * DiffCallback used for GuidedActions, see {@link
 * androidx.leanback.app.GuidedStepSupportFragment#setActionsDiffCallback(DiffCallback)}.
 */
public class GuidedActionDiffCallback extends DiffCallback<GuidedAction> {

    static final GuidedActionDiffCallback sInstance = new GuidedActionDiffCallback();

    /**
     * Returns the singleton GuidedActionDiffCallback.
     * @return The singleton GuidedActionDiffCallback.
     */
    public static GuidedActionDiffCallback getInstance() {
        return sInstance;
    }

    @Override
    public boolean areItemsTheSame(@NonNull GuidedAction oldItem, @NonNull GuidedAction newItem) {
        if (oldItem == null) {
            return newItem == null;
        } else if (newItem == null) {
            return false;
        }
        return oldItem.getId() == newItem.getId();
    }

    @Override
    public boolean areContentsTheSame(@NonNull GuidedAction oldItem,
            @NonNull GuidedAction newItem) {
        if (oldItem == null) {
            return newItem == null;
        } else if (newItem == null) {
            return false;
        }
        return oldItem.getCheckSetId() == newItem.getCheckSetId()
                && oldItem.mActionFlags == newItem.mActionFlags
                && TextUtils.equals(oldItem.getTitle(), newItem.getTitle())
                && TextUtils.equals(oldItem.getDescription(), newItem.getDescription())
                && oldItem.getInputType() == newItem.getInputType()
                && TextUtils.equals(oldItem.getEditTitle(), newItem.getEditTitle())
                && TextUtils.equals(oldItem.getEditDescription(), newItem.getEditDescription())
                && oldItem.getEditInputType() == newItem.getEditInputType()
                && oldItem.getDescriptionEditInputType() == newItem.getDescriptionEditInputType();
    }
}