From ca09b4786e34a617e927b85c54bc8068f1a33e46 Mon Sep 17 00:00:00 2001 From: Aleksandr Zaycev Date: Wed, 25 Nov 2015 11:06:02 +0200 Subject: [PATCH 1/4] fix setClosableOutside destroy the current activity bug --- .../yalantis/contextmenu/lib/ContextMenuDialogFragment.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/main/java/com/yalantis/contextmenu/lib/ContextMenuDialogFragment.java b/lib/src/main/java/com/yalantis/contextmenu/lib/ContextMenuDialogFragment.java index f546cb8..3cc9a74 100644 --- a/lib/src/main/java/com/yalantis/contextmenu/lib/ContextMenuDialogFragment.java +++ b/lib/src/main/java/com/yalantis/contextmenu/lib/ContextMenuDialogFragment.java @@ -130,7 +130,9 @@ public void run() { rootView.findViewById(R.id.root).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - getActivity().onBackPressed(); + if (isAdded()) { + dismiss(); + } } }); } From dc4c4f9a09e7c9aca51aae789f726eeab7db59d8 Mon Sep 17 00:00:00 2001 From: Aleksandr Zaycev Date: Wed, 25 Nov 2015 11:41:13 +0200 Subject: [PATCH 2/4] fix implements in fragment bug (you can implement click listeners in any place) --- .../contextmenu/sample/MainActivity.java | 10 +++---- .../lib/ContextMenuDialogFragment.java | 27 ++++++------------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/yalantis/contextmenu/sample/MainActivity.java b/app/src/main/java/com/yalantis/contextmenu/sample/MainActivity.java index d739b83..027b83c 100644 --- a/app/src/main/java/com/yalantis/contextmenu/sample/MainActivity.java +++ b/app/src/main/java/com/yalantis/contextmenu/sample/MainActivity.java @@ -4,11 +4,10 @@ import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; -import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuInflater; @@ -27,11 +26,10 @@ import java.util.ArrayList; import java.util.List; -public class MainActivity extends ActionBarActivity implements OnMenuItemClickListener, - OnMenuItemLongClickListener{ +public class MainActivity extends AppCompatActivity implements OnMenuItemClickListener, OnMenuItemLongClickListener{ private FragmentManager fragmentManager; - private DialogFragment mMenuDialogFragment; + private ContextMenuDialogFragment mMenuDialogFragment; @Override protected void onCreate(Bundle savedInstanceState) { @@ -49,6 +47,8 @@ private void initMenuFragment() { menuParams.setMenuObjects(getMenuObjects()); menuParams.setClosableOutside(false); mMenuDialogFragment = ContextMenuDialogFragment.newInstance(menuParams); + mMenuDialogFragment.setItemClickListener(this); + mMenuDialogFragment.setItemLongClickListener(this); } private List getMenuObjects() { diff --git a/lib/src/main/java/com/yalantis/contextmenu/lib/ContextMenuDialogFragment.java b/lib/src/main/java/com/yalantis/contextmenu/lib/ContextMenuDialogFragment.java index 3cc9a74..dc1ed80 100644 --- a/lib/src/main/java/com/yalantis/contextmenu/lib/ContextMenuDialogFragment.java +++ b/lib/src/main/java/com/yalantis/contextmenu/lib/ContextMenuDialogFragment.java @@ -2,12 +2,10 @@ import android.annotation.SuppressLint; import android.annotation.TargetApi; -import android.app.Activity; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.DialogFragment; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -83,23 +81,6 @@ public static ContextMenuDialogFragment newInstance(MenuParams menuParams) { return fragment; } - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - try { - mItemClickListener = (OnMenuItemClickListener) activity; - } catch (ClassCastException e) { - Log.e(TAG, activity.getClass().getSimpleName() + - " should implement " + OnMenuItemClickListener.class.getSimpleName()); - } - try { - mItemLongClickListener = (OnMenuItemLongClickListener) activity; - } catch (ClassCastException e) { - Log.e(TAG, activity.getClass().getSimpleName() + - " should implement " + OnMenuItemLongClickListener.class.getSimpleName()); - } - } - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -161,6 +142,14 @@ public void run() { }, mMenuParams.getAnimationDelay()); } + public void setItemLongClickListener(OnMenuItemLongClickListener itemLongClickListener) { + this.mItemLongClickListener = itemLongClickListener; + } + + public void setItemClickListener(OnMenuItemClickListener itemClickListener) { + this.mItemClickListener = itemClickListener; + } + /** * Menu item click method */ From b3e48a969b6e23823e622f1c7a1508b655f9ffb6 Mon Sep 17 00:00:00 2001 From: Aleksandr Zaycev Date: Wed, 25 Nov 2015 12:27:44 +0200 Subject: [PATCH 3/4] =?UTF-8?q?fix=20setAnimationDuration=20doesn=C2=B4t?= =?UTF-8?q?=20work=20for=20open=20event=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/main/java/com/yalantis/contextmenu/lib/MenuAdapter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/main/java/com/yalantis/contextmenu/lib/MenuAdapter.java b/lib/src/main/java/com/yalantis/contextmenu/lib/MenuAdapter.java index 511b7e5..3740293 100644 --- a/lib/src/main/java/com/yalantis/contextmenu/lib/MenuAdapter.java +++ b/lib/src/main/java/com/yalantis/contextmenu/lib/MenuAdapter.java @@ -285,6 +285,8 @@ private void toggleIsMenuOpen() { public void setAnimationDuration(int durationMillis) { mAnimationDurationMilis = durationMillis; + mAnimatorSetShowMenu.setDuration(mAnimationDurationMilis); + mAnimatorSetHideMenu.setDuration(mAnimationDurationMilis); } private Animator.AnimatorListener mCloseOpenAnimatorListener = new Animator.AnimatorListener() { From 2e44ffa545260538d9483399ddaf47dc613bb3e9 Mon Sep 17 00:00:00 2001 From: Aleksandr Zaycev Date: Wed, 25 Nov 2015 13:01:41 +0200 Subject: [PATCH 4/4] 1.0.5 --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 91fa8c9..56eb563 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,8 +17,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.0.4 -VERSION_CODE=5 +VERSION_NAME=1.0.5 +VERSION_CODE=6 GROUP=com.yalantis POM_DESCRIPTION=Android Library to display awesome context menu