code clean up
This commit is contained in:
parent
b0927c174a
commit
03c5a9a3ce
@ -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());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/mapInfoImageButton"
|
||||
android:onClick="infoDialog"
|
||||
style="@android:style/Widget.Material.Light.ImageButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
76
app/src/main/res/layout/info_popup_userlist.xml
Normal file
76
app/src/main/res/layout/info_popup_userlist.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/layout_bg">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewP1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/map_info_text_p1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewP2"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/map_info_text_p2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewP3"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/map_info_text_p3" />
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/exactMarkerTextView"
|
||||
android:gravity="center"
|
||||
android:drawableLeft="@drawable/exact_localization_marker"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="5dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/map_info_text_marker_exact" />
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/approximateTextView"
|
||||
android:drawableLeft="@drawable/approximate_localization_marker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/map_info_text_marker_approximated" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/manualMarkerTextView"
|
||||
android:drawableLeft="@drawable/manual_localization_marker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/map_info_text_marker_manual" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user