손장민

Move to Community After Writepost, Length limit Titles, Desc

......@@ -24,7 +24,6 @@
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
......@@ -35,22 +34,10 @@
android:label="@string/title_activity_main2"
android:theme="@style/AppTheme.NoActionBar"/>
<activity android:name=".PostActivity"/>
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key"/>
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
</activity>
</application>
</manifest>
\ No newline at end of file
......
......@@ -74,18 +74,31 @@ public class Community extends Fragment {
public BlogViewHolder(View itemView) {
super(itemView);
mView = itemView;
}
public void setTitle(String title){
TextView post_title = (TextView) mView.findViewById(R.id.post_title);
if(title.length()>30)
{
post_title.setText(title.substring(0,30));
}
else
{
post_title.setText(title);
}
}
public void setDesc(String desc){
TextView post_desc = (TextView) mView.findViewById(R.id.post_desc);
if(desc.length()>50)
{
post_desc.setText(desc.substring(0,50));
}
else
{
post_desc.setText(desc);
}
}
public void setImage(Context ctx, String image){
ImageView post_image = (ImageView) mView.findViewById(R.id.post_image);
......
......@@ -24,7 +24,6 @@ public class Main2Activity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
......
package com.example.user.firebaseauthdemo;
import android.Manifest;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
......@@ -91,13 +94,28 @@ public class PostActivity extends AppCompatActivity {
final String title_val = mPostTitle.getText().toString().trim();
final String desc_val = mPostDesc.getText().toString().trim();
if(!TextUtils.isEmpty(title_val) && !TextUtils.isEmpty(desc_val) && mImageUri != null) {
if(!TextUtils.isEmpty(title_val) && !TextUtils.isEmpty(desc_val) /*&& mImageUri != null*/)
{
mProgress.show();
if(mImageUri==null)
{
DatabaseReference newPost = mDatabase.push();
newPost.child("title").setValue(title_val);
newPost.child("desc").setValue(desc_val);
newPost.child("uid").setValue(mCurrentUser.getUid());
mProgress.dismiss();
}
else
{
StorageReference filepath = mStorage.child("Blog_Images").child(mImageUri.getLastPathSegment());
filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>()
{
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot)
{
Uri downloadUrl = taskSnapshot.getDownloadUrl();
DatabaseReference newPost = mDatabase.push();
......@@ -108,11 +126,17 @@ public class PostActivity extends AppCompatActivity {
mProgress.dismiss();
startActivity(new Intent(PostActivity.this, Main2Activity.class));
Toast.makeText(PostActivity.this, "Success!", Toast.LENGTH_LONG).show();
//startActivity(new Intent(PostActivity.this, Main2Activity.class));
}
});
}
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();
}
}
@Override
......
......@@ -8,10 +8,27 @@
android:fitsSystemWindows="true"
tools:openDrawer="start">
<FrameLayout
android:id="@+id/fl_activity_main_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
</FrameLayout>
<include
layout="@layout/app_bar_main2"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
......@@ -20,6 +37,8 @@
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main2"
app:menu="@menu/activity_main2_drawer" />
app:menu="@menu/activity_main2_drawer"/>
</android.support.v4.widget.DrawerLayout>
......
......@@ -7,6 +7,7 @@
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/blog_list"></android.support.v7.widget.RecyclerView>
android:id="@+id/blog_list"></android.support.v7.widget.RecyclerView
>
</LinearLayout>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
</menu>
......