Merge pull request #11167 from osmandapp/fix_class_cast_exc
Fix ClassCastException
This commit is contained in:
commit
8020884d6a
1 changed files with 36 additions and 19 deletions
|
@ -11,7 +11,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
@ -20,6 +19,18 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.widget.TextViewCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.github.ksoichiro.android.observablescrollview.ScrollUtils;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
|
@ -85,17 +96,6 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.widget.TextViewCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import static net.osmand.IndexConstants.GPX_FILE_EXT;
|
||||
import static net.osmand.IndexConstants.GPX_INDEX_DIR;
|
||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode;
|
||||
|
@ -303,9 +303,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
} else {
|
||||
cardsContainer = mapActivity.findViewById(R.id.left_side_menu);
|
||||
bottomMapControls = mapActivity.findViewById(R.id.bottom_controls_container);
|
||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
ScrollUtils.addOnGlobalLayoutListener(mainView, new Runnable() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
public void run() {
|
||||
updateCardContainerSize();
|
||||
}
|
||||
});
|
||||
|
@ -676,19 +676,36 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
}
|
||||
|
||||
private void updateCardContainerSize() {
|
||||
if (portrait) {
|
||||
return;
|
||||
}
|
||||
View measureModeControls = mainView.findViewById(R.id.measure_mode_controls);
|
||||
int width = mainView.getWidth() - measureModeControls.getWidth();
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(width, -1);
|
||||
int bottomMargin = measureModeControls.getHeight();
|
||||
bottomMargin = progressBarVisible ? bottomMargin + mainView.findViewById(R.id.snap_to_road_progress_bar).getHeight() : bottomMargin;
|
||||
if (mainView.getParent() instanceof FrameLayout) {
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(width, -1);
|
||||
params.setMargins(0, 0, 0, bottomMargin);
|
||||
cardsContainer.setLayoutParams(params);
|
||||
} else if (mainView.getParent() instanceof LinearLayout) {
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, -1);
|
||||
params.setMargins(0, 0, 0, bottomMargin);
|
||||
cardsContainer.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
|
||||
private void shiftBottomMapControls(boolean toInitialPosition) {
|
||||
if (portrait) {
|
||||
return;
|
||||
}
|
||||
int leftMargin = toInitialPosition ? 0 : cardsContainer.getWidth();
|
||||
if (bottomMapControls.getParent() instanceof LinearLayout) {
|
||||
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) bottomMapControls.getLayoutParams();
|
||||
params.setMargins(leftMargin, 0, 0, 0);
|
||||
} else if (bottomMapControls.getParent() instanceof FrameLayout) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) bottomMapControls.getLayoutParams();
|
||||
params.setMargins(leftMargin, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInEditMode() {
|
||||
|
|
Loading…
Reference in a new issue