public View getView(int position, View convertView, ViewGroup parent) { View vi = convertView; if (convertView == null) vi = inflater.inflate(R.layout.droplet_list_row, null); final Droplet droplet = data.get(position); Region region = droplet.getRegion(); Image image = droplet.getImage(); TextView nameTextView = (TextView) vi.findViewById(R.id.nameTextView); TextView ipAddressTextView = (TextView) vi.findViewById(R.id.ipAddressTextView); TextView statusTextView = (TextView) vi.findViewById(R.id.statusTextView); ImageView distroImageView = (ImageView) vi.findViewById(R.id.distroImageView); ImageView flagImageView = (ImageView) vi.findViewById(R.id.flagImageView); if (region != null) flagImageView.setImageResource(ApiHelper.getLocationFlag(region.getName())); else flagImageView.setVisibility(View.GONE); if (image != null) distroImageView.setImageResource( ApiHelper.getDistributionLogo(image.getDistribution(), droplet.getStatus())); nameTextView.setText(droplet.getName()); ipAddressTextView.setText(droplet.getIpAddress()); statusTextView.setText(droplet.getStatus()); return vi; }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_save_account) { Account account = new Account(); account.setName(accountNameEditText.getText().toString()); account.setToken(tokenEditText.getText().toString()); account.setExpiresIn(expiresIn.getTime()); account.setRefreshToken(refreshToken); account.setSelected(true); ApiHelper.selectAccount(this, account); startActivity(new Intent(this, MainActivity.class)); finish(); return true; } else if (item.getItemId() == android.R.id.home) { NavUtils.navigateUpFromSameTask(this); return true; } return false; }