Android Open Source - final_year_frontend Match Preferences Fragment






From Project

Back to project page final_year_frontend.

License

The source code is released under:

MIT License

If you think the Android project final_year_frontend 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 com.james.erebus.core;
//  w ww . ja va 2  s .  c  o m
import java.util.ArrayList;


import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;

/**
 * Class that controls data flow and what is on the filter Fragment that shows when pressing
 * the filter button on the {@link com.james.erebus.core.Match} activity screen
 * @author james
 *
 */

public class MatchPreferencesFragment extends ParentPreferencesFragment{
  
  private static ArrayList<TournyMatchOptions> selectedItems;
  
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    filterTitleNumber = com.james.erebus.R.string.match_filter_prefs;
    filterPrefsNumber = com.james.erebus.R.array.match_filter_preferences;
    
    mIsLargeLayout = getResources().getBoolean(com.james.erebus.R.bool.large_layout);
    ArrayList<TournyMatchOptions> items = MatchActivity.getSelectedItems();
    if(items != null)
      System.out.println("is items empty?:" + items.isEmpty());
    if(items == null || (items.isEmpty()))// Where we track the selected items
    {
      selectedItems = new ArrayList<TournyMatchOptions>();
      System.out.println("empty/null");
    }
    else
    {
      System.out.println("previous items");
      selectedItems = items;
      for(TournyMatchOptions o : selectedItems)
      {
        System.out.println("an object: " + o);
      }
      
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Set the dialog title
    builder.setTitle(com.james.erebus.R.string.match_filter_prefs)
    // Specify the list array, the items to be selected by default (null for none),
    // and the listener through which to receive callbacks when items are selected
        .setMultiChoiceItems(filterPrefsNumber, generateTickedBoxes(selectedItems),

        new DialogInterface.OnMultiChoiceClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which,
          boolean isChecked) {
        TournyMatchOptions mp = idToEnum(which);
        if (isChecked) {
          // If the user checked the item, add it to the selected items
          selectedItems.add(mp);
        } else  {
          
          ArrayList<TournyMatchOptions> selectedItemsCopy = new ArrayList<TournyMatchOptions> (selectedItems);
          // Else, if the item is already in the array, remove it 
          for(TournyMatchOptions tmo : selectedItems)
          {
            if (tmo.compareTo(mp) == 0)
              selectedItemsCopy.remove(mp);
          }
          selectedItems = selectedItemsCopy;
          
        }
      }
    })
    // Set the action buttons
    .setPositiveButton(com.james.erebus.R.string.ok, new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int id) {
        // User clicked OK, so save the mSelectedItems results somewhere
        // or return them to the component that opened the dialog
        Log.d("dialogLog", "pressed ok!");
        System.out.println("printing mListener:" + mListener);
        if(mListener == null)
          Log.d("nul1", "mlistener null");
        mListener.onDialogPositiveClick(MatchPreferencesFragment.this);
      }
    })
    .setNegativeButton(com.james.erebus.R.string.cancel, new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int id) {
        Log.d("dialogLog", "pressed cancel!");
        mListener.onDialogNegativeClick(MatchPreferencesFragment.this);
        //do nothing
      }
    });

    return builder.create();
  }
  
  /**
   * 
   * @return The selected items from the Fragment
   */
  public static ArrayList<TournyMatchOptions> getSelectedItems()
  {
    return selectedItems;
  }


}




Java Source Code List

com.james.erebus.GCMIntentService.java
com.james.erebus.JSONJava.CDL.java
com.james.erebus.JSONJava.CookieList.java
com.james.erebus.JSONJava.Cookie.java
com.james.erebus.JSONJava.HTTPTokener.java
com.james.erebus.JSONJava.HTTP.java
com.james.erebus.JSONJava.JSONArray.java
com.james.erebus.JSONJava.JSONException.java
com.james.erebus.JSONJava.JSONML.java
com.james.erebus.JSONJava.JSONObject.java
com.james.erebus.JSONJava.JSONString.java
com.james.erebus.JSONJava.JSONStringer.java
com.james.erebus.JSONJava.JSONTokener.java
com.james.erebus.JSONJava.JSONWriter.java
com.james.erebus.JSONJava.XMLTokener.java
com.james.erebus.JSONJava.XML.java
com.james.erebus.core.C2DMRegistrationReceiver.java
com.james.erebus.core.CustomOnItemSelectedListener.java
com.james.erebus.core.MainActivity.java
com.james.erebus.core.MatchActivity.java
com.james.erebus.core.MatchButtonActivity.java
com.james.erebus.core.MatchOptions.java
com.james.erebus.core.MatchPreferencesFragment.java
com.james.erebus.core.Match.java
com.james.erebus.core.NotificationActivity.java
com.james.erebus.core.Notification.java
com.james.erebus.core.ParentPreferencesFragment.java
com.james.erebus.core.TournamentActivity.java
com.james.erebus.core.TournamentButtonActivity.java
com.james.erebus.core.TournamentFactory.java
com.james.erebus.core.TournamentPreferencesFragment.java
com.james.erebus.core.Tournament.java
com.james.erebus.core.TournyMatchOptions.java
com.james.erebus.misc.AppConsts.java
com.james.erebus.misc.MiscJsonHelpers.java
com.james.erebus.misc.misc.java
com.james.erebus.networking.AddDeviceTask.java
com.james.erebus.networking.AddMatchSubscriptionTask.java
com.james.erebus.networking.AddTournamentSubscriptionToServerTask.java
com.james.erebus.networking.GcmRegisterDeviceTask.java
com.james.erebus.networking.GetMatchesTask.java
com.james.erebus.networking.GetTournamentsTask.java
com.james.erebus.networking.MatchRetriever.java
com.james.erebus.networking.MatchSubscriptionManager.java
com.james.erebus.networking.MiscNetworkingHelpers.java
com.james.erebus.networking.NotificationManager.java
com.james.erebus.networking.RemoveMatchSubscriptionFromServerTask.java
com.james.erebus.networking.RemoveTournamentSubscriptionFromServerTask.java
com.james.erebus.networking.Retriever.java
com.james.erebus.networking.SubscriptionManager.java
com.james.erebus.networking.SubscriptionRetriever.java
com.james.erebus.networking.TournamentRetriever.java
com.james.erebus.networking.TournamentSubscriptionManager.java