Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #79 from grandcentrix/feature/restrict_tifragment_…
Browse files Browse the repository at this point in the history
…api_for_subclasses

Feature: restrict TiFragment api for subclasses
  • Loading branch information
passsy authored Apr 5, 2017
2 parents 4af1f33 + 73cf99f commit 972fd68
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

Expand All @@ -54,7 +55,7 @@ public class TiActivityPlugin<P extends TiPresenter<V>, V extends TiView> extend
implements TiViewProvider<V>, DelegatedTiActivity<P>, TiLoggingTagProvider,
InterceptableViewBinder<V>, PresenterAccessor<P, V> {

public static final String NCI_KEY_PRESENTER = "presenter";
private static final String NCI_KEY_PRESENTER = "presenter";

private String TAG = this.getClass().getSimpleName()
+ "@" + Integer.toHexString(this.hashCode());
Expand All @@ -81,7 +82,7 @@ public TiActivityPlugin(@NonNull final TiPresenterProvider<P> presenterProvider)

@NonNull
@Override
public Removable addBindViewInterceptor(@NonNull final BindViewInterceptor interceptor) {
public final Removable addBindViewInterceptor(@NonNull final BindViewInterceptor interceptor) {
return mDelegate.addBindViewInterceptor(interceptor);
}

Expand All @@ -90,7 +91,7 @@ public Removable addBindViewInterceptor(@NonNull final BindViewInterceptor inter
*/
@Nullable
@Override
public V getInterceptedViewOf(@NonNull final BindViewInterceptor interceptor) {
public final V getInterceptedViewOf(@NonNull final BindViewInterceptor interceptor) {
return mDelegate.getInterceptedViewOf(interceptor);
}

Expand All @@ -100,7 +101,7 @@ public V getInterceptedViewOf(@NonNull final BindViewInterceptor interceptor) {
*/
@NonNull
@Override
public List<BindViewInterceptor> getInterceptors(
public final List<BindViewInterceptor> getInterceptors(
@NonNull final Filter<BindViewInterceptor> predicate) {
return mDelegate.getInterceptors(predicate);
}
Expand All @@ -111,14 +112,14 @@ public String getLoggingTag() {
}

@Override
public P getPresenter() {
public final P getPresenter() {
return mDelegate.getPresenter();
}

@SuppressWarnings("unchecked")
@Nullable
@Override
public P getRetainedPresenter() {
public final P getRetainedPresenter() {
final Object nci = getLastNonConfigurationInstance(NCI_KEY_PRESENTER);
if (nci != null) {
return (P) nci;
Expand All @@ -127,7 +128,7 @@ public P getRetainedPresenter() {
}

@Override
public Executor getUiThreadExecutor() {
public final Executor getUiThreadExecutor() {
return mUiThreadExecutor;
}

Expand All @@ -136,7 +137,7 @@ public Executor getUiThreadExecutor() {
* through all the interceptors (again).
*/
@Override
public void invalidateView() {
public final void invalidateView() {
mDelegate.invalidateView();
}

Expand All @@ -146,33 +147,37 @@ public boolean isActivityChangingConfigurations() {
}

@Override
public boolean isActivityFinishing() {
public final boolean isActivityFinishing() {
return getActivity().isFinishing();
}

@Override
public boolean isDontKeepActivitiesEnabled() {
public final boolean isDontKeepActivitiesEnabled() {
return AndroidDeveloperOptions.isDontKeepActivitiesEnabled(getActivity());
}

@CallSuper
@Override
public void onConfigurationChanged(final Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mDelegate.onConfigurationChanged_afterSuper(newConfig);
}

@CallSuper
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDelegate.onCreate_afterSuper(savedInstanceState);
}

@CallSuper
@Override
public void onDestroy() {
super.onDestroy();
mDelegate.onDestroy_afterSuper();
}

@CallSuper
@Override
@Nullable
public CompositeNonConfigurationInstance onRetainNonConfigurationInstance() {
Expand All @@ -188,18 +193,21 @@ public CompositeNonConfigurationInstance onRetainNonConfigurationInstance() {
return null;
}

@CallSuper
@Override
public void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
mDelegate.onSaveInstanceState_afterSuper(outState);
}

@CallSuper
@Override
public void onStart() {
super.onStart();
mDelegate.onStart_afterSuper();
}

@CallSuper
@Override
public void onStop() {
mDelegate.onStop_beforeSuper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import net.grandcentrix.thirtyinch.util.AnnotationUtil;

import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
Expand Down Expand Up @@ -82,7 +83,7 @@ public TiFragmentPlugin(@NonNull final TiPresenterProvider<P> presenterProvider)

@NonNull
@Override
public Removable addBindViewInterceptor(@NonNull final BindViewInterceptor interceptor) {
public final Removable addBindViewInterceptor(@NonNull final BindViewInterceptor interceptor) {
return mDelegate.addBindViewInterceptor(interceptor);
}

Expand All @@ -91,7 +92,7 @@ public Removable addBindViewInterceptor(@NonNull final BindViewInterceptor inter
*/
@Nullable
@Override
public V getInterceptedViewOf(@NonNull final BindViewInterceptor interceptor) {
public final V getInterceptedViewOf(@NonNull final BindViewInterceptor interceptor) {
return mDelegate.getInterceptedViewOf(interceptor);
}

Expand All @@ -101,7 +102,7 @@ public V getInterceptedViewOf(@NonNull final BindViewInterceptor interceptor) {
*/
@NonNull
@Override
public List<BindViewInterceptor> getInterceptors(
public final List<BindViewInterceptor> getInterceptors(
@NonNull final Filter<BindViewInterceptor> predicate) {
return mDelegate.getInterceptors(predicate);
}
Expand All @@ -112,12 +113,12 @@ public String getLoggingTag() {
}

@Override
public P getPresenter() {
public final P getPresenter() {
return mDelegate.getPresenter();
}

@Override
public Executor getUiThreadExecutor() {
public final Executor getUiThreadExecutor() {
return mUiThreadExecutor;
}

Expand All @@ -126,41 +127,43 @@ public Executor getUiThreadExecutor() {
* through all the interceptors (again).
*/
@Override
public void invalidateView() {
public final void invalidateView() {
mDelegate.invalidateView();
}

@Override
public boolean isDontKeepActivitiesEnabled() {
public final boolean isDontKeepActivitiesEnabled() {
return AndroidDeveloperOptions.isDontKeepActivitiesEnabled(getFragment().getActivity());
}

@Override
public boolean isFragmentAdded() {
public final boolean isFragmentAdded() {
return getFragment().isAdded();
}

@Override
public boolean isFragmentDetached() {
public final boolean isFragmentDetached() {
return getFragment().isDetached();
}

@Override
public boolean isHostingActivityChangingConfigurations() {
public final boolean isHostingActivityChangingConfigurations() {
return getFragment().getActivity().isChangingConfigurations();
}

@Override
public boolean isHostingActivityFinishing() {
public final boolean isHostingActivityFinishing() {
return getFragment().getActivity().isFinishing();
}

@CallSuper
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDelegate.onCreate_afterSuper(savedInstanceState);
}

@CallSuper
@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container,
Expand All @@ -169,30 +172,35 @@ public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGrou
return super.onCreateView(inflater, container, savedInstanceState);
}

@CallSuper
@Override
public void onDestroy() {
super.onDestroy();
mDelegate.onDestroy_afterSuper();
}

@CallSuper
@Override
public void onDestroyView() {
mDelegate.onDestroyView_beforeSuper();
super.onDestroyView();
}

@CallSuper
@Override
public void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
mDelegate.onSaveInstanceState_afterSuper(outState);
}

@CallSuper
@Override
public void onStart() {
super.onStart();
mDelegate.onStart_afterSuper();
}

@CallSuper
@Override
public void onStop() {
mDelegate.onStop_beforeSuper();
Expand Down Expand Up @@ -229,7 +237,7 @@ public V provideView() {
}

@Override
public void setFragmentRetainInstance(final boolean retain) {
public final void setFragmentRetainInstance(final boolean retain) {
getFragment().setRetainInstance(retain);
}

Expand Down
Loading

0 comments on commit 972fd68

Please sign in to comment.