diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java index 17843df..ce57f75 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java @@ -131,7 +131,7 @@ public class MapActivity extends BaseActivity }; - + findViewById(R.id.mapInfoImageButton).setOnClickListener(v-> InfoHelperUtils.infoPopUp(this,v, R.layout.info_popup_map)); selectLocationButton = findViewById(R.id.select_location_button); removeLocationButton = findViewById(R.id.remove_location_button); Mapbox.getInstance(this, getString(R.string.access_token)); @@ -144,7 +144,6 @@ public class MapActivity extends BaseActivity manualLocationUtils = new ManualLocationUtils(MapActivity.this); approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson")); - findViewById(R.id.mapInfoImageButton).setOnClickListener(this::infoDialog); } @Override @@ -737,22 +736,4 @@ public class MapActivity extends BaseActivity MapUtils.setZoom(mapboxMap, zoom); } - - public void infoDialog(View anchorView) { - View popupView = getLayoutInflater().inflate(R.layout.info_popup_map, null); - PopupWindow popupWindow = new PopupWindow(popupView, - LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); - // If the PopupWindow should be focusable - popupWindow.setFocusable(true); - // If you need the PopupWindow to dismiss when when touched outside - popupWindow.setBackgroundDrawable(new ColorDrawable()); - int location[] = new int[2]; - // Get the View's(the one that was clicked in the Fragment) location - anchorView.getLocationOnScreen(location); - // Using location, the PopupWindow will be displayed right under anchorView - popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, - location[0] + anchorView.getWidth(), location[1] + anchorView.getHeight()); - } - - } \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java index c9cfa82..1b83e8b 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java @@ -84,12 +84,7 @@ public class UsersListFragment extends Fragment { public void onViewCreated(View view, Bundle savedInstanceState) { ButterKnife.bind(this, view); - - // TODO: Merge with code from home - InfoHelperUtils infoHelperUtils = new InfoHelperUtils(); - view.findViewById(R.id.userListInfoImageButton).setOnClickListener(v -> - infoHelperUtils.infoDialogUserList(getActivity(), v) - ); + view.findViewById(R.id.userListInfoImageButton).setOnClickListener(v -> InfoHelperUtils.infoPopUp(getActivity(),v,R.layout.info_popup_userlist)); userService = ApiClient.getClient(getApplicationContext()) .create(UserService.class); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java index 0ccf9dd..b6e61ca 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java @@ -2,11 +2,14 @@ package com.uam.wmi.findmytutor.utils; import android.app.Activity; import android.content.Context; +import android.graphics.drawable.ColorDrawable; import android.support.v7.app.AlertDialog; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.Button; +import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.Toast; @@ -18,11 +21,22 @@ import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext; public class InfoHelperUtils { - public static void infoDialogUserList(Activity activity, View anchorView ) { + public static void infoPopUp(Activity activity, View anchorView, int layoutId) { + + View popupView = LayoutInflater.from(activity).inflate(layoutId, null); + PopupWindow popupWindow = new PopupWindow(popupView, + LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); + // If the PopupWindow should be focusable + popupWindow.setFocusable(true); + // If you need the PopupWindow to dismiss when when touched outside + popupWindow.setBackgroundDrawable(new ColorDrawable()); + int location[] = new int[2]; + // Get the View's(the one that was clicked in the Fragment) location + anchorView.getLocationOnScreen(location); + // Using location, the PopupWindow will be displayed right under anchorView + popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, + location[0] + anchorView.getWidth(), location[1] + anchorView.getHeight()); - View popupView = LayoutInflater.from(activity).inflate(R.layout.feedback_modal, null); - final PopupWindow popupWindow = new PopupWindow(popupView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); - popupWindow.showAsDropDown(popupView); Toast.makeText(getApplicationContext(), anchorView.getId() + "", Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/res/layout/activity_map.xml b/app/src/main/res/layout/activity_map.xml index 6b9f0e1..212a860 100644 --- a/app/src/main/res/layout/activity_map.xml +++ b/app/src/main/res/layout/activity_map.xml @@ -23,7 +23,6 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file