Skip to content

Commit

Permalink
Merge branch 'release/1.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Zaycev committed Nov 25, 2015
2 parents 36698a1 + 2e44ffa commit bff827d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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<MenuObject> getMenuObjects() {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -130,7 +111,9 @@ public void run() {
rootView.findViewById(R.id.root).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
if (isAdded()) {
dismiss();
}
}
});
}
Expand Down Expand Up @@ -159,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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit bff827d

Please sign in to comment.