Merge branch 'develop' of github.com:Agorise/graphenej into develop

This commit is contained in:
Nelson R. Perez 2018-10-04 13:44:11 -05:00
commit 2618a6a3a0
2 changed files with 15 additions and 17 deletions

View file

@ -598,6 +598,11 @@ public class NetworkService extends Service {
Log.e(TAG,"Response: "+response.message()); Log.e(TAG,"Response: "+response.message());
} }
// Adding a very high latency value to this node in order to prevent
// us from getting it again
mSelectedNode.addLatencyValue(Long.MAX_VALUE);
nodeProvider.updateNode(mSelectedNode);
RxBus.getBusInstance().send(new ConnectionStatusUpdate(ConnectionStatusUpdate.DISCONNECTED, ApiAccess.API_NONE)); RxBus.getBusInstance().send(new ConnectionStatusUpdate(ConnectionStatusUpdate.DISCONNECTED, ApiAccess.API_NONE));
if(nodeProvider.getBestNode() == null){ if(nodeProvider.getBestNode() == null){

View file

@ -9,6 +9,7 @@ import android.content.ServiceConnection;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.util.Log;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
@ -74,17 +75,13 @@ public class NetworkServiceManager implements Application.ActivityLifecycleCallb
} }
@Override @Override
public void onActivityCreated(Activity activity, Bundle bundle) { public void onActivityCreated(Activity activity, Bundle bundle) { }
if(mService == null){
// Starting a NetworkService instance
Context context = mContextReference.get();
Intent intent = new Intent(context, NetworkService.class);
context.startService(intent);
}
}
@Override @Override
public void onActivityStarted(Activity activity) { public void onActivityStarted(Activity activity) { }
@Override
public void onActivityResumed(Activity activity) {
mHandler.removeCallbacks(mDisconnectRunnable); mHandler.removeCallbacks(mDisconnectRunnable);
if(mService == null){ if(mService == null){
// Creating a new Intent that will be used to start the NetworkService // Creating a new Intent that will be used to start the NetworkService
@ -107,14 +104,10 @@ public class NetworkServiceManager implements Application.ActivityLifecycleCallb
.putExtra(NetworkService.KEY_CUSTOM_NODE_URLS, customNodes) .putExtra(NetworkService.KEY_CUSTOM_NODE_URLS, customNodes)
.putExtra(NetworkService.KEY_AUTO_CONNECT, mAutoConnect) .putExtra(NetworkService.KEY_AUTO_CONNECT, mAutoConnect)
.putExtra(NetworkService.KEY_ENABLE_LATENCY_VERIFIER, mVerifyLatency); .putExtra(NetworkService.KEY_ENABLE_LATENCY_VERIFIER, mVerifyLatency);
context.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); context.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
} }
} }
@Override
public void onActivityResumed(Activity activity) {}
@Override @Override
public void onActivityPaused(Activity activity) { public void onActivityPaused(Activity activity) {
mHandler.postDelayed(mDisconnectRunnable, DISCONNECT_DELAY); mHandler.postDelayed(mDisconnectRunnable, DISCONNECT_DELAY);
@ -148,8 +141,8 @@ public class NetworkServiceManager implements Application.ActivityLifecycleCallb
return mUserName; return mUserName;
} }
public void setUserName(String mUserName) { public void setUserName(String userName) {
this.mUserName = mUserName; this.mUserName = userName;
} }
public String getPassword() { public String getPassword() {
@ -286,8 +279,8 @@ public class NetworkServiceManager implements Application.ActivityLifecycleCallb
*/ */
public NetworkServiceManager build(Context context){ public NetworkServiceManager build(Context context){
NetworkServiceManager manager = new NetworkServiceManager(context); NetworkServiceManager manager = new NetworkServiceManager(context);
if(username != null) manager.setUserName(username); if(username != null) manager.setUserName(username); else manager.setUserName("");
if(password != null) manager.setPassword(password); if(password != null) manager.setPassword(password); else manager.setPassword("");
if(customNodeUrls != null) manager.setCustomNodeUrls(customNodeUrls); if(customNodeUrls != null) manager.setCustomNodeUrls(customNodeUrls);
manager.setRequestedApis(requestedApis); manager.setRequestedApis(requestedApis);
manager.setAutoConnect(autoconnect); manager.setAutoConnect(autoconnect);