mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43: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.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
|
@ -44,19 +43,15 @@ import javax.inject.Named;
|
|||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
||||
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.kvstore.JsonKvStore;
|
||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||
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.theme.NavigationBaseActivity;
|
||||
import fr.free.nrw.commons.utils.FragmentUtils;
|
||||
import fr.free.nrw.commons.utils.NearbyFABUtils;
|
||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||
|
|
@ -67,7 +62,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
|||
import io.reactivex.schedulers.Schedulers;
|
||||
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.nearby.NearbyTestFragmentLayersActivity.CONTRIBUTIONS_TAB_POSITION;
|
||||
|
||||
|
|
@ -140,8 +134,8 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
|||
@BindView(R.id.search_this_area_button)
|
||||
Button searchThisAreaButton;
|
||||
|
||||
@BindView(R.id.search_this_area_button_progress_bar)
|
||||
ProgressBar searchThisAreaButtonProgressBar;
|
||||
@BindView(R.id.map_progress_bar)
|
||||
ProgressBar progressBar;
|
||||
|
||||
@Inject
|
||||
LocationServiceManager locationManager;
|
||||
|
|
@ -506,11 +500,11 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setSearchThisAreaProgressVisibility(boolean isVisible) {
|
||||
public void setProgressBarVisibility(boolean isVisible) {
|
||||
if (isVisible) {
|
||||
searchThisAreaButtonProgressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
searchThisAreaButtonProgressBar.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public interface NearbyParentFragmentContract {
|
|||
void addOnCameraMoveListener(MapboxMap.OnCameraMoveListener onCameraMoveListener);
|
||||
void addSearchThisAreaButtonAction();
|
||||
void setSearchThisAreaButtonVisibility(boolean isVisible);
|
||||
void setSearchThisAreaProgressVisibility(boolean isVisible);
|
||||
void setProgressBarVisibility(boolean isVisible);
|
||||
}
|
||||
|
||||
interface UserActions {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ 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;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -33,7 +32,6 @@ import javax.inject.Inject;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
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.location.LatLng;
|
||||
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.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.LocationUtils;
|
||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||
import fr.free.nrw.commons.utils.PermissionUtils;
|
||||
import fr.free.nrw.commons.wikidata.WikidataEditListener;
|
||||
|
|
@ -58,9 +54,7 @@ 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.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.SEARCH_CUSTOM_AREA;
|
||||
|
||||
/**
|
||||
* This fragment is under MainActivity at the came level with ContributionFragment and holds
|
||||
|
|
@ -84,7 +78,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
ConstraintLayout loadingNearbyLayout;
|
||||
@BindView(R.id.search_this_area_button)
|
||||
Button searchThisAreaButton;
|
||||
@BindView(R.id.search_this_area_button_progress_bar)
|
||||
@BindView(R.id.progress_bar)
|
||||
ProgressBar searchThisAreaButtonProgressBar;
|
||||
|
||||
@Inject
|
||||
|
|
@ -187,7 +181,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setSearchThisAreaProgressVisibility(boolean isVisible) {
|
||||
public void setProgressBarVisibility(boolean isVisible) {
|
||||
if (isVisible) {
|
||||
searchThisAreaButtonProgressBar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ public class NearbyParentFragmentPresenter
|
|||
*/
|
||||
@Override
|
||||
public void initializeNearbyOperations() {
|
||||
// TODO: do not update every time user selected tab
|
||||
Timber.d("initializing nearby operations started");
|
||||
// Add location listener to be notified about location changes
|
||||
//locationServiceManager.addLocationListener(this);
|
||||
|
|
@ -259,8 +260,8 @@ public class NearbyParentFragmentPresenter
|
|||
|| locationChangeType.equals(MAP_UPDATED)) {
|
||||
Log.d("denemeTest","1");
|
||||
lockUnlockNearby(true);
|
||||
nearbyParentFragmentView.setProgressBarVisibility(true);
|
||||
nearbyParentFragmentView.populatePlaces(lastLocation, lastLocation);
|
||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(false);
|
||||
//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 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)) {
|
||||
Log.d("denemeTest","2");
|
||||
lockUnlockNearby(true);
|
||||
nearbyParentFragmentView.setProgressBarVisibility(true);
|
||||
nearbyParentFragmentView.populatePlaces(lastLocation, cameraTarget);
|
||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(false);
|
||||
searchingThisArea = false;
|
||||
} else { // Means location changed slightly, ie user is walking or driving.
|
||||
Log.d("denemeTest","3");
|
||||
|
|
@ -290,6 +291,7 @@ public class NearbyParentFragmentPresenter
|
|||
nearbyMapFragmentView.addCurrentLocationMarker(nearbyPlacesInfo.curLatLng);
|
||||
nearbyMapFragmentView.updateMapToTrackPosition(nearbyPlacesInfo.curLatLng);
|
||||
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.addCurrentLocationMarker(nearbyPlacesInfo.curLatLng);
|
||||
lockUnlockNearby(false); // So that new location updates wont come
|
||||
nearbyParentFragmentView.setProgressBarVisibility(false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -336,7 +340,8 @@ public class NearbyParentFragmentPresenter
|
|||
// If our nearby markers are calculated at least once
|
||||
if (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));
|
||||
if (nearbyParentFragmentView.isNetworkConnectionEstablished()) {
|
||||
if (distance > NearbyController.latestSearchRadius) {
|
||||
|
|
@ -359,9 +364,6 @@ public class NearbyParentFragmentPresenter
|
|||
public void onClick(View v) {
|
||||
Log.d("denemeTestt","onSearchThisAreaClicked");
|
||||
// Lock map operations during search this area operation
|
||||
// TODO: test lock nearby
|
||||
nearbyParentFragmentView.setSearchThisAreaProgressVisibility(true);
|
||||
// TODO: make this invisible at somewhere
|
||||
nearbyParentFragmentView.setSearchThisAreaButtonVisibility(false);
|
||||
|
||||
if (searchCloseToCurrentLocation()){
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@
|
|||
app:elevation="6dp" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/search_this_area_button_progress_bar"
|
||||
android:id="@+id/progress_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
|
|
|
|||
|
|
@ -74,10 +74,11 @@
|
|||
app:elevation="6dp" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/search_this_area_button_progress_bar"
|
||||
android:id="@+id/map_progress_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
app:elevation="6dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue