-
Notifications
You must be signed in to change notification settings - Fork 78
Conversation
@Mecharyry onCreate of a DummyApplication would never be called. This is a library, so it's Application class is never instantiated .. as it is not an application. It is used by another application. |
Oh yea of course. Just as well I didn't go for that option then 👅 |
This The methods are static, so what about a new class? Also a
Example useage
Debate away @Mecharyry @ouchadam |
or |
@@ -42,6 +46,16 @@ public void registerBindable(Bindable bindable) { | |||
registerer.registerBindable(bindable); | |||
} | |||
|
|||
public static boolean isConnected(Context context) { |
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.
❌ the whole point of Merlin
is to provide a connected state which has done a network ping to guarantee the network is available. It should use the state attained by the MerlinService
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.
yeah so if we move this to another class and have it javadoc'd correctly we can have this quicker method with the caveat that it is not as accurate. (this is what the github issue defines?)
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.
what I mean is that this logic is duplicating what the MerlinService
does. The isConnected
state is fetched in callbacks.
The issue meant the state within the service, which can be created via the builder with or without host pinging (if you want a less reliable result)
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.
but that's a lot of setup and service binding where this is 1 synchronous call?
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.
Thought I should probably comment here 👅 Does this issue want a network connectivity method, which is the solution above. Or does the issue call for knowledge on whether the endpoint is active, in my opinion these are two separate issues. @ouchadam We create two separate issues to handle the two use cases?
return new MerlinsBeard(context); | ||
} | ||
|
||
private MerlinsBeard(Context context) { |
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.
👎 would prefer a newInstance which takes a context but a constructor which takes a ConnectivityManager!
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.
good point @ouchadam (from
is more client facing friendly than newInstance
tho)
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.
and lets not forget the tests 👻
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.
👍
LGTM @ouchadam the constructor comment needs addressing. Then as we discussed the NoTils change, can that be in another PR. As the public interface here looks good? |
👍 that's good with me |
Sorry @ouchadam should have said that I ran the tests again, they all passed. |
👍 good stuff, but it also means there's an untested class 😉 |
Sorry @ouchadam didn't notice this comment. Which class are you talking about? The MerlinService? That one is tested, it couldn't be tested as well as it could have been due to the constructor. I am happy to write a test if you let me know which one you are talking about. |
The |
Right, I'm on it. 😄 |
@ouchadam Tests added 😃 |
} | ||
|
||
@Test | ||
public void getPerformsHostPingerPingWhenIsConnectedReturnsTrue() { |
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.
it's preferential to write these method names givenwhenthen rather than thenwhengiven. Just easier to think about going from A - B rather than backwards B - A
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.
i.e. whenNetworkIsConnectedHostPingerPings()
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.
I'll add that to my notes 👅
public void get(Context context) { | ||
NetworkInfo activeNetworkInfo = getNetworkInfo(context); | ||
if (isConnectable(activeNetworkInfo)) { | ||
public void get() { |
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.
A public get()
method that is void
? There must be a better name for that method.
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.
💯
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.
Any suggestions? getAndReturnInCallback?
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.
fetch()
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.
fetch() going once......twice.......sold
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.
fetchViaPing
?
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.
Doesn't always perform a ping though, only if available.
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.
Do you not think that we should highlight that the result is retrieved via a callback?
public void get(Context context) { | ||
NetworkInfo activeNetworkInfo = getNetworkInfo(context); | ||
if (isConnectable(activeNetworkInfo)) { | ||
public void fetch() { |
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.
maybe fetchWithPing()
makes more sense now I read the other methid
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.
fetchWithPing
fetchWithoutPing
? both should follow the same prefix
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.
no because fetch
and get
are two different commands.
fetch is go fetch this and come back to me when you have done it - callback
get is GET THIS NOW - return value
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.
makes sense, but the class needs a new name in that case!
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.
Sorry, will change it back then....
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.
Retreiver
? haha i think the class name is fine for now
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.
💯 @Mecharyry after this change to Retreiver
I'll be happy to merge
LGTM |
<Button | ||
android:id="@+id/currentStatus" |
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 id should be underscored not camelCase!
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.
Sorry thought I had changed this....
👍 nice one @Mecharyry |
@ouchadam @blundell @Mecharyry has this been released? |
that is on @Mecharyry 's //TODO list |
This pull request addresses issue #29 Provide the Current Network State.
Just adds two methods into Merlin class which will retrieve the network info from a given context and return the network status.
I was tempted to create a dummy Application in the android manifest and have it static so that you would not be required to pass a context in order to retrieve a network status, but there wouldn't be any guarantee that the onCreate would be called before someone tried to access the isConnected method.^^ Me forgetting that this is a library 👅