-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathHomePage.java
More file actions
149 lines (129 loc) · 4.8 KB
/
HomePage.java
File metadata and controls
149 lines (129 loc) · 4.8 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.something.chandra.tictactoe;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
public class HomePage extends AppCompatActivity {
Button play,exit,how,about;
InterstitialAd mInterstitialAd;
/* private void initializeCalldorado() {
Calldorado.startCalldorado(this);
}*/
private void showInterstitial() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mInterstitialAd = new InterstitialAd(this);
// set the ad unit ID
mInterstitialAd.setAdUnitId("ca-app-pub-7158819369536945/6997398913");
AdRequest adRequest1 = new AdRequest.Builder()
.build();
// Load ads into Interstitial Ads
mInterstitialAd.loadAd(adRequest1);
mInterstitialAd.setAdListener(new AdListener() {
public void onAdLoaded() {
showInterstitial();
}
});
// initializeCalldorado();
setContentView(R.layout.activity_home_page);
play=(Button)findViewById(R.id.b1);
exit=(Button)findViewById(R.id.b3);
how=(Button)findViewById(R.id.b2);
about=(Button)findViewById(R.id.b4);
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent info =new Intent(HomePage.this,MainActivity.class);
startActivity(info);
}
});
exit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder b= new AlertDialog.Builder(HomePage.this);
b.setTitle("EXIT");
b.setMessage("Do you want to Exit");
b.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finishAffinity();
}
});
b.setNegativeButton("No",null);
b.setCancelable(false);
AlertDialog db = b.create();
db.show();
}
});
how.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent info =new Intent(HomePage.this,HowToPlay.class);
startActivity(info);
}
});
about.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent info =new Intent(HomePage.this,AboutUs.class);
startActivity(info);
}
});
}
public boolean onCreateOptionsMenu(Menu menu) { //for on Screen Menu...
MenuInflater mi = getMenuInflater();
mi.inflate(R.menu.mymenuoption,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {//for menu options...
int mid = item.getItemId();
if(mid==R.id.home)
{
Intent info = new Intent(this,HomePage.class);
startActivity(info);
// finish();
}
if(mid == R.id.about){
Intent info = new Intent(this,AboutUs.class);
startActivity(info);
// finish();
}
if(mid == R.id.help){
Intent info = new Intent(this,HowToPlay.class);
startActivity(info);
// finish();
}
if (mid == R.id.exit)
{
AlertDialog.Builder b= new AlertDialog.Builder(HomePage.this);
b.setTitle("EXIT");
b.setMessage("Do you want to Exit");
b.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finishAffinity();
}
});
b.setNegativeButton("No",null);
b.setCancelable(false);
AlertDialog db = b.create();
db.show();
}
return super.onOptionsItemSelected(item);
}
}