Skip to content

Commit 43b5a3b

Browse files
committed
fix whitespace
1 parent 38c4c6b commit 43b5a3b

10 files changed

+5150
-3471
lines changed

AndroidXamarinChat/ChatActionBarDrawerToggle.cs

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,55 @@
77

88
namespace AndroidXamarinChat
99
{
10-
public class ChatActionBarDrawerToggle : ActionBarDrawerToggle
11-
{
12-
private AppCompatActivity mHostActivity;
13-
private readonly DrawerLayout drawerLayout;
14-
private int mOpenedResource;
15-
private int mClosedResource;
16-
17-
private bool rightIsClosed = true;
18-
private bool leftIsClosed = true;
19-
20-
public ChatActionBarDrawerToggle (AppCompatActivity host,
21-
DrawerLayout drawerLayout,
22-
Android.Support.V7.Widget.Toolbar toolbar,
23-
int openedResource,
24-
int closedResource)
25-
: base(host, drawerLayout,toolbar,openedResource,closedResource)
26-
{
27-
mHostActivity = host;
28-
this.drawerLayout = drawerLayout;
29-
mOpenedResource = openedResource;
30-
mClosedResource = closedResource;
10+
public class ChatActionBarDrawerToggle : ActionBarDrawerToggle
11+
{
12+
private AppCompatActivity mHostActivity;
13+
private readonly DrawerLayout drawerLayout;
14+
private int mOpenedResource;
15+
private int mClosedResource;
16+
17+
private bool rightIsClosed = true;
18+
private bool leftIsClosed = true;
19+
20+
public ChatActionBarDrawerToggle(AppCompatActivity host,
21+
DrawerLayout drawerLayout,
22+
Android.Support.V7.Widget.Toolbar toolbar,
23+
int openedResource,
24+
int closedResource)
25+
: base(host, drawerLayout, toolbar, openedResource, closedResource)
26+
{
27+
mHostActivity = host;
28+
this.drawerLayout = drawerLayout;
29+
mOpenedResource = openedResource;
30+
mClosedResource = closedResource;
3131
}
3232

33-
public override void OnDrawerOpened (View drawerView)
34-
{
35-
int drawerType = (int)drawerView.Tag;
33+
public override void OnDrawerOpened(View drawerView)
34+
{
35+
int drawerType = (int)drawerView.Tag;
3636

3737
if (drawerType == 0)
38-
{
39-
base.OnDrawerOpened (drawerView);
40-
mHostActivity.SupportActionBar.SetTitle(mOpenedResource);
41-
}
38+
{
39+
base.OnDrawerOpened(drawerView);
40+
mHostActivity.SupportActionBar.SetTitle(mOpenedResource);
41+
}
4242

43-
if (drawerView.Id == Resource.Id.nav_view)
44-
leftIsClosed = false;
43+
if (drawerView.Id == Resource.Id.nav_view)
44+
leftIsClosed = false;
4545

46-
if (drawerView.Id == Resource.Id.right_drawer)
47-
rightIsClosed = false;
48-
}
46+
if (drawerView.Id == Resource.Id.right_drawer)
47+
rightIsClosed = false;
48+
}
4949

50-
public override void OnDrawerClosed (View drawerView)
51-
{
52-
int drawerType = (int)drawerView.Tag;
50+
public override void OnDrawerClosed(View drawerView)
51+
{
52+
int drawerType = (int)drawerView.Tag;
5353

54-
if (drawerType == 0)
55-
{
56-
base.OnDrawerClosed (drawerView);
57-
mHostActivity.SupportActionBar.SetTitle(mClosedResource);
58-
}
54+
if (drawerType == 0)
55+
{
56+
base.OnDrawerClosed(drawerView);
57+
mHostActivity.SupportActionBar.SetTitle(mClosedResource);
58+
}
5959

6060
if (drawerView.Id == Resource.Id.nav_view)
6161
leftIsClosed = true;
@@ -64,9 +64,9 @@ public override void OnDrawerClosed (View drawerView)
6464
rightIsClosed = true;
6565
}
6666

67-
public override void OnDrawerSlide (View drawerView, float slideOffset)
68-
{
69-
int drawerType = (int)drawerView.Tag;
67+
public override void OnDrawerSlide(View drawerView, float slideOffset)
68+
{
69+
int drawerType = (int)drawerView.Tag;
7070

7171
var leftDrawer = mHostActivity.FindViewById<NavigationView>(Resource.Id.nav_view);
7272
var rightDrawer = mHostActivity.FindViewById<ListView>(Resource.Id.right_drawer);
@@ -90,10 +90,10 @@ public override void OnDrawerSlide (View drawerView, float slideOffset)
9090
}
9191

9292
if (drawerType == 0)
93-
{
94-
base.OnDrawerSlide (drawerView, slideOffset);
95-
}
96-
}
97-
}
93+
{
94+
base.OnDrawerSlide(drawerView, slideOffset);
95+
}
96+
}
97+
}
9898
}
9999

AndroidXamarinChat/ChatCmdReceiver.cs

Lines changed: 108 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -12,64 +12,67 @@
1212

1313
namespace AndroidXamarinChat
1414
{
15-
public class ChatCommandHandler
16-
{
17-
private Activity parentActivity;
18-
private MessageListViewAdapter messageAdapter;
19-
public Dictionary<string,List<ChatMessage>> FullHistory { get; set; }
20-
21-
public string CurrentChannel { get; set; }
22-
23-
public ChatCommandHandler(Activity parentActivity, MessageListViewAdapter messageAdapter, string initialChannel)
24-
{
25-
this.parentActivity = parentActivity;
26-
this.messageAdapter = messageAdapter;
27-
this.FullHistory = new Dictionary<string, List<ChatMessage>> ();
28-
this.CurrentChannel = initialChannel;
29-
}
30-
31-
public void AppendMessage(ChatMessage chatMessage)
32-
{
33-
if (!FullHistory.ContainsKey (chatMessage.Channel)) {
34-
FullHistory.Add (chatMessage.Channel, new List<ChatMessage> ());
35-
}
36-
FullHistory [chatMessage.Channel].Add (chatMessage);
37-
if (chatMessage.Channel == this.CurrentChannel) {
38-
Application.SynchronizationContext.Post(_ =>
39-
{
15+
public class ChatCommandHandler
16+
{
17+
private Activity parentActivity;
18+
private MessageListViewAdapter messageAdapter;
19+
public Dictionary<string, List<ChatMessage>> FullHistory { get; set; }
20+
21+
public string CurrentChannel { get; set; }
22+
23+
public ChatCommandHandler(Activity parentActivity, MessageListViewAdapter messageAdapter, string initialChannel)
24+
{
25+
this.parentActivity = parentActivity;
26+
this.messageAdapter = messageAdapter;
27+
this.FullHistory = new Dictionary<string, List<ChatMessage>>();
28+
this.CurrentChannel = initialChannel;
29+
}
30+
31+
public void AppendMessage(ChatMessage chatMessage)
32+
{
33+
if (!FullHistory.ContainsKey(chatMessage.Channel))
34+
{
35+
FullHistory.Add(chatMessage.Channel, new List<ChatMessage>());
36+
}
37+
FullHistory[chatMessage.Channel].Add(chatMessage);
38+
if (chatMessage.Channel == this.CurrentChannel)
39+
{
40+
Application.SynchronizationContext.Post(_ =>
41+
{
4042
messageAdapter.Add(chatMessage);
4143
messageAdapter.NotifyDataSetChanged();
42-
},null);
43-
}
44-
}
45-
46-
public void ChangeChannel(string channel)
47-
{
48-
this.CurrentChannel = channel;
49-
Application.SynchronizationContext.Post(_ =>
50-
{
44+
}, null);
45+
}
46+
}
47+
48+
public void ChangeChannel(string channel)
49+
{
50+
this.CurrentChannel = channel;
51+
Application.SynchronizationContext.Post(_ =>
52+
{
5153
messageAdapter.Clear();
5254
if (FullHistory.ContainsKey(channel))
5355
{
54-
FullHistory[channel].ForEach(msg => {
56+
FullHistory[channel].ForEach(msg =>
57+
{
5558
messageAdapter.Add(msg);
5659
});
5760
}
58-
},null);
59-
}
61+
}, null);
62+
}
6063

61-
public void SyncAdapter()
62-
{
63-
ChangeChannel (this.CurrentChannel);
64-
}
64+
public void SyncAdapter()
65+
{
66+
ChangeChannel(this.CurrentChannel);
67+
}
6568

66-
public void ShowVideo(string videoUrl)
67-
{
68-
parentActivity.StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse(videoUrl)));
69-
}
69+
public void ShowVideo(string videoUrl)
70+
{
71+
parentActivity.StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse(videoUrl)));
72+
}
7073

71-
public void Announce(string message)
72-
{
74+
public void Announce(string message)
75+
{
7376
Notification.Builder builder = new Notification.Builder(parentActivity)
7477
.SetLocalOnly(true)
7578
.SetAutoCancel(true)
@@ -86,74 +89,77 @@ public void Announce(string message)
8689

8790
// Publish the notification:
8891
const int notificationId = 0;
89-
if (notificationManager != null)
90-
{
91-
notificationManager.Notify(notificationId, notification);
92-
93-
Vibrator vibrator = (Vibrator)parentActivity.GetSystemService(Context.VibratorService);
94-
vibrator.Vibrate(1000);
95-
CancelNotification(notificationManager).ConfigureAwait(false);
96-
}
97-
}
98-
99-
private async Task CancelNotification(NotificationManager notificationManager)
100-
{
101-
await Task.Delay(5000);
92+
if (notificationManager != null)
93+
{
94+
notificationManager.Notify(notificationId, notification);
95+
96+
Vibrator vibrator = (Vibrator)parentActivity.GetSystemService(Context.VibratorService);
97+
vibrator.Vibrate(1000);
98+
CancelNotification(notificationManager).ConfigureAwait(false);
99+
}
100+
}
101+
102+
private async Task CancelNotification(NotificationManager notificationManager)
103+
{
104+
await Task.Delay(5000);
102105
notificationManager.CancelAll();
103-
}
104-
105-
public void ChangeBackground(string message)
106-
{
107-
var url = message.StartsWith("url(") ? message.Substring(4, message.Length - 5) : message;
108-
url.GetImageBitmap().ContinueWith(t =>
109-
{
110-
t.Wait();
106+
}
107+
108+
public void ChangeBackground(string message)
109+
{
110+
var url = message.StartsWith("url(") ? message.Substring(4, message.Length - 5) : message;
111+
url.GetImageBitmap().ContinueWith(t =>
112+
{
113+
t.Wait();
111114
var bitmap = t.Result;
112115
var chatBackground = parentActivity.FindViewById<ImageView>(Resource.Id.chat_background);
113116
Application.SynchronizationContext.Post(_ =>
114117
{
115118
chatBackground.SetImageBitmap(bitmap);
116-
},null);
117-
});
119+
}, null);
120+
});
118121
}
119122

120-
public void ChangeBackgroundColor(string message)
121-
{
123+
public void ChangeBackgroundColor(string message)
124+
{
122125
// Inject alpha values
123-
string color = message.Replace("#", "#AA");
124-
var chatLayout = parentActivity.FindViewById<ListView>(Resource.Id.messageHistory);
125-
var editText = parentActivity.FindViewById<EditText>(Resource.Id.message);
126-
var sendButton = parentActivity.FindViewById<Button>(Resource.Id.sendMessageButton);
126+
string color = message.Replace("#", "#AA");
127+
var chatLayout = parentActivity.FindViewById<ListView>(Resource.Id.messageHistory);
128+
var editText = parentActivity.FindViewById<EditText>(Resource.Id.message);
129+
var sendButton = parentActivity.FindViewById<Button>(Resource.Id.sendMessageButton);
127130
Application.SynchronizationContext.Post(_ =>
128131
{
129132
chatLayout.SetBackgroundColor(Color.ParseColor(color));
130133
editText.SetBackgroundColor(Color.ParseColor(color));
131134
sendButton.SetBackgroundColor(Color.ParseColor(color));
132135
}, null);
133-
}
134-
}
135-
136-
public class MessageResolver : IResolver
137-
{
138-
ChatCommandHandler messageHandler;
139-
public MessageResolver(ChatCommandHandler messageHandler)
140-
{
141-
this.messageHandler = messageHandler;
142-
}
143-
144-
public T TryResolve<T> ()
145-
{
146-
if (typeof(T) == typeof(ChatReceiver)) {
147-
return (T)(new ChatReceiver (this.messageHandler) as object);
148-
}
149-
if (typeof(T) == typeof(TvReciever)) {
150-
return (T)(new TvReciever (this.messageHandler) as object);
151-
}
152-
if (typeof (T) == typeof (CssReceiver)) {
153-
return (T)(new CssReceiver(this.messageHandler) as object);
154-
}
155-
156-
return typeof(T).CreateInstance<T> ();
157-
}
158-
}
136+
}
137+
}
138+
139+
public class MessageResolver : IResolver
140+
{
141+
ChatCommandHandler messageHandler;
142+
public MessageResolver(ChatCommandHandler messageHandler)
143+
{
144+
this.messageHandler = messageHandler;
145+
}
146+
147+
public T TryResolve<T>()
148+
{
149+
if (typeof(T) == typeof(ChatReceiver))
150+
{
151+
return (T)(new ChatReceiver(this.messageHandler) as object);
152+
}
153+
if (typeof(T) == typeof(TvReciever))
154+
{
155+
return (T)(new TvReciever(this.messageHandler) as object);
156+
}
157+
if (typeof(T) == typeof(CssReceiver))
158+
{
159+
return (T)(new CssReceiver(this.messageHandler) as object);
160+
}
161+
162+
return typeof(T).CreateInstance<T>();
163+
}
164+
}
159165
}

AndroidXamarinChat/EventReceivers.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
6-
using Android.App;
7-
using Android.Content;
8-
using Android.OS;
9-
using Android.Runtime;
10-
using Android.Views;
11-
using Android.Widget;
121
using Chat;
132
using ServiceStack;
143

0 commit comments

Comments
 (0)