-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove strange enum from ServiceControl #427
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -157,7 +157,7 @@ public void runServices(Intent intent, | |||
|
||||
// do we have data network? | ||||
if (isConnected()) { | ||||
SchedulerInstance.INSTANCE.getScheduler(mContext, mFileManager, intent, requestCode) | ||||
getScheduler(intent, requestCode) | ||||
.updateScheduler(interval); | ||||
} | ||||
} | ||||
|
@@ -173,7 +173,7 @@ public void runServices(Intent intent, | |||
*/ | ||||
public void stopServices(Intent intent, int requestCode) { | ||||
Logger.log(CLASS_TAG, "Stopping services"); | ||||
SchedulerInstance.INSTANCE.getScheduler(mContext, mFileManager, intent, requestCode) | ||||
getScheduler(intent, requestCode) | ||||
.stopScheduler(); | ||||
} | ||||
|
||||
|
@@ -207,13 +207,8 @@ public boolean isConnected() { | |||
return Utility.isConnected(mContext); | ||||
} | ||||
|
||||
public enum SchedulerInstance { | ||||
INSTANCE; | ||||
|
||||
private Scheduler getScheduler(Context context, FileManager fileManager, Intent intent, | ||||
int requestCode) { | ||||
return new Scheduler(context, fileManager, intent, requestCode, | ||||
PendingIntent.FLAG_UPDATE_CURRENT); | ||||
} | ||||
private Scheduler getScheduler(Intent intent, int requestCode) { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though this is convenient, it increases the method counts on Android. Android has a limitation on method count so usually I think twice before declaring new methods There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know! Looks like both implementations have the same number of methods, though :¬p There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make more sense for SMSSync/smssync/src/main/java/org/addhen/smssync/presentation/receiver/BootReceiver.java Line 82 in b8cd41a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh :-) In that case let's maintain your There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me check this before you merge. If it's meant to be a singleton, then we should enforce that everywhere; if it's not then this change should be fine. |
||||
return new Scheduler(mContext, mFileManager, intent, requestCode, | ||||
PendingIntent.FLAG_UPDATE_CURRENT); | ||||
} | ||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to make the Scheduler a Singleton. More thread-safety this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, I obviously missed the singletoning - sorry!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely something's thread-safe or it's not - the area between the two is scary (and not thread-safe)!