Android Open Source - adventure-quest Level Up Dialog






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;
/* w w w  .j  a v  a2  s  .co  m*/
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.widget.TextView;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class LevelUpDialog extends DialogFragment {
  private static final String TAG = "LevelUpDialog";
  private static final int CHOICES = 5;

  private int mLevel;
  private TextView mMessage;

  public LevelUpDialog(int level) {
    mLevel = level;
  }

  @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    List<String> attributes = Arrays.asList(getResources().getStringArray(R.array.item_attributes));
    Collections.shuffle(attributes);
    final String[] choices = attributes.subList(0, CHOICES).toArray(new String[CHOICES]);

    Collections.sort(Arrays.asList(choices));

    builder.setTitle(getString(R.string.levelup_message))
           .setItems(choices, new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               Log.d(TAG, "chose " + choices[id]);
               ((TitleActivity) getDialog().getOwnerActivity()).addStat(choices[id]);
             }
           });

    return builder.create();
  }
}




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