Showing
8 changed files
with
66 additions
and
24 deletions
... | @@ -24,7 +24,6 @@ | ... | @@ -24,7 +24,6 @@ |
24 | <activity android:name=".MainActivity"> | 24 | <activity android:name=".MainActivity"> |
25 | <intent-filter> | 25 | <intent-filter> |
26 | <action android:name="android.intent.action.MAIN"/> | 26 | <action android:name="android.intent.action.MAIN"/> |
27 | - | ||
28 | <category android:name="android.intent.category.LAUNCHER"/> | 27 | <category android:name="android.intent.category.LAUNCHER"/> |
29 | </intent-filter> | 28 | </intent-filter> |
30 | </activity> | 29 | </activity> |
... | @@ -35,22 +34,10 @@ | ... | @@ -35,22 +34,10 @@ |
35 | android:label="@string/title_activity_main2" | 34 | android:label="@string/title_activity_main2" |
36 | android:theme="@style/AppTheme.NoActionBar"/> | 35 | android:theme="@style/AppTheme.NoActionBar"/> |
37 | <activity android:name=".PostActivity"/> | 36 | <activity android:name=".PostActivity"/> |
38 | - <!-- | ||
39 | - The API key for Google Maps-based APIs is defined as a string resource. | ||
40 | - (See the file "res/values/google_maps_api.xml"). | ||
41 | - Note that the API key is linked to the encryption key used to sign the APK. | ||
42 | - You need a different API key for each encryption key, including the release key that is used to | ||
43 | - sign the APK for publishing. | ||
44 | - You can define the keys for the debug and release targets in src/debug/ and src/release/. | ||
45 | - --> | ||
46 | <meta-data | 37 | <meta-data |
47 | android:name="com.google.android.geo.API_KEY" | 38 | android:name="com.google.android.geo.API_KEY" |
48 | android:value="@string/google_maps_key"/> | 39 | android:value="@string/google_maps_key"/> |
49 | 40 | ||
50 | - <activity | ||
51 | - android:name=".MapsActivity" | ||
52 | - android:label="@string/title_activity_maps"> | ||
53 | - </activity> | ||
54 | </application> | 41 | </application> |
55 | 42 | ||
56 | </manifest> | 43 | </manifest> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -74,18 +74,31 @@ public class Community extends Fragment { | ... | @@ -74,18 +74,31 @@ public class Community extends Fragment { |
74 | 74 | ||
75 | public BlogViewHolder(View itemView) { | 75 | public BlogViewHolder(View itemView) { |
76 | super(itemView); | 76 | super(itemView); |
77 | - | ||
78 | mView = itemView; | 77 | mView = itemView; |
79 | } | 78 | } |
80 | public void setTitle(String title){ | 79 | public void setTitle(String title){ |
81 | TextView post_title = (TextView) mView.findViewById(R.id.post_title); | 80 | TextView post_title = (TextView) mView.findViewById(R.id.post_title); |
81 | + if(title.length()>30) | ||
82 | + { | ||
83 | + post_title.setText(title.substring(0,30)); | ||
84 | + } | ||
85 | + else | ||
86 | + { | ||
82 | post_title.setText(title); | 87 | post_title.setText(title); |
83 | } | 88 | } |
89 | + } | ||
84 | 90 | ||
85 | public void setDesc(String desc){ | 91 | public void setDesc(String desc){ |
86 | TextView post_desc = (TextView) mView.findViewById(R.id.post_desc); | 92 | TextView post_desc = (TextView) mView.findViewById(R.id.post_desc); |
93 | + if(desc.length()>50) | ||
94 | + { | ||
95 | + post_desc.setText(desc.substring(0,50)); | ||
96 | + } | ||
97 | + else | ||
98 | + { | ||
87 | post_desc.setText(desc); | 99 | post_desc.setText(desc); |
88 | } | 100 | } |
101 | + } | ||
89 | 102 | ||
90 | public void setImage(Context ctx, String image){ | 103 | public void setImage(Context ctx, String image){ |
91 | ImageView post_image = (ImageView) mView.findViewById(R.id.post_image); | 104 | ImageView post_image = (ImageView) mView.findViewById(R.id.post_image); | ... | ... |
... | @@ -24,7 +24,6 @@ public class Main2Activity extends AppCompatActivity | ... | @@ -24,7 +24,6 @@ public class Main2Activity extends AppCompatActivity |
24 | 24 | ||
25 | @Override | 25 | @Override |
26 | protected void onCreate(Bundle savedInstanceState) { | 26 | protected void onCreate(Bundle savedInstanceState) { |
27 | - | ||
28 | super.onCreate(savedInstanceState); | 27 | super.onCreate(savedInstanceState); |
29 | setContentView(R.layout.activity_main2); | 28 | setContentView(R.layout.activity_main2); |
30 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | 29 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ... | ... |
1 | package com.example.user.firebaseauthdemo; | 1 | package com.example.user.firebaseauthdemo; |
2 | 2 | ||
3 | import android.Manifest; | 3 | import android.Manifest; |
4 | +import android.app.Fragment; | ||
5 | +import android.app.FragmentManager; | ||
4 | import android.app.ProgressDialog; | 6 | import android.app.ProgressDialog; |
5 | import android.content.Intent; | 7 | import android.content.Intent; |
6 | import android.net.Uri; | 8 | import android.net.Uri; |
7 | import android.os.Bundle; | 9 | import android.os.Bundle; |
8 | import android.support.v4.app.ActivityCompat; | 10 | import android.support.v4.app.ActivityCompat; |
11 | +import android.support.v4.app.FragmentTransaction; | ||
9 | import android.support.v7.app.AppCompatActivity; | 12 | import android.support.v7.app.AppCompatActivity; |
10 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
11 | import android.view.View; | 14 | import android.view.View; |
... | @@ -91,13 +94,28 @@ public class PostActivity extends AppCompatActivity { | ... | @@ -91,13 +94,28 @@ public class PostActivity extends AppCompatActivity { |
91 | final String title_val = mPostTitle.getText().toString().trim(); | 94 | final String title_val = mPostTitle.getText().toString().trim(); |
92 | final String desc_val = mPostDesc.getText().toString().trim(); | 95 | final String desc_val = mPostDesc.getText().toString().trim(); |
93 | 96 | ||
94 | - if(!TextUtils.isEmpty(title_val) && !TextUtils.isEmpty(desc_val) && mImageUri != null) { | 97 | + if(!TextUtils.isEmpty(title_val) && !TextUtils.isEmpty(desc_val) /*&& mImageUri != null*/) |
98 | + { | ||
95 | mProgress.show(); | 99 | mProgress.show(); |
96 | 100 | ||
101 | + if(mImageUri==null) | ||
102 | + { | ||
103 | + | ||
104 | + DatabaseReference newPost = mDatabase.push(); | ||
105 | + newPost.child("title").setValue(title_val); | ||
106 | + newPost.child("desc").setValue(desc_val); | ||
107 | + newPost.child("uid").setValue(mCurrentUser.getUid()); | ||
108 | + | ||
109 | + mProgress.dismiss(); | ||
110 | + } | ||
111 | + else | ||
112 | + { | ||
97 | StorageReference filepath = mStorage.child("Blog_Images").child(mImageUri.getLastPathSegment()); | 113 | StorageReference filepath = mStorage.child("Blog_Images").child(mImageUri.getLastPathSegment()); |
98 | - filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { | 114 | + filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() |
115 | + { | ||
99 | @Override | 116 | @Override |
100 | - public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { | 117 | + public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) |
118 | + { | ||
101 | Uri downloadUrl = taskSnapshot.getDownloadUrl(); | 119 | Uri downloadUrl = taskSnapshot.getDownloadUrl(); |
102 | 120 | ||
103 | DatabaseReference newPost = mDatabase.push(); | 121 | DatabaseReference newPost = mDatabase.push(); |
... | @@ -108,11 +126,17 @@ public class PostActivity extends AppCompatActivity { | ... | @@ -108,11 +126,17 @@ public class PostActivity extends AppCompatActivity { |
108 | 126 | ||
109 | mProgress.dismiss(); | 127 | mProgress.dismiss(); |
110 | 128 | ||
111 | - startActivity(new Intent(PostActivity.this, Main2Activity.class)); | 129 | + //startActivity(new Intent(PostActivity.this, Main2Activity.class)); |
112 | - Toast.makeText(PostActivity.this, "Success!", Toast.LENGTH_LONG).show(); | ||
113 | } | 130 | } |
114 | }); | 131 | }); |
115 | } | 132 | } |
133 | + android.support.v4.app.FragmentManager fm = getSupportFragmentManager(); | ||
134 | + android.support.v4.app.FragmentTransaction ft = fm.beginTransaction(); | ||
135 | + | ||
136 | + finish(); | ||
137 | + Toast.makeText(PostActivity.this, "Success!", Toast.LENGTH_LONG).show(); | ||
138 | + | ||
139 | + } | ||
116 | } | 140 | } |
117 | 141 | ||
118 | @Override | 142 | @Override | ... | ... |
app/src/main/res/helplist.png
0 → 100644

6.59 KB
... | @@ -8,10 +8,27 @@ | ... | @@ -8,10 +8,27 @@ |
8 | android:fitsSystemWindows="true" | 8 | android:fitsSystemWindows="true" |
9 | tools:openDrawer="start"> | 9 | tools:openDrawer="start"> |
10 | 10 | ||
11 | + | ||
12 | + <FrameLayout | ||
13 | + android:id="@+id/fl_activity_main_container" | ||
14 | + android:layout_width="match_parent" | ||
15 | + android:layout_height="match_parent"> | ||
16 | + | ||
17 | + <EditText | ||
18 | + android:id="@+id/editText2" | ||
19 | + android:layout_width="wrap_content" | ||
20 | + android:layout_height="wrap_content" | ||
21 | + android:ems="10" | ||
22 | + android:inputType="textPersonName" | ||
23 | + android:text="Name"/> | ||
24 | + | ||
25 | + </FrameLayout> | ||
26 | + | ||
11 | <include | 27 | <include |
12 | layout="@layout/app_bar_main2" | 28 | layout="@layout/app_bar_main2" |
13 | android:layout_width="match_parent" | 29 | android:layout_width="match_parent" |
14 | - android:layout_height="match_parent" /> | 30 | + android:layout_height="match_parent" |
31 | + /> | ||
15 | 32 | ||
16 | <android.support.design.widget.NavigationView | 33 | <android.support.design.widget.NavigationView |
17 | android:id="@+id/nav_view" | 34 | android:id="@+id/nav_view" |
... | @@ -20,6 +37,8 @@ | ... | @@ -20,6 +37,8 @@ |
20 | android:layout_gravity="start" | 37 | android:layout_gravity="start" |
21 | android:fitsSystemWindows="true" | 38 | android:fitsSystemWindows="true" |
22 | app:headerLayout="@layout/nav_header_main2" | 39 | app:headerLayout="@layout/nav_header_main2" |
23 | - app:menu="@menu/activity_main2_drawer" /> | 40 | + app:menu="@menu/activity_main2_drawer"/> |
41 | + | ||
42 | + | ||
24 | 43 | ||
25 | </android.support.v4.widget.DrawerLayout> | 44 | </android.support.v4.widget.DrawerLayout> | ... | ... |
... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
7 | <android.support.v7.widget.RecyclerView | 7 | <android.support.v7.widget.RecyclerView |
8 | android:layout_width="match_parent" | 8 | android:layout_width="match_parent" |
9 | android:layout_height="match_parent" | 9 | android:layout_height="match_parent" |
10 | - android:id="@+id/blog_list"></android.support.v7.widget.RecyclerView> | 10 | + android:id="@+id/blog_list"></android.support.v7.widget.RecyclerView |
11 | + > | ||
11 | 12 | ||
12 | </LinearLayout> | 13 | </LinearLayout> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <menu xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <menu xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:app="http://schemas.android.com/apk/res-auto"> | 3 | xmlns:app="http://schemas.android.com/apk/res-auto"> |
4 | - | ||
5 | </menu> | 4 | </menu> | ... | ... |
-
Please register or login to post a comment