mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Cleanup
This commit is contained in:
parent
230d62dd54
commit
c326cce576
8 changed files with 1 additions and 682 deletions
|
|
@ -16,7 +16,6 @@ import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
|||
import fr.free.nrw.commons.nearby.NearbyListFragment;
|
||||
import fr.free.nrw.commons.nearby.NearbyTestLayersFragment;
|
||||
import fr.free.nrw.commons.nearby.SupportMapFragment;
|
||||
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment;
|
||||
import fr.free.nrw.commons.review.ReviewImageFragment;
|
||||
import fr.free.nrw.commons.settings.SettingsFragment;
|
||||
import fr.free.nrw.commons.upload.categories.UploadCategoriesFragment;
|
||||
|
|
@ -63,9 +62,6 @@ public abstract class FragmentBuilderModule {
|
|||
@ContributesAndroidInjector
|
||||
abstract SupportMapFragment bindSupportMapFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract NearbyParentFragment bindNearbyParentFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract NearbyTestLayersFragment bindNearbyTestLayersFragment();
|
||||
|
||||
|
|
|
|||
|
|
@ -461,24 +461,11 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment
|
|||
nearbyMapFragment.getMapboxMap().addOnCameraMoveListener(onCameraMoveListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListFragmentExpanded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshView() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void registerLocationUpdates(LocationServiceManager locationManager) {
|
||||
locationManager.registerLocationManager();
|
||||
}
|
||||
|
||||
public void registerLocationUpdates() {
|
||||
locationManager.registerLocationManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkConnectionEstablished() {
|
||||
return NetworkUtils.isInternetConnectionEstablished(getActivity());
|
||||
|
|
|
|||
|
|
@ -257,21 +257,6 @@ public class SupportMapFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showSearchThisAreaButton() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showInformationBottomSheet() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initViews() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMapMarkers(LatLng latLng, List<Place> placeList
|
||||
, Marker selectedMarker
|
||||
|
|
@ -303,16 +288,6 @@ public class SupportMapFragment extends CommonsDaggerSupportFragment
|
|||
.newCameraPosition(cameraPosition), 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListeners() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapView setupMapView(Bundle savedInstanceState) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a marker for the user's current position. Adds a
|
||||
* circle which uses the accuracy * 2, to draw a circle
|
||||
|
|
@ -371,18 +346,6 @@ public class SupportMapFragment extends CommonsDaggerSupportFragment
|
|||
return circle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setSearchThisAreaButtonVisibility(boolean visible) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurrentLocationMarkerVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNearbyMarkersToMapBoxMap(@Nullable List<NearbyBaseMarker> baseMarkerList
|
||||
, Marker selectedMarker
|
||||
|
|
@ -401,65 +364,6 @@ public class SupportMapFragment extends CommonsDaggerSupportFragment
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareViewsForSheetPosition() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideFABs() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showFABs() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAnchorToBigFABs(FloatingActionButton floatingActionButton, int anchorID) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAnchorFromFABs(FloatingActionButton fab) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAnchorToSmallFABs(FloatingActionButton floatingActionButton, int anchorID) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passInfoToSheet(Place place) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBookmarkButtonImage(Place place) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openWebView(Uri link) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateFABs(boolean isFabOpen) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeFabs(boolean isFabOpen) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMarker(boolean isBookmarked, Place place) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public LatLng getCameraTarget() {
|
||||
|
|
@ -482,11 +386,6 @@ public class SupportMapFragment extends CommonsDaggerSupportFragment
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPlaces() {
|
||||
|
||||
}
|
||||
|
||||
void setMapMarkerActions(Marker selected, NearbyParentFragmentPresenter nearbyParentFragmentPresenter) {
|
||||
getMapboxMap().setOnInfoWindowCloseListener(marker -> {
|
||||
if (marker == selected) {
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
package fr.free.nrw.commons.nearby.mvp.contract;
|
||||
|
||||
/**
|
||||
* General View and UserAction methods are defined under
|
||||
* this interface. This interface can be considered parent
|
||||
* of both NearbyMapContract and NearbyListContract
|
||||
*/
|
||||
public interface NearbyElementContract {
|
||||
|
||||
interface View {
|
||||
void showPlaces();
|
||||
}
|
||||
|
||||
interface UserActions {
|
||||
void uploadImageGallery();
|
||||
void uploadImageCamera();
|
||||
void bookmarkItem();
|
||||
void getDirections();
|
||||
void seeWikidataItem();
|
||||
void seeWikipediaArticle();
|
||||
void seeCommonsFilePage();
|
||||
void rotateScreen();
|
||||
}
|
||||
}
|
||||
|
|
@ -25,42 +25,14 @@ import fr.free.nrw.commons.nearby.mvp.presenter.NearbyParentFragmentPresenter;
|
|||
*/
|
||||
public interface NearbyMapContract {
|
||||
|
||||
interface View extends NearbyElementContract.View{
|
||||
void showSearchThisAreaButton();
|
||||
void showInformationBottomSheet();
|
||||
void initViews();
|
||||
interface View{
|
||||
void updateMapMarkers(LatLng latLng, List<Place> placeList, Marker selectedMarker, NearbyParentFragmentPresenter nearbyParentFragmentPresenter);
|
||||
void updateMapToTrackPosition(LatLng curLatLng);
|
||||
void setListeners();
|
||||
MapView setupMapView(Bundle savedInstanceState);
|
||||
void addCurrentLocationMarker(LatLng curLatLng);
|
||||
void setSearchThisAreaButtonVisibility(boolean visible);
|
||||
boolean isCurrentLocationMarkerVisible();
|
||||
void addNearbyMarkersToMapBoxMap(List<NearbyBaseMarker> baseMarkerOptions, Marker marker, NearbyParentFragmentPresenter nearbyParentFragmentPresenter);
|
||||
void prepareViewsForSheetPosition();
|
||||
void hideFABs();
|
||||
void showFABs();
|
||||
void addAnchorToBigFABs(FloatingActionButton floatingActionButton, int anchorID);
|
||||
void removeAnchorFromFABs(FloatingActionButton fab);
|
||||
void addAnchorToSmallFABs(FloatingActionButton floatingActionButton, int anchorID);
|
||||
void passInfoToSheet(Place place);
|
||||
void updateBookmarkButtonImage(Place place);
|
||||
void openWebView(Uri link);
|
||||
void animateFABs(boolean isFabOpen);
|
||||
void closeFabs ( boolean isFabOpen);
|
||||
void updateMarker(boolean isBookmarked, Place place);
|
||||
LatLng getCameraTarget();
|
||||
MapboxMap getMapboxMap();
|
||||
void viewsAreAssignedToPresenter(NearbyParentFragmentContract.ViewsAreReadyCallback viewsAreReadyCallback);
|
||||
void addOnCameraMoveListener(MapboxMap.OnCameraMoveListener onCameraMoveListener);
|
||||
}
|
||||
|
||||
interface UserActions extends NearbyElementContract.UserActions {
|
||||
void searchThisArea();
|
||||
void storeSharedPrefs();
|
||||
void recenterMap();
|
||||
void updateMapMarkers(LatLng latLng);
|
||||
void updateMapToTrackPosition();
|
||||
void getBundleContent();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import fr.free.nrw.commons.nearby.Place;
|
|||
public interface NearbyParentFragmentContract {
|
||||
|
||||
interface View {
|
||||
void setListFragmentExpanded();
|
||||
void refreshView();
|
||||
void registerLocationUpdates(LocationServiceManager locationServiceManager);
|
||||
boolean isNetworkConnectionEstablished();
|
||||
void addNetworkBroadcastReceiver();
|
||||
|
|
@ -49,19 +47,16 @@ public interface NearbyParentFragmentContract {
|
|||
}
|
||||
|
||||
interface UserActions {
|
||||
void displayListFragmentExpanded();
|
||||
void onTabSelected();
|
||||
void initializeNearbyOperations();
|
||||
void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType, LatLng cameraTarget);
|
||||
void lockUnlockNearby(boolean isNearbyLocked);
|
||||
void setActionListeners(JsonKvStore applicationKvStore);
|
||||
void backButtonClicked();
|
||||
|
||||
MapboxMap.OnCameraMoveListener onCameraMove(MapboxMap mapboxMap);
|
||||
}
|
||||
|
||||
interface ViewsAreReadyCallback {
|
||||
void nearbyFragmentsAreReady();
|
||||
void nearbyMapViewReady();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,485 +0,0 @@
|
|||
package fr.free.nrw.commons.nearby.mvp.fragments;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.gson.Gson;
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.maps.SupportMapFragment;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.contributions.MainActivity;
|
||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||
import fr.free.nrw.commons.nearby.NearbyController;
|
||||
import fr.free.nrw.commons.nearby.NearbyListFragment;
|
||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
||||
import fr.free.nrw.commons.nearby.mvp.presenter.NearbyParentFragmentPresenter;
|
||||
import fr.free.nrw.commons.utils.FragmentUtils;
|
||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||
import fr.free.nrw.commons.utils.PermissionUtils;
|
||||
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static fr.free.nrw.commons.contributions.MainActivity.CONTRIBUTIONS_TAB_POSITION;
|
||||
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
||||
|
||||
/**
|
||||
* This fragment is under MainActivity at the came level with ContributionFragment and holds
|
||||
* two nearby element fragments as NearbyMapFragment and NearbyListFragment
|
||||
*/
|
||||
public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||
implements WikidataEditListener.WikidataP18EditListener,
|
||||
NearbyParentFragmentContract.View, OnMapReadyCallback {
|
||||
|
||||
@BindView(R.id.progressBar)
|
||||
ProgressBar progressBar;
|
||||
@BindView(R.id.bottom_sheet)
|
||||
LinearLayout bottomSheet;
|
||||
@BindView(R.id.bottom_sheet_details)
|
||||
LinearLayout bottomSheetDetails;
|
||||
@BindView(R.id.transparentView)
|
||||
View transparentView;
|
||||
@BindView(R.id.container_sheet)
|
||||
FrameLayout frameLayout;
|
||||
@BindView(R.id.loading_nearby_list)
|
||||
ConstraintLayout loadingNearbyLayout;
|
||||
@BindView(R.id.search_this_area_button)
|
||||
Button searchThisAreaButton;
|
||||
@BindView(R.id.progress_bar)
|
||||
ProgressBar searchThisAreaButtonProgressBar;
|
||||
|
||||
@Inject
|
||||
NearbyController nearbyController;
|
||||
@Inject
|
||||
WikidataEditListener wikidataEditListener;
|
||||
@Inject
|
||||
Gson gson;
|
||||
@Inject
|
||||
LocationServiceManager locationManager;
|
||||
|
||||
private NearbyParentFragmentContract.UserActions userActions;
|
||||
|
||||
private SupportMapFragment nearbyMapFragment;
|
||||
private NearbyListFragment nearbyListFragment;
|
||||
private static final String TAG_RETAINED_MAP_FRAGMENT = SupportMapFragment.class.getSimpleName();
|
||||
private static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName();
|
||||
public NearbyParentFragmentPresenter nearbyParentFragmentPresenter;
|
||||
|
||||
// Variables for adding network broadcast receiver.
|
||||
private Snackbar snackbar;
|
||||
private final String NETWORK_INTENT_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
|
||||
private BroadcastReceiver broadcastReceiver;
|
||||
private boolean isNetworkErrorOccurred = false;
|
||||
public View view;
|
||||
|
||||
// Variables for bottom sheet behaviour management
|
||||
private BottomSheetBehavior bottomSheetBehavior; // Behavior for list bottom sheet
|
||||
private BottomSheetBehavior bottomSheetBehaviorForDetails; // Behavior for details bottom sheet
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
Mapbox.getInstance(getActivity(),
|
||||
getString(R.string.mapbox_commons_app_token));
|
||||
Mapbox.getTelemetry().setUserTelemetryRequestState(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
// Resume the fragment if exist
|
||||
resumeFragment();
|
||||
if (!((MainActivity) getActivity()).isContributionsFragmentVisible) {
|
||||
checkPermissionsAndPerformAction(nearbyParentFragmentPresenter::performNearbyOperationsIfPermissionGiven);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkPermissionsAndPerformAction(Runnable runnable) {
|
||||
PermissionUtils.checkPermissionsAndPerformAction(getActivity(),
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
runnable,
|
||||
() -> ((MainActivity) getActivity()).viewPager.setCurrentItem(CONTRIBUTIONS_TAB_POSITION),
|
||||
R.string.location_permission_title,
|
||||
R.string.location_permission_rationale_nearby);
|
||||
}
|
||||
|
||||
/**
|
||||
* Thanks to this method we make sure NearbyMapFragment is ready and attached. So that we can
|
||||
* prevent NPE caused by null child fragment. This method is called from child fragment when
|
||||
* it is attached.
|
||||
*/
|
||||
public void childMapFragmentAttached() {
|
||||
nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter
|
||||
(null,this, null, locationManager);
|
||||
Timber.d("Child fragment attached");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSearchThisAreaButtonAction() {
|
||||
//searchThisAreaButton.setOnClickListener(nearbyParentFragmentPresenter.onSearchThisAreaClicked());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSearchThisAreaButtonVisibility(boolean isVisible) {
|
||||
if (isVisible) {
|
||||
searchThisAreaButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
searchThisAreaButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgressBarVisibility(boolean isVisible) {
|
||||
if (isVisible) {
|
||||
searchThisAreaButtonProgressBar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
searchThisAreaButtonProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTabItemContributions() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDetailsBottomSheetVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBottomSheetDetailsSmaller() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
wikidataEditListener.setAuthenticationStateListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
wikidataEditListener.setAuthenticationStateListener(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates places and calls update map markers method
|
||||
* @param curlatLng current location that user is at
|
||||
* @param searchLatLng the location user searches around
|
||||
*/
|
||||
@Override
|
||||
public void populatePlaces(LatLng curlatLng, LatLng searchLatLng){
|
||||
compositeDisposable.add(Observable.fromCallable(() -> nearbyController
|
||||
.loadAttractionsFromLocation(curlatLng, searchLatLng, false, true))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::updateMapMarkers,
|
||||
throwable -> {
|
||||
Timber.d(throwable);
|
||||
//showErrorMessage(getString(R.string.error_fetching_nearby_places));
|
||||
// TODO solve first unneeded method call here
|
||||
progressBar.setVisibility(View.GONE);
|
||||
//nearbyParentFragmentPresenter.lockUnlockNearby(false);
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates places for custom location, should be used for finding nearby places around a
|
||||
* location where you are not at.
|
||||
* @param nearbyPlacesInfo This variable has place list information and distances.
|
||||
*/
|
||||
private void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
||||
nearbyParentFragmentPresenter.updateMapMarkers(nearbyPlacesInfo, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the map fragment added to child fragment manager previously, if exists.
|
||||
*/
|
||||
private SupportMapFragment getMapFragment() {
|
||||
SupportMapFragment existingFragment = (SupportMapFragment) getChildFragmentManager()
|
||||
.findFragmentByTag(TAG_RETAINED_MAP_FRAGMENT);
|
||||
if (existingFragment == null) {
|
||||
existingFragment = setMapFragment();
|
||||
}
|
||||
return existingFragment;
|
||||
}
|
||||
|
||||
private SupportMapFragment setMapFragment() {
|
||||
Log.d("deneme2","setMapFragment is called");
|
||||
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
|
||||
// Build mapboxMap
|
||||
MapboxMapOptions options = new MapboxMapOptions();
|
||||
options.camera(new CameraPosition.Builder()
|
||||
.target(new com.mapbox.mapboxsdk.geometry.LatLng(-52.6885, -70.1395))
|
||||
.zoom(9)
|
||||
.build());
|
||||
|
||||
// Create map fragment
|
||||
SupportMapFragment nearbyMapFragment = SupportMapFragment.newInstance(options);
|
||||
|
||||
//NearbyMapFragment2 nearbyMapFragment = new NearbyMapFragment2();
|
||||
fragmentTransaction.replace(R.id.container, nearbyMapFragment, TAG_RETAINED_MAP_FRAGMENT);
|
||||
fragmentTransaction.commitAllowingStateLoss();
|
||||
|
||||
//nearbyMapFragment.getMapAsync(this);
|
||||
nearbyMapFragment.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
Log.d("deneme2","on map ready is finally called, problem is solved!");
|
||||
}
|
||||
});
|
||||
/*if (nearbyMapFragment.getMapboxMap()!=null){
|
||||
|
||||
}*/
|
||||
return nearbyMapFragment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list fragment added to child fragment manager previously, if exists.
|
||||
*/
|
||||
private NearbyListFragment getListFragment() {
|
||||
return (NearbyListFragment) getChildFragmentManager().findFragmentByTag(TAG_RETAINED_LIST_FRAGMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWikidataEditSuccessful() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListFragmentExpanded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshView() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method first checks if the location permissions has been granted and then register the
|
||||
* location manager for updates.
|
||||
* @param locationServiceManager passed from presenter to check updates if location
|
||||
* permissions are given
|
||||
*/
|
||||
@Override
|
||||
public void registerLocationUpdates(LocationServiceManager locationServiceManager) {
|
||||
locationManager.registerLocationManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume fragments if they exists
|
||||
*/
|
||||
@Override
|
||||
public void resumeFragment() {
|
||||
// Find the retained fragment on activity restarts
|
||||
nearbyMapFragment = getMapFragment();
|
||||
nearbyListFragment = getListFragment();
|
||||
addNetworkBroadcastReceiver();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayLoginSkippedWarning() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFABPlusAction(View.OnClickListener onClickListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFABRecenterAction(View.OnClickListener onClickListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateFABs() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recenterMap(LatLng curLatLng) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initViewPositions() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideBottomSheet() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayBottomSheetWithInfo(Marker marker) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOnCameraMoveListener(MapboxMap.OnCameraMoveListener onCameraMoveListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkConnectionEstablished() {
|
||||
return NetworkUtils.isInternetConnectionEstablished(getActivity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds network broadcast receiver to recognize connection established
|
||||
*/
|
||||
@Override
|
||||
public void addNetworkBroadcastReceiver() {
|
||||
if (!FragmentUtils.isFragmentUIActive(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (broadcastReceiver != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IntentFilter intentFilter = new IntentFilter(NETWORK_INTENT_ACTION);
|
||||
|
||||
broadcastReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (getActivity() != null) {
|
||||
if (NetworkUtils.isInternetConnectionEstablished(getActivity())) {
|
||||
if (isNetworkErrorOccurred) {
|
||||
nearbyParentFragmentPresenter.updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED, null);
|
||||
isNetworkErrorOccurred = false;
|
||||
}
|
||||
|
||||
if (snackbar != null) {
|
||||
snackbar.dismiss();
|
||||
snackbar = null;
|
||||
}
|
||||
} else {
|
||||
if (snackbar == null) {
|
||||
snackbar = Snackbar.make(view, R.string.no_internet, Snackbar.LENGTH_INDEFINITE);
|
||||
// TODO make search this area button invisible
|
||||
}
|
||||
|
||||
isNetworkErrorOccurred = true;
|
||||
snackbar.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public void listOptionMenuItemClicked() {
|
||||
if(bottomSheetBehavior.getState()== BottomSheetBehavior.STATE_COLLAPSED || bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_HIDDEN){
|
||||
bottomSheetBehaviorForDetails.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
}else if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED){
|
||||
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListBottomSheetExpanded() {
|
||||
return bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
Log.d("deneme2","on map ready");
|
||||
}
|
||||
}
|
||||
|
|
@ -57,14 +57,6 @@ public class NearbyParentFragmentPresenter
|
|||
this.locationServiceManager = locationServiceManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be called on list button click to expand list fragment at 9/16 rate
|
||||
*/
|
||||
@Override
|
||||
public void displayListFragmentExpanded() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: To initialize nearby operations both views should be ready and tab is selected.
|
||||
* Initializes nearby operations if nearby views are ready
|
||||
|
|
@ -126,19 +118,6 @@ public class NearbyParentFragmentPresenter
|
|||
initializeMapOperations();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Will be called when map view is created and ready to be used.
|
||||
*/
|
||||
@Override
|
||||
public void nearbyMapViewReady() {
|
||||
// TODO: remove this
|
||||
nearbyMapViewReady = true;
|
||||
if (nearbyOperationsInitialized) {
|
||||
initializeMapOperations();
|
||||
}
|
||||
}
|
||||
|
||||
public void nearbyOperationsInitialized() {
|
||||
Log.d("deneme2","nearbyOperationsinitialized");
|
||||
nearbyOperationsInitialized = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue