Toggle navigation
Toggle navigation
This project
Loading...
Sign in
손장민
/
FirebaseAuth
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
손장민
2017-10-19 21:17:42 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3725667462ca8c7e535e8942c34f1a0967cf39f8
37256674
1 parent
12835403
Move to Community After Writepost, Length limit Titles, Desc
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
24 deletions
app/src/main/AndroidManifest.xml
app/src/main/java/com/example/user/firebaseauthdemo/Community.java
app/src/main/java/com/example/user/firebaseauthdemo/Main2Activity.java
app/src/main/java/com/example/user/firebaseauthdemo/PostActivity.java
app/src/main/res/helplist.png
app/src/main/res/layout/activity_main2.xml
app/src/main/res/layout/community.xml
app/src/main/res/menu/main2.xml
app/src/main/AndroidManifest.xml
View file @
3725667
...
...
@@ -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
...
...
app/src/main/java/com/example/user/firebaseauthdemo/Community.java
View file @
3725667
...
...
@@ -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
);
...
...
app/src/main/java/com/example/user/firebaseauthdemo/Main2Activity.java
View file @
3725667
...
...
@@ -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
);
...
...
app/src/main/java/com/example/user/firebaseauthdemo/PostActivity.java
View file @
3725667
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
...
...
app/src/main/res/helplist.png
0 → 100644
View file @
3725667
6.59 KB
app/src/main/res/layout/activity_main2.xml
View file @
3725667
...
...
@@ -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>
...
...
app/src/main/res/layout/community.xml
View file @
3725667
...
...
@@ -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
...
...
app/src/main/res/menu/main2.xml
View file @
3725667
<?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>
...
...
Please
register
or
login
to post a comment