-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainActivity.cs
98 lines (77 loc) · 3 KB
/
MainActivity.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
using Android.App;
using Android.OS;
using Android.Runtime;
using AndroidX.AppCompat.App;
using Android.Views;
using Android.Widget;
using Android.Content;
using static Android.Manifest;
using Android;
using NewInventoryApp.Classes;
using AlertDialog = Android.App.AlertDialog;
namespace NewInventoryApp
{
[Activity(Label = "tusik", Theme = "@style/AppTheme", MainLauncher = true)]
public class MainActivity : AppCompatActivity, View.IOnClickListener
{
Button btnNewShoe, btnConnectDb;
EditText SearchCompany, SearchSize;
readonly string[] permissionGroup =
{
Manifest.Permission.ReadExternalStorage,
Manifest.Permission.WriteExternalStorage,
Manifest.Permission.Camera
};
public void OnClick(View v)
{
if (v == SearchSize)
{
SearchSize.SetTextColor(Android.Graphics.Color.Black);
}
if (v == SearchCompany)
{
SearchCompany.SetTextColor(Android.Graphics.Color.Black);
}
if (v == btnNewShoe)
{
Intent newShowIntent = new Intent(this, typeof(Activities.NewShoeActivity));
StartActivity((newShowIntent));
}
if (v == btnConnectDb)
{
try
{
DbConnection.ConnectDb();
}
catch (System.Exception ex)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetTitle("db error");
builder.SetMessage(ex.Message);
builder.Create().Show();
}
}
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.MainScreen);
SearchSize = (EditText)FindViewById(Resource.Id.SearchSize);
SearchSize.SetOnClickListener(this);
SearchCompany = (EditText)FindViewById(Resource.Id.SearchCompany);
SearchCompany.SetOnClickListener(this);
btnNewShoe = (Button)FindViewById(Resource.Id.BtnAddShoe);
btnNewShoe.SetOnClickListener(this);
btnConnectDb = (Button)FindViewById(Resource.Id.BtnConnectDb);
btnConnectDb.SetOnClickListener(this);
RequestPermissions(permissionGroup, 0);
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}