Fix #4577
This commit is contained in:
parent
d511e7c103
commit
3792267857
4 changed files with 44 additions and 5 deletions
|
@ -10,6 +10,7 @@ import android.support.annotation.IdRes;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.osmand.plus.IconsCache;
|
||||
|
@ -18,10 +19,11 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||
|
||||
public class BaseOsmAndFragment extends Fragment {
|
||||
public class BaseOsmAndFragment extends Fragment implements TransitionAnimator {
|
||||
private IconsCache iconsCache;
|
||||
|
||||
private int statusBarColor = -1;
|
||||
private boolean transitionAnimationAllowed = true;
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
@ -68,6 +70,27 @@ public class BaseOsmAndFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
|
||||
if (transitionAnimationAllowed) {
|
||||
return super.onCreateAnimation(transit, enter, nextAnim);
|
||||
}
|
||||
Animation anim = new Animation() {
|
||||
};
|
||||
anim.setDuration(0);
|
||||
return anim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableTransitionAnimation() {
|
||||
transitionAnimationAllowed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableTransitionAnimation() {
|
||||
transitionAnimationAllowed = true;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
public int getStatusBarColorId() {
|
||||
return -1;
|
||||
|
|
8
OsmAnd/src/net/osmand/plus/base/TransitionAnimator.java
Normal file
8
OsmAnd/src/net/osmand/plus/base/TransitionAnimator.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package net.osmand.plus.base;
|
||||
|
||||
public interface TransitionAnimator {
|
||||
|
||||
void disableTransitionAnimation();
|
||||
|
||||
void enableTransitionAnimation();
|
||||
}
|
|
@ -440,7 +440,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
return result;
|
||||
}
|
||||
|
||||
public boolean hide() {
|
||||
public boolean hide(boolean allowTransitionAnimation) {
|
||||
boolean result = false;
|
||||
if (mapPosition != 0) {
|
||||
mapActivity.getMapView().setMapPosition(mapPosition);
|
||||
|
@ -451,12 +451,19 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
}
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
if (!allowTransitionAnimation) {
|
||||
fragmentRef.get().disableTransitionAnimation();
|
||||
}
|
||||
fragmentRef.get().dismissMenu();
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean hide() {
|
||||
return hide(true);
|
||||
}
|
||||
|
||||
public void updateControlsVisibility(boolean menuVisible) {
|
||||
int topControlsVisibility = shouldShowTopControls(menuVisible) ? View.VISIBLE : View.GONE;
|
||||
mapActivity.findViewById(R.id.map_center_info).setVisibility(topControlsVisibility);
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.plus.mapcontextmenu.other;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -18,12 +17,13 @@ import android.widget.TextView;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.mapcontextmenu.other.ShareMenu.ShareItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ShareMenuFragment extends Fragment implements OnItemClickListener {
|
||||
public class ShareMenuFragment extends BaseOsmAndFragment implements OnItemClickListener {
|
||||
public static final String TAG = "ShareMenuFragment";
|
||||
|
||||
private ArrayAdapter<ShareItem> listAdapter;
|
||||
|
@ -119,13 +119,14 @@ public class ShareMenuFragment extends Fragment implements OnItemClickListener {
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
menu.share(listAdapter.getItem(position));
|
||||
disableTransitionAnimation();
|
||||
dismissMenu();
|
||||
}
|
||||
|
||||
public void dismissMenu() {
|
||||
menu.getMapActivity().getSupportFragmentManager().popBackStackImmediate(TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
if (menu.getMapActivity().getContextMenu().isVisible()) {
|
||||
menu.getMapActivity().getContextMenu().hide();
|
||||
menu.getMapActivity().getContextMenu().hide(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue