package hm.edu.pulsebuddy;

import android.os.Bundle;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

/**
 * A dummy fragment representing a section of the app, but that simply displays
 * dummy text.
 */
public class SportTestResultFragment extends Fragment implements
    View.OnClickListener
{
  /**
   * The fragment argument representing the section number for this fragment.
   */
  public static final String ARG_SECTION_NUMBER = "section_number";
  private View view;

  public SportTestResultFragment()
  {
  }

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

    Button buttonAgain = (Button) view.findViewById( R.id.buttonAgain );
    buttonAgain.setOnClickListener( this );
    Button buttonSave = (Button) view.findViewById( R.id.buttonSave );
    buttonSave.setOnClickListener( this );

    // TODO @Team: Methode um Sport Test abzubrechen wenn Läufer nicht mehr
    // kann. Anschließend wert in DB schrieben

    return view;
  }

  @Override
  public void onClick( View view )
  {
    switch ( view.getId() )
    {
      case R.id.buttonAgain:
        Intent intent = new Intent( getActivity(), SportModeActivity.class );
        startActivity( intent );
        break;
      case R.id.buttonSave:
        saveSportTestResult();
        break;
      default:
    }

  }

  private void saveSportTestResult()
  {
    // TODO @Tore save value in DB

    // customToast( getResources().getString( R.string.common_saved_values ) );

  }

  // /**
  // * Notifies the user that the data has been stored in the database.
  // *
  // * @param text
  // * The message.
  // */
  // private void customToast( String text )
  // {
  //
  // LayoutInflater inflater = getLayoutInflater();
  // View layout = inflater.inflate( R.layout.custom_toast,
  // (ViewGroup) findViewById( R.id.toast_layout ) );
  //
  // TextView textV = (TextView) layout.findViewById( R.id.toastText );
  // textV.setText( text );
  //
  // Toast toast = new Toast( getApplicationContext() );
  // toast.setDuration( Toast.LENGTH_LONG );
  // toast.setView( layout );
  // toast.show();
  // }

}

@@ -240,16 +240,77 @@
 .Button;
+%0Aimport android.widget.TextView;%0Aimport android.widget.Toast;
 %0A%0A/**%0A *
@@ -676,16 +676,39 @@
 ew view;
+%0A  private View layout;
 %0A%0A  publ
@@ -960,24 +960,141 @@
   false );%0A%0A
+    layout = inflater.inflate( R.layout.custom_toast,%0A        (ViewGroup) view.findViewById( R.id.toast_layout ) );%0A%0A
     Button b
@@ -1880,19 +1880,16 @@
  DB%0A%0A   
- //
  customT
@@ -1965,20 +1965,15 @@
 %7D%0A%0A 
- //
  /**%0A  
-//
  * N
@@ -2042,17 +2042,14 @@
 .%0A  
-//
  *
+ 
 %0A  
-//
  * @
@@ -2061,20 +2061,27 @@
  text%0A  
-//
  *
+         
  The mes
@@ -2092,18 +2092,13 @@
 .%0A  
-//
  */%0A 
- //
  pri
@@ -2139,194 +2139,14 @@
  )%0A 
- //
  %7B%0A  
-//%0A  // LayoutInflater inflater = getLayoutInflater();%0A  // View layout = inflater.inflate( R.layout.custom_toast,%0A  // (ViewGroup) findViewById( R.id.toast_layout ) );%0A  //%0A  //
+ 
  Tex
@@ -2211,18 +2211,17 @@
 xt );%0A  
-//
+ 
  textV.s
@@ -2240,17 +2240,12 @@
  );%0A
+%0A
   
-//%0A  //
+ 
  Toa
@@ -2274,33 +2274,23 @@
 getA
-pplicationContext
+ctivity
 () );%0A  
 // t
@@ -2281,26 +2281,25 @@
 vity() );%0A  
-//
+ 
  toast.setDu
@@ -2325,26 +2325,25 @@
 H_LONG );%0A  
-//
+ 
  toast.setVi
@@ -2358,18 +2358,17 @@
 ut );%0A  
-//
+ 
  toast.s
@@ -2375,17 +2375,14 @@
 how();%0A 
- //
  %7D%0A%0A%7D%0A

Add custom toast to sport test.