Android Open Source - EulerSolutions Solution Select Fragment






From Project

Back to project page EulerSolutions.

License

The source code is released under:

MIT License

If you think the Android project EulerSolutions 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.eulersolutions.controllers;
/* w ww.ja v  a 2 s.  c  o m*/
import com.eulersolutions.interfaces.ISelectionListener;
import com.eulersolutions.interfaces.ISolutionHandler;

import android.app.Activity;
import android.app.ListFragment;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class SolutionSelectFragment extends ListFragment {

  private static final String TAG = "EulerSolutions-SolutionSelectFragment";
  
  private ISelectionListener selectionCallback = null;
  private ISolutionHandler solutionCallback = null;
  private ArrayAdapter<String> adapter = null;
  
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    Log.i(TAG, "entered onCreate");
    super.onCreate(savedInstanceState);
    
    adapter = new ArrayAdapter<String>(this.getActivity(), 
        android.R.layout.simple_list_item_activated_1);
    if(solutionCallback != null)
    {
      adapter.addAll(solutionCallback.getSolutionTitles());
    }
    this.setListAdapter(adapter);
  }
  
  @Override
  public void onAttach(Activity activity)
  {
    Log.i(TAG, "entered onAttach");
    super.onAttach(activity);
    if((activity instanceof ISelectionListener) && (activity instanceof ISolutionHandler))
    {
      selectionCallback = (ISelectionListener) activity;
      solutionCallback = (ISolutionHandler) activity;
    }
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState)
  {
    Log.i(TAG, "entered onActivityCreated");
    super.onActivityCreated(savedInstanceState);
    this.getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  }
  
  @Override
  public void onListItemClick(ListView l, View view, int position, long id)
  {
    Log.i(TAG, "entered onListItemClicked");
    if(selectionCallback != null)
      selectionCallback.onItemSelected(position);
  }
}




Java Source Code List

com.eulersolutions.controllers.MainActivity.java
com.eulersolutions.controllers.ProblemPresentationActivity.java
com.eulersolutions.controllers.ProblemSelectArrayAdapter.java
com.eulersolutions.controllers.ProblemSolutionActivity.java
com.eulersolutions.controllers.SolutionDisplayFragment.java
com.eulersolutions.controllers.SolutionSelectFragment.java
com.eulersolutions.interfaces.ISelectionListener.java
com.eulersolutions.interfaces.ISolutionDisplay.java
com.eulersolutions.interfaces.ISolutionHandler.java
com.eulersolutions.model.CompletedProblems.java
com.eulersolutions.model.EvenFibonacciNmCalculator.java
com.eulersolutions.model.LargestPrimeFactorCalculator.java
com.eulersolutions.model.MultiplesABCalculator.java
com.eulersolutions.model.ProblemCalculator.java
com.eulersolutions.model.ProblemSummary.java