손장민

Map is added with Error

......@@ -39,6 +39,8 @@ dependencies {
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-location:11.0.2'
compile 'com.google.android.gms:play-services-places:11.0.2'
testCompile 'junit:junit:4.12'
}
......
......@@ -6,13 +6,11 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
......
......@@ -9,39 +9,66 @@ public class Blog
private String title;
private String desc;
private String image;
private String nickname;
public Blog(){
public Blog()
{
}
public Blog(String title, String desc, String image) {
public Blog(String title, String desc, String image)
{
this.title = title;
this.desc = desc;
this.image = image;
}
public String getDesc() {
public Blog(String title, String desc, String image, String nickname)
{
this.title = title;
this.desc = desc;
this.image = image;
this.nickname = nickname;
}
public String getDesc()
{
return desc;
}
public void setDesc(String desc) {
public void setDesc(String desc)
{
this.desc = desc;
}
public String getImage() {
public String getImage()
{
return image;
}
public void setImage(String image) {
public void setImage(String image)
{
this.image = image;
}
public String getTitle() {
public String getTitle()
{
return title;
}
public void setTitle(String title) {
public void setTitle(String title)
{
this.title = title;
}
public String getNickname()
{
return nickname;
}
public void setNickname(String nickname)
{
this.nickname = nickname;
}
}
......
......@@ -7,6 +7,7 @@ import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
......@@ -21,8 +22,10 @@ import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.squareup.picasso.Picasso;
import org.w3c.dom.Text;
/**
* Created by HYB on 2017. 10. 11..
* Created by HYB on 2017. 10 . 11..
*/
public class Community extends Fragment
......@@ -37,14 +40,17 @@ public class Community extends Fragment
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState)
{
setHasOptionsMenu(true);
LinearLayoutManager lm = new LinearLayoutManager(getActivity());
View view = inflater.inflate(R.layout.community, container, false);
mDatabase = FirebaseDatabase.getInstance().getReference().child("Blog");
lm.setReverseLayout(true);
lm.setStackFromEnd(true);
mBlogList = (RecyclerView) view.findViewById(R.id.blog_list);
mBlogList.setHasFixedSize(true);
mBlogList.setLayoutManager(new LinearLayoutManager(getActivity()));
mBlogList.setLayoutManager(lm);
return view;
}
......@@ -54,9 +60,8 @@ public class Community extends Fragment
{
super.onStart();
FirebaseRecyclerAdapter<Blog, BlogViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Blog, BlogViewHolder>(
Blog.class, R.layout.blog_row, BlogViewHolder.class, mDatabase)
FirebaseRecyclerAdapter<Blog, BlogViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Blog, BlogViewHolder>
( Blog.class, R.layout.blog_row, BlogViewHolder.class, mDatabase)
{
@Override
protected void populateViewHolder(BlogViewHolder viewHolder, Blog model, int position)
......@@ -64,6 +69,7 @@ public class Community extends Fragment
viewHolder.setTitle(model.getTitle());
viewHolder.setDesc(model.getDesc());
viewHolder.setImage(getActivity().getApplicationContext(), model.getImage());
viewHolder.setNickname(model.getNickname());
}
};
mBlogList.setAdapter(firebaseRecyclerAdapter);
......@@ -112,6 +118,12 @@ public class Community extends Fragment
Picasso.with(ctx).load(image).into(post_image);
}
public void setNickname(String nickname)
{
TextView nick_title = (TextView)mView.findViewById(R.id.nick_Title);
nick_title.setText(nickname);
}
}
......
package com.example.user.firebaseauthdemo;
import android.*;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
......@@ -27,6 +33,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private EditText editTextEmail;
private EditText editTextPassword;
private TextView textViewSignIn;
public static final int REQUEST_LOCATION_CODE = 99;
private ProgressDialog progressDialog;
......@@ -43,6 +50,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
firebaseAuth = FirebaseAuth.getInstance();
mDatabase = FirebaseDatabase.getInstance().getReference().child("Users");
Log.d("", "퍼미션 체크전");
checkLocationPermission();
if(firebaseAuth.getCurrentUser() != null){
//profile activity here
finish();
......@@ -121,4 +131,34 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
startActivity(new Intent(this, LoginActivity.class));
}
}
public boolean checkLocationPermission()
{
Log.d("", "퍼미션 체크안");
if(ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED)
{
Log.d("", "퍼미션 받음");
if(ActivityCompat.shouldShowRequestPermissionRationale(this, android.Manifest.permission.ACCESS_FINE_LOCATION))
{
Log.d("", "리퀘ㅡ트 띠움");
ActivityCompat.requestPermissions(this, new String[] {android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_CODE);
}
else
{
Log.d("", "리퀘ㅡ트 띠움");
ActivityCompat.requestPermissions(this, new String[] {android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_CODE);
}
return false;
}
else
{
return true;
}
}
}
......
package com.example.user.firebaseauthdemo;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApi;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.PlaceLikelihood;
import com.google.android.gms.location.places.PlaceLikelihoodBuffer;
import com.google.android.gms.location.places.Places;
import com.google.android.gms.location.places.ui.PlaceAutocompleteFragment;
import com.google.android.gms.location.places.ui.PlaceSelectionListener;
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.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
/**
* Created by HYB on 2017. 10. 11..
*/
public class Map extends Fragment implements OnMapReadyCallback
public class Map extends Fragment
implements OnMapReadyCallback ,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
LocationListener
{
private static final LatLng DEFAULT_LOCATION = new LatLng(37.56, 126.97);
private static final String TAG = "googlemap_example";
private static final int GPS_ENABLE_REQUEST_CODE = 2001;
private static final int PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION = 2002;
private static final int UPDATE_INTERVAL_MS = 15000;
private static final int FASTEST_UPDATE_INTERVAL_MS = 15000;
private GoogleMap googleMap = null;
private MapView mapView = null;
private GoogleApiClient googleApiClient = null;
private Marker currentMarker = null;
private final static int MAXENTRIES = 5;
private String[] LikelyPlaceNames = null;
private String[] LikelyAddresses = null;
private String[] LikelyAttributions = null;
private LatLng[] LikelyLatLngs = null;
public Map()
{
}
public void setCurrentLocation(Location location, String markerTitle, String markerSnippet) {
if ( currentMarker != null ) currentMarker.remove();
if ( location != null) {
//현재위치의 위도 경도 가져옴
LatLng currentLocation = new LatLng( location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(currentLocation);
markerOptions.title(markerTitle);
markerOptions.snippet(markerSnippet);
markerOptions.draggable(true);
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
currentMarker = this.googleMap.addMarker(markerOptions);
this.googleMap.moveCamera(CameraUpdateFactory.newLatLng(currentLocation));
return;
}
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(DEFAULT_LOCATION);
markerOptions.title(markerTitle);
markerOptions.snippet(markerSnippet);
markerOptions.draggable(true);
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
currentMarker = this.googleMap.addMarker(markerOptions);
this.googleMap.moveCamera(CameraUpdateFactory.newLatLng(DEFAULT_LOCATION));
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
public void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{
View layout = inflater.inflate(R.layout.map, container, false);
mapView = (MapView)layout.findViewById(R.id.mapView);
mapView.getMapAsync(this);
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getActivity().getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
Location location = new Location("");
location.setLatitude(place.getLatLng().latitude);
location.setLongitude(place.getLatLng().longitude);
setCurrentLocation(location, place.getName().toString(), place.getAddress().toString());
}
@Override
public void onError(Status status) {
Log.i(TAG, "An error occurred: " + status);
}
});
return layout;
}
@Override
public void onStart() {
public void onStart()
{
super.onStart();
mapView.onStart();
}
@Override
public void onStop() {
public void onStop()
{
super.onStop();
mapView.onStop();
if ( googleApiClient != null && googleApiClient.isConnected())
googleApiClient.disconnect();
}
@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}
@Override
public void onResume() {
public void onResume()
{
super.onResume();
mapView.onResume();
if ( googleApiClient != null)
googleApiClient.connect();
}
@Override
public void onPause() {
public void onPause()
{
super.onPause();
mapView.onPause();
if ( googleApiClient != null && googleApiClient.isConnected()) {
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, (com.google.android.gms.location.LocationListener) this);
googleApiClient.disconnect();
}
}
@Override
public void onLowMemory() {
public void onLowMemory()
{
super.onLowMemory();
mapView.onLowMemory();
}
@Override
public void onDestroy() {
public void onDestroy()
{
super.onDestroy();
mapView.onLowMemory();
if ( googleApiClient != null ) {
googleApiClient.unregisterConnectionCallbacks(this);
googleApiClient.unregisterConnectionFailedListener(this);
if ( googleApiClient.isConnected()) {
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, (com.google.android.gms.location.LocationListener) this);
googleApiClient.disconnect();
}
}
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
public void onActivityCreated(@Nullable Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
//액티비티가 처음 생성될 때 실행되는 함수
MapsInitializer.initialize(getActivity().getApplicationContext());
if(mapView != null)
if (mapView != null)
{
mapView.onCreate(savedInstanceState);
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
LatLng SEOUL = new LatLng(37.56, 126.97);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(SEOUL);
markerOptions.title("서울");
markerOptions.snippet("수도");
googleMap.addMarker(markerOptions);
googleMap.moveCamera(CameraUpdateFactory.newLatLng(SEOUL));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(13));
public void onMapReady(GoogleMap googleMap)
{
//
// LatLng SEOUL = new LatLng(37.56, 126.97);
// MarkerOptions markerOptions = new MarkerOptions();
// markerOptions.position(SEOUL);
// markerOptions.title("서울");
// markerOptions.snippet("수도");
// googleMap.addMarker(markerOptions);
// googleMap.moveCamera(CameraUpdateFactory.newLatLng(SEOUL));
// googleMap.animateCamera(CameraUpdateFactory.zoomTo(13));
// OnMapReadyCallback implements 해야 mapView.getMapAsync(this); 사용가능. this 가 OnMapReadyCallback
this.googleMap = googleMap;
//런타임 퍼미션 요청 대화상자나 GPS 활성 요청 대화상자 보이기전에 지도의 초기위치를 서울로 이동
setCurrentLocation(null, "위치정보 가져올 수 없음", "위치 퍼미션과 GPS 활성 여부 확인");
//나침반이 나타나도록 설정
googleMap.getUiSettings().setCompassEnabled(true);
// 매끄럽게 이동함
googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
// API 23 이상이면 런타임 퍼미션 처리 필요
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// 사용권한체크
int hasFineLocationPermission = ContextCompat.checkSelfPermission(getActivity(), android.Manifest.permission.ACCESS_FINE_LOCATION);
if ( hasFineLocationPermission == PackageManager.PERMISSION_DENIED) {
//사용권한이 없을경우
//권한 재요청
ActivityCompat.requestPermissions(getActivity(), new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
} else {
//사용권한이 있는경우
if ( googleApiClient == null) {
buildGoogleApiClient();
}
if ( ActivityCompat.checkSelfPermission(getActivity(), android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
{
googleMap.setMyLocationEnabled(true);
}
}
} else {
if ( googleApiClient == null) {
buildGoogleApiClient();
}
googleMap.setMyLocationEnabled(true);
}
}
private void buildGoogleApiClient()
{
googleApiClient = new GoogleApiClient.Builder(getActivity())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.enableAutoManage(getActivity(), this)
.build();
googleApiClient.connect();
}
public boolean checkLocationServicesStatus() {
LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) ||
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
}
@Override
public void onLocationChanged(Location location)
{
Log.i(TAG, "onLocationChanged call..");
searchCurrentPlaces();
}
private void searchCurrentPlaces()
{
@SuppressWarnings("MissingPermission") PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
.getCurrentPlace(googleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>(){
@Override
public void onResult(@NonNull PlaceLikelihoodBuffer placeLikelihoods) {
int i = 0;
LikelyPlaceNames = new String[MAXENTRIES];
LikelyAddresses = new String[MAXENTRIES];
LikelyAttributions = new String[MAXENTRIES];
LikelyLatLngs = new LatLng[MAXENTRIES];
for(PlaceLikelihood placeLikelihood : placeLikelihoods) {
LikelyPlaceNames[i] = (String) placeLikelihood.getPlace().getName();
LikelyAddresses[i] = (String) placeLikelihood.getPlace().getAddress();
LikelyAttributions[i] = (String) placeLikelihood.getPlace().getAttributions();
LikelyLatLngs[i] = placeLikelihood.getPlace().getLatLng();
i++;
if(i > MAXENTRIES - 1 ) {
break;
}
}
placeLikelihoods.release();
Location location = new Location("");
location.setLatitude(LikelyLatLngs[0].latitude);
location.setLongitude(LikelyLatLngs[0].longitude);
setCurrentLocation(location, LikelyPlaceNames[0], LikelyAddresses[0]);
}
});
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
@Override
public void onProviderEnabled(String provider)
{
}
@Override
public void onProviderDisabled(String provider)
{
}
@Override
public void onConnected(@Nullable Bundle bundle)
{
if ( !checkLocationServicesStatus()) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("위치 서비스 비활성화");
builder.setMessage("앱을 사용하기 위해서는 위치 서비스가 필요합니다.\n" +
"위치 설정을 수정하십시오.");
builder.setCancelable(true);
builder.setPositiveButton("설정", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent callGPSSettingIntent =
new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(callGPSSettingIntent, GPS_ENABLE_REQUEST_CODE);
}
});
builder.setNegativeButton("취소", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
}
});
builder.create().show();
}
LocationRequest locationRequest = new LocationRequest();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(UPDATE_INTERVAL_MS);
locationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_MS);
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if ( ActivityCompat.checkSelfPermission(getActivity(),
android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
LocationServices.FusedLocationApi
.requestLocationUpdates(googleApiClient, locationRequest, (com.google.android.gms.location.LocationListener) this);
}
} else {
LocationServices.FusedLocationApi
.requestLocationUpdates(googleApiClient, locationRequest, (com.google.android.gms.location.LocationListener) this);
this.googleMap.getUiSettings().setCompassEnabled(true);
this.googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
}
}
@Override
public void onConnectionSuspended(int i)
{
if ( i == CAUSE_NETWORK_LOST )
Log.e(TAG, "onConnectionSuspended(): Google Play services " +
"connection lost. Cause: network lost.");
else if (i == CAUSE_SERVICE_DISCONNECTED )
Log.e(TAG,"onConnectionSuspended(): Google Play services " +
"connection lost. Cause: service disconnected");
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult)
{
Location location = new Location("");
location.setLatitude(DEFAULT_LOCATION.latitude);
location.setLongitude((DEFAULT_LOCATION.longitude));
setCurrentLocation(location, "위치정보 가져올 수 없음",
"위치 퍼미션과 GPS활성 여부 확인");
}
}
......
......@@ -37,7 +37,15 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.common_google_signin_btn_icon_dark).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)).setContentTitle("Push Title ").setContentText(message).setAutoCancel(true).setSound(defaultSoundUri).setLights(000000255, 500, 2000).setContentIntent(pendingIntent);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.setContentTitle("Admin")
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setLights(000000255, 500, 2000)
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
......
......@@ -20,6 +20,7 @@ import android.widget.Toast;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.UserInfo;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.storage.FirebaseStorage;
......@@ -78,7 +79,6 @@ public class PostActivity extends AppCompatActivity {
startActivityForResult(gallaryIntent, GALLARY_REQUEST);
}
});
mSubmitBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
......@@ -105,6 +105,7 @@ public class PostActivity extends AppCompatActivity {
newPost.child("title").setValue(title_val);
newPost.child("desc").setValue(desc_val);
newPost.child("uid").setValue(mCurrentUser.getUid());
newPost.child("nickname").setValue(mCurrentUser.getDisplayName());
mProgress.dismiss();
}
......@@ -123,6 +124,7 @@ public class PostActivity extends AppCompatActivity {
newPost.child("desc").setValue(desc_val);
newPost.child("image").setValue(downloadUrl.toString());
newPost.child("uid").setValue(mCurrentUser.getUid());
newPost.child("nickname").setValue(mCurrentUser.getDisplayName());
mProgress.dismiss();
......@@ -130,9 +132,6 @@ public class PostActivity extends AppCompatActivity {
}
});
}
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
android.support.v4.app.FragmentTransaction ft = fm.beginTransaction();
finish();
Toast.makeText(PostActivity.this, "Success!", Toast.LENGTH_LONG).show();
......
......@@ -17,14 +17,14 @@
<ImageButton
android:id="@+id/imageSelect"
android:layout_width="match_parent"
android:layout_height="204dp"
app:srcCompat="@mipmap/add_btn"
android:layout_weight="0.05" />
android:layout_height="match_parent"
android:layout_weight="0.05"
app:srcCompat="@mipmap/add_btn"/>
<EditText
android:id="@+id/titleField"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_margin="15dp"
android:background="@drawable/input_outline"
......@@ -33,7 +33,7 @@
android:inputType="textPersonName"
android:singleLine="true"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
tools:layout_editor_absoluteY="0dp"/>
<EditText
android:id="@+id/descField"
......@@ -43,7 +43,7 @@
android:background="@drawable/input_outline"
android:ems="10"
android:hint=" Post Descriptions..."
android:inputType="textMultiLine" />
android:inputType="textMultiLine"/>
<Button
android:id="@+id/submitBtn"
......
......@@ -19,12 +19,28 @@
android:scaleType="centerCrop"
app:srcCompat="@mipmap/add_btn" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/post_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="15dp"
android:text="post title in here"/>
<TextView
android:id="@+id/nick_Title"
android:gravity="right"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:padding="15dp"
android:text="post title in here" />
android:text="Nickname"
/>
</LinearLayout>
<TextView
android:id="@+id/post_desc"
......@@ -33,6 +49,8 @@
android:padding="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="post description" />
android:text="post description"/>
</LinearLayout>
</android.support.v7.widget.CardView>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:weightSum="1">
<TextView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="82dp"
android:layout_centerHorizontal="true"
android:text="Terror inform is displayed in here."
android:textAppearance="@style/TextAppearance.AppCompat.Headline" />
......@@ -13,6 +15,25 @@
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="250dp"
android:layout_weight="0.93"/>
<android.support.v7.widget.CardView
android:name="@+id/card_view"
android:layout_width="400dp"
android:layout_height="40dp"
android:layout_gravity="center"
card_view:cardCornerRadius="4dp"
>
<fragment
android:id="@+id/place_autocomplete_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
</fragment>
</android.support.v7.widget.CardView>
</LinearLayout>
\ No newline at end of file
......