Android Open Source - adventure-quest Profile Fragment






From Project

Back to project page adventure-quest.

License

The source code is released under:

Copyright ? 2012 Alan Berndt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softwar...

If you think the Android project adventure-quest listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.honeybadgerlabs.adventurequest;
/*from  ww  w. j a v a 2 s . c  o m*/
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.TextView;

public class ProfileFragment extends Fragment {
  private GridView listView;
  private TextView button;
  private StatAdapter adapter;

  @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.profile, container, false);

    listView = (GridView) view.findViewById(R.id.attribute_list);
    button = (TextView) view.findViewById(R.id.spend_points);

    return view;
  }

  @Override public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    adapter = ((TitleActivity) getActivity()).getStatAdapter();
    listView.setAdapter(adapter);
  }

  @Override public void onResume() {
    super.onResume();

    updateButton();
  }

  public void updateButton() {
    TitleActivity activity = (TitleActivity) getActivity();

    if (activity != null) {
      int points = ((TitleActivity) getActivity()).getCharLevel() - adapter.totalPoints() - 1;

      if (points > 0) {
        String message = getResources().getQuantityString(R.plurals.points, points, points);
        button.setText(message);
        button.setVisibility(View.VISIBLE);
      } else {
        button.setVisibility(View.GONE);
      }
    }
  }
}




Java Source Code List

net.honeybadgerlabs.adventurequest.CompleteReceiver.java
net.honeybadgerlabs.adventurequest.CurrentFragment.java
net.honeybadgerlabs.adventurequest.HistoryFragment.java
net.honeybadgerlabs.adventurequest.LevelUpDialog.java
net.honeybadgerlabs.adventurequest.PagerAdapter.java
net.honeybadgerlabs.adventurequest.ProfileFragment.java
net.honeybadgerlabs.adventurequest.QuestAdapter.java
net.honeybadgerlabs.adventurequest.Quest.java
net.honeybadgerlabs.adventurequest.StatAdapter.java
net.honeybadgerlabs.adventurequest.Stat.java
net.honeybadgerlabs.adventurequest.TitleActivity.java