// Path: app/src/main/java/project/android/net/ServerInfo.java
// public class ServerInfo {
//     private byte[] mServerPubKey;
//     private String mServerInfo;
//     private String mAddress;
//     private String mPairingKey;
//     private boolean mStopFlag;
// 
//     static final int SERVER_INFO_LENGTH = 600;
// 
//     /**
//      * Constructor.
//      * Initializes this <code>ServerInfo</code>.
//      *
//      * @param publicKey public key of the server.
//      * @param serverInfo canonical hostname of the server.
//      */
//     public ServerInfo(byte[] publicKey, String serverInfo) {
//         mServerPubKey = publicKey;
//         mServerInfo = serverInfo;
//         mStopFlag = false;
//     }
// 
//     /**
//      * Compares two <code>ServerInfo</code> objects.
//      *
//      * @param obj the object to be compared.
//      * @return <code>true</code>, if the two objects are equal, <br/>
//      *         <code>false</code>, otherwise.
//      */
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj)    return true;
//         if (obj == null)    return false;
//         if (getClass() != obj.getClass())   return false;
//         ServerInfo other = (ServerInfo) obj;
//         return mAddress.equals(other.mAddress);
//     }
// 
//     /**
//      * Sets the IPv4 server address.
//      * @param address IPv4 server address.
//      */
//     void setServerAddress(String address) { mAddress = address; }
// 
//     /**
//      * Sets the pairing key used during client-server authentication.
//      * @param pairingKey the pairing key.
//      */
//     public void setPairingKey(String pairingKey) { mPairingKey = pairingKey; }
// 
//     /**
//      * Returns the status of the server.
//      * @return server status.
//      */
//     boolean getStopFlag() { return mStopFlag; }
// 
//     /**
//      * Returns the server public key.
//      * @return server public key.
//      */
//     byte[] getServerPubKey() { return mServerPubKey; }
// 
//     /**
//      * Returns the canonical host name of the server.
//      * @return the canonical host name.
//      */
//     public String getServerInfo() { return mServerInfo; }
// 
//     /**
//      * Returns the IPv4 address of the server.
//      * @return the IPv4 server address.
//      */
//     public String getAddress() { return mAddress; }
// 
//     /**
//      * Returns the pairing key used during client-server authentication.
//      * @return the pairing key.
//      */
//     String getPairingKey() { return mPairingKey; }
// }
// 
// Path: app/src/main/java/project/android/ConnectionFragment.java
// public static HashMap<String, Boolean> sConnectionAlive = new HashMap<>();


import android.app.Activity;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import project.android.net.ServerInfo;
import static project.android.ConnectionFragment.sConnectionAlive;
     * position in the data set.
     *
     * @param position the position of the item within the adapter's data
     *                 set of the item whose view is required.
     * @param convertView The old view to reuse, if possible.
     * @param parent The parent that this view will eventually be attached to.
     * @return A <code>View</code> corresponding to the data at the specified
     *         position.
     */
    @NonNull
    @Override
    public View getView(int position, View convertView, @NonNull ViewGroup parent) {

        ViewHolder viewHolder;
        if (convertView == null) {
            LayoutInflater layoutInflater = LayoutInflater.from(mActivity);
            convertView = layoutInflater.inflate(R.layout.local_devices, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.mTextView = (TextView) convertView.findViewById(R.id.code);
            viewHolder.mImageView = (ImageView) convertView.findViewById(R.id.connectIcon);
            convertView.setTag(viewHolder);
        }
        else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        ArrayList<ServerInfo> serverList = mConnectionFragment.getNetworkList();
        if(!serverList.isEmpty()) {
            ServerInfo serverInfo = serverList.get(position);
            viewHolder.mTextView.setText(serverInfo.getServerInfo() + " (" + serverInfo.getAddress() + ")");
// Path: app/src/main/java/project/android/net/ServerInfo.java
// public class ServerInfo {
//     private byte[] mServerPubKey;
//     private String mServerInfo;
//     private String mAddress;
//     private String mPairingKey;
//     private boolean mStopFlag;
// 
//     static final int SERVER_INFO_LENGTH = 600;
// 
//     /**
//      * Constructor.
//      * Initializes this <code>ServerInfo</code>.
//      *
//      * @param publicKey public key of the server.
//      * @param serverInfo canonical hostname of the server.
//      */
//     public ServerInfo(byte[] publicKey, String serverInfo) {
//         mServerPubKey = publicKey;
//         mServerInfo = serverInfo;
//         mStopFlag = false;
//     }
// 
//     /**
//      * Compares two <code>ServerInfo</code> objects.
//      *
//      * @param obj the object to be compared.
//      * @return <code>true</code>, if the two objects are equal, <br/>
//      *         <code>false</code>, otherwise.
//      */
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj)    return true;
//         if (obj == null)    return false;
//         if (getClass() != obj.getClass())   return false;
//         ServerInfo other = (ServerInfo) obj;
//         return mAddress.equals(other.mAddress);
//     }
// 
//     /**
//      * Sets the IPv4 server address.
//      * @param address IPv4 server address.
//      */
//     void setServerAddress(String address) { mAddress = address; }
// 
//     /**
//      * Sets the pairing key used during client-server authentication.
//      * @param pairingKey the pairing key.
//      */
//     public void setPairingKey(String pairingKey) { mPairingKey = pairingKey; }
// 
//     /**
//      * Returns the status of the server.
//      * @return server status.
//      */
//     boolean getStopFlag() { return mStopFlag; }
// 
//     /**
//      * Returns the server public key.
//      * @return server public key.
//      */
//     byte[] getServerPubKey() { return mServerPubKey; }
// 
//     /**
//      * Returns the canonical host name of the server.
//      * @return the canonical host name.
//      */
//     public String getServerInfo() { return mServerInfo; }
// 
//     /**
//      * Returns the IPv4 address of the server.
//      * @return the IPv4 server address.
//      */
//     public String getAddress() { return mAddress; }
// 
//     /**
//      * Returns the pairing key used during client-server authentication.
//      * @return the pairing key.
//      */
//     String getPairingKey() { return mPairingKey; }
// }
// 
// Path: app/src/main/java/project/android/ConnectionFragment.java
// public static HashMap<String, Boolean> sConnectionAlive = new HashMap<>();


// Path: app/src/main/java/project/android/CustomAdapter.java
import android.app.Activity;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import project.android.net.ServerInfo;
import static project.android.ConnectionFragment.sConnectionAlive;

     * position in the data set.
     *
     * @param position the position of the item within the adapter's data
     *                 set of the item whose view is required.
     * @param convertView The old view to reuse, if possible.
     * @param parent The parent that this view will eventually be attached to.
     * @return A <code>View</code> corresponding to the data at the specified
     *         position.
     */
    @NonNull
    @Override
    public View getView(int position, View convertView, @NonNull ViewGroup parent) {

        ViewHolder viewHolder;
        if (convertView == null) {
            LayoutInflater layoutInflater = LayoutInflater.from(mActivity);
            convertView = layoutInflater.inflate(R.layout.local_devices, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.mTextView = (TextView) convertView.findViewById(R.id.code);
            viewHolder.mImageView = (ImageView) convertView.findViewById(R.id.connectIcon);
            convertView.setTag(viewHolder);
        }
        else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        ArrayList<ServerInfo> serverList = mConnectionFragment.getNetworkList();
        if(!serverList.isEmpty()) {
            ServerInfo serverInfo = serverList.get(position);
            viewHolder.mTextView.setText(serverInfo.getServerInfo() + " (" + serverInfo.getAddress() + ")");
            if(sConnectionAlive.get(serverInfo.getAddress())) {