gt:         if (mMedicine != null) {
context: package es.usc.citius.servando.calendula.fragments;
  
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.app.ProgressDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.SharedPreferences;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.preference.PreferenceManager;
  import android.support.v4.app.Fragment;
  import android.text.Editable;
  import android.text.TextWatcher;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.inputmethod.InputMethodManager;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.AutoCompleteTextView;
  import android.widget.Filter;
  import android.widget.Filterable;
  import android.widget.HorizontalScrollView;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import es.usc.citius.servando.calendula.CalendulaApp;
  import es.usc.citius.servando.calendula.R;
  import es.usc.citius.servando.calendula.activities.MedicinesActivity;
  import es.usc.citius.servando.calendula.activities.ScheduleCreationActivity;
  import es.usc.citius.servando.calendula.persistence.Medicine;
  import es.usc.citius.servando.calendula.persistence.Prescription;
  import es.usc.citius.servando.calendula.persistence.Presentation;
  import es.usc.citius.servando.calendula.services.PopulatePrescriptionDBService;
  import es.usc.citius.servando.calendula.util.Snack;
  
  /**
   * Created by joseangel.pineiro on 12/4/13.
   */
  public class MedicineCreateOrEditFragment extends Fragment {
  
      OnMedicineEditListener mMedicineEditCallback;
      Medicine mMedicine;
      Prescription mPrescription;
  
      Boolean showConfirmButton = true;
      AutoCompleteTextView mNameTextView;
      TextView mPresentationTv;
      TextView mDescriptionTv;
      ImageView searchButton;
      //    Button mConfirmButton;
      Presentation selectedPresentation;
      HorizontalScrollView presentationScroll;
  
      boolean showcaseShown = false;
      boolean enableSearch = false;
      long mMedicineId;
      String cn;
  
      private static ArrayList<View> getViewsByTag(ViewGroup root, String tag) {
          ArrayList<View> views = new ArrayList<View>();
          final int childCount = root.getChildCount();
          for (int i = 0; i < childCount; i++) {
              final View child = root.getChildAt(i);
              if (child instanceof ViewGroup) {
                  views.addAll(getViewsByTag((ViewGroup) child, tag));
              }
  
              final Object tagObj = child.getTag();
              if (tagObj != null && tagObj.equals(tag)) {
                  views.add(child);
              }
  
          }
          return views;
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment_create_or_edit_medicine, container, false);
          //final String[] names = Medicine.findAllMedicineNames();
          //ArrayAdapter<Prescription> adapter = new AutoCompleteAdapter(getActivity(), R.layout.med_drop_down_item);
  
          SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
  
          mNameTextView = (AutoCompleteTextView) rootView.findViewById(R.id.medicine_edit_name);
          mPresentationTv = (TextView) rootView.findViewById(R.id.textView3);
          mDescriptionTv = (TextView) rootView.findViewById(R.id.medicine_edit_description);
          searchButton = (ImageView) rootView.findViewById(R.id.search_button);
          //mNameTextView.setAdapter(adapter);
          mNameTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView<?> parent, View arg1, int pos, long id) {
                  Prescription p = (Prescription) parent.getItemAtPosition(pos);
                  String shortName = p.shortName();
                  mNameTextView.setText(shortName);
                  mDescriptionTv.setText(p.name);
                  hideKeyboard();
  
                  // save referenced prescription to med
                  cn = p.cn;
  
                  // selectPresentation(mMedicine != null ? mMedicine.presentation() : null);
              }
          });
  
          enableSearch = prefs.getBoolean("enable_prescriptions_db", false);
  
          if (enableSearch) {
              enableSearchButton();
          } else {
              searchButton.setVisibility(View.GONE);
          }
  
          presentationScroll = (HorizontalScrollView) rootView.findViewById(R.id.med_presentation_scroll);
  //        mConfirmButton = (Button) rootView.findViewById(R.id.medicine_button_ok);
  //        if (showConfirmButton) {
  //            mConfirmButton.setText(getString(mMedicine == null ? R.string.create_medicine_button_text : R.string.edit_medicine_button_text));
  //            mConfirmButton.setOnClickListener(new View.OnClickListener() {
  //                @Override
  //                public void onClick(View view) {
  //                    onEdit();
  //                }
  //            });
  //        } else {
  //            mConfirmButton.setVisibility(View.GONE);
  //        }
  
          Log.d(getTag(), "Arguments:  " + (getArguments() != null) + ", savedState: " + (savedInstanceState != null));
          if (getArguments() != null) {
  
              mMedicineId = getArguments().getLong(CalendulaApp.INTENT_EXTRA_MEDICINE_ID, -1);
          }
  
          if (mMedicineId == -1 && savedInstanceState != null) {
              mMedicineId = savedInstanceState.getLong(CalendulaApp.INTENT_EXTRA_MEDICINE_ID, -1);
          }
  
          if (mMedicineId != -1) {
              mMedicine = Medicine.findById(mMedicineId);
  //            mConfirmButton.setText(getString(R.string.edit_routine_button_text));
          }
  
          setupMedPresentationChooser(rootView);
  
          mNameTextView.addTextChangedListener(new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence s, int start, int before, int count) {
  
              }
  
              @Override
              public void afterTextChanged(Editable s) {
                  String name = mNameTextView.getText().toString();
  
                  if (mPrescription != null && !mPrescription.shortName().toLowerCase().equals(name.toLowerCase())) {
                      mPrescription = null;
                      mDescriptionTv.setText("");
                  }
  
              }
          });
          mNameTextView.requestFocus();
          askForPrescriptionUsage();
          return rootView;
      }
  
      private void enableSearchButton() {
          searchButton.setVisibility(View.VISIBLE);
          searchButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Editable editable = mNameTextView.getText();
                  ((MedicinesActivity) getActivity()).showSearchView(editable != null ? editable.toString() : null);
              }
          });
      }
  
      public void showDeleteConfirmationDialog(final Medicine m) {
          AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
          // "Remove " + m.name() + "?"
          builder.setMessage(String.format(getString(R.string.remove_medicine_message_short), m.name()))
                  .setCancelable(true)
                  .setPositiveButton(getString(R.string.dialog_yes_option), new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int id) {
                          if (mMedicineEditCallback != null)
                              mMedicineEditCallback.onMedicineDeleted(m);
                      }
                  })
                  .setNegativeButton(getString(R.string.dialog_no_option), new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int id) {
                          dialog.cancel();
                      }
                  });
          AlertDialog alert = builder.create();
          alert.show();
      }
  
      @Override
      public void onViewCreated(View view, Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
  