Back to project page eve-datapad.
The source code is released under:
GNU General Public License
If you think the Android project eve-datapad listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.pocketcircuit.evedatapad; /*from w w w .j a va 2s . c o m*/ import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.text.format.DateUtils; import android.view.Menu; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import java.util.ArrayList; import java.util.Date; public class CharacterList extends Activity { private ArrayList<Character> mCharacters; private ImageView mCharacterAvatar; private TextView mCharacterNameText; private TextView mCharacterTrainingQueueValue; private TextView mCharacterWealthValue; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.character_list); mCharacters = Account.get(CharacterList.this).getCharacters(); for(Character character : mCharacters ) { fillFields(character); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.character_list, menu); return true; } private void fillFields(Character passedCharacter) { RelativeLayout mCharacterListItem = (RelativeLayout) findViewById( R.id.character ); mCharacterAvatar = (ImageView) findViewById( R.id.characterAvatar ); mCharacterNameText = (TextView) findViewById( R.id.characterName ); mCharacterTrainingQueueValue = (TextView) findViewById( R.id.trainingQueueValue ); mCharacterWealthValue = (TextView) findViewById( R.id.wealthValue ); Character current = passedCharacter; String currentWalletBalance = "$" + String.format("%1$,.2f", current.getWalletBalance()); int currentAvatar = getResources().getIdentifier(current.getAvatarResource(), "id", getPackageName()); mCharacterListItem.setId(current.getId()); mCharacterListItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent toNavigate = new Intent(CharacterList.this, CharacterDetail.class); toNavigate.putExtra("characterId", 1); startActivity(toNavigate); } }); mCharacterAvatar.setImageResource(currentAvatar); mCharacterNameText.setText(current.getName()); mCharacterTrainingQueueValue.setText(getSkillExpir(current)); mCharacterWealthValue.setText(currentWalletBalance); } private String getSkillExpir(Character current) { Integer currentTrainingTime = 0; for (Skill skill : current.getSkillQueue()) { currentTrainingTime += skill.getTimeRemaining(); } Long currentTrainingTimeMillSec = (currentTrainingTime * 60L * 1000L); Date today = new Date(); Date expir = new Date(today.getTime() + currentTrainingTimeMillSec); String displayTimeRemaining = DateUtils.getRelativeTimeSpanString(expir.getTime(), today.getTime(), DateUtils.SECOND_IN_MILLIS).toString(); return displayTimeRemaining; } }