From e2928e453dd7ac1771cfc695e1123bac4632b09e Mon Sep 17 00:00:00 2001 From: Kuzniarski Jacek Date: Fri, 13 Oct 2017 16:05:41 +0200 Subject: [PATCH] OnDestroy view now should call presenter with unbind --- .../infullmvp/InFullMvpBottomSheetDialogFragment.kt | 9 +++++++-- .../android/infullmvp/InFullMvpDialogFragment.kt | 6 +++++- .../InFullMvpBottomSheetDialogFragment.java | 6 ++++++ .../android/infullmvp/InFullMvpDialogFragment.java | 13 +++++++++---- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/infullmvp-kotlin/src/main/java/com/infullmobile/android/infullmvp/InFullMvpBottomSheetDialogFragment.kt b/infullmvp-kotlin/src/main/java/com/infullmobile/android/infullmvp/InFullMvpBottomSheetDialogFragment.kt index fd27d82..8a6e07d 100644 --- a/infullmvp-kotlin/src/main/java/com/infullmobile/android/infullmvp/InFullMvpBottomSheetDialogFragment.kt +++ b/infullmvp-kotlin/src/main/java/com/infullmobile/android/infullmvp/InFullMvpBottomSheetDialogFragment.kt @@ -22,10 +22,15 @@ abstract class InFullMvpBottomSheetDialogFragment< val rootView = View.inflate(context, presentedView.layoutResId, null) dialog.setContentView(rootView) presentedView.bindUiElements(dialog, presenter) - presenter.bind(arguments?: Bundle(), Bundle(), activity.intent.data) + presenter.bind(arguments ?: Bundle(), Bundle(), activity.intent.data) } override fun onContextItemSelected(item: MenuItem?): Boolean { - return presenter.onContextItemSelected(item) || super.onContextItemSelected(item) + return presenter.onContextItemSelected(item) || super.onContextItemSelected(item) + } + + override fun onDestroyView() { + presenter.unbind() + super.onDestroyView() } } \ No newline at end of file diff --git a/infullmvp-kotlin/src/main/java/com/infullmobile/android/infullmvp/InFullMvpDialogFragment.kt b/infullmvp-kotlin/src/main/java/com/infullmobile/android/infullmvp/InFullMvpDialogFragment.kt index a47def6..c9efe88 100644 --- a/infullmvp-kotlin/src/main/java/com/infullmobile/android/infullmvp/InFullMvpDialogFragment.kt +++ b/infullmvp-kotlin/src/main/java/com/infullmobile/android/infullmvp/InFullMvpDialogFragment.kt @@ -2,7 +2,6 @@ package com.infullmobile.android.infullmvp import android.app.Dialog import android.os.Bundle -import android.support.annotation.CallSuper import android.support.v4.app.DialogFragment import android.view.MenuItem import android.view.View @@ -34,4 +33,9 @@ abstract class InFullMvpDialogFragment< override fun onContextItemSelected(item: MenuItem?): Boolean { return presenter.onContextItemSelected(item) || super.onContextItemSelected(item) } + + override fun onDestroyView() { + presenter.unbind() + super.onDestroyView() + } } \ No newline at end of file diff --git a/infullmvp/src/main/java/com/infullmobile/android/infullmvp/InFullMvpBottomSheetDialogFragment.java b/infullmvp/src/main/java/com/infullmobile/android/infullmvp/InFullMvpBottomSheetDialogFragment.java index 5677e30..8e716a9 100644 --- a/infullmvp/src/main/java/com/infullmobile/android/infullmvp/InFullMvpBottomSheetDialogFragment.java +++ b/infullmvp/src/main/java/com/infullmobile/android/infullmvp/InFullMvpBottomSheetDialogFragment.java @@ -37,4 +37,10 @@ public void setupDialog(Dialog dialog, int style) { public boolean onContextItemSelected(final MenuItem item) { return getPresenter().onContextItemSelected(item) || super.onContextItemSelected(item); } + + @Override + public void onDestroyView() { + getPresenter().unbind(); + super.onDestroyView(); + } } diff --git a/infullmvp/src/main/java/com/infullmobile/android/infullmvp/InFullMvpDialogFragment.java b/infullmvp/src/main/java/com/infullmobile/android/infullmvp/InFullMvpDialogFragment.java index 011840d..f7ef875 100644 --- a/infullmvp/src/main/java/com/infullmobile/android/infullmvp/InFullMvpDialogFragment.java +++ b/infullmvp/src/main/java/com/infullmobile/android/infullmvp/InFullMvpDialogFragment.java @@ -2,7 +2,6 @@ import android.app.Dialog; import android.os.Bundle; -import android.support.annotation.CallSuper; import android.support.v4.app.DialogFragment; import android.view.MenuItem; import android.view.View; @@ -14,6 +13,9 @@ public abstract class InFullMvpDialogFragment< PresentedViewType extends PresentedDialogView > extends DialogFragment { + private static final int NO_INPUT_FLAGS = + WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; + protected abstract PresenterType getPresenter(); protected abstract PresentedViewType getPresentedView(); @@ -54,11 +56,14 @@ void unrestrictedSetup(Dialog dialog, int style) { } } - private static final int NO_INPUT_FLAGS = - WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; - @Override public boolean onContextItemSelected(final MenuItem item) { return getPresenter().onContextItemSelected(item) || super.onContextItemSelected(item); } + + @Override + public void onDestroyView() { + getPresenter().unbind(); + super.onDestroyView(); + } }