Search in sources :

Example 1 with NodeInfo

use of run.wallet.iota.model.NodeInfo in project run-wallet-android by runplay.

the class NetworkNodeInfoFragment method setAdapter.

private void setAdapter() {
    NodeInfoResponse nir = Store.getNodeInfo();
    Activity activity = getActivity();
    if (activity != null && nir != null) {
        swipeRefreshLayout.setRefreshing(false);
        SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.getDefault());
        nodeInfos = new ArrayList<>();
        nodeInfos.add(new NodeInfo(activity.getString(R.string.info_app_name), nir.getAppName()));
        nodeInfos.add(new NodeInfo(getString(R.string.info_app_version), nir.getAppVersion()));
        nodeInfos.add(new NodeInfo(getString(R.string.info_jre_version), nir.getJreVersion()));
        nodeInfos.add(new NodeInfo(getString(R.string.info_max_processors), nir.getJreAvailableProcessors() + ""));
        nodeInfos.add(new NodeInfo(getString(R.string.info_free_memory), Formatter.formatShortFileSize(getActivity(), nir.getJreFreeMemory())));
        nodeInfos.add(new NodeInfo(getString(R.string.info_max_memory), Formatter.formatShortFileSize(getActivity(), nir.getJreMaxMemory())));
        nodeInfos.add(new NodeInfo(getString(R.string.info_total_memory), Formatter.formatShortFileSize(getActivity(), nir.getJreTotalMemory())));
        nodeInfos.add(new NodeInfo(getString(R.string.info_latest_milestone), nir.getLatestMilestone()));
        nodeInfos.add(new NodeInfo(getString(R.string.info_latest_milestone_index), nir.getLatestMilestoneIndex()));
        nodeInfos.add(new NodeInfo(getString(R.string.info_latest_milestone_solid_subtangle), nir.getLatestSolidSubtangleMilestone()));
        nodeInfos.add(new NodeInfo(getString(R.string.info_latest_milestone_solid_subtangle_index), nir.getLatestSolidSubtangleMilestoneIndex()));
        nodeInfos.add(new NodeInfo(getString(R.string.info_neighbors), nir.getNeighbors()));
        nodeInfos.add(new NodeInfo(getString(R.string.info_packets_queue_size), nir.getPacketsQueueSize()));
        nodeInfos.add(new NodeInfo(getString(R.string.info_time), df.format(new Date(nir.getTime()))));
        nodeInfos.add(new NodeInfo(getString(R.string.info_tips), nir.getTips()));
        nodeInfos.add(new NodeInfo(getString(R.string.info_transactions_to_request), nir.getTransactionsToRequest()));
        updateChart(nir.getTips(), nir.getTransactionsToRequest());
        NodeInfoListAdapter nodeInfoListAdapter = new NodeInfoListAdapter(getActivity(), R.layout.item_node_info, nodeInfos);
        Utils.fixListView(list, swipeRefreshLayout);
        list.setAdapter(nodeInfoListAdapter);
        nodeAddress.setText(Store.getNode().getName());
        if (nir.isSyncOk()) {
            nodeActive.setImageResource(R.drawable.node_tick_grey);
        } else {
            nodeActive.setImageResource(R.drawable.indicator_offline);
        }
    }
}
Also used : NodeInfo(run.wallet.iota.model.NodeInfo) NodeInfoResponse(run.wallet.iota.api.responses.NodeInfoResponse) Activity(android.app.Activity) NodeInfoListAdapter(run.wallet.iota.ui.adapter.NodeInfoListAdapter) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 2 with NodeInfo

use of run.wallet.iota.model.NodeInfo in project run-wallet-android by runplay.

the class NodeInfoListAdapter method getView.

@NonNull
@Override
public View getView(int position, View view, @NonNull ViewGroup parent) {
    ViewHolderItem viewHolder;
    if (view == null) {
        view = inflator.inflate(R.layout.item_node_info, parent, false);
        viewHolder = new ViewHolderItem(view);
        view.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolderItem) view.getTag();
    }
    NodeInfo nodeInfo = getItem(position);
    if (nodeInfo != null) {
        if (viewHolder.label != null) {
            viewHolder.label.setText(nodeInfo.getParam());
        }
        if (viewHolder.value != null) {
            if (nodeInfo.getValue() != null)
                viewHolder.value.setText(nodeInfo.getValue());
            else
                viewHolder.value.setText(String.valueOf(nodeInfo.getIndex()));
        }
    }
    return view;
}
Also used : NodeInfo(run.wallet.iota.model.NodeInfo) NonNull(android.support.annotation.NonNull)

Aggregations

NodeInfo (run.wallet.iota.model.NodeInfo)2 Activity (android.app.Activity)1 NonNull (android.support.annotation.NonNull)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 NodeInfoResponse (run.wallet.iota.api.responses.NodeInfoResponse)1 NodeInfoListAdapter (run.wallet.iota.ui.adapter.NodeInfoListAdapter)1