Skip to content

Commit 6dda5b6

Browse files
committed
ch
1 parent 1c26ccf commit 6dda5b6

30 files changed

+321
-61
lines changed

app/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,19 @@ dependencies {
2929
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
3030
implementation 'com.google.firebase:firebase-auth:20.0.1'
3131
implementation 'com.google.android.gms:play-services-maps:17.0.0'
32-
testImplementation 'junit:junit:4.12'
32+
implementation 'com.google.firebase:firebase-database:19.5.1'
33+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
34+
testImplementation 'junit:junit:4.13.1'
3335
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
3436
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
3537
implementation 'com.google.android.gms:play-services-auth:19.0.0'
3638
implementation 'com.google.maps.android:android-maps-utils:2.2.0'
3739

40+
implementation 'com.github.bumptech.glide:glide:4.11.0'
41+
implementation 'com.firebaseui:firebase-ui-database:6.3.0'
42+
43+
implementation 'androidx.cardview:cardview:1.0.0'
44+
implementation 'androidx.recyclerview:recyclerview:1.1.0'
3845

3946
}
4047
configurations.all {

app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
<meta-data android:name="com.google.android.geo.API_KEY"
1919
android:value="@string/map_key"/>
2020

21-
<activity android:name=".BaseActivity"></activity>
21+
<activity android:name=".BaseActivity">
22+
<intent-filter>
23+
<action android:name="Firebase01.BaseActivity" />
24+
25+
<category android:name="android.intent.category.DEFAULT" />
26+
</intent-filter>
27+
</activity>
28+
2229
<activity android:name=".MapActivity"></activity>
2330
<activity android:name=".WebActivity"></activity>
2431

app/src/main/img1-playstore.png

53.5 KB
Loading

app/src/main/java/com/example/firebase01/BaseActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.example.firebase01;
22

33
import android.os.Bundle;
4+
import android.view.WindowManager;
45

56
import androidx.appcompat.app.AppCompatActivity;
67

@@ -10,5 +11,8 @@ public class BaseActivity extends AppCompatActivity {
1011
protected void onCreate(Bundle savedInstanceState) {
1112
super.onCreate(savedInstanceState);
1213
setContentView(R.layout.activity_base);
14+
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
15+
16+
getSupportFragmentManager().beginTransaction().replace(R.id.wrapper, new recfragment()).commit();
1317
}
1418
}

app/src/main/java/com/example/firebase01/GoogleSignInActivity.java

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.os.Bundle;
66
import android.util.Log;
77
import android.view.View;
8+
import android.view.WindowManager;
89
import android.widget.Button;
910
import android.widget.TextView;
1011
import android.widget.Toast;
@@ -26,27 +27,14 @@
2627
import com.google.firebase.auth.FirebaseUser;
2728
import com.google.firebase.auth.GoogleAuthProvider;
2829

29-
30-
/*import com.google.android.material.snackbar.Snackbar;
31-
import com.google.firebase.quickstart.auth.R;
32-
import com.google.firebase.quickstart.auth.databinding.ActivityGoogleBinding;*/
33-
34-
35-
36-
37-
38-
/**
39-
* Demonstrate Firebase Authentication using a Google ID Token.
40-
*/
4130
public class GoogleSignInActivity extends AppCompatActivity implements
4231
View.OnClickListener {
4332

4433
private static final String TAG = "GoogleActivity";
4534
private static final int RC_SIGN_IN = 9001;
4635

47-
// [START declare_auth]
4836
private FirebaseAuth mAuth;
49-
// [END declare_auth]
37+
5038

5139
private GoogleSignInClient mGoogleSignInClient;
5240
private TextView mStatusTextView;
@@ -68,6 +56,11 @@ protected void onCreate(Bundle savedInstanceState) {
6856

6957
setContentView(R.layout.activity_google_sign_in);
7058

59+
60+
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
61+
62+
getSupportFragmentManager().beginTransaction().replace(R.id.wrapper,new recfragment()).commit();
63+
7164
mStatusTextView = (TextView) findViewById(R.id.status);
7265
mDetailTextView = (TextView) findViewById(R.id.detail);
7366

@@ -107,69 +100,50 @@ public void onClick(View v) {
107100
});
108101

109102

110-
/*mBinding = ActivityGoogleBinding.inflate(getLayoutInflater());
111-
setContentView(mBinding.getRoot());
112-
setProgressBar(mBinding.progressBar); */
113103

114-
// Button listeners
115104
findViewById(R.id.signInButton).setOnClickListener(this);
116105
findViewById(R.id.signOutButton).setOnClickListener(this);
117106
findViewById(R.id.disconnectButton).setOnClickListener(this);
118107

119-
// [START config_signin]
120-
// Configure Google Sign In
108+
121109
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
122110
.requestIdToken(getString(R.string.default_web_client_id))
123111
.requestEmail()
124112
.build();
125-
// [END config_signin]
126113

127114
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
128115

129-
// [START initialize_auth]
130-
// Initialize Firebase Auth
131116
mAuth = FirebaseAuth.getInstance();
132-
// [END initialize_auth]
133117
}
134118

135-
// [START on_start_check_user]
136119
@Override
137120
public void onStart() {
138121
super.onStart();
139-
// Check if user is signed in (non-null) and update UI accordingly.
140122
FirebaseUser currentUser = mAuth.getCurrentUser();
141123
updateUI(currentUser);
142124
}
143-
// [END on_start_check_user]
144125

145-
// [START onactivityresult]
146126
@Override
147127
public void onActivityResult(int requestCode, int resultCode, Intent data) {
148128
super.onActivityResult(requestCode, resultCode, data);
149129

150-
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
151130
if (requestCode == RC_SIGN_IN) {
152131
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
153132
try {
154-
// Google Sign In was successful, authenticate with Firebase
155133
GoogleSignInAccount account = task.getResult(ApiException.class);
156134
Log.d(TAG, "firebaseAuthWithGoogle:" + account.getId());
157135
firebaseAuthWithGoogle(account.getIdToken());
158136
} catch (ApiException e) {
159-
// Google Sign In failed, update UI appropriately
137+
160138
Log.w(TAG, "Google sign in failed", e);
161-
// [START_EXCLUDE]
139+
162140
updateUI(null);
163-
// [END_EXCLUDE]
141+
164142
}
165143
}
166144
}
167-
// [END onactivityresult]
168145

169-
// [START auth_with_google]
170146
private void firebaseAuthWithGoogle(String idToken) {
171-
// [START_EXCLUDE silent];
172-
// [END_EXCLUDE]
173147
AuthCredential credential = GoogleAuthProvider.getCredential(idToken, null);
174148
mAuth.signInWithCredential(credential)
175149
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@@ -187,25 +161,18 @@ public void onComplete(@NonNull Task<AuthResult> task) {
187161
updateUI(null);
188162
}
189163

190-
// [START_EXCLUDE]
191-
// [END_EXCLUDE]
192164
}
193165
});
194166
}
195-
// [END auth_with_google]
196167

197-
// [START signin]
198168
private void signIn() {
199169
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
200170
startActivityForResult(signInIntent, RC_SIGN_IN);
201171
}
202-
// [END signin]
203172

204173
private void signOut() {
205-
// Firebase sign out
206174
mAuth.signOut();
207175

208-
// Google sign out
209176
mGoogleSignInClient.signOut().addOnCompleteListener(this,
210177
new OnCompleteListener<Void>() {
211178
@Override
@@ -216,7 +183,6 @@ public void onComplete(@NonNull Task<Void> task) {
216183
}
217184

218185
private void revokeAccess() {
219-
// Firebase sign out
220186
mAuth.signOut();
221187

222188
// Google revoke access
@@ -252,6 +218,11 @@ private void updateUI(FirebaseUser user) {
252218
}
253219
}
254220

221+
private void button6Click(){
222+
startActivity(new Intent("Firebase01.BaseActivity"));
223+
224+
}
225+
255226
@Override
256227
public void onClick(View v) {
257228
int i = v.getId();
@@ -262,6 +233,12 @@ public void onClick(View v) {
262233
} else if (i == R.id.disconnectButton) {
263234
revokeAccess();
264235
}
236+
switch (v.getId()){
237+
case R.id.button6:
238+
button6Click();
239+
break;
240+
}
241+
265242
}
266243

267244

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.example.firebase01;
2+
3+
public class model {
4+
5+
String course,email,name,purl;
6+
7+
public model() {
8+
9+
}
10+
11+
public model(String course, String email, String name, String purl) {
12+
this.course = course;
13+
this.email = email;
14+
this.name = name;
15+
this.purl = purl;
16+
}
17+
18+
public String getCourse() {
19+
return course;
20+
}
21+
22+
public void setCourse(String course) {
23+
this.course = course;
24+
}
25+
26+
public String getEmail() {
27+
return email;
28+
}
29+
30+
public void setEmail(String email) {
31+
this.email = email;
32+
}
33+
34+
public String getName() {
35+
return name;
36+
}
37+
38+
public void setName(String name) {
39+
this.name = name;
40+
}
41+
42+
public String getPurl() {
43+
return purl;
44+
}
45+
46+
public void setPurl(String purl) {
47+
this.purl = purl;
48+
}
49+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.example.firebase01;
2+
3+
import android.view.LayoutInflater;
4+
import android.view.View;
5+
import android.view.ViewGroup;
6+
import android.widget.ImageView;
7+
import android.widget.TextView;
8+
9+
import androidx.annotation.NonNull;
10+
import androidx.recyclerview.widget.RecyclerView;
11+
12+
import com.bumptech.glide.Glide;
13+
import com.firebase.ui.database.FirebaseRecyclerAdapter;
14+
import com.firebase.ui.database.FirebaseRecyclerOptions;
15+
16+
public class myadapter extends FirebaseRecyclerAdapter<model,myadapter.myviewholder> {
17+
18+
19+
public myadapter(@NonNull FirebaseRecyclerOptions<model> options) {
20+
super(options);
21+
}
22+
23+
@Override
24+
protected void onBindViewHolder(@NonNull myviewholder holder, int position, @NonNull model model) {
25+
holder.nametext.setText(model.getName());
26+
holder.coursetext.setText(model.getCourse());
27+
holder.emailtext.setText(model.getEmail());
28+
Glide.with(holder.img1.getContext()).load(model.getPurl()).into(holder.img1);
29+
30+
31+
}
32+
33+
@NonNull
34+
@Override
35+
public myviewholder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
36+
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.singlerowdesign,parent,false);
37+
return new myviewholder(view);
38+
}
39+
40+
public class myviewholder extends RecyclerView.ViewHolder {
41+
42+
ImageView img1;
43+
TextView nametext,coursetext,emailtext;
44+
45+
public myviewholder(@NonNull View itemView) {
46+
super(itemView);
47+
48+
img1=itemView.findViewById(R.id.img1);
49+
nametext=itemView.findViewById(R.id.nametext);
50+
coursetext=itemView.findViewById(R.id.coursetext);
51+
emailtext=itemView.findViewById(R.id.emailtext);
52+
53+
54+
}
55+
}
56+
57+
}

0 commit comments

Comments
 (0)