Skip to content
Permalink
Browse files
Updated UI to display status of workers + added Start options for Wor…
…ker + ListenableWorker.
  • Loading branch information
DamienDennehy committed Jul 12, 2020
1 parent 9259221 commit 140ad02a5018ae888b28fb12a02d03ea6e7db01b
Showing 7 changed files with 8,731 additions and 74 deletions.
@@ -2,10 +2,8 @@
using Android.App;
using Android.OS;
using Android.Runtime;
using Android.Support.Design.Widget;
using Android.Support.V7.App;
using Android.Views;
using Android.Widget;

namespace XamarinAndroidWorkerDemos
{
@@ -20,9 +18,6 @@ protected override void OnCreate(Bundle savedInstanceState)

Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(toolbar);

FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.fab);
fab.Click += FabOnClick;
}

public override bool OnCreateOptionsMenu(IMenu menu)
@@ -34,21 +29,18 @@ public override bool OnCreateOptionsMenu(IMenu menu)
public override bool OnOptionsItemSelected(IMenuItem item)
{
int id = item.ItemId;
if (id == Resource.Id.action_settings)
if (id == Resource.Id.action_start_worker)
{
return true;
}
else if (id == Resource.Id.action_start_listenable_worker)
{
return true;
}

return base.OnOptionsItemSelected(item);
}

private void FabOnClick(object sender, EventArgs eventArgs)
{
View view = (View) sender;
Snackbar.Make(view, "Replace with your own action", Snackbar.LengthLong)
.SetAction("Action", (Android.Views.View.IOnClickListener)null).Show();
}

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

Large diffs are not rendered by default.

@@ -21,12 +21,4 @@

<include layout="@layout/content_main" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>
@@ -4,13 +4,14 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/layout_padding"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Hello World!" />
android:layout_centerInParent="false"
android:id="@+id/worker_status"/>

</RelativeLayout>
@@ -2,8 +2,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<item
android:id="@+id/action_settings"
android:id="@+id/action_start_worker"
android:orderInCategory="100"
android:title="@string/action_settings"
android:title="@string/action_start_worker"
app:showAsAction="never" />
<item
android:id="@+id/action_start_listenable_worker"
android:orderInCategory="100"
android:title="@string/action_start_listenable_worker"
app:showAsAction="never" />
</menu>
@@ -1,3 +1,3 @@
<resources>
<dimen name="fab_margin">16dp</dimen>
<dimen name="layout_padding">16dp</dimen>
</resources>
@@ -1,4 +1,5 @@
<resources>
<string name="app_name">XamarinAndroidWorkerDemos</string>
<string name="action_settings">Settings</string>
<string name="app_name">Worker Demos</string>
<string name="action_start_worker">Start Worker</string>
<string name="action_start_listenable_worker">Start Listenable Worker</string>
</resources>

0 comments on commit 140ad02

Please sign in to comment.