Skip to content

Commit

Permalink
Update Class Name
Browse files Browse the repository at this point in the history
-Removed unnecessary string variable
-Renamed MyWorker to FlowerWorker
  • Loading branch information
Shaz-hash committed Oct 14, 2023
1 parent f9729b6 commit 3120705
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/android/client/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />

<service android:name=".MyWorker"
<service android:name=".FlowerWorker"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import androidx.work.Worker;
import androidx.work.WorkerParameters;

public class MyWorker extends Worker {
public class FlowerWorker extends Worker {

private ManagedChannel channel;
public FlowerClient fc;
Expand Down Expand Up @@ -73,9 +73,9 @@ public String getTime() {

private static String PROGRESS = "PROGRESS";

public MyWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
public FlowerWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
MyWorker worker = this;
FlowerWorker worker = this;
notificationManager = (NotificationManager)
context.getSystemService(NOTIFICATION_SERVICE);
fc = new FlowerClient(context.getApplicationContext());
Expand Down Expand Up @@ -162,7 +162,7 @@ public void loadData() {
public CompletableFuture<Void> runGrpc() {

CompletableFuture<Void> future = new CompletableFuture<>();
MyWorker worker = this;
FlowerWorker worker = this;
ExecutorService executor = Executors.newSingleThreadExecutor();

ProgressUpdater progressUpdater = new ProgressUpdater();
Expand Down Expand Up @@ -247,7 +247,7 @@ public void setProgress() {

private static class FlowerServiceRunnable{
protected Throwable failed;
public void run(FlowerServiceStub asyncStub, MyWorker worker , CountDownLatch latch , ProgressUpdater progressUpdater , Context context) {
public void run(FlowerServiceStub asyncStub, FlowerWorker worker , CountDownLatch latch , ProgressUpdater progressUpdater , Context context) {
join(asyncStub, worker , latch , progressUpdater , context);
}

Expand Down Expand Up @@ -281,7 +281,7 @@ public void writeStringToFile( Context context , String fileName, String content
}
}

private void join(FlowerServiceStub asyncStub, MyWorker worker, CountDownLatch latch , ProgressUpdater progressUpdater , Context context)
private void join(FlowerServiceStub asyncStub, FlowerWorker worker, CountDownLatch latch , ProgressUpdater progressUpdater , Context context)
throws RuntimeException {
final CountDownLatch finishLatch = new CountDownLatch(1);

Expand Down Expand Up @@ -320,7 +320,7 @@ public void onCompleted() {
}
}

private void handleMessage(ServerMessage message, MyWorker worker , ProgressUpdater progressUpdater , Context context) {
private void handleMessage(ServerMessage message, FlowerWorker worker , ProgressUpdater progressUpdater , Context context) {

try {
ByteBuffer[] weights;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void startWorker(View view) {
.build();

PeriodicWorkRequest workRequest = new PeriodicWorkRequest.Builder(
MyWorker.class, 15, TimeUnit.MINUTES)
FlowerWorker.class, 15, TimeUnit.MINUTES)
.setInitialDelay(0, TimeUnit.MILLISECONDS)
.setInputData(new Data.Builder()
.putString( "dataslice", deviceIdEditText.getText().toString() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
<string name="notification_channel_id">1002</string>
<string name="notification_title">Federated learning running</string>
<string name="cancel_download">Cancel federated learning</string>
<string name="channelId">123</string>
</resources>

0 comments on commit 3120705

Please sign in to comment.