PieterVanPoyer commented on issue #110:
URL: 
https://github.com/apache/cordova-plugin-network-information/issues/110#issuecomment-640016840


   Hey
   
   I did check the Android code and found something interesting.
   
   On next lines, there is a check on the equality of the network state before 
and after a change.
   The code seems to try to send an update only after a change. But this code 
goes long way back.
   
   
https://github.com/apache/cordova-plugin-network-information/blob/9f8527062776ead04982d7fab12875a66bf69855/src/android/NetworkManager.java#L221-L233
   
   The thisInfo and lastInfo are JSONObjects.
   
   _But when I run following code in a testproject. 2 JSONObjects with the same 
values are not seen as equal._
   
   ```
   try {
               JSONObject connectionInfo = new JSONObject();
               connectionInfo.put("type", "myType");
               connectionInfo.put("extraInfo", "myExtraInfo");
   
               JSONObject otherConnectionInfo = new JSONObject();
               otherConnectionInfo.put("type", "myType");
               otherConnectionInfo.put("extraInfo", "myExtraInfo");
   
               
prependToNetworkOutputState(this.tvNetworkStateOutputKeepsListening, "equals 
JSONObjects " + connectionInfo.equals(otherConnectionInfo)); // THIS EQUALS 
RETURNS FALSE
           } catch (JSONException e) {
   
           }
   ```
   I found something like this on StackOverflow:  _the Android's built-in 
JSONObject does not define hashCode() and equals() in any sensible way._  
   Check also the Android Docs: [Android 
Docs](https://developer.android.com/reference/org/json/JSONObject.html)
   
   **Can anyone confirm this?**
   If yes, then we should just correct the equality check.
   
   There is also another path we have to check for state, but that's for later.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to