Commit 151a4c05 authored by MUTTINENI NAVYA's avatar MUTTINENI NAVYA

maps fragment added

parent 1494d5c3
...@@ -39,6 +39,7 @@ import androidx.annotation.RequiresApi; ...@@ -39,6 +39,7 @@ import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import androidx.fragment.app.Fragment;
import android.os.Environment; import android.os.Environment;
import android.os.Handler; import android.os.Handler;
...@@ -71,7 +72,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener ...@@ -71,7 +72,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
private static final String TAG = FoundItem.class.getSimpleName(); ; private static final String TAG = FoundItem.class.getSimpleName(); ;
//private FirebaseAuth mAuth; //private FirebaseAuth mAuth;
EditText title; EditText title;
EditText place; TextView place;
EditText desc; EditText desc;
TextView date; TextView date;
Spinner category; Spinner category;
...@@ -109,6 +110,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener ...@@ -109,6 +110,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
callingclass = getIntent().getStringExtra("CallingClass"); callingclass = getIntent().getStringExtra("CallingClass");
title = findViewById(R.id.title); title = findViewById(R.id.title);
place = findViewById(R.id.place); place = findViewById(R.id.place);
place.setOnClickListener(this);
desc = findViewById(R.id.desc); desc = findViewById(R.id.desc);
date = findViewById(R.id.date); date = findViewById(R.id.date);
category = findViewById(R.id.category); category = findViewById(R.id.category);
...@@ -117,6 +119,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener ...@@ -117,6 +119,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
pd = new ProgressDialog(this); pd = new ProgressDialog(this);
pd.setMessage("Uploading...."); pd.setMessage("Uploading....");
date.setOnClickListener(this); date.setOnClickListener(this);
if(callingclass.equals("MyPosts")) if(callingclass.equals("MyPosts"))
{ {
...@@ -264,7 +267,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener ...@@ -264,7 +267,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
Date datef = new Date(); Date datef = new Date();
Toast.makeText(FoundItem.this, "No file selected", Toast.LENGTH_SHORT).show(); Toast.makeText(FoundItem.this, "No file selected", Toast.LENGTH_SHORT).show();
CreateFoundObject upload = new CreateFoundObject(username,Title ,"NO-IMAGE","location", Desc, CreateFoundObject upload = new CreateFoundObject(username,Title ,"NO-IMAGE",Place, Desc,
Category, Date,"found"); Category, Date,"found");
String uploadId = myRef.push().getKey(); String uploadId = myRef.push().getKey();
Log.v("UploadID", uploadId); Log.v("UploadID", uploadId);
...@@ -310,6 +313,41 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener ...@@ -310,6 +313,41 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
intent.setAction(Intent.ACTION_PICK); intent.setAction(Intent.ACTION_PICK);
startActivityForResult(Intent.createChooser(intent, "Select Image"), PICK_IMAGE_REQUEST); startActivityForResult(Intent.createChooser(intent, "Select Image"), PICK_IMAGE_REQUEST);
break; break;
case R.id.place:
Fragment locationFragment = new LocationFragment();
Bundle bundle = new Bundle();
if(place.getText().toString().trim().isEmpty()){
//bundle.putDouble("Lat", 19.131482);
//bundle.putDouble("Lon", 72.916129);
//Toast.makeText(FoundItem.this, "empty!", Toast.LENGTH_SHORT).show();
}
else{
//Toast.makeText(FoundItem.this, "not empty", Toast.LENGTH_SHORT).show();
String coordinates;
Double lat=0.0,lon=0.0;
coordinates = place.getText().toString().trim();
Log.v("coordinatesbefore: ", coordinates);
Log.v("coordinates: ", coordinates);
lat = Double.parseDouble(coordinates.split(",")[0]);
lon = Double.parseDouble(coordinates.split(",")[1]);
//Toast.makeText(FoundItem.this, coordinates.split(",")[0], Toast.LENGTH_SHORT).show();
bundle.putDouble("Lat", lat);
bundle.putDouble("Lon", lon);
bundle.putString("type", "Found");
}
locationFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.map_container,
locationFragment).commit();
//Intent i = new Intent(getApplicationContext(), LocationFragment.class);
//startActivity(i);
break;
case R.id.date: case R.id.date:
Calendar cal= Calendar.getInstance(); Calendar cal= Calendar.getInstance();
int year = cal.get(Calendar.YEAR); int year = cal.get(Calendar.YEAR);
......
...@@ -23,6 +23,8 @@ public class ItemClaim extends AppCompatActivity implements View.OnClickListene ...@@ -23,6 +23,8 @@ public class ItemClaim extends AppCompatActivity implements View.OnClickListene
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_claim); setContentView(R.layout.activity_item_claim);
findViewById(R.id.buttonClaim).setOnClickListener(this); findViewById(R.id.buttonClaim).setOnClickListener(this);
findViewById(R.id.placeclaim).setOnClickListener(this);
username = getIntent().getStringExtra("username"); username = getIntent().getStringExtra("username");
objectfound = (CreateFoundObject)getIntent().getSerializableExtra("FoundObject"); objectfound = (CreateFoundObject)getIntent().getSerializableExtra("FoundObject");
...@@ -56,6 +58,31 @@ public class ItemClaim extends AppCompatActivity implements View.OnClickListene ...@@ -56,6 +58,31 @@ public class ItemClaim extends AppCompatActivity implements View.OnClickListene
.beginTransaction().replace(R.id.frameLayout, emailFragment) .beginTransaction().replace(R.id.frameLayout, emailFragment)
.addToBackStack(null).commit(); .addToBackStack(null).commit();
break; break;
case R.id.placeclaim:
Fragment seeLocationFragment = new SeeLocationFragment();
Bundle bundle1 = new Bundle();
if(objectfound.getmLocation().trim().isEmpty()){
break;
}
else{
String coordinates;
Double lat=0.0,lon=0.0;
coordinates = objectfound.getmLocation().trim();
Log.v("coordinatesbefore: ", coordinates);
Log.v("coordinates: ", coordinates);
lat = Double.parseDouble(coordinates.split(",")[0]);
lon = Double.parseDouble(coordinates.split(",")[1]);
bundle1.putDouble("Lat", lat);
bundle1.putDouble("Lon", lon);
}
seeLocationFragment.setArguments(bundle1);
getSupportFragmentManager().beginTransaction().replace(R.id.map_container,
seeLocationFragment).commit();
break;
} }
} }
} }
package com.example.instilostandfound; package com.example.instilostandfound;
import android.content.Intent;
import android.location.LocationListener;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMap;
...@@ -17,17 +22,22 @@ import com.google.android.gms.maps.MapsInitializer; ...@@ -17,17 +22,22 @@ import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.MarkerOptions;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class LocationFragment extends Fragment implements OnMapReadyCallback { public class LocationFragment extends Fragment implements OnMapReadyCallback, GoogleMap.OnMarkerDragListener, GoogleMap.OnMarkerClickListener, View.OnClickListener {
GoogleMap mGoogleMap; GoogleMap mMap;
MapView mMapView; MapView mMapView;
public View mView; public View mView;
public Marker my_marker;
Double lat=19.131482, lon=72.916129;
public LocationFragment() { public LocationFragment() {
// Required empty public constructor // Required empty public constructor
...@@ -51,18 +61,75 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback { ...@@ -51,18 +61,75 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback {
mMapView.onCreate(null); mMapView.onCreate(null);
mMapView.onResume(); mMapView.onResume();
mMapView.getMapAsync(this); mMapView.getMapAsync(this);
} }
mView.findViewById(R.id.select_location).setOnClickListener(this);
} }
@Override @Override
public void onMapReady(GoogleMap googleMap) { public void onMapReady(GoogleMap googleMap) {
MapsInitializer.initialize(getContext()); MapsInitializer.initialize(getContext());
mMap = googleMap;
mGoogleMap = googleMap;
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.addMarker(new MarkerOptions().position(new LatLng(40.689247, -74.04450)).title("KReSIT")); Bundle bundle = getArguments();
CameraPosition Liberty = CameraPosition.builder().target(new LatLng(40.689247, -74.04450)).zoom(16).bearing(0).tilt(45).build(); if(bundle.containsKey("Lat")){
googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(Liberty)); lat = bundle.getDouble("Lat");
}
if(bundle.containsKey("Lon")){
lon = bundle.getDouble("Lon");
//Toast.makeText(getActivity(), "!!!!!"+lon.toString(), Toast.LENGTH_SHORT).show();
}
LatLng kresit = new LatLng(lat, lon);
//Toast.makeText(getActivity(), "Kresit!!"+kresit.longitude, Toast.LENGTH_SHORT).show();
my_marker = mMap.addMarker(new MarkerOptions().position(kresit).draggable(true));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(kresit,16f));
mMap.setOnMarkerClickListener(this);
mMap.setOnMarkerDragListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.select_location:
lat = my_marker.getPosition().latitude;
lon = my_marker.getPosition().longitude;
//Toast.makeText(getActivity(), lat.toString(), Toast.LENGTH_SHORT).show();
((FoundItem)getActivity()).place.setText(lat.toString()+","+lon.toString());
getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
break;
}
}
@Override
public boolean onMarkerClick(Marker marker) {
LatLng my_marker_location = marker.getPosition();
//Toast.makeText(getActivity(), my_marker_location.toString(), Toast.LENGTH_SHORT).show();
return false;
}
@Override
public void onMarkerDragStart(Marker marker) {
}
@Override
public void onMarkerDrag(Marker marker) {
}
@Override
public void onMarkerDragEnd(Marker marker) {
my_marker.setPosition(marker.getPosition());
//Toast.makeText(getActivity(), my_marker.getPosition().toString(), Toast.LENGTH_SHORT).show();
} }
} }
...@@ -25,6 +25,7 @@ import androidx.annotation.NonNull; ...@@ -25,6 +25,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
...@@ -38,6 +39,8 @@ import android.widget.Spinner; ...@@ -38,6 +39,8 @@ import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.w3c.dom.Text;
import java.io.Serializable; import java.io.Serializable;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -46,7 +49,7 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener, ...@@ -46,7 +49,7 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
private static final String TAG = LostItem.class.getSimpleName(); ; private static final String TAG = LostItem.class.getSimpleName(); ;
EditText title; EditText title;
EditText place; TextView place;
EditText desc; EditText desc;
TextView date; TextView date;
Spinner category; Spinner category;
...@@ -86,6 +89,7 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener, ...@@ -86,6 +89,7 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
date = findViewById(R.id.date); date = findViewById(R.id.date);
category = findViewById(R.id.category); category = findViewById(R.id.category);
camera = findViewById(R.id.camera); camera = findViewById(R.id.camera);
place.setOnClickListener(this);
camera.setOnClickListener(this); camera.setOnClickListener(this);
pd = new ProgressDialog(this); pd = new ProgressDialog(this);
pd.setMessage("Uploading...."); pd.setMessage("Uploading....");
...@@ -240,7 +244,7 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener, ...@@ -240,7 +244,7 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
Date datef = new Date(); Date datef = new Date();
Toast.makeText(LostItem.this, "No file selected", Toast.LENGTH_SHORT).show(); Toast.makeText(LostItem.this, "No file selected", Toast.LENGTH_SHORT).show();
CreateFoundObject upload = new CreateFoundObject(username,Title ,"NO-IMAGE","location", Desc, CreateFoundObject upload = new CreateFoundObject(username,Title ,"NO-IMAGE",Place, Desc,
Category, Date,"lost"); Category, Date,"lost");
String uploadId = myRef.push().getKey(); String uploadId = myRef.push().getKey();
Log.v("UploadID", uploadId); Log.v("UploadID", uploadId);
...@@ -291,6 +295,35 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener, ...@@ -291,6 +295,35 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
intent.setAction(Intent.ACTION_PICK); intent.setAction(Intent.ACTION_PICK);
startActivityForResult(Intent.createChooser(intent, "Select Image"), PICK_IMAGE_REQUEST); startActivityForResult(Intent.createChooser(intent, "Select Image"), PICK_IMAGE_REQUEST);
break; break;
case R.id.place:
Fragment lostItemLocationFragment = new LostItemLocationFragment();
Bundle bundle = new Bundle();
if(place.getText().toString().trim().isEmpty()){
bundle.putDouble("Lat", 19.131482);
bundle.putDouble("Lon", 72.916129);
}
else{
String coordinates;
Double lat=0.0,lon=0.0;
coordinates = place.getText().toString().trim();
Log.v("coordinatesbefore: ", coordinates);
Log.v("coordinates: ", coordinates);
lat = Double.parseDouble(coordinates.split(",")[0]);
lon = Double.parseDouble(coordinates.split(",")[1]);
bundle.putDouble("Lat", lat);
bundle.putDouble("Lon", lon);
bundle.putString("type", "Lost");
}
lostItemLocationFragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.map_container,
lostItemLocationFragment).commit();
break;
case R.id.date: case R.id.date:
Calendar cal= Calendar.getInstance(); Calendar cal= Calendar.getInstance();
int year = cal.get(Calendar.YEAR); int year = cal.get(Calendar.YEAR);
......
package com.example.instilostandfound;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
/**
* A simple {@link Fragment} subclass.
*/
public class LostItemLocationFragment extends Fragment implements OnMapReadyCallback, GoogleMap.OnMarkerDragListener, GoogleMap.OnMarkerClickListener, View.OnClickListener {
GoogleMap mMap;
MapView mMapView;
public View mView;
Marker my_marker;
Double lat = 19.131482, lon = 72.916129;
public LostItemLocationFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
mView = inflater.inflate(R.layout.fragment_lost_item_location, container, false);
return mView;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState){
super.onViewCreated(view, savedInstanceState);
mMapView = (MapView) mView.findViewById(R.id.map);
if(mMapView != null){
mMapView.onCreate(null);
mMapView.onResume();
mMapView.getMapAsync(this);
}
mView.findViewById(R.id.select_location).setOnClickListener(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
MapsInitializer.initialize(getContext());
mMap = googleMap;
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
Bundle bundle = getArguments();
lat = bundle.getDouble("Lat");
lon = bundle.getDouble("Lon");
LatLng kresit = new LatLng(lat, lon);
my_marker = mMap.addMarker(new MarkerOptions().position(kresit).draggable(true));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(kresit,16f));
mMap.setOnMarkerClickListener(this);
mMap.setOnMarkerDragListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.select_location:
Double lat, lon;
lat = my_marker.getPosition().latitude;
lon = my_marker.getPosition().longitude;
Bundle bundle = getArguments();
((LostItem)getActivity()).place.setText(lat.toString()+","+lon.toString());
break;
}
getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
}
@Override
public boolean onMarkerClick(Marker marker) {
LatLng my_marker_location = marker.getPosition();
return false;
}
@Override
public void onMarkerDragStart(Marker marker) {
}
@Override
public void onMarkerDrag(Marker marker) {
}
@Override
public void onMarkerDragEnd(Marker marker) {
my_marker = marker;
}
}
...@@ -2,18 +2,27 @@ package com.example.instilostandfound; ...@@ -2,18 +2,27 @@ package com.example.instilostandfound;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { import java.util.Map;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, GoogleMap.OnMarkerClickListener, GoogleMap.OnMarkerDragListener, LocationListener, View.OnClickListener {
private GoogleMap mMap; private GoogleMap mMap;
Marker my_marker;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -23,6 +32,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback ...@@ -23,6 +32,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map); .findFragmentById(R.id.map);
mapFragment.getMapAsync(this); mapFragment.getMapAsync(this);
findViewById(R.id.select_location).setOnClickListener(this);
} }
...@@ -41,7 +51,72 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback ...@@ -41,7 +51,72 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
// Add a marker in Sydney and move the camera // Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151); LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); my_marker = mMap.addMarker(new MarkerOptions().position(sydney).draggable(true));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
mMap.setOnMarkerClickListener(this);
mMap.setOnMarkerDragListener(this);
}
@Override
public boolean onMarkerClick(Marker marker) {
LatLng my_marker_location = marker.getPosition();
Toast.makeText(MapsActivity.this, my_marker_location.toString(), Toast.LENGTH_SHORT).show();
return false;
}
@Override
public void onMarkerDragStart(Marker marker) {
}
@Override
public void onMarkerDrag(Marker marker) {
}
@Override
public void onMarkerDragEnd(Marker marker) {
my_marker = marker;
}
@Override
public void onLocationChanged(Location location) {
}
@Override
public void onStatusChanged(String s, int i, Bundle bundle) {
}
@Override
public void onProviderEnabled(String s) {
}
@Override
public void onProviderDisabled(String s) {
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.select_location:
Intent intent = new Intent(MapsActivity.this, FoundItem.class);
CreateFoundObject item = (CreateFoundObject)getIntent().getSerializableExtra("FoundObject");
item.setmLocation(my_marker.toString());
//CreateFoundObject item = new CreateFoundObject(null, getIntent().getStringExtra("title"), null, null, null,
// null, null, null);
intent.putExtra("FoundObject", item);
startActivity(intent);
break;
}
} }
} }
...@@ -150,7 +150,7 @@ public class NewsFeedFound extends AppCompatActivity implements NewsfeedAdaptor. ...@@ -150,7 +150,7 @@ public class NewsFeedFound extends AppCompatActivity implements NewsfeedAdaptor.
//create alert dialog //create alert dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Sort by") //set title builder.setTitle("Sort by") //set title
.setIcon(R.drawable.filter) //set icon .setIcon(R.drawable.camera) //set icon
.setItems(sortOptions, new DialogInterface.OnClickListener() { .setItems(sortOptions, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
......
...@@ -148,7 +148,7 @@ public class NewsFeedLost extends AppCompatActivity implements NewsfeedAdaptor.O ...@@ -148,7 +148,7 @@ public class NewsFeedLost extends AppCompatActivity implements NewsfeedAdaptor.O
//create alert dialog //create alert dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Sort by") //set title builder.setTitle("Sort by") //set title
.setIcon(R.drawable.filter) //set icon .setIcon(R.drawable.camera) //set icon
.setItems(sortOptions, new DialogInterface.OnClickListener() { .setItems(sortOptions, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
......
package com.example.instilostandfound;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
/**
* A simple {@link Fragment} subclass.
*/
public class SeeLocationFragment extends Fragment implements OnMapReadyCallback, GoogleMap.OnMarkerClickListener, View.OnClickListener {
GoogleMap mMap;
MapView mMapView;
public View mView;
Marker my_marker;
Double lat = 19.131482, lon = 72.916129;
public SeeLocationFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
mView = inflater.inflate(R.layout.fragment_see_location, container, false);
return mView;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState){
super.onViewCreated(view, savedInstanceState);
mMapView = (MapView) mView.findViewById(R.id.map);
if(mMapView != null){
mMapView.onCreate(null);
mMapView.onResume();
mMapView.getMapAsync(this);
}
mView.findViewById(R.id.done).setOnClickListener(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
MapsInitializer.initialize(getContext());
mMap = googleMap;
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
Bundle bundle = getArguments();
lat = bundle.getDouble("Lat");
lon = bundle.getDouble("Lon");
LatLng location = new LatLng(lat, lon);
my_marker = mMap.addMarker(new MarkerOptions().position(location).draggable(false));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location,16f));
mMap.setOnMarkerClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.done:
getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
break;
}
}
@Override
public boolean onMarkerClick(Marker marker) {
LatLng my_marker_location = marker.getPosition();
return false;
}
}
...@@ -157,6 +157,11 @@ ...@@ -157,6 +157,11 @@
android:id="@+id/frameLayout" android:id="@+id/frameLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<FrameLayout
android:id="@+id/map_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout> </FrameLayout>
......
...@@ -6,4 +6,16 @@ ...@@ -6,4 +6,16 @@
android:name="com.google.android.gms.maps.SupportMapFragment" android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MapsActivity" /> tools:context=".MapsActivity">
\ No newline at end of file
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Select"
android:id="@+id/select_location"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@color/colorPrimary"
/>
</fragment>
\ No newline at end of file
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
android:paddingRight = "@dimen/activity_horizontal_margin" android:paddingRight = "@dimen/activity_horizontal_margin"
android:paddingTop = "@dimen/activity_vertical_margin" android:paddingTop = "@dimen/activity_vertical_margin"
android:paddingBottom = "@dimen/activity_vertical_margin" android:paddingBottom = "@dimen/activity_vertical_margin"
android:id="@+id/full_found_layout"
> >
...@@ -43,13 +44,14 @@ ...@@ -43,13 +44,14 @@
android:layout_alignParentRight = "true" android:layout_alignParentRight = "true"
android:layout_alignParentEnd = "true" android:layout_alignParentEnd = "true"
/> />
<EditText <TextView
android:layout_width = "wrap_content" android:layout_width = "wrap_content"
android:layout_height = "wrap_content" android:layout_height = "wrap_content"
android:id = "@+id/place" android:id = "@+id/place"
android:hint = "@string/place" android:hint = "@string/place"
android:focusable = "true" android:focusable = "true"
android:textColorHighlight = "#ff7eff15" android:textColorHighlight = "#ff7eff15"
android:textSize="20dp"
android:textColorHint = "@color/hint_color" android:textColorHint = "@color/hint_color"
android:layout_marginTop = "15dp" android:layout_marginTop = "15dp"
android:layout_below = "@+id/title" android:layout_below = "@+id/title"
...@@ -85,6 +87,11 @@ ...@@ -85,6 +87,11 @@
android:background="@color/colorPrimary" android:background="@color/colorPrimary"
/> />
<RelativeLayout
android:id="@+id/map_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView <TextView
android:gravity="start|top" android:gravity="start|top"
android:id="@+id/date" android:id="@+id/date"
...@@ -103,5 +110,7 @@ ...@@ -103,5 +110,7 @@
android:layout_alignParentRight = "true" android:layout_alignParentRight = "true"
android:layout_alignParentEnd = "true"/> android:layout_alignParentEnd = "true"/>
</RelativeLayout> </RelativeLayout>
...@@ -103,6 +103,11 @@ ...@@ -103,6 +103,11 @@
android:layout_alignParentRight = "true" android:layout_alignParentRight = "true"
android:layout_alignParentEnd = "true"/> android:layout_alignParentEnd = "true"/>
<RelativeLayout
android:id="@+id/map_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout> </RelativeLayout>
......
...@@ -10,4 +10,15 @@ ...@@ -10,4 +10,15 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/map" android:id="@+id/map"
/> />
</FrameLayout>
\ No newline at end of file
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Select1"
android:id="@+id/select_location"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@color/colorPrimary"
/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LostItemLocationFragment">
<com.google.android.gms.maps.MapView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Select"
android:id="@+id/select_location"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@color/colorPrimary"
/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SeeLocationFragment">
<com.google.android.gms.maps.MapView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Done"
android:id="@+id/done"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@color/colorPrimary"
/>
</FrameLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment