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; /*w w w . j a v a 2s.c om*/ import android.app.Activity; import android.os.Bundle; import android.text.format.DateUtils; import android.view.Menu; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import java.util.ArrayList; import java.util.Date; public class CharacterDetail 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_detail); getActionBar().setDisplayHomeAsUpEnabled(true); mCharacters = Account.get(CharacterDetail.this).getCharacters(); assignFillableFields(); fillFields(mCharacters.get(0)); createSkillList(mCharacters.get(0)); } @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_detail, menu); return true; } private void assignFillableFields() { mCharacterAvatar = (ImageView) findViewById( R.id.characterAvatar ); mCharacterNameText = (TextView) findViewById( R.id.characterName ); mCharacterTrainingQueueValue = (TextView) findViewById( R.id.trainingQueueValue ); mCharacterWealthValue = (TextView) findViewById( R.id.wealthValue ); } private void fillFields(Character current) { String currentWalletBalance = "$" + String.format("%1$,.2f", current.getWalletBalance()); int currentAvatar = getResources().getIdentifier(current.getAvatarResource(), "id", getPackageName()); mCharacterAvatar.setImageResource(currentAvatar); mCharacterNameText.setText(current.getName()); mCharacterTrainingQueueValue.setText(getSkillExpir(current)); mCharacterWealthValue.setText(currentWalletBalance); } private void createSkillList(Character current) { ListView mCharacterSkillList = (ListView) findViewById( R.id.skillList ); ArrayList<String> passedArray = new ArrayList<String>(); for(Skill mSkill : current.getSkillQueue()) { passedArray.add(mSkill.getName()); } ArrayAdapter skills = new ArrayAdapter(this, android.R.layout.simple_list_item_1, passedArray); mCharacterSkillList.setAdapter(skills); } 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; } }