Package com.gwesm.presenters

Source Code of com.gwesm.presenters.AccountPresenter

package com.gwesm.presenters;

import java.util.ArrayList;
import java.util.List;

import com.gwesm.core.Account;
import com.gwesm.core.Character;
import com.gwesm.core.GWESM;
import com.gwesm.mvp.Presenter;

public class AccountPresenter extends Presenter {

  GWESM gwesm;

  Account account;

  public AccountPresenter(final GWESM gwesm, final Account account) {
    this.gwesm = gwesm;
    this.account = account;
  }

  public void setAccount(final Account account) {
    this.account = account;
    refresh();
  }

  public String getAccountName() {
    return this.account.getName();
  }

  public List<CharacterPresenter> getCharacterPresenters() {
    List<CharacterPresenter> presenters = new ArrayList<CharacterPresenter>();
    for (Character characters : this.account.getCharacters()) {
      presenters.add(new CharacterPresenter(this.gwesm, characters));
    }
    return presenters;
  }

  public String[] getAccountsName() { // XXX

    List<Account> accounts = this.gwesm.getAccounts();
    String[] accountsName = new String[accounts.size()];
    int i = 0;
    for (Account account : accounts) {
      accountsName[i] = account.getName();
      i++;
    }
    return accountsName;
  }

  public void createAccount(final String name) {
    Account newAccount = new Account(name);
    this.gwesm.addAccount(newAccount);
    refresh();
  }

}
TOP

Related Classes of com.gwesm.presenters.AccountPresenter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.