org.solovyev.android.fragments.ReflectionFragmentBuilder Maven / Gradle / Ivy
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 extends F> fragmentClass;
@Nullable
private Bundle fragmentArgs;
private ReflectionFragmentBuilder(@Nonnull Context context, @Nonnull Class extends F> fragmentClass, @Nullable Bundle fragmentArgs) {
this.context = context;
this.fragmentClass = fragmentClass;
this.fragmentArgs = fragmentArgs;
}
@Nonnull
public static ReflectionFragmentBuilder forClass(@Nonnull Context context, @Nonnull Class extends F> 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