Search in sources :

Example 1 with NearbyFilterSearchRecyclerViewAdapter

use of fr.free.nrw.commons.nearby.NearbyFilterSearchRecyclerViewAdapter in project apps-android-commons by commons-app.

the class NearbyParentFragment method initNearbyFilter.

public void initNearbyFilter() {
    nearbyFilterList.setVisibility(View.GONE);
    searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> {
        if (hasFocus) {
            presenter.searchViewGainedFocus();
            nearbyFilterList.setVisibility(View.VISIBLE);
        } else {
            nearbyFilterList.setVisibility(View.GONE);
        }
    });
    recyclerView.setHasFixedSize(true);
    recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
    final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(linearLayoutManager);
    nearbyFilterSearchRecyclerViewAdapter = new NearbyFilterSearchRecyclerViewAdapter(getContext(), new ArrayList<>(Label.valuesAsList()), recyclerView);
    nearbyFilterSearchRecyclerViewAdapter.setCallback(new NearbyFilterSearchRecyclerViewAdapter.Callback() {

        @Override
        public void setCheckboxUnknown() {
            presenter.setCheckboxUnknown();
        }

        @Override
        public void filterByMarkerType(final ArrayList<Label> selectedLabels, final int i, final boolean b, final boolean b1) {
            presenter.filterByMarkerType(selectedLabels, i, b, b1);
        }

        @Override
        public boolean isDarkTheme() {
            return isDarkTheme;
        }
    });
    nearbyFilterList.getLayoutParams().width = (int) LayoutUtils.getScreenWidth(getActivity(), 0.75);
    recyclerView.setAdapter(nearbyFilterSearchRecyclerViewAdapter);
    LayoutUtils.setLayoutHeightAllignedToWidth(1.25, nearbyFilterList);
    compositeDisposable.add(RxSearchView.queryTextChanges(searchView).takeUntil(RxView.detaches(searchView)).debounce(500, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(query -> {
        ((NearbyFilterSearchRecyclerViewAdapter) recyclerView.getAdapter()).getFilter().filter(query.toString());
    }));
    initFilterChips();
}
Also used : DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Chip(com.google.android.material.chip.Chip) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) BookmarkLocationsDao(fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao) MapView(com.mapbox.mapboxsdk.maps.MapView) Marker(com.mapbox.mapboxsdk.annotations.Marker) VectorDrawableCompat(androidx.vectordrawable.graphics.drawable.VectorDrawableCompat) OnClick(butterknife.OnClick) CommonsApplication(fr.free.nrw.commons.CommonsApplication) Manifest(android.Manifest) Utils(fr.free.nrw.commons.Utils) Log(android.util.Log) RxSearchView(com.jakewharton.rxbinding3.appcompat.RxSearchView) IntentFilter(android.content.IntentFilter) SearchView(androidx.appcompat.widget.SearchView) LocationServiceManager(fr.free.nrw.commons.location.LocationServiceManager) LayoutUtils(fr.free.nrw.commons.utils.LayoutUtils) Unit(kotlin.Unit) Nullable(androidx.annotation.Nullable) SystemThemeUtils(fr.free.nrw.commons.utils.SystemThemeUtils) UiUtils(fr.free.nrw.commons.utils.UiUtils) LOCATION_SLIGHTLY_CHANGED(fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SLIGHTLY_CHANGED) Html(android.text.Html) LOCATION_SIGNIFICANTLY_CHANGED(fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) LatLngBounds(com.mapbox.mapboxsdk.geometry.LatLngBounds) CommonsDaggerSupportFragment(fr.free.nrw.commons.di.CommonsDaggerSupportFragment) Place(fr.free.nrw.commons.nearby.Place) ButterKnife(butterknife.ButterKnife) BottomSheetBehavior(com.google.android.material.bottomsheet.BottomSheetBehavior) OnMenuItemClickListener(android.view.MenuItem.OnMenuItemClickListener) ChipGroup(com.google.android.material.chip.ChipGroup) NearbyParentFragmentPresenter(fr.free.nrw.commons.nearby.presenter.NearbyParentFragmentPresenter) Callback(fr.free.nrw.commons.nearby.fragments.AdvanceQueryFragment.Callback) ArrayList(java.util.ArrayList) CameraUpdateFactory(com.mapbox.mapboxsdk.camera.CameraUpdateFactory) RxView(com.jakewharton.rxbinding2.view.RxView) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) Settings(android.provider.Settings) Observable(io.reactivex.Observable) Named(javax.inject.Named) MapboxMap(com.mapbox.mapboxsdk.maps.MapboxMap) LocationUtils(fr.free.nrw.commons.utils.LocationUtils) ScaleBarOptions(com.mapbox.pluginscalebar.ScaleBarOptions) IOException(java.io.IOException) Gravity(android.view.Gravity) NearbyPlacesInfo(fr.free.nrw.commons.nearby.NearbyController.NearbyPlacesInfo) Configuration(android.content.res.Configuration) NetworkUtils(fr.free.nrw.commons.utils.NetworkUtils) NearbyMarker(fr.free.nrw.commons.nearby.NearbyMarker) LinearLayout(android.widget.LinearLayout) MainActivity(fr.free.nrw.commons.contributions.MainActivity) LengthUtils.formatDistanceBetween(fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween) UiSettings(com.mapbox.mapboxsdk.maps.UiSettings) PackageManager(android.content.pm.PackageManager) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) Date(java.util.Date) R(fr.free.nrw.commons.R) LinkMovementMethod(android.text.method.LinkMovementMethod) DrawableRes(androidx.annotation.DrawableRes) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) BindView(butterknife.BindView) ScaleBarPlugin(com.mapbox.pluginscalebar.ScaleBarPlugin) MarkerOptions(com.mapbox.mapboxsdk.annotations.MarkerOptions) ActiveFragment(fr.free.nrw.commons.contributions.MainActivity.ActiveFragment) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) View(android.view.View) Button(android.widget.Button) Schedulers(io.reactivex.schedulers.Schedulers) Animation(android.view.animation.Animation) RecyclerView(androidx.recyclerview.widget.RecyclerView) Label(fr.free.nrw.commons.nearby.Label) JsonKvStore(fr.free.nrw.commons.kvstore.JsonKvStore) BroadcastReceiver(android.content.BroadcastReceiver) AppCompatButton(androidx.appcompat.widget.AppCompatButton) ViewGroup(android.view.ViewGroup) CheckBoxTriStates(fr.free.nrw.commons.nearby.CheckBoxTriStates) Timber(timber.log.Timber) CUSTOM_QUERY(fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.CUSTOM_QUERY) PolygonOptions(com.mapbox.mapboxsdk.annotations.PolygonOptions) FileUtils(fr.free.nrw.commons.upload.FileUtils) List(java.util.List) TextView(android.widget.TextView) NearbyBaseMarker(fr.free.nrw.commons.nearby.NearbyBaseMarker) Style(com.mapbox.mapboxsdk.maps.Style) RelativeLayout(android.widget.RelativeLayout) PermissionUtils(fr.free.nrw.commons.utils.PermissionUtils) NotNull(org.jetbrains.annotations.NotNull) LocationManager(android.location.LocationManager) Snackbar(com.google.android.material.snackbar.Snackbar) NearbyParentFragmentContract(fr.free.nrw.commons.nearby.contract.NearbyParentFragmentContract) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) DialogUtil(fr.free.nrw.commons.utils.DialogUtil) Context(android.content.Context) IconFactory(com.mapbox.mapboxsdk.annotations.IconFactory) NearbyFilterState(fr.free.nrw.commons.nearby.NearbyFilterState) AlertDialog(androidx.appcompat.app.AlertDialog) WikidataEditListener(fr.free.nrw.commons.wikidata.WikidataEditListener) Intent(android.content.Intent) ExecutorUtils(fr.free.nrw.commons.utils.ExecutorUtils) ViewUtil(fr.free.nrw.commons.utils.ViewUtil) MAP_UPDATED(fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.MAP_UPDATED) ContributionController(fr.free.nrw.commons.contributions.ContributionController) MenuItem(android.view.MenuItem) AnimationUtils(android.view.animation.AnimationUtils) Inject(javax.inject.Inject) SuppressLint(android.annotation.SuppressLint) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) LoginActivity(fr.free.nrw.commons.auth.LoginActivity) LocationUpdateListener(fr.free.nrw.commons.location.LocationUpdateListener) MotionEvent(android.view.MotionEvent) Icon(com.mapbox.mapboxsdk.annotations.Icon) MarkerPlaceGroup(fr.free.nrw.commons.nearby.MarkerPlaceGroup) Iterator(java.util.Iterator) LayoutInflater(android.view.LayoutInflater) TimeUnit(java.util.concurrent.TimeUnit) Bitmap(android.graphics.Bitmap) NearbyFilterSearchRecyclerViewAdapter(fr.free.nrw.commons.nearby.NearbyFilterSearchRecyclerViewAdapter) NearbyController(fr.free.nrw.commons.nearby.NearbyController) Polygon(com.mapbox.mapboxsdk.annotations.Polygon) NearbyFABUtils(fr.free.nrw.commons.utils.NearbyFABUtils) PLACE_OBJECT(fr.free.nrw.commons.wikidata.WikidataConstants.PLACE_OBJECT) NearbyFilterSearchRecyclerViewAdapter(fr.free.nrw.commons.nearby.NearbyFilterSearchRecyclerViewAdapter) ArrayList(java.util.ArrayList) Label(fr.free.nrw.commons.nearby.Label) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) SuppressLint(android.annotation.SuppressLint)

Aggregations

Manifest (android.Manifest)1 SuppressLint (android.annotation.SuppressLint)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 PackageManager (android.content.pm.PackageManager)1 Configuration (android.content.res.Configuration)1 Bitmap (android.graphics.Bitmap)1 LocationManager (android.location.LocationManager)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 Settings (android.provider.Settings)1 Html (android.text.Html)1 LinkMovementMethod (android.text.method.LinkMovementMethod)1 Log (android.util.Log)1 Gravity (android.view.Gravity)1 LayoutInflater (android.view.LayoutInflater)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1