-
Notifications
You must be signed in to change notification settings - Fork 0
/
BankVideoFragment.cs
129 lines (90 loc) · 3.62 KB
/
BankVideoFragment.cs
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
using Android.OS;
using Android.Views;
using Android.Support.V4.App;
using Android.Webkit;
using Android.Content;
using System;
using ImageSlider.MyTest;
namespace ImageSlider.Fragments
{
public class BankVideoFragment : Fragment
{
string you_tubebank;
WebView mWebView;
CustomProgressDialog cpd;
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
ISharedPreferences pref = Android.App.Application.Context.GetSharedPreferences("MyYouTubeBANK", FileCreationMode.Private);
you_tubebank = pref.GetString("YOUTUBEBANK", String.Empty);
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.Inflate(Resource.Layout.BankVideoLayout, container, false);
mWebView = v.FindViewById<WebView>(Resource.Id.youtubebank);
if (you_tubebank.Length <= 0)
{
getMyYouTubebank();
}
else
{
mWebView.Settings.JavaScriptEnabled = true;
mWebView.SetWebViewClient(new MyWebViewClientbankvideo(Activity));
mWebView.LoadUrl("https://myshop.mahendras.org/Display/DisplayItem?icd=299");
}
return v;
}
public void getMyYouTubebank()
{
try
{
mWebView.Settings.JavaScriptEnabled = true;
mWebView.SetWebViewClient(new MyWebViewClientbankvideo(Activity));
mWebView.LoadUrl("https://myshop.mahendras.org/Display/DisplayItem?icd=299");
if (you_tubebank.Length <= 0)
{
ISharedPreferences pref = Android.App.Application.Context.GetSharedPreferences("MyYouTubeBANK", FileCreationMode.Private);
ISharedPreferencesEditor edit = pref.Edit();
edit.PutString("YOUTUBEBANK", "https://myshop.mahendras.org/Display/DisplayItem?icd=299");
edit.Apply();
}
Intent intent = new Intent(Activity, typeof(BankVideoFragment));
Activity.StartActivity(intent);
}
catch
{
}
}
}
public class MyWebViewClientbankvideo : WebViewClient
{
Android.App.Activity ac;
CustomProgressDialog cpd;
public MyWebViewClientbankvideo(Android.App.Activity ac)
{
this.ac = ac;
cpd = new CustomProgressDialog(ac);
cpd.Show();
}
public override bool ShouldOverrideUrlLoading(WebView view, string url)
{
view.LoadUrl(url);
return true;
}
public override void OnPageStarted(WebView view, string url, Android.Graphics.Bitmap favicon)
{
base.OnPageStarted(view, url, favicon);
cpd.DismissDialog();
}
public override void OnPageFinished(WebView view, string url)
{
base.OnPageFinished(view, url);
cpd.DismissDialog();
}
public override void OnReceivedError(WebView view, ClientError errorCode, string description, string failingUrl)
{
base.OnReceivedError(view, errorCode, description, failingUrl);
cpd.DismissDialog();
}
}
}