This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity : MvxFormsAppCompatActivity | |
{ | |
protected override void OnCreate(Bundle savedInstanceState) | |
{ | |
//other on initialization code here skipped | |
using var builder = new Constraints.Builder(); | |
builder.SetRequiredNetworkType(NetworkType.Connected); | |
var workConstraints = builder.Build(); | |
var interval = TimeSpan.FromMinutes(16); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Android Background Worker | |
/// </summary> | |
public class BackgroundWork : Worker | |
{ | |
#region Fields | |
private ILogger _logger; | |
private IBackgroundWorkManager _backgroundWorkManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Android Native Background Service | |
/// </summary> | |
[Service] | |
public class BackgroundService : Service | |
{ | |
#region Fields | |
/// <summary> | |
/// The Id of the Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Native Background Worker Interface | |
/// </summary> | |
public interface IBackgroundWorker | |
{ | |
/// <summary> | |
/// Worker Stopped Event | |
/// </summary> | |
public event EventHandler WorkerStopped; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Simple Background Work Manager to set and get work delegate | |
/// </summary> | |
/// <remarks>it's too simple to show how it's implemented, LOL</remarks> | |
public interface IBackgroundWorkManager | |
{ | |
/// <summary> | |
/// Get Background Work | |
/// </summary> | |
Func<Task> GetBackgroundWork(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override double Convert(double value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
if (value > 0) | |
{ | |
var result = value * (double)parameter; | |
return result; | |
} | |
return value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ChatWebView.Source = new HtmlWebViewSource | |
{ | |
Html = "<html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"></head><body>" + | |
"<script type=\"text/javascript\">" + | |
" function Run(text) { try { InvokeDisplayJSText(link); } catch(err) { alert(err); }} " + | |
" function DisplayXFText(text) { alert('DisplayXFText ' + text); } " + | |
"</script >" + | |
"<p><a href=\"#\" onclick=\"Run('Hello');\">Send 'Hello' to Xamarin.Forms</a></p>" + | |
"<p><a href=\"#\" onclick=\"Run2('From JS');\">Send 'From JS' to Xamarin.Forms</a></p>" + | |
"</body ></html >" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomWebView : WebView | |
{ | |
public void Cleanup() | |
{ | |
_displayJSTextAction = null; | |
} | |
#region DisplayJSTextAction | |
private Action<string> _displayJSTextAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DraggableView : ContentView, IDisposable | |
{ | |
public static readonly BindableProperty NewXProperty = BindableProperty.Create( | |
propertyName: nameof(NewX), | |
returnType: typeof(double), | |
declaringType: typeof(DraggableView)); | |
public double NewX | |
{ | |
get => (double)GetValue(NewXProperty); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Protected Methods | |
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) | |
{ | |
base.OnElementPropertyChanged(sender, e); | |
if (e.PropertyName == Xamarin.Forms.VisualElement.XProperty.PropertyName || e.PropertyName == Xamarin.Forms.VisualElement.YProperty.PropertyName) | |
{ | |
CancellationToken(() => | |
{ | |
var draggableView = Element as DraggableView; |