From 86679176d66f5ff3e805f2d09fbdbd1b3744abbb Mon Sep 17 00:00:00 2001 From: neslihanturan Date: Thu, 13 Jun 2019 23:00:05 +0300 Subject: [PATCH] Add list item clicked and bottom sheet for list of nearby items is expanded --- .../mvp/fragments/NearbyParentFragment.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyParentFragment.java b/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyParentFragment.java index d77cb12de..0a1a1a874 100644 --- a/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyParentFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyParentFragment.java @@ -6,6 +6,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; import android.util.Log; @@ -114,12 +115,19 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment setRetainInstance(true); } + @Override + public void onConfigurationChanged(@NonNull Configuration newConfig) { + super.onConfigurationChanged(newConfig); + Log.d("deneme3","oncongi changed fragmenr"+this); + } + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_nearby, container, false); ButterKnife.bind(this, view); this.view = view; + initBottomSheetBehaviour(); Timber.d("onCreateView"); return view; } @@ -337,6 +345,36 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment getActivity().registerReceiver(broadcastReceiver, intentFilter); } + /** + * Initialize bottom sheet behaviour (sheet for map list.) Set height 9/16 of all window. + * Add callback for bottom sheet changes, so that we can sync it with bottom sheet for details + * (sheet for nearby details) + */ + private void initBottomSheetBehaviour() { + + transparentView.setAlpha(0); + bottomSheet.getLayoutParams().height = getActivity().getWindowManager() + .getDefaultDisplay().getHeight() / 16 * 9; + bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); + bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { + + @Override + public void onStateChanged(View bottomSheet, int unusedNewState) { + //prepareViewsForSheetPosition(); + } + + @Override + public void onSlide(View bottomSheet, float slideOffset) { + + } + }); + + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); + bottomSheetBehaviorForDetails = BottomSheetBehavior.from(bottomSheetDetails); + bottomSheetBehaviorForDetails.setState(BottomSheetBehavior.STATE_HIDDEN); + } + + /** * Hide or expand bottom sheet according to states of all sheets */