-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Hello,
I followed this example : https://github.com/soundcloud/lightcycle/blob/master/lightcycle-lib/src/main/java/com/soundcloud/lightcycle/LightCycleSupportFragment.java
to build my parent class wich will be inherited by all fragments :
public abstract class M360LightCycleSupportFragment<FragmentType extends M360Fragment> extends M360Fragment implements LightCycleDispatcher<SupportFragmentLightCycle<FragmentType>> {
private final SupportFragmentLightCycleDispatcher<FragmentType> lifeCycleDispatcher;
private boolean bound;
public M360LightCycleSupportFragment() {
lifeCycleDispatcher = new SupportFragmentLightCycleDispatcher<>();
}
@Override
public void bind(SupportFragmentLightCycle<FragmentType> lifeCycleComponent) {
Preconditions.checkBindingTarget(lifeCycleComponent);
lifeCycleDispatcher.bind(lifeCycleComponent);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
bindIfNecessary();
lifeCycleDispatcher.onAttach(fragment(), activity);
}
private void bindIfNecessary() {
if (!bound) {
LightCycles.bind(this);
bound = true;
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lifeCycleDispatcher.onCreate(fragment(), savedInstanceState);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
lifeCycleDispatcher.onViewCreated(fragment(), view, savedInstanceState);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
lifeCycleDispatcher.onActivityCreated(fragment(), savedInstanceState);
}
@Override
public void onStart() {
super.onStart();
lifeCycleDispatcher.onStart(fragment());
}
@Override
public void onResume() {
super.onResume();
lifeCycleDispatcher.onResume(fragment());
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return lifeCycleDispatcher.onOptionsItemSelected(fragment(), item);
}
@Override
public void onPause() {
lifeCycleDispatcher.onPause(fragment());
super.onPause();
}
@Override
public void onStop() {
lifeCycleDispatcher.onStop(fragment());
super.onStop();
}
@Override
public void onSaveInstanceState(Bundle outState) {
lifeCycleDispatcher.onSaveInstanceState(fragment(), outState);
super.onSaveInstanceState(outState);
}
@Override
public void onDestroyView() {
lifeCycleDispatcher.onDestroyView(fragment());
super.onDestroyView();
}
@Override
public void onDestroy() {
lifeCycleDispatcher.onDestroy(fragment());
super.onDestroy();
}
@Override
public void onDetach() {
lifeCycleDispatcher.onDetach(fragment());
super.onDetach();
}
@SuppressWarnings("unchecked")
private FragmentType fragment() {
return (FragmentType) this;
}
}Then my Fragment :
public class ProgramDetailsFragment extends M360LightCycleSupportFragment<ProgramDetailsFragment> {
@LightCycle
final ProgramPresenter programPresenter = new ProgramPresenter();
[...]my Controller :
public class ProgramPresenter extends DefaultSupportFragmentLightCycle<ProgramDetailsFragment> {
private static final String TAG = "ProgramPresenter";
@Override
public void onAttach(ProgramDetailsFragment fragment, Activity activity) {
Log.i(TAG, "onAttach");
super.onAttach(fragment, activity);
}
[...]when I extends this class in my code I obtain the following error at compilation :
Error:(5, 63) error: cannot find symbol class FragmentType
Is there something I didn't understand ? It feels like it won't be possible
A gist of a working 'parent fragment dispatcher' - 'inherited fragment' - 'controller' would be the perfect resource for me, maybe it already exists.
Thank you all,
Metadata
Metadata
Assignees
Labels
No labels