mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-05 09:13:55 +01:00
Compare commits
5 commits
09638b0c9b
...
a6b0ecc0b2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6b0ecc0b2 | ||
|
|
df8585d877 | ||
|
|
b31a01c3ee | ||
|
|
c44a610db9 | ||
|
|
55ff68b729 |
3 changed files with 21 additions and 6 deletions
|
|
@ -18,6 +18,17 @@ public class ViewPagerAdapter extends FragmentPagerAdapter {
|
||||||
super(manager);
|
super(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a ViewPagerAdapter with a specified Fragment Manager and Fragment resume behavior.
|
||||||
|
*
|
||||||
|
* @param manager The FragmentManager
|
||||||
|
* @param behavior An integer which represents the behavior of non visible fragments. See
|
||||||
|
* FragmentPagerAdapter.java for options.
|
||||||
|
*/
|
||||||
|
public ViewPagerAdapter(FragmentManager manager, int behavior) {
|
||||||
|
super(manager, behavior);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the fragment of the viewpager at a particular position
|
* This method returns the fragment of the viewpager at a particular position
|
||||||
* @param position
|
* @param position
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import android.view.ViewGroup;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentPagerAdapter;
|
||||||
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
|
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.ViewPagerAdapter;
|
import fr.free.nrw.commons.ViewPagerAdapter;
|
||||||
|
|
@ -69,7 +70,9 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
|
||||||
loadNearbyMapData();
|
loadNearbyMapData();
|
||||||
binding = FragmentExploreBinding.inflate(inflater, container, false);
|
binding = FragmentExploreBinding.inflate(inflater, container, false);
|
||||||
|
|
||||||
viewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager());
|
viewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager(),
|
||||||
|
FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||||
|
|
||||||
binding.viewPager.setAdapter(viewPagerAdapter);
|
binding.viewPager.setAdapter(viewPagerAdapter);
|
||||||
binding.viewPager.setId(R.id.viewPager);
|
binding.viewPager.setId(R.id.viewPager);
|
||||||
binding.tabLayout.setupWithViewPager(binding.viewPager);
|
binding.tabLayout.setupWithViewPager(binding.viewPager);
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,6 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
binding.mapView.getController().setZoom(ZOOM_LEVEL);
|
binding.mapView.getController().setZoom(ZOOM_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
performMapReadyActions();
|
|
||||||
|
|
||||||
binding.mapView.getOverlays().add(new MapEventsOverlay(new MapEventsReceiver() {
|
binding.mapView.getOverlays().add(new MapEventsOverlay(new MapEventsReceiver() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -341,7 +340,12 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
!locationPermissionsHelper.checkLocationPermission(getActivity())) {
|
!locationPermissionsHelper.checkLocationPermission(getActivity())) {
|
||||||
isPermissionDenied = true;
|
isPermissionDenied = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastKnownLocation = getLastLocation();
|
||||||
|
|
||||||
|
if (lastKnownLocation == null) {
|
||||||
lastKnownLocation = MapUtils.getDefaultLatLng();
|
lastKnownLocation = MapUtils.getDefaultLatLng();
|
||||||
|
}
|
||||||
|
|
||||||
// if we came from 'Show in Explore' in Nearby, load Nearby map center and zoom
|
// if we came from 'Show in Explore' in Nearby, load Nearby map center and zoom
|
||||||
if (isCameFromNearbyMap()) {
|
if (isCameFromNearbyMap()) {
|
||||||
|
|
@ -962,9 +966,6 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
-0.07483536015053005, 1f);
|
-0.07483536015053005, 1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isCameFromNearbyMap()) {
|
|
||||||
moveCameraToPosition(new GeoPoint(latLnge.getLatitude(), latLnge.getLongitude()));
|
|
||||||
}
|
|
||||||
return latLnge;
|
return latLnge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue