mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Fix progress bar visibility issue
This commit is contained in:
parent
a3c6734f70
commit
be1ca1a2ae
6 changed files with 19 additions and 28 deletions
|
|
@ -23,7 +23,6 @@ import android.widget.Toast;
|
||||||
|
|
||||||
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.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||||
|
|
@ -44,19 +43,15 @@ import javax.inject.Named;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
||||||
import fr.free.nrw.commons.contributions.ContributionController;
|
import fr.free.nrw.commons.contributions.ContributionController;
|
||||||
import fr.free.nrw.commons.contributions.MainActivity;
|
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
||||||
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment;
|
|
||||||
import fr.free.nrw.commons.nearby.mvp.presenter.NearbyParentFragmentPresenter;
|
import fr.free.nrw.commons.nearby.mvp.presenter.NearbyParentFragmentPresenter;
|
||||||
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
|
||||||
import fr.free.nrw.commons.utils.FragmentUtils;
|
import fr.free.nrw.commons.utils.FragmentUtils;
|
||||||
import fr.free.nrw.commons.utils.NearbyFABUtils;
|
import fr.free.nrw.commons.utils.NearbyFABUtils;
|
||||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||||
|
|
@ -67,7 +62,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static fr.free.nrw.commons.contributions.ContributionsFragment.CONTRIBUTION_LIST_FRAGMENT_TAG;
|
|
||||||
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
||||||
import static fr.free.nrw.commons.nearby.NearbyTestFragmentLayersActivity.CONTRIBUTIONS_TAB_POSITION;
|
import static fr.free.nrw.commons.nearby.NearbyTestFragmentLayersActivity.CONTRIBUTIONS_TAB_POSITION;
|
||||||
|
|
||||||
|
|
@ -140,8 +134,8 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
@BindView(R.id.search_this_area_button)
|
@BindView(R.id.search_this_area_button)
|
||||||
Button searchThisAreaButton;
|
Button searchThisAreaButton;
|
||||||
|
|
||||||
@BindView(R.id.search_this_area_button_progress_bar)
|
@BindView(R.id.map_progress_bar)
|
||||||
ProgressBar searchThisAreaButtonProgressBar;
|
ProgressBar progressBar;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
LocationServiceManager locationManager;
|
LocationServiceManager locationManager;
|
||||||
|
|
@ -506,11 +500,11 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSearchThisAreaProgressVisibility(boolean isVisible) {
|
public void setProgressBarVisibility(boolean isVisible) {
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
searchThisAreaButtonProgressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
searchThisAreaButtonProgressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public interface NearbyParentFragmentContract {
|
||||||
void addOnCameraMoveListener(MapboxMap.OnCameraMoveListener onCameraMoveListener);
|
void addOnCameraMoveListener(MapboxMap.OnCameraMoveListener onCameraMoveListener);
|
||||||
void addSearchThisAreaButtonAction();
|
void addSearchThisAreaButtonAction();
|
||||||
void setSearchThisAreaButtonVisibility(boolean isVisible);
|
void setSearchThisAreaButtonVisibility(boolean isVisible);
|
||||||
void setSearchThisAreaProgressVisibility(boolean isVisible);
|
void setProgressBarVisibility(boolean isVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UserActions {
|
interface UserActions {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
@ -33,7 +32,6 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
|
|
@ -43,12 +41,10 @@ import fr.free.nrw.commons.contributions.MainActivity;
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
import fr.free.nrw.commons.location.LatLng;
|
import fr.free.nrw.commons.location.LatLng;
|
||||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||||
import fr.free.nrw.commons.location.LocationUpdateListener;
|
|
||||||
import fr.free.nrw.commons.nearby.NearbyController;
|
import fr.free.nrw.commons.nearby.NearbyController;
|
||||||
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
import fr.free.nrw.commons.nearby.mvp.contract.NearbyParentFragmentContract;
|
||||||
import fr.free.nrw.commons.nearby.mvp.presenter.NearbyParentFragmentPresenter;
|
import fr.free.nrw.commons.nearby.mvp.presenter.NearbyParentFragmentPresenter;
|
||||||
import fr.free.nrw.commons.utils.FragmentUtils;
|
import fr.free.nrw.commons.utils.FragmentUtils;
|
||||||
import fr.free.nrw.commons.utils.LocationUtils;
|
|
||||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||||
import fr.free.nrw.commons.utils.PermissionUtils;
|
import fr.free.nrw.commons.utils.PermissionUtils;
|
||||||
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
||||||
|
|
@ -58,9 +54,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static fr.free.nrw.commons.contributions.MainActivity.CONTRIBUTIONS_TAB_POSITION;
|
import static fr.free.nrw.commons.contributions.MainActivity.CONTRIBUTIONS_TAB_POSITION;
|
||||||
import static fr.free.nrw.commons.contributions.MainActivity.NEARBY_TAB_POSITION;
|
|
||||||
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
||||||
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.SEARCH_CUSTOM_AREA;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This fragment is under MainActivity at the came level with ContributionFragment and holds
|
* This fragment is under MainActivity at the came level with ContributionFragment and holds
|
||||||
|
|
@ -84,7 +78,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
ConstraintLayout loadingNearbyLayout;
|
ConstraintLayout loadingNearbyLayout;
|
||||||
@BindView(R.id.search_this_area_button)
|
@BindView(R.id.search_this_area_button)
|
||||||
Button searchThisAreaButton;
|
Button searchThisAreaButton;
|
||||||
@BindView(R.id.search_this_area_button_progress_bar)
|
@BindView(R.id.progress_bar)
|
||||||
ProgressBar searchThisAreaButtonProgressBar;
|
ProgressBar searchThisAreaButtonProgressBar;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
@ -187,7 +181,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSearchThisAreaProgressVisibility(boolean isVisible) {
|
public void setProgressBarVisibility(boolean isVisible) {
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
searchThisAreaButtonProgressBar.setVisibility(View.VISIBLE);
|
searchThisAreaButtonProgressBar.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ public class NearbyParentFragmentPresenter
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initializeNearbyOperations() {
|
public void initializeNearbyOperations() {
|
||||||
|
// TODO: do not update every time user selected tab
|
||||||
Timber.d("initializing nearby operations started");
|
Timber.d("initializing nearby operations started");
|
||||||
// Add location listener to be notified about location changes
|
// Add location listener to be notified about location changes
|
||||||
//locationServiceManager.addLocationListener(this);
|
//locationServiceManager.addLocationListener(this);
|
||||||
|
|
@ -259,8 +260,8 @@ public class NearbyParentFragmentPresenter
|
||||||
|| locationChangeType.equals(MAP_UPDATED)) {
|
|| locationChangeType.equals(MAP_UPDATED)) {
|
||||||
Log.d("denemeTest","1");
|
Log.d("denemeTest","1");
|
||||||
lockUnlockNearby(true);
|
lockUnlockNearby(true);
|
||||||
|
nearbyParentFragmentView.setProgressBarVisibility(true);
|
||||||
nearbyParentFragmentView.populatePlaces(lastLocation, lastLocation);
|
nearbyParentFragmentView.populatePlaces(lastLocation, lastLocation);
|
||||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(false);
|
|
||||||
//nearbyMapFragmentView.updateMapToTrackPosition(curLatLng);
|
//nearbyMapFragmentView.updateMapToTrackPosition(curLatLng);
|
||||||
// TODO: when unneeded populate places call problem is solved, open commented out line and remove it from update map markers method
|
// TODO: when unneeded populate places call problem is solved, open commented out line and remove it from update map markers method
|
||||||
// TODO dont forget map updated state after an wikidata item is updated
|
// TODO dont forget map updated state after an wikidata item is updated
|
||||||
|
|
@ -268,8 +269,8 @@ public class NearbyParentFragmentPresenter
|
||||||
} else if (locationChangeType.equals(SEARCH_CUSTOM_AREA)) {
|
} else if (locationChangeType.equals(SEARCH_CUSTOM_AREA)) {
|
||||||
Log.d("denemeTest","2");
|
Log.d("denemeTest","2");
|
||||||
lockUnlockNearby(true);
|
lockUnlockNearby(true);
|
||||||
|
nearbyParentFragmentView.setProgressBarVisibility(true);
|
||||||
nearbyParentFragmentView.populatePlaces(lastLocation, cameraTarget);
|
nearbyParentFragmentView.populatePlaces(lastLocation, cameraTarget);
|
||||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(false);
|
|
||||||
searchingThisArea = false;
|
searchingThisArea = false;
|
||||||
} else { // Means location changed slightly, ie user is walking or driving.
|
} else { // Means location changed slightly, ie user is walking or driving.
|
||||||
Log.d("denemeTest","3");
|
Log.d("denemeTest","3");
|
||||||
|
|
@ -290,6 +291,7 @@ public class NearbyParentFragmentPresenter
|
||||||
nearbyMapFragmentView.addCurrentLocationMarker(nearbyPlacesInfo.curLatLng);
|
nearbyMapFragmentView.addCurrentLocationMarker(nearbyPlacesInfo.curLatLng);
|
||||||
nearbyMapFragmentView.updateMapToTrackPosition(nearbyPlacesInfo.curLatLng);
|
nearbyMapFragmentView.updateMapToTrackPosition(nearbyPlacesInfo.curLatLng);
|
||||||
lockUnlockNearby(false); // So that new location updates wont come
|
lockUnlockNearby(false); // So that new location updates wont come
|
||||||
|
nearbyParentFragmentView.setProgressBarVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -301,6 +303,8 @@ public class NearbyParentFragmentPresenter
|
||||||
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList, selectedMarker, this);
|
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList, selectedMarker, this);
|
||||||
nearbyMapFragmentView.addCurrentLocationMarker(nearbyPlacesInfo.curLatLng);
|
nearbyMapFragmentView.addCurrentLocationMarker(nearbyPlacesInfo.curLatLng);
|
||||||
lockUnlockNearby(false); // So that new location updates wont come
|
lockUnlockNearby(false); // So that new location updates wont come
|
||||||
|
nearbyParentFragmentView.setProgressBarVisibility(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -337,6 +341,7 @@ public class NearbyParentFragmentPresenter
|
||||||
if (NearbyController.currentLocation != null) {
|
if (NearbyController.currentLocation != null) {
|
||||||
Log.d("denemeTestt","NearbyController.currentLocation != null");
|
Log.d("denemeTestt","NearbyController.currentLocation != null");
|
||||||
double distance = mapboxMap.getCameraPosition().target.distanceTo
|
double distance = mapboxMap.getCameraPosition().target.distanceTo
|
||||||
|
//TODO: test this distances
|
||||||
(LocationUtils.commonsLatLngToMapBoxLatLng(NearbyController.latestSearchLocation));
|
(LocationUtils.commonsLatLngToMapBoxLatLng(NearbyController.latestSearchLocation));
|
||||||
if (nearbyParentFragmentView.isNetworkConnectionEstablished()) {
|
if (nearbyParentFragmentView.isNetworkConnectionEstablished()) {
|
||||||
if (distance > NearbyController.latestSearchRadius) {
|
if (distance > NearbyController.latestSearchRadius) {
|
||||||
|
|
@ -359,9 +364,6 @@ public class NearbyParentFragmentPresenter
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Log.d("denemeTestt","onSearchThisAreaClicked");
|
Log.d("denemeTestt","onSearchThisAreaClicked");
|
||||||
// Lock map operations during search this area operation
|
// Lock map operations during search this area operation
|
||||||
// TODO: test lock nearby
|
|
||||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(true);
|
|
||||||
// TODO: make this invisible at somewhere
|
|
||||||
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
||||||
|
|
||||||
if (searchCloseToCurrentLocation()){
|
if (searchCloseToCurrentLocation()){
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@
|
||||||
app:elevation="6dp" />
|
app:elevation="6dp" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/search_this_area_button_progress_bar"
|
android:id="@+id/progress_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,11 @@
|
||||||
app:elevation="6dp" />
|
app:elevation="6dp" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/search_this_area_button_progress_bar"
|
android:id="@+id/map_progress_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
app:elevation="6dp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue