Skip to content

Commit

Permalink
Started to implement the MainServiceHelper class
Browse files Browse the repository at this point in the history
  • Loading branch information
tilmanginzel committed Sep 3, 2015
1 parent 5f3a2b2 commit 3a36c06
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions app/src/main/java/de/mobcomp/grades/main/MainServiceHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.mobcomp.grades.main;

import android.content.Context;
import android.content.Intent;

/**
* Helper class with convenience methods to start background
* threads by sending intents to the MainService.
*
* This class is responsible for creating unique request ids for different requests.
*/
public class MainServiceHelper {
private Context context;

public MainServiceHelper(Context context) {
this.context = context.getApplicationContext();
}

/**
* Build a basic intent with required extra data for each request.
*
* @param processor - processor to create (declared in the MainService)
* @param method - method to call by (declared in the MainService)
* @param requestId - request id
* @return intent
*/
private Intent getBasicIntent(int processor, int method, long requestId) {
Intent intent = new Intent(context, MainService.class);
intent.putExtra(MainService.PROCESSOR_KEY, processor);
intent.putExtra(MainService.METHOD_KEY, method);
intent.putExtra(MainService.REQUEST_ID, requestId);
return intent;
}
}

0 comments on commit 3a36c06

Please sign in to comment.