Merge branch 'sasha_pasha_branch' of ssh://github.com/osmandapp/Osmand into sasha_pasha_branch
This commit is contained in:
commit
b478b1c00e
2 changed files with 23 additions and 11 deletions
|
@ -5,6 +5,7 @@ import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -13,17 +14,19 @@ import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout.LayoutParams;
|
import android.widget.LinearLayout.LayoutParams;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
|
||||||
public class PointsListFragment extends Fragment {
|
public class MeasurePointsListFragment extends Fragment {
|
||||||
|
|
||||||
public static final String TAG = "pointsListFragment";
|
public static final String TAG = "MeasurePointsListFragment";
|
||||||
|
|
||||||
private RecyclerView rv;
|
private RecyclerView rv;
|
||||||
private int height;
|
private int height;
|
||||||
private int width;
|
private int width;
|
||||||
private FrameLayout parent;
|
private FrameLayout parent;
|
||||||
|
private FrameLayout mainView;
|
||||||
|
|
||||||
public void setRecyclerView(RecyclerView rv) {
|
public void setRecyclerView(RecyclerView rv) {
|
||||||
this.rv = rv;
|
this.rv = rv;
|
||||||
|
@ -44,11 +47,16 @@ public class PointsListFragment extends Fragment {
|
||||||
final boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
final boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||||
final int backgroundColor = ContextCompat.getColor(getActivity(),
|
final int backgroundColor = ContextCompat.getColor(getActivity(),
|
||||||
nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
|
nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
|
||||||
|
final TypedValue typedValueAttr = new TypedValue();
|
||||||
|
getActivity().getTheme().resolveAttribute(R.attr.left_menu_view_bg, typedValueAttr, true);
|
||||||
|
|
||||||
parent = new FrameLayout(mapActivity);
|
parent = new FrameLayout(mapActivity);
|
||||||
parent.setLayoutParams(new LayoutParams(width, height));
|
parent.setLayoutParams(new LayoutParams(width + AndroidUtils.dpToPx(getActivity(), 16), height));
|
||||||
parent.setBackgroundColor(backgroundColor);
|
parent.setBackgroundResource(typedValueAttr.resourceId);
|
||||||
parent.addView(rv);
|
|
||||||
|
mainView = new FrameLayout(mapActivity);
|
||||||
|
mainView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
mainView.setBackgroundColor(backgroundColor);
|
||||||
|
|
||||||
ImageView shadow = new ImageView(mapActivity);
|
ImageView shadow = new ImageView(mapActivity);
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
@ -56,7 +64,10 @@ public class PointsListFragment extends Fragment {
|
||||||
shadow.setLayoutParams(params);
|
shadow.setLayoutParams(params);
|
||||||
shadow.setScaleType(ImageView.ScaleType.FIT_XY);
|
shadow.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||||
shadow.setImageResource(R.drawable.bg_shadow_onmap);
|
shadow.setImageResource(R.drawable.bg_shadow_onmap);
|
||||||
parent.addView(shadow);
|
|
||||||
|
mainView.addView(rv);
|
||||||
|
mainView.addView(shadow);
|
||||||
|
parent.addView(mainView);
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
@ -64,8 +75,9 @@ public class PointsListFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
if (parent != null) {
|
if (parent != null && mainView != null) {
|
||||||
parent.removeAllViews();
|
parent.removeAllViews();
|
||||||
|
mainView.removeAllViews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -495,14 +495,14 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
private void showPointsListFragment() {
|
private void showPointsListFragment() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
PointsListFragment fragment = new PointsListFragment();
|
MeasurePointsListFragment fragment = new MeasurePointsListFragment();
|
||||||
int screenHeight = AndroidUtils.getScreenHeight(mapActivity) - AndroidUtils.getStatusBarHeight(mapActivity);
|
int screenHeight = AndroidUtils.getScreenHeight(mapActivity) - AndroidUtils.getStatusBarHeight(mapActivity);
|
||||||
fragment.setRecyclerView(pointsRv);
|
fragment.setRecyclerView(pointsRv);
|
||||||
fragment.setWidth(upDownRow.getWidth());
|
fragment.setWidth(upDownRow.getWidth());
|
||||||
fragment.setHeight(screenHeight - upDownRow.getHeight());
|
fragment.setHeight(screenHeight - upDownRow.getHeight());
|
||||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||||
.add(R.id.fragmentContainer, fragment, PointsListFragment.TAG)
|
.add(R.id.fragmentContainer, fragment, MeasurePointsListFragment.TAG)
|
||||||
.addToBackStack(PointsListFragment.TAG)
|
.addToBackStack(MeasurePointsListFragment.TAG)
|
||||||
.commitAllowingStateLoss();
|
.commitAllowingStateLoss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
try {
|
try {
|
||||||
mapActivity.getSupportFragmentManager()
|
mapActivity.getSupportFragmentManager()
|
||||||
.popBackStackImmediate(PointsListFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
.popBackStackImmediate(MeasurePointsListFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue