|
1 | 1 | package fr.free.nrw.commons.nearby.fragments;
|
2 | 2 |
|
3 | 3 | import android.Manifest;
|
| 4 | +import android.app.Activity; |
4 | 5 | import android.app.AlertDialog;
|
5 | 6 | import android.content.BroadcastReceiver;
|
6 | 7 | import android.content.Context;
|
|
9 | 10 | import android.content.res.Configuration;
|
10 | 11 | import android.graphics.Bitmap;
|
11 | 12 | import android.os.Bundle;
|
12 |
| -import android.text.TextUtils; |
| 13 | +import android.os.IBinder; |
13 | 14 | import android.util.Log;
|
14 | 15 | import android.view.Gravity;
|
15 | 16 | import android.view.LayoutInflater;
|
16 | 17 | import android.view.View;
|
17 | 18 | import android.view.ViewGroup;
|
18 | 19 | import android.view.animation.Animation;
|
19 | 20 | import android.view.animation.AnimationUtils;
|
| 21 | +import android.view.inputmethod.InputMethodManager; |
20 | 22 | import android.widget.Button;
|
21 | 23 | import android.widget.ImageView;
|
22 | 24 | import android.widget.LinearLayout;
|
@@ -598,9 +600,34 @@ public void centerMapToPlace(Place place) {
|
598 | 600 | }
|
599 | 601 | }
|
600 | 602 |
|
601 |
| - @Override |
602 |
| - public void updateListFragment(List<Place> placeList) { |
603 |
| - adapterFactory.updateAdapterData(placeList, (RVRendererAdapter<Place>) rvNearbyList.getAdapter()); |
| 603 | + /** |
| 604 | + * Hides the keyboard in case the tab is switched |
| 605 | + */ |
| 606 | + public void hideKeyboard(){ |
| 607 | + if(!searchView.isIconified()) { |
| 608 | + searchView.clearFocus(); |
| 609 | + InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE); |
| 610 | + final IBinder windowToken = this.getView().getRootView().getWindowToken(); |
| 611 | + if (view != null) { |
| 612 | + imm.hideSoftInputFromWindow(windowToken, InputMethodManager.HIDE_NOT_ALWAYS); |
| 613 | + } |
| 614 | + } |
| 615 | + } |
| 616 | + |
| 617 | + |
| 618 | + /** |
| 619 | + * Thanks to this method we make sure NearbyMapFragment is ready and attached. So that we can |
| 620 | + * prevent NPE caused by null child fragment. This method is called from child fragment when |
| 621 | + * it is attached. |
| 622 | + */ |
| 623 | + private void childMapFragmentAttached() { |
| 624 | + Timber.d("Child map fragment attached"); |
| 625 | + nearbyParentFragmentPresenter = NearbyParentFragmentPresenter.getInstance |
| 626 | + (nearbyListFragment,this, nearbyMapFragment, locationManager); |
| 627 | + nearbyParentFragmentPresenter.nearbyFragmentsAreReady(); |
| 628 | + initViews(); |
| 629 | + nearbyParentFragmentPresenter.setActionListeners(applicationKvStore); |
| 630 | + initNearbyFilter(); |
604 | 631 | }
|
605 | 632 |
|
606 | 633 | @Override
|
|
0 commit comments