Logging connection status updates and including a new node URL in the sample app
This commit is contained in:
parent
7a19220c51
commit
f3731d140b
2 changed files with 32 additions and 0 deletions
|
@ -7,6 +7,7 @@ import android.support.v7.app.AppCompatActivity;
|
|||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
@ -14,12 +15,21 @@ import android.widget.TextView;
|
|||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import cy.agorise.graphenej.RPC;
|
||||
import cy.agorise.graphenej.api.ConnectionStatusUpdate;
|
||||
import cy.agorise.graphenej.api.android.RxBus;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
|
||||
public class CallsActivity extends AppCompatActivity {
|
||||
private final String TAG = this.getClass().getName();
|
||||
|
||||
@BindView(R.id.call_list)
|
||||
RecyclerView mRecyclerView;
|
||||
|
||||
private CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -29,6 +39,21 @@ public class CallsActivity extends AppCompatActivity {
|
|||
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
mRecyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
|
||||
mRecyclerView.setAdapter(new CallAdapter());
|
||||
|
||||
Disposable disposable = RxBus.getBusInstance()
|
||||
.asFlowable()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Object>() {
|
||||
|
||||
@Override
|
||||
public void accept(Object message) throws Exception {
|
||||
if(message instanceof ConnectionStatusUpdate){
|
||||
ConnectionStatusUpdate statusUpdate = (ConnectionStatusUpdate) message;
|
||||
Log.d(TAG, String.format("ConnectionStatusUpdate. code: %d, api: %d", statusUpdate.getUpdateCode(),statusUpdate.getApi()));
|
||||
}
|
||||
}
|
||||
});
|
||||
compositeDisposable.add(disposable);
|
||||
}
|
||||
|
||||
private final class CallAdapter extends RecyclerView.Adapter<CallAdapter.ViewHolder> {
|
||||
|
@ -93,4 +118,10 @@ public class CallsActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
compositeDisposable.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ public class SampleApplication extends Application {
|
|||
int requestedApis = ApiAccess.API_DATABASE | ApiAccess.API_HISTORY | ApiAccess.API_NETWORK_BROADCAST;
|
||||
|
||||
String[] nodeURLs = new String[]{
|
||||
"wss://miami.bitshares.apasia.tech/ws",
|
||||
"wss://bitshares.crypto.fans/ws",
|
||||
"wss://bitshares.openledger.info/ws",
|
||||
"wss://us.nodes.bitshares.ws",
|
||||
|
|
Loading…
Reference in a new issue