-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain2Activity.java
More file actions
69 lines (61 loc) · 2.76 KB
/
Main2Activity.java
File metadata and controls
69 lines (61 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.example.mygame;
import androidx.annotation.NonNull;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
public class Main2Activity extends Activity implements View.OnClickListener {
private Button goGame, highscore;
Member m;
DatabaseReference reference1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main2);
goGame = findViewById(R.id.gogame);
goGame.setOnClickListener(this);
highscore = findViewById(R.id.highscore);
highscore.setOnClickListener(this);
Long highscore = Long.valueOf(0);
highscore = getIntent().getLongExtra("Highscore", highscore);
m = new Member(getIntent().getStringExtra("Name"), getIntent().getStringExtra("Password"), highscore);
reference1 = FirebaseDatabase.getInstance().getReference().child("Highscores");
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.highscore:
final Intent i1 = new Intent(this, Highscore.class);
DatabaseReference reff = FirebaseDatabase.getInstance().getReference().child("MEMBER").child(m.getName());
reff.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Long Hig = (Long) dataSnapshot.child("highscore").getValue();
i1.putExtra("Highscores", Hig);
startActivity(i1);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
break;
case R.id.gogame:
Intent i = new Intent(this, Activity1.class);
i.putExtra("Name", m.getName());
i.putExtra("Password", m.getPassword());
i.putExtra("Highscore", m.getHighscore());
startActivity(i);
break;
}
}
}