-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started to implement the MainServiceHelper class
- Loading branch information
1 parent
5f3a2b2
commit 3a36c06
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
app/src/main/java/de/mobcomp/grades/main/MainServiceHelper.java
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
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; | ||
} | ||
} |