All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.solovyev.android.fragments.AbstractFragmentReuseCondition Maven / Gradle / Ivy

There is a newer version: 1.1.18
Show newest version
package org.solovyev.android.fragments;

import android.support.v4.app.Fragment;
import org.solovyev.common.JPredicate;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public abstract class AbstractFragmentReuseCondition implements JPredicate {

	@Nonnull
	private final Class fragmentClass;

	public AbstractFragmentReuseCondition(@Nonnull Class fragmentClass) {
		this.fragmentClass = fragmentClass;
	}

	@Override
	public final boolean apply(@Nullable Fragment f) {
		if (f != null && fragmentClass.isAssignableFrom(f.getClass())) {
			return canReuseFragment((F) f);
		} else {
			return false;
		}
	}

	/**
	 * @param fragment typed for fragment on which reuse check must be done
	 * @return true if fragment can be reused
	 */
	protected abstract boolean canReuseFragment(@Nonnull F fragment);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy