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

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

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

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import org.solovyev.common.Builder;

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

public class ReflectionFragmentBuilder implements Builder {

	@Nonnull
	private Context context;

	@Nonnull
	private Class fragmentClass;

	@Nullable
	private Bundle fragmentArgs;

	private ReflectionFragmentBuilder(@Nonnull Context context, @Nonnull Class fragmentClass, @Nullable Bundle fragmentArgs) {
		this.context = context;
		this.fragmentClass = fragmentClass;
		this.fragmentArgs = fragmentArgs;
	}

	@Nonnull
	public static  ReflectionFragmentBuilder forClass(@Nonnull Context context, @Nonnull Class fragmentClass, @Nullable Bundle fragmentArgs) {
		return new ReflectionFragmentBuilder(context, fragmentClass, fragmentArgs);
	}

	@Nonnull
	@Override
	public F build() {
		return (F) Fragment.instantiate(context, fragmentClass.getName(), fragmentArgs);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy