-
Notifications
You must be signed in to change notification settings - Fork 0
/
sitepage.java
209 lines (199 loc) · 6.77 KB
/
sitepage.java
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package tinesandbarbs.tinesandbarbs;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.CookieManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import static tinesandbarbs.tinesandbarbs.login.Email;
public class sitepage extends AppCompatActivity {
WebView site;
ProgressDialog pb;
SharedPreferences sharedPreferences;
String url="http://tinesandbarbs.com/login/index.php?page=start&keep_mobile=1",b;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sitepage);
site = (WebView) findViewById(R.id.site);
load();
}
public void load()
{
try {
if(new net(getApplicationContext()).network()) {
cookie();
site.getSettings().getJavaScriptEnabled();
site.getSettings().setLoadsImagesAutomatically(true);
site.setWebViewClient(new browser());
site.loadUrl(url);
}
}catch(Exception e)
{
start();
}
}
public void cookie()
{
CookieManager cookieManager=CookieManager.getInstance();
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP)
{
cookieManager.acceptCookie();
cookieManager.setAcceptThirdPartyCookies(site,true);
}
else
{
cookieManager.acceptCookie();
cookieManager.setAcceptCookie(true);
}
}
private class browser extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
sitepage.this.pb = new ProgressDialog(sitepage.this);
sitepage.this.pb.setMessage("Loading");
sitepage.this.pb.setIndeterminate(true);
sitepage.this.pb.show();
sitepage.this.pb.setCancelable(true);
sitepage.this.pb.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
site.stopLoading();
}
});
}
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
sitepage.this.pb.dismiss();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
sharedPreferences=getSharedPreferences(login.MyPREFERENCES, Context.MODE_PRIVATE);
if(sharedPreferences.getString(Email,"").length()==0)
{
getMenuInflater().inflate(R.menu.toolbar2,menu);
}
else
{
getMenuInflater().inflate(R.menu.toolbar3,menu);
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(sharedPreferences.getString(Email,"").length()==0)
{
switch(item.getItemId()) {
case R.id.apk:
startActivity(new Intent(this, login.class));
return (true);
}
}
else
{
switch(item.getItemId()) {
case R.id.apk:
see();
return (true);
case R.id.out:
shared();
startActivity(new Intent(this, login.class));
return (true);
case R.id.refresh:
load();
}
}
return(super.onOptionsItemSelected(item));
}
public void see()
{
Bundle extras=getIntent().getExtras();
b=extras.getString("page");
assert b!=null;
switch (b)
{
case "round":
startActivity(new Intent(this,round.class));
break;
case "round3":
startActivity(new Intent(this,round3.class));
break;
case "round2":
startActivity(new Intent(this,round2.class));
break;
case "round1":
startActivity(new Intent(this,round1.class));
break;
case "login":
startActivity(new Intent(this,login.class));
break;
case "l":
startActivity(new Intent(this,l.class));
break;
}
}
public void onBackPressed()
{
if (site.canGoBack()) {
cookie();
site.setWebViewClient(new browser());
site.goBack();
} else{
switch(login.a)
{
case 1:
startActivity(new Intent(this,login.class));
break;
case 2:
startActivity(new Intent(this,round.class));
break;
case 3:
startActivity(new Intent(this,round1.class));
break;
case 4:
startActivity(new Intent(this,round2.class));
break;
case 5:
startActivity(new Intent(this,round3.class));
break;
case 6:
startActivity(new Intent(this,notournament.class));
break;
case 7:
startActivity(new Intent(this,l.class));
break;
}
}
}
public void shared() {
SharedPreferences sharedPreferences = getSharedPreferences(login.MyPREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.clear();
editor.apply();
}
public void start()
{
Intent i=new Intent(this,network.class);
i.putExtra("from","sitepage");
i.putExtra("from1","sitepage");
startActivity(i);
}
}