Search in sources :

Example 6 with ApiRequest

use of run.wallet.iota.api.requests.ApiRequest in project run-wallet-android by runplay.

the class IotaRequestTask method doInBackground.

@Override
protected ApiResponse doInBackground(ApiRequest... params) {
    Context context = this.context.get();
    if (context != null) {
        // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        // String protocol = prefs.getString(Constants.PREFERENCE_NODE_PROTOCOL, Constants.PREFERENCE_NODE_DEFAULT_PROTOCOL);
        // String host = prefs.getString(Constants.PREFERENCE_NODE_IP, Constants.PREFERENCE_NODE_DEFAULT_IP);
        // int port = Integer.parseInt(prefs.getString(Constants.PREFERENCE_NODE_PORT, Constants.PREFERENCE_NODE_DEFAULT_PORT));
        Nodes.Node node = Store.getNode();
        // Log.e("NODE ON:",node.protocol+":"+node.ip+":"+node.port);
        if (node != null) {
            String protocol = node.protocol;
            String host = node.ip;
            int port = node.port;
            if (IOTA.DEBUG) {
                // Log.e("ApiRequest", params[0].toString());
                start = new Date();
            // Log.e("started req at", start.getTime() + "");
            }
            ApiRequest apiRequest = params[0];
            tag = apiRequest.getClass().getCanonicalName();
            ApiProvider apiProvider = new IotaApiProvider(protocol, host, port, context);
            ApiResponse response = apiProvider.processRequest(apiRequest);
            return response;
        }
    }
    // TaskManager.removeTask(tag);
    return null;
}
Also used : Context(android.content.Context) ApiRequest(run.wallet.iota.api.requests.ApiRequest) Nodes(run.wallet.iota.model.Nodes) Date(java.util.Date) ApiResponse(run.wallet.iota.api.responses.ApiResponse)

Example 7 with ApiRequest

use of run.wallet.iota.api.requests.ApiRequest in project run-wallet-android by runplay.

the class MessageRequestTask method doInBackground.

@Override
protected ApiResponse doInBackground(ApiRequest... params) {
    Context context = this.context.get();
    if (context != null) {
        // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        // String protocol = prefs.getString(Constants.PREFERENCE_NODE_PROTOCOL, Constants.PREFERENCE_NODE_DEFAULT_PROTOCOL);
        // String host = prefs.getString(Constants.PREFERENCE_NODE_IP, Constants.PREFERENCE_NODE_DEFAULT_IP);
        // int port = Integer.parseInt(prefs.getString(Constants.PREFERENCE_NODE_PORT, Constants.PREFERENCE_NODE_DEFAULT_PORT));
        Nodes.Node node = Store.getNode();
        // Log.e("MESSAGE REQUEST NODE:",node.protocol+":"+node.ip+":"+node.port);
        String protocol = node.protocol;
        String host = node.ip;
        int port = node.port;
        // if (IOTA.DEBUG) {
        // Log.e("ApiRequest", params[0].toString());
        // start = new Date();
        // Log.e("started at", start.getTime() + "");
        // }
        ApiRequest apiRequest = params[0];
        tag = apiRequest.getClass().getCanonicalName();
        ApiProvider apiProvider = new IotaMessageApiProvider(protocol, host, port, context);
        ApiResponse response = apiProvider.processRequest(apiRequest);
        return response;
    }
    TaskManager.removeTask(tag);
    return null;
}
Also used : Context(android.content.Context) ApiRequest(run.wallet.iota.api.requests.ApiRequest) Nodes(run.wallet.iota.model.Nodes) ApiResponse(run.wallet.iota.api.responses.ApiResponse)

Aggregations

ApiRequest (run.wallet.iota.api.requests.ApiRequest)7 Context (android.content.Context)3 HashMap (java.util.HashMap)3 RequestHandler (run.wallet.iota.api.handler.RequestHandler)3 ApiResponse (run.wallet.iota.api.responses.ApiResponse)3 Date (java.util.Date)2 Nodes (run.wallet.iota.model.Nodes)2 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 AddNeighborsRequestHandler (run.wallet.iota.api.handler.AddNeighborsRequestHandler)1 AddressSecurityChangeRequestHandler (run.wallet.iota.api.handler.AddressSecurityChangeRequestHandler)1 AuditAddressesRequestHandler (run.wallet.iota.api.handler.AuditAddressesRequestHandler)1 AutoNudgeHandler (run.wallet.iota.api.handler.AutoNudgeHandler)1 FindTransactionsRequestHandler (run.wallet.iota.api.handler.FindTransactionsRequestHandler)1 GetAccountDataRequestHandler (run.wallet.iota.api.handler.GetAccountDataRequestHandler)1