This source file includes following definitions.
- getView
package org.chromium.chromoting;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
class HostListAdapter extends ArrayAdapter<HostInfo> {
private static final String HOST_COLOR_ONLINE = "green";
private static final String HOST_COLOR_OFFLINE = "red";
private Chromoting mChromoting;
public HostListAdapter(Chromoting chromoting, int textViewResourceId, HostInfo[] hosts) {
super(chromoting, textViewResourceId, hosts);
mChromoting = chromoting;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView target = (TextView)super.getView(position, convertView, parent);
final HostInfo host = getItem(position);
target.setText(host.name);
target.setCompoundDrawablesWithIntrinsicBounds(
host.isOnline ? R.drawable.icon_host : R.drawable.icon_host_offline, 0, 0, 0);
if (host.isOnline) {
target.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mChromoting.connectToHost(host);
}
});
} else {
target.setTextColor(mChromoting.getResources().getColor(R.color.host_offline_text));
target.setBackgroundResource(R.drawable.list_item_disabled_selector);
target.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mChromoting,
mChromoting.getString(R.string.host_offline_tooltip),
Toast.LENGTH_SHORT).show();
}
});
}
return target;
}
}