private void showProxyFields() {
    WifiConfiguration config = null;

    mView.findViewById(R.id.proxy_settings_fields).setVisibility(View.VISIBLE);

    if (mAccessPoint != null && mAccessPoint.networkId != INVALID_NETWORK_ID) {
      config = mAccessPoint.getConfig();
    }

    if (mProxySettingsSpinner.getSelectedItemPosition() == PROXY_STATIC) {
      mView.findViewById(R.id.proxy_warning_limited_support).setVisibility(View.VISIBLE);
      mView.findViewById(R.id.proxy_fields).setVisibility(View.VISIBLE);
      if (mProxyHostView == null) {
        mProxyHostView = (TextView) mView.findViewById(R.id.proxy_hostname);
        mProxyHostView.addTextChangedListener(this);
        mProxyPortView = (TextView) mView.findViewById(R.id.proxy_port);
        mProxyPortView.addTextChangedListener(this);
        mProxyExclusionListView = (TextView) mView.findViewById(R.id.proxy_exclusionlist);
        mProxyExclusionListView.addTextChangedListener(this);
      }
      if (config != null) {
        ProxyProperties proxyProperties = config.linkProperties.getHttpProxy();
        if (proxyProperties != null) {
          mProxyHostView.setText(proxyProperties.getHost());
          mProxyPortView.setText(Integer.toString(proxyProperties.getPort()));
          mProxyExclusionListView.setText(proxyProperties.getExclusionList());
        }
      }
    } else {
      mView.findViewById(R.id.proxy_warning_limited_support).setVisibility(View.GONE);
      mView.findViewById(R.id.proxy_fields).setVisibility(View.GONE);
    }
  }
  @Override
  protected void onFinishInflate() {
    mLockPatternUtils = new LockPatternUtils(mContext);

    mPasswordEntry = (TextView) findViewById(getPasswordTextViewId());
    mPasswordEntry.setOnEditorActionListener(this);
    mPasswordEntry.addTextChangedListener(this);

    // Set selected property on so the view can send accessibility events.
    mPasswordEntry.setSelected(true);

    // Poke the wakelock any time the text is selected or modified
    mPasswordEntry.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            mCallback.userActivity(0); // TODO: customize timeout for text?
          }
        });

    mQuickUnlock =
        (Settings.System.getInt(
                mContext.getContentResolver(), Settings.System.LOCKSCREEN_QUICK_UNLOCK_CONTROL, 0)
            == 1);

    mPasswordEntry.addTextChangedListener(
        new TextWatcher() {
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          public void afterTextChanged(Editable s) {
            if (mCallback != null) {
              mCallback.userActivity(0);
            }
            if (mQuickUnlock) {
              String entry = mPasswordEntry.getText().toString();
              if (entry.length() > MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT
                  && mLockPatternUtils.checkPassword(entry)) {
                mCallback.reportSuccessfulUnlockAttempt();
                mCallback.dismiss(true);
              }
            }
          }
        });
    mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
    mEcaView = findViewById(R.id.keyguard_selector_fade_container);
    View bouncerFrameView = findViewById(R.id.keyguard_bouncer_frame);
    if (bouncerFrameView != null) {
      mBouncerFrame =
          KeyguardSecurityViewHelper.colorizeFrame(mContext, bouncerFrameView.getBackground());
    }
  }
  private void showIpConfigFields() {
    WifiConfiguration config = null;

    mView.findViewById(R.id.ip_fields).setVisibility(View.VISIBLE);

    if (mAccessPoint != null && mAccessPoint.networkId != INVALID_NETWORK_ID) {
      config = mAccessPoint.getConfig();
    }

    if (mIpSettingsSpinner.getSelectedItemPosition() == STATIC_IP) {
      mView.findViewById(R.id.staticip).setVisibility(View.VISIBLE);
      if (mIpAddressView == null) {
        mIpAddressView = (TextView) mView.findViewById(R.id.ipaddress);
        mIpAddressView.addTextChangedListener(this);
        mGatewayView = (TextView) mView.findViewById(R.id.gateway);
        mGatewayView.addTextChangedListener(this);
        mNetworkPrefixLengthView = (TextView) mView.findViewById(R.id.network_prefix_length);
        mNetworkPrefixLengthView.addTextChangedListener(this);
        mDns1View = (TextView) mView.findViewById(R.id.dns1);
        mDns1View.addTextChangedListener(this);
        mDns2View = (TextView) mView.findViewById(R.id.dns2);
        mDns2View.addTextChangedListener(this);
      }
      if (config != null) {
        LinkProperties linkProperties = config.linkProperties;
        Iterator<LinkAddress> iterator = linkProperties.getLinkAddresses().iterator();
        if (iterator.hasNext()) {
          LinkAddress linkAddress = iterator.next();
          mIpAddressView.setText(linkAddress.getAddress().getHostAddress());
          mNetworkPrefixLengthView.setText(Integer.toString(linkAddress.getNetworkPrefixLength()));
        }

        for (RouteInfo route : linkProperties.getRoutes()) {
          if (route.isDefaultRoute()) {
            mGatewayView.setText(route.getGateway().getHostAddress());
            break;
          }
        }

        Iterator<InetAddress> dnsIterator = linkProperties.getDnses().iterator();
        if (dnsIterator.hasNext()) {
          mDns1View.setText(dnsIterator.next().getHostAddress());
        }
        if (dnsIterator.hasNext()) {
          mDns2View.setText(dnsIterator.next().getHostAddress());
        }
      }
    } else {
      mView.findViewById(R.id.staticip).setVisibility(View.GONE);
    }
  }
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
          // TODO Auto-generated method stub
          if (txtDni.getText() != null) {
            txtCodigo.removeTextChangedListener(txtCodigoTextWatcher);
            txtRuc.removeTextChangedListener(txtRucTextWatcher);

            txtCodigo.setText(null);
            txtRuc.setText(null);

            txtCodigo.addTextChangedListener(txtCodigoTextWatcher);
            txtRuc.addTextChangedListener(txtRucTextWatcher);
          }
        }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    setContentView(R.layout.ficha_consultar_cliente_activity);

    mActionBar.setTitle(titulo);
    mActionBar.setSubTitle(subtitulo);
    mActionBar.setHomeLogo(R.drawable.header_logo);
    txtCodigo.addTextChangedListener(txtCodigoTextWatcher);
    txtRuc.addTextChangedListener(txtRucTextWatcher);
    txtDni.addTextChangedListener(txtDniTextWatcher);
  }
  /** Inflate the layout for this fragment */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.encrypt_text_fragment, container, false);

    TextView textView = (TextView) view.findViewById(R.id.encrypt_text_text);
    textView.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) {
            mMessage = s.toString();
          }
        });

    // set initial text
    if (mMessage != null) {
      textView.setText(mMessage);
    }

    return view;
  }
  /**
   * Applies a Typeface to a TextView, if deferred,its recommend you don't call this multiple times,
   * as this adds a TextWatcher.
   *
   * <p>Deferring should really only be used on tricky views which get Typeface set by the system at
   * weird times.
   *
   * @param textView Not null, TextView or child of.
   * @param typeface Not null, Typeface to apply to the TextView.
   * @param deferred If true we use Typefaces and TextChange listener to make sure font is always
   *     applied, but this sometimes conflicts with other {@link android.text.Spannable}'s.
   * @return true if applied otherwise false.
   * @see #applyFontToTextView(android.widget.TextView, android.graphics.Typeface)
   */
  public static boolean applyFontToTextView(
      final TextView textView, final Typeface typeface, boolean deferred) {
    if (textView == null || typeface == null) return false;
    textView.setPaintFlags(
        textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    textView.setTypeface(typeface);
    if (deferred) {
      textView.setText(
          applyTypefaceSpan(textView.getText(), typeface), TextView.BufferType.SPANNABLE);
      textView.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) {
              applyTypefaceSpan(s, typeface);
            }
          });
    }
    return true;
  }
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View root = inflater.inflate(R.layout.fragment_course_detail, container, false);

    mCourseTitle = (TextView) root.findViewById(R.id.fragment_course_name_text_view);
    mCourseImage = (ImageView) root.findViewById(R.id.fragment_course_photo_image_view);
    mCourseAllergens = (TextView) root.findViewById(R.id.fragment_course_allergens_text_view);
    mCourseDescription = (TextView) root.findViewById(R.id.fragment_course_description_text_view);
    mCourseNotes = (TextView) root.findViewById(R.id.fragment_course_notes_edit_text);

    // Allergens images
    mCoursePeanutsImage = (ImageView) root.findViewById(R.id.fragment_course_has_peanuts);
    mCourseMustardImage = (ImageView) root.findViewById(R.id.fragment_course_has_mustard);
    mCourseGlutenImage = (ImageView) root.findViewById(R.id.fragment_course_has_gluten);
    mCourseFishImage = (ImageView) root.findViewById(R.id.fragment_course_has_fish);
    mCourseShellfishImage = (ImageView) root.findViewById(R.id.fragment_course_has_shellfish);
    mCourseEggImage = (ImageView) root.findViewById(R.id.fragment_course_has_egg);
    mCourseMilkImage = (ImageView) root.findViewById(R.id.fragment_course_has_milk);

    // Set allergens vissible (if needed)
    setAllergensVisibility();

    mCourseTitle.setText(mCourse.getName());
    mCourseAllergens.setText(mCourse.getAllergensString());
    mCourseDescription.setText(mCourse.getDescription());
    mCourseNotes.setText(mCourse.getNotes());

    mCourseNotes.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) {
            // TODO: avisar a la activity para que actualice el mCourse
            if (mOnCourseNotesChangedListener != null
                && mOnCourseNotesChangedListener.get() != null) {
              mCourse.setNotes(mCourseNotes.getText().toString());
              mOnCourseNotesChangedListener.get().onCourseNotesChanged(mCourse);
            }
          }
        });

    ImageDownloader.ImageDownloaderParams params =
        new ImageDownloader.ImageDownloaderParams(mCourse.getPhotoUrl(), mCourse.getPhoto());
    ImageDownloader imageDownloader =
        new ImageDownloader(getActivity(), mCourseImage, R.drawable.icon_course);
    imageDownloader.execute(params);

    return root;
  }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mNameView.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void afterTextChanged(Editable editable) {
            mPage
                .getData()
                .putString(
                    CustomerInfoPage.NAME_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
          }
        });

    mEmailView.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void afterTextChanged(Editable editable) {
            mPage
                .getData()
                .putString(
                    CustomerInfoPage.EMAIL_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
          }
        });
  }
Beispiel #10
0
  public void resetSaveButton() {
    et_username.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            btnSave.setProgress(0);
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });
    et_email.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            btnSave.setProgress(0);
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });
    et_address.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            btnSave.setProgress(0);
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });
    et_password.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            btnSave.setProgress(0);
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActivityUtils.setLayout(this, R.layout.activity_starting_point, R.layout.title_bar);

    mProgressBar = (ProgressBar) findViewById(R.id.dictionary_progressBar);

    mTopBarEditText = (TextView) findViewById(R.id.topbar_editText);
    mTopBarEditText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

          @Override
          public void afterTextChanged(Editable editable) {
            mProgressBar.setVisibility(View.VISIBLE);
            mProgressBar.bringToFront();
            new PopulateListView().execute(editable.toString());
          }
        });
    mProgressBar.setVisibility(View.VISIBLE);
    mProgressBar.bringToFront();
    new PopulateListView().execute();

    LinearLayout ll =
        (LinearLayout) findViewById(R.id.titlebar_linearlayout_tap_to_change_directions);
    ll.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            ImageView iv = (ImageView) findViewById(R.id.titlebar_arrow_tap_to_change_directions);
            TextView silesianTextView = (TextView) findViewById(R.id.titlebar_silesian_textView);
            TextView polishTextView = (TextView) findViewById(R.id.titlebar_polish_textView);
            if (isSilesianToPolish) {
              isSilesianToPolish = false;
              //
              // iv.setImageDrawable(getResources().getDrawable(R.drawable.left_arrow));
              silesianTextView.setText(R.string.to_silesian);
              polishTextView.setText(R.string.from_polish);
            } else {
              isSilesianToPolish = true;
              //
              // iv.setImageDrawable(getResources().getDrawable(R.drawable.right_arrow));
              silesianTextView.setText(R.string.from_silesian);
              polishTextView.setText(R.string.to_polish);
            }
            new PopulateListView().execute();
            mTopBarEditText.setText("");
          }
        });
  }
  private void showSecurityFields() {
    if (mInXlSetupWizard) {
      // Note: XL SetupWizard won't hide "EAP" settings here.
      if (!((WifiSettingsForSetupWizardXL) mConfigUi.getContext())
          .initSecurityFields(mView, mAccessPointSecurity)) {
        return;
      }
    }
    if (mAccessPointSecurity == AccessPoint.SECURITY_NONE) {
      mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
      return;
    }
    mView.findViewById(R.id.security_fields).setVisibility(View.VISIBLE);

    if (mPasswordView == null) {
      mPasswordView = (TextView) mView.findViewById(R.id.password);
      mPasswordView.addTextChangedListener(this);
      ((CheckBox) mView.findViewById(R.id.show_password)).setOnClickListener(this);

      if (mAccessPoint != null && mAccessPoint.networkId != INVALID_NETWORK_ID) {
        mPasswordView.setHint(R.string.wifi_unchanged);
      }
    }

    if (mAccessPointSecurity != AccessPoint.SECURITY_EAP) {
      mView.findViewById(R.id.eap).setVisibility(View.GONE);
      return;
    }
    mView.findViewById(R.id.eap).setVisibility(View.VISIBLE);

    if (mEapMethodSpinner == null) {
      mEapMethodSpinner = (Spinner) mView.findViewById(R.id.method);
      mPhase2Spinner = (Spinner) mView.findViewById(R.id.phase2);
      mEapCaCertSpinner = (Spinner) mView.findViewById(R.id.ca_cert);
      mEapUserCertSpinner = (Spinner) mView.findViewById(R.id.user_cert);
      mEapIdentityView = (TextView) mView.findViewById(R.id.identity);
      mEapAnonymousView = (TextView) mView.findViewById(R.id.anonymous);

      loadCertificates(mEapCaCertSpinner, Credentials.CA_CERTIFICATE);
      loadCertificates(mEapUserCertSpinner, Credentials.USER_PRIVATE_KEY);

      if (mAccessPoint != null && mAccessPoint.networkId != INVALID_NETWORK_ID) {
        WifiConfiguration config = mAccessPoint.getConfig();
        setSelection(mEapMethodSpinner, config.eap.value());
        setSelection(mPhase2Spinner, config.phase2.value());
        setCertificate(mEapCaCertSpinner, Credentials.CA_CERTIFICATE, config.ca_cert.value());
        setCertificate(
            mEapUserCertSpinner, Credentials.USER_PRIVATE_KEY, config.private_key.value());
        mEapIdentityView.setText(config.identity.value());
        mEapAnonymousView.setText(config.anonymous_identity.value());
      }
    }
  }
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_calculator_decimal, container, false);

    // Text views for displaying users input and results
    txtInput = (TextView) getActivity().findViewById(R.id.textViewInput);
    txtResult = (TextView) getActivity().findViewById(R.id.textViewResult);
    txtInput.addTextChangedListener(this);

    // Make results view scrollable
    txtResult.setMovementMethod(new ScrollingMovementMethod());

    // Setting button listeners for calculators Buttons
    nineButton = (Button) view.findViewById(R.id.buttonNine);
    nineButton.setOnClickListener(this);
    eightButton = (Button) view.findViewById(R.id.buttonEight);
    eightButton.setOnClickListener(this);
    sevenButton = (Button) view.findViewById(R.id.buttonSeven);
    sevenButton.setOnClickListener(this);
    sixButton = (Button) view.findViewById(R.id.buttonSix);
    sixButton.setOnClickListener(this);
    fiveButton = (Button) view.findViewById(R.id.buttonFive);
    fiveButton.setOnClickListener(this);
    fourButton = (Button) view.findViewById(R.id.buttonFour);
    fourButton.setOnClickListener(this);
    threeButton = (Button) view.findViewById(R.id.buttonThree);
    threeButton.setOnClickListener(this);
    twoButton = (Button) view.findViewById(R.id.buttonTwo);
    twoButton.setOnClickListener(this);
    oneButton = (Button) view.findViewById(R.id.buttonOne);
    oneButton.setOnClickListener(this);
    zeroButton = (Button) view.findViewById(R.id.buttonZero);
    zeroButton.setOnClickListener(this);
    minusButton = (Button) view.findViewById(R.id.buttonMinus);
    minusButton.setOnClickListener(this);
    plusButton = (Button) view.findViewById(R.id.buttonPlus);
    plusButton.setOnClickListener(this);
    divideButton = (Button) view.findViewById(R.id.buttonDivide);
    divideButton.setOnClickListener(this);
    multiplyButton = (Button) view.findViewById(R.id.buttonMultiply);
    multiplyButton.setOnClickListener(this);
    pointButton = (Button) view.findViewById(R.id.buttonPoint);
    pointButton.setOnClickListener(this);
    deleteButton = (Button) view.findViewById(R.id.buttonDelete);
    deleteButton.setOnClickListener(this);
    clearButton = (Button) view.findViewById(R.id.buttonClear);
    clearButton.setOnClickListener(this);

    return view;
  }
  private void setFlashAnimationToTextView(final TextView textView) {

    textView.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            textView.startAnimation(zoom_in);
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
  /** Set the enabled state of automatically resizing text. */
  public AutofitHelper setEnabled(boolean enabled) {
    if (mEnabled != enabled) {
      mEnabled = enabled;

      if (enabled) {
        mTextView.addTextChangedListener(mTextWatcher);
        mTextView.addOnLayoutChangeListener(mOnLayoutChangeListener);

        autofit();
      } else {
        mTextView.removeTextChangedListener(mTextWatcher);
        mTextView.removeOnLayoutChangeListener(mOnLayoutChangeListener);

        mTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
      }
    }
    return this;
  }
Beispiel #16
0
  private void initView(Context context) {
    // Scroll View
    LayoutParams sv1lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    sv1lp.gravity = Gravity.CENTER_HORIZONTAL;
    mScrollView = new ScrollView(context);

    // Scroll View 1 - Text Field
    mTextField = (TextView) getChildAt(0);
    removeView(mTextField);

    mScrollView.addView(
        mTextField, new ScrollView.LayoutParams(TEXTVIEW_VIRTUAL_WIDTH, LayoutParams.WRAP_CONTENT));

    mTextField.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

          @Override
          public void afterTextChanged(Editable editable) {
            final boolean continueAnimation = mStarted;

            reset();
            prepareAnimation();

            cutTextView();

            post(
                new Runnable() {
                  @Override
                  public void run() {
                    if (continueAnimation) {
                      startMarquee();
                    }
                  }
                });
          }
        });

    addView(mScrollView, sv1lp);
  }
  public WifiConfigController(
      WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit) {
    mConfigUi = parent;
    mInXlSetupWizard = (parent instanceof WifiConfigUiForSetupWizardXL);

    mView = view;
    mAccessPoint = accessPoint;
    mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE : accessPoint.security;
    mEdit = edit;

    final Context context = mConfigUi.getContext();
    final Resources resources = context.getResources();

    if (mAccessPoint == null) { // new network
      mConfigUi.setTitle(R.string.wifi_add_network);

      mSsidView = (TextView) mView.findViewById(R.id.ssid);
      mSsidView.addTextChangedListener(this);
      mSecuritySpinner = ((Spinner) mView.findViewById(R.id.security));
      mSecuritySpinner.setOnItemSelectedListener(this);
      if (mInXlSetupWizard) {
        mView.findViewById(R.id.type_ssid).setVisibility(View.VISIBLE);
        mView.findViewById(R.id.type_security).setVisibility(View.VISIBLE);
        // We want custom layout. The content must be same as the other cases.

        ArrayAdapter<String> adapter =
            new ArrayAdapter<String>(
                context,
                R.layout.wifi_setup_custom_list_item_1,
                android.R.id.text1,
                context.getResources().getStringArray(R.array.wifi_security_no_eap));
        mSecuritySpinner.setAdapter(adapter);
      } else {
        mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
      }
      mConfigUi.setSubmitButton(context.getString(R.string.wifi_save));
    } else {
      mConfigUi.setTitle(mAccessPoint.ssid);

      mIpSettingsSpinner = (Spinner) mView.findViewById(R.id.ip_settings);
      mIpSettingsSpinner.setOnItemSelectedListener(this);
      mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
      mProxySettingsSpinner.setOnItemSelectedListener(this);

      ViewGroup group = (ViewGroup) mView.findViewById(R.id.info);

      DetailedState state = mAccessPoint.getState();
      if (state != null) {
        addRow(group, R.string.wifi_status, Summary.get(mConfigUi.getContext(), state));
      }

      int level = mAccessPoint.getLevel();
      if (level != -1) {
        String[] signal = resources.getStringArray(R.array.wifi_signal);
        addRow(group, R.string.wifi_signal, signal[level]);
      }

      WifiInfo info = mAccessPoint.getInfo();
      if (info != null && info.getLinkSpeed() != -1) {
        addRow(group, R.string.wifi_speed, info.getLinkSpeed() + WifiInfo.LINK_SPEED_UNITS);
      }

      addRow(group, R.string.wifi_security, mAccessPoint.getSecurityString(false));

      boolean showAdvancedFields = false;
      if (mAccessPoint.networkId != INVALID_NETWORK_ID) {
        WifiConfiguration config = mAccessPoint.getConfig();
        if (config.ipAssignment == IpAssignment.STATIC) {
          mIpSettingsSpinner.setSelection(STATIC_IP);
          showAdvancedFields = true;
        } else {
          mIpSettingsSpinner.setSelection(DHCP);
        }
        // Display IP addresses
        for (InetAddress a : config.linkProperties.getAddresses()) {
          addRow(group, R.string.wifi_ip_address, a.getHostAddress());
        }

        if (config.proxySettings == ProxySettings.STATIC) {
          mProxySettingsSpinner.setSelection(PROXY_STATIC);
          showAdvancedFields = true;
        } else {
          mProxySettingsSpinner.setSelection(PROXY_NONE);
        }

        if (config.status == Status.DISABLED
            && config.disableReason == WifiConfiguration.DISABLED_DNS_FAILURE) {
          addRow(
              group,
              R.string.wifi_disabled_heading,
              context.getString(R.string.wifi_disabled_help));
        }
      }

      /* Show network setup options only for a new network */
      if (mAccessPoint.networkId == INVALID_NETWORK_ID && mAccessPoint.wpsAvailable) {
        showNetworkSetupFields();
      }

      if (mAccessPoint.networkId == INVALID_NETWORK_ID || mEdit) {
        showSecurityFields();
        showIpConfigFields();
        showProxyFields();
        mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
        mView.findViewById(R.id.wifi_advanced_togglebox).setOnClickListener(this);
        if (showAdvancedFields) {
          ((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox)).setChecked(true);
          mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
        }
      }

      if (mEdit) {
        mConfigUi.setSubmitButton(context.getString(R.string.wifi_save));
      } else {
        if (state == null && level != -1) {
          mConfigUi.setSubmitButton(context.getString(R.string.wifi_connect));
        } else {
          mView.findViewById(R.id.ip_fields).setVisibility(View.GONE);
        }
        if (mAccessPoint.networkId != INVALID_NETWORK_ID) {
          mConfigUi.setForgetButton(context.getString(R.string.wifi_forget));
        }
      }
    }

    mConfigUi.setCancelButton(context.getString(R.string.wifi_cancel));
    if (mConfigUi.getSubmitButton() != null) {
      enableSubmitIfAppropriate();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    if (isOnline()) {
      // System.out.println("this is car detail view");
      car_id = getIntent().getStringExtra("CAR_ID");
      carid = getIntent().getStringExtra("CAR_ID");
      // System.out.println("cars id" + car_id);
      setContentView(R.layout.cardetailsview);
      helpers = new com.mobi.adapters.MySQLiteHelper(getApplicationContext());
      helpers.open();
      cursors = helpers.getCarList();
      cursors.moveToFirst();
      if (cursors.getCount() == 0) {
        // System.out.println("No data ADDED");
        /* finish(); */
        // Toast.makeText(getApplicationContext(), "No Records Found",
        // Toast.LENGTH_LONG).show();
      } else if (cursors.getCount() > 0) {
        do {

          carIDlist.add(
              cursors.getString(cursors.getColumnIndex(com.mobi.adapters.MySQLiteHelper.CID)));

          // System.out.println("mani" + carIDlist);
        } while (cursors.moveToNext());
      }

      mylist = (CheckBox) findViewById(R.id.mylist_checkbox);
      galeeryLayout = (LinearLayout) findViewById(R.id.ll_layout);
      // carres = (TextView) findViewById(R.id.carresults);
      carnote = (TextView) findViewById(R.id.textView4);
      viewGalLayout = (LinearLayout) findViewById(R.id.viewGalLayout);
      viewGallery = (Gallery) findViewById(R.id.viewGaleery);
      imageView = (ImageView) findViewById(R.id.image_id);
      Phone1 = (TextView) findViewById(R.id.phone);
      Phone1.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
      Zip = (TextView) findViewById(R.id.Zip);
      Email = (TextView) findViewById(R.id.Email);
      Make = (TextView) findViewById(R.id.makedisplay);
      Model = (TextView) findViewById(R.id.modeldisplay);
      Year = (TextView) findViewById(R.id.yeardisplay);
      Bodystyle = (TextView) findViewById(R.id.bodystyledisplay);
      exteriorcolor = (TextView) findViewById(R.id.ExteriorColordisplay);
      interiorcolor = (TextView) findViewById(R.id.InteriorColordisplay);
      Doors = (TextView) findViewById(R.id.Doorsdisplay);
      ConditionDescription = (TextView) findViewById(R.id.VehicleConditiondisplay);
      price = (TextView) findViewById(R.id.Pricedisplay);
      Millage = (TextView) findViewById(R.id.Mileageisplay);
      fuel = (TextView) findViewById(R.id.Fueldisplay);
      Engione = (TextView) findViewById(R.id.Enginedisplay);
      Transmission = (TextView) findViewById(R.id.Transmissiondisplay);
      Drive = (TextView) findViewById(R.id.DriveTraindisplay);
      Vin = (TextView) findViewById(R.id.vindisplay);
      Description = (TextView) findViewById(R.id.descriptiondisplay);
      viewGal = (Button) findViewById(R.id.viewgallery);
      cardetails_features = (Button) findViewById(R.id.cardetails_features);
      tv_year = (TextView) findViewById(R.id.tv_cardetailview_year);
      cardetail_tablayout = (TableLayout) findViewById(R.id.tableLayout_new);
      btn_search = (Button) findViewById(R.id.search);
      btn_preferencs = (Button) findViewById(R.id.preference);
      btn_mylist = (Button) findViewById(R.id.mylist);
      btn_car = (Button) findViewById(R.id.car);
      btn_cardetailsback = (Button) findViewById(R.id.cardetails_back);
      btn_preferencs.setBackgroundResource(R.drawable.preference_act);
      btn_car.setOnClickListener(this);
      btn_mylist.setOnClickListener(this);
      btn_preferencs.setOnClickListener(this);
      btn_search.setOnClickListener(this);
      cardetails_features.setOnClickListener(this);
      viewGal.setOnClickListener(this);
      call = (Button) findViewById(R.id.call);
      btn_cardetailsback.setOnClickListener(this);

      loadCarDetails();
      PhoneCallListener phoneListener = new PhoneCallListener(getApplicationContext());
      TelephonyManager telephonyManager =
          (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
      telephonyManager.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
      call.setOnClickListener(this);
      isStringExists = carIDlist.contains(carid);
      // System.out.println("carlist" + isStringExists);
      if (isStringExists == true) {
        mylist.setEnabled(false);
        mylist.setChecked(true);
      }
      mylist.setOnCheckedChangeListener(
          new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {

              if (mylist.isChecked()) {
                /*mylist.setText("Added to My List");
                mylist.setTextSize(12);*/
                Toast.makeText(
                        PreferenceCarDetailViewThree.this,
                        "Car  added into My List",
                        Toast.LENGTH_LONG)
                    .show();

                mylist.setEnabled(false);
                com.mobi.adapters.MySQLiteHelper helper =
                    new com.mobi.adapters.MySQLiteHelper(PreferenceCarDetailViewThree.this);
                db = helper.open();
                if (Make.getText().toString() != null
                    && Millage.getText().toString() != null
                    && Model.getText().toString() != null
                    && price.getText().toString() != null
                    && Year.getText().toString() != null
                    && bytes != null
                    && bytes.length > 0) {

                  contentValues = new ContentValues();

                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.MAKE, Make.getText().toString());
                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.Millage, Millage.getText().toString());
                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.Model, Model.getText().toString());
                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.PRICE, price.getText().toString());
                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.CID, getIntent().getStringExtra("CAR_ID"));
                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.YEAR, Year.getText().toString());
                  contentValues.put(com.mobi.adapters.MySQLiteHelper.IMG, bytes);
                  // System.out.println("my list image" + imageURL);
                } else {
                  // System.out.println("sock");
                  String StockMake = Make.getText().toString();
                  StockMake = StockMake.replace(" ", "-");
                  String StockModel = Model.getText().toString();
                  StockModel = StockModel.replace("/", "@");
                  StockModel = StockModel.replace("&", "@");
                  StockModel = StockModel.replace(" ", "-");
                  StockUrl =
                      "http://unitedcarexchange.com/images/MakeModelThumbs/"
                          + StockMake
                          + "_"
                          + StockModel
                          + ".jpg";

                  bytes1 = getImageByteArray(imageURL);
                  if (bytes1 != null) {
                    if (bytes1.length > 0) {
                      Log.d("Size is : ", "" + bytes1.length);
                    }
                  }
                  contentValues = new ContentValues();

                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.MAKE, Make.getText().toString());
                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.Millage, Millage.getText().toString());
                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.Model, Model.getText().toString());
                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.PRICE, price.getText().toString());
                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.YEAR, Year.getText().toString());
                  contentValues.put(
                      com.mobi.adapters.MySQLiteHelper.CID, getIntent().getStringExtra("CAR_ID"));
                  contentValues.put(com.mobi.adapters.MySQLiteHelper.IMG, bytes1);
                  // System.out.println("sock" + imageURL);
                }

                long res = helper.inserDetails(contentValues);

                helper.close();
              }
            }
          });
    } else {
      try {

        AlertDialog alertDialog = new AlertDialog.Builder(getApplicationContext()).create();
        alertDialog.setTitle("Info");
        alertDialog.setMessage(
            "Internet not available, Cross check your internet connectivity and try again");
        alertDialog.setIcon(R.drawable.icon);

        alertDialog.setButton(
            "OK",
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                finish();
              }
            });
        alertDialog.show();
      } catch (Exception e) {

      }
    }
  }
 public UnprintableWatcher(TextView textView) {
   mTextView = textView;
   mTextView.addTextChangedListener(this);
 }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.addentry);

    this.timePicker = (TimePicker) findViewById(R.id.entrytimePicker1);
    this.timePicker.setIs24HourView(true);
    GregorianCalendar calendar = new GregorianCalendar();
    this.timePicker.setCurrentHour(calendar.get(calendar.HOUR_OF_DAY));
    this.datePicker = (DatePicker) findViewById(R.id.entrydatePicker1);
    this.dateIso = "";

    this.dbHelper = new DbHelper(this);
    this.db = this.dbHelper.getWritableDatabase();

    buttonSave = (Button) findViewById(R.id.buttonSave);
    buttonSave.setEnabled(false);
    buttonSave.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            StringBuilder sb = new StringBuilder();
            Formatter f = new Formatter(sb, Locale.GERMAN);
            f.format(
                "%4d-%02d-%02d %02d:%02d:00",
                AddEntry.this.datePicker.getYear(),
                AddEntry.this.datePicker.getMonth() + 1,
                AddEntry.this.datePicker.getDayOfMonth(),
                AddEntry.this.timePicker.getCurrentHour(),
                AddEntry.this.timePicker.getCurrentMinute());
            AddEntry.this.dateIso = sb.toString();
            try {
              AddEntry.this.gewicht = Double.parseDouble(AddEntry.this.kg.getText().toString());
            } catch (NumberFormatException e) {
              return;
            }
            ContentValues values = new ContentValues();
            values.put(DbHelper.C_DATETIME, AddEntry.this.dateIso);
            values.put(DbHelper.C_GEWICHT, AddEntry.this.gewicht);
            AddEntry.this.db.insertOrThrow(dbHelper.TABLE, null, values);
            AddEntry.this.db.close();

            AddEntry.this.datum = Toast.makeText(AddEntry.this, sb, Toast.LENGTH_LONG);
            AddEntry.this.datum.show();

            // Sending result back
            Bundle bundle = new Bundle();
            Intent intent = new Intent();
            intent.putExtras(bundle);
            setResult(RESULT_OK, intent);

            AddEntry.this.finish();
          }
        });

    kg = (TextView) findViewById(R.id.editWeight);
    kg.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            String inputValue = AddEntry.this.kg.getText().toString();
            // double value = Double.parseDouble( AddEntry.this.kg.getText( ).toString( ) );
            if (inputValue.length() == 0) {
              AddEntry.this.buttonSave.setEnabled(false);
              return;
            }
            double value = Double.parseDouble(inputValue);
            if (value != 0) {
              AddEntry.this.buttonSave.setEnabled(true);
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
  public void initUI(double latitude, double longitude) {
    latitude = MapUtils.checkLatitude(latitude);
    longitude = MapUtils.checkLongitude(longitude);
    final TextView latEdit = ((TextView) view.findViewById(R.id.LatitudeEdit));
    final TextView lonEdit = ((TextView) view.findViewById(R.id.LongitudeEdit));
    currentFormat = Location.FORMAT_DEGREES;
    latEdit.setText(convert(latitude, Location.FORMAT_DEGREES));
    lonEdit.setText(convert(longitude, Location.FORMAT_DEGREES));
    final Spinner format = ((Spinner) view.findViewById(R.id.Format));
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(
            getSherlockActivity(),
            android.R.layout.simple_spinner_item,
            new String[] {
              getString(R.string.navigate_point_format_D),
              getString(R.string.navigate_point_format_DM),
              getString(R.string.navigate_point_format_DMS)
            });
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    format.setAdapter(adapter);
    format.setSelection(0);
    format.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
            int newFormat = currentFormat;
            String itm = (String) format.getItemAtPosition(position);
            if (getString(R.string.navigate_point_format_D).equals(itm)) {
              newFormat = Location.FORMAT_DEGREES;
            } else if (getString(R.string.navigate_point_format_DM).equals(itm)) {
              newFormat = Location.FORMAT_MINUTES;
            } else if (getString(R.string.navigate_point_format_DMS).equals(itm)) {
              newFormat = Location.FORMAT_SECONDS;
            }
            currentFormat = newFormat;
            try {
              double lat =
                  convert(((TextView) view.findViewById(R.id.LatitudeEdit)).getText().toString());
              double lon =
                  convert(((TextView) view.findViewById(R.id.LongitudeEdit)).getText().toString());
              ((TextView) view.findViewById(R.id.ValidateTextView)).setVisibility(View.INVISIBLE);
              latEdit.setText(convert(lat, newFormat));
              lonEdit.setText(convert(lon, newFormat));
            } catch (RuntimeException e) {
              ((TextView) view.findViewById(R.id.ValidateTextView)).setVisibility(View.VISIBLE);
              ((TextView) view.findViewById(R.id.ValidateTextView))
                  .setText(R.string.invalid_locations);
              Log.w(PlatformUtil.TAG, "Convertion failed", e); // $NON-NLS-1$
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
    TextWatcher textWatcher =
        new TextWatcher() {
          String pasteString = null;

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            pasteString = null;
            if (count > 3) {
              pasteString = s.subSequence(start, start + count).toString();
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {

            if (pasteString != null) {
              int latSt = -1;
              int latEnd = -1;
              int lonSt = -1;
              int lonEnd = -1;
              int step = 0; // 0 - init, 1- lat, 2-between, 3-lon
              for (int i = 0; i < pasteString.length(); i++) {
                char ch = pasteString.charAt(i);
                if (Character.isDigit(ch)) {
                  if (step == 0 || step == 2) {
                    int t = i;
                    if (i > 0 && pasteString.charAt(i - 1) == '-') {
                      t--;
                    }
                    if (step == 0) {
                      latSt = t;
                    } else {
                      lonSt = t;
                    }
                    step++;
                  }
                } else if (ch == '.' || ch == ':') {
                  // do nothing here
                } else {
                  if (step == 1) {
                    latEnd = i;
                    step++;
                  } else if (step == 3) {
                    lonEnd = i;
                    step++;
                    break;
                  }
                }
              }

              if (lonSt != -1) {
                if (lonEnd == -1) {
                  lonEnd = pasteString.length();
                }
                try {
                  String latString = pasteString.substring(latSt, latEnd);
                  String lonString = pasteString.substring(lonSt, lonEnd);
                  Double.parseDouble(latString);
                  Double.parseDouble(lonString);
                  latEdit.setText(latString);
                  lonEdit.setText(lonString);
                } catch (NumberFormatException e) {
                }
              }
            }
          }
        };
    latEdit.addTextChangedListener(textWatcher);
    lonEdit.addTextChangedListener(textWatcher);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.item_choose_list);

    // Intent intent = getIntent();
    opr = this.getIntent().getIntExtra("opr", 0);
    userType = this.getIntent().getIntExtra("user_type", 0);
    _id = this.getIntent().getIntExtra("_id", 0);
    _name = this.getIntent().getStringExtra("_name");
    _address = this.getIntent().getStringExtra("_address");
    userId = getIntent().getStringExtra("userId");

    newBtn = (Button) findViewById(R.id.createNewBtn);
    TextView keyView = (TextView) findViewById(R.id.item_chose_text_edit);

    if (opr == DbAdapter.PRACTICE) {
      setTitle(getString(R.string.app_name) + " - Choose your Practice");
      newBtn.setVisibility(View.GONE);
    } else if (opr == DbAdapter.HOSPITAL) {
      setTitle(getString(R.string.app_name) + " - Choose your Hospital");
      newBtn.setVisibility(View.GONE);
    } else if (opr == DbAdapter.SPECIALTY) {
      setTitle(getString(R.string.app_name) + " - Choose your Specialty");
      newBtn.setVisibility(View.GONE);
    } else if (opr == DbAdapter.DOCTOR) {
      setTitle("Choose your Name");
      newBtn.setVisibility(View.VISIBLE);
      keyView.setHint("Enter your last name");
      newBtn.setText("Click, if you do not find your name");
    }

    // dba = new DbAdapter(this);
    // dba.open();
    itemListView = (ListView) findViewById(R.id.itemChoseList);

    if (opr == DbAdapter.DOCTOR) {
      simpleAdapter =
          new SimpleAdapter(
              this,
              docList,
              R.layout.doctor_row_lite,
              new String[] {"docTitile1", "docTitile2"},
              new int[] {R.id.doc_lite_title1, R.id.doc_lite_title2});
      simpleAdapter.notifyDataSetChanged();
      // simpleAdapter.setNotifyOnChange(true); // This is so I don't have to manually sync whenever
      // changed
      itemListView.setAdapter(simpleAdapter);
    } else {
      autoCompleteAdapter =
          new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line);
      autoCompleteAdapter.setNotifyOnChange(
          true); // This is so I don't have to manually sync whenever changed
      itemListView.setAdapter(autoCompleteAdapter);
    }
    textView = (TextView) findViewById(R.id.item_chose_text_edit);
    // footerView = (TextView)findViewById(R.id.item_chose_footer);

    final TextWatcher textChecker =
        new TextWatcher() {

          public void afterTextChanged(Editable s) {
            // textView.setEnabled(true);
          }

          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // textView.setEnabled(false);
          }

          public void onTextChanged(CharSequence s, int start, int before, int count) {

            searchText = s.toString();
            systemtaskHandler.removeCallbacks(systemTaskRunner);
            systemtaskHandler.postDelayed(systemTaskRunner, 1500);
            //

          }
        };
    textView.addTextChangedListener(textChecker);

    itemListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            selectedItemIdx = position;
            if (opr == DbAdapter.PRACTICE) {
              Intent intent = new Intent(ItemChooseActivity.this, ItemChooseActivity.class);
              intent.putExtra("opr", DbAdapter.SPECIALTY);
              intent.putExtra("user_type", 1);
              intent.putExtra("_id", Integer.parseInt((String) idArr[selectedItemIdx]));
              intent.putExtra("_name", (String) nameArr[selectedItemIdx]);
              intent.putExtra("_address", (String) addArr[selectedItemIdx]);
              System.out.println("SMM::PRAC_ID::" + (String) idArr[selectedItemIdx]);
              startActivityForResult(intent, 1100);
            } else if (opr == DbAdapter.HOSPITAL) {
              Intent intent = new Intent(ItemChooseActivity.this, ItemChooseActivity.class);
              intent.putExtra("opr", DbAdapter.SPECIALTY);
              intent.putExtra("user_type", 2);
              intent.putExtra("_id", Integer.parseInt((String) idArr[selectedItemIdx]));
              intent.putExtra("_name", (String) nameArr[selectedItemIdx]);
              intent.putExtra("_address", (String) addArr[selectedItemIdx]);
              System.out.println("SMM::PRAC_ID::" + (String) idArr[selectedItemIdx]);
              startActivityForResult(intent, 1100);
              // Intent intent = new Intent(ItemChooseActivity.this, RegFormActivity.class);
              // intent.putExtra("prac_id", Integer.parseInt((String)idArr[selectedItemIdx+1]));
              // intent.putExtra("prac_name", (String)nameArr[selectedItemIdx+1]);
              // intent.putExtra("prac_address", (String)addArr[selectedItemIdx+1]);
              // System.out.println("SMM::HOSP_ID::"+(String)idArr[selectedItemIdx]);
              // startActivityForResult(intent, 1100);
            } else if (opr == DbAdapter.SPECIALTY) {
              Intent intent = new Intent(ItemChooseActivity.this, PCPRegFormActivity.class);
              intent.putExtra("user_type", userType);
              intent.putExtra("prac_id", _id);
              intent.putExtra("prac_name", _name);
              intent.putExtra("prac_address", _address);
              intent.putExtra("spec_id", Integer.parseInt((String) idArr[selectedItemIdx]));
              intent.putExtra("spec_name", (String) nameArr[selectedItemIdx]);
              System.out.println("SMM::SPEC_ID::" + (String) idArr[selectedItemIdx]);
              startActivityForResult(intent, 1100);
            } else if (opr == DbAdapter.DOCTOR) {
              Intent intent = new Intent(ItemChooseActivity.this, PCPRegFormActivity.class);
              try {
                JSONObject obj = (JSONObject) docList2.get(selectedItemIdx);
                intent.putExtra("user_type", userType);
                intent.putExtra("doc_id", obj.getInt("id"));
                intent.putExtra("prac_id", obj.getInt("prac_id"));
                // System.out.println("SMM::PRAC_ID="+obj.getInt("prac_id"));
                intent.putExtra("prac_name", obj.getString("prac_name"));
                intent.putExtra("prac_address", obj.getString("add_line_1"));
              } catch (Exception ex) {
                System.out.println("SMM::ERROR::" + ex);
              }
              intent.putExtra("doc_id", Integer.parseInt((String) idArr[selectedItemIdx]));
              System.out.println("SMM::DOC_ID::" + (String) idArr[selectedItemIdx]);
              startActivityForResult(intent, 1100);
            }
          }
        });

    newBtn.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intent = new Intent(ItemChooseActivity.this, ItemChooseActivity.class);
            if (userType == 1) intent.putExtra("opr", DbAdapter.PRACTICE);
            if (userType == 2) intent.putExtra("opr", DbAdapter.HOSPITAL);
            // intent.putExtra("_id", _id);
            // intent.putExtra("_name", _name);
            // intent.putExtra("_address", _address);
            startActivityForResult(intent, 1100);
            /*
            Intent intent = new Intent(ItemChooseActivity.this, PCPRegFormActivity.class);
            intent.putExtra("prac_id", _id);
            intent.putExtra("prac_name", _name);
            intent.putExtra("prac_address", _address);
            startActivityForResult(intent, 1100);
            */
          }
        });

    searchText = "";
    systemtaskHandler.removeCallbacks(systemTaskRunner);
    systemtaskHandler.postDelayed(systemTaskRunner, 1500);
  }
  private void init(Context context, AttributeSet attrs, int defStyle) {
    // Load custom attributes
    final int layout;
    final CharSequence text;
    final CharSequence hint;
    final ColorStateList hintColor;
    final int inputType;
    final int imeOptions;
    if (attrs == null) {
      layout = R.layout.float_label;
      text = null;
      hint = null;
      hintColor = null;
      inputType = EditorInfo.TYPE_CLASS_TEXT;
      imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED;
    } else {
      final TypedArray a =
          context.obtainStyledAttributes(attrs, R.styleable.FloatLabel, defStyle, 0);
      layout = a.getResourceId(R.styleable.FloatLabel_android_layout, R.layout.float_label);
      text = a.getText(R.styleable.FloatLabel_android_text);
      hint = a.getText(R.styleable.FloatLabel_android_hint);
      hintColor = a.getColorStateList(R.styleable.FloatLabel_android_textColorHint);
      inputType = a.getInt(R.styleable.FloatLabel_android_inputType, EditorInfo.TYPE_CLASS_TEXT);
      imeOptions =
          a.getInt(R.styleable.FloatLabel_android_imeOptions, EditorInfo.IME_ACTION_UNSPECIFIED);
      a.recycle();
    }

    inflate(context, layout, this);
    mEditText = (TextView) findViewById(R.id.edit_text);
    if (mEditText == null) {
      throw new RuntimeException("Your layout must have an EditText whose ID is @id/edit_text");
    }
    mEditText.setHint(hint);
    mEditText.setText(text);
    if (hintColor != null) {
      mEditText.setHintTextColor(hintColor);
    }
    mEditText.setInputType(inputType);
    mEditText.setImeOptions(imeOptions);

    mLabel = (TextView) findViewById(R.id.float_label);
    if (mLabel == null) {
      throw new RuntimeException("Your layout must have a TextView whose ID is @id/float_label");
    }
    mLabel.setText(mEditText.getHint());

    // Listen to EditText to know when it is empty or nonempty
    mEditText.addTextChangedListener(new EditTextWatcher());

    // Check current state of EditText
    if (mEditText.getText().length() == 0) {
      mLabel.setAlpha(0);
      mLabelShowing = false;
    } else {
      mLabel.setVisibility(View.VISIBLE);
      mLabelShowing = true;
    }

    // Mark init as complete to prevent accidentally breaking the view by
    // adding children
    mInitComplete = true;
  }
  private void showSecurityFields() {
    if (mInXlSetupWizard) {
      // Note: XL SetupWizard won't hide "EAP" settings here.
      if (!((WifiSettingsForSetupWizardXL) mConfigUi.getContext())
          .initSecurityFields(mView, mAccessPointSecurity)) {
        return;
      }
    }
    if (mAccessPointSecurity == AccessPoint.SECURITY_NONE) {
      mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
      return;
    }
    mView.findViewById(R.id.security_fields).setVisibility(View.VISIBLE);

    if (mPasswordView == null) {
      mPasswordView = (TextView) mView.findViewById(R.id.password);
      mPasswordView.addTextChangedListener(this);
      ((CheckBox) mView.findViewById(R.id.show_password)).setOnCheckedChangeListener(this);

      if (mAccessPoint != null && mAccessPoint.networkId != INVALID_NETWORK_ID) {
        mPasswordView.setHint(R.string.wifi_unchanged);
      }
    }

    if (mAccessPointSecurity != AccessPoint.SECURITY_EAP) {
      mView.findViewById(R.id.eap).setVisibility(View.GONE);
      return;
    }
    mView.findViewById(R.id.eap).setVisibility(View.VISIBLE);

    if (mEapMethodSpinner == null) {
      mEapMethodSpinner = (Spinner) mView.findViewById(R.id.method);
      mEapMethodSpinner.setOnItemSelectedListener(this);
      mPhase2Spinner = (Spinner) mView.findViewById(R.id.phase2);
      mEapCaCertSpinner = (Spinner) mView.findViewById(R.id.ca_cert);
      mEapUserCertSpinner = (Spinner) mView.findViewById(R.id.user_cert);
      mEapIdentityView = (TextView) mView.findViewById(R.id.identity);
      mEapAnonymousView = (TextView) mView.findViewById(R.id.anonymous);

      loadCertificates(mEapCaCertSpinner, Credentials.CA_CERTIFICATE);
      loadCertificates(mEapUserCertSpinner, Credentials.USER_PRIVATE_KEY);

      // Modifying an existing network
      if (mAccessPoint != null && mAccessPoint.networkId != INVALID_NETWORK_ID) {
        WifiEnterpriseConfig enterpriseConfig = mAccessPoint.getConfig().enterpriseConfig;
        int eapMethod = enterpriseConfig.getEapMethod();
        int phase2Method = enterpriseConfig.getPhase2Method();
        mEapMethodSpinner.setSelection(eapMethod);
        showEapFieldsByMethod(eapMethod);
        switch (eapMethod) {
          case Eap.PEAP:
            switch (phase2Method) {
              case Phase2.NONE:
                mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_NONE);
                break;
              case Phase2.MSCHAPV2:
                mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_MSCHAPV2);
                break;
              case Phase2.GTC:
                mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_GTC);
                break;
              default:
                Log.e(TAG, "Invalid phase 2 method " + phase2Method);
                break;
            }
            break;
          default:
            mPhase2Spinner.setSelection(phase2Method);
            break;
        }
        setSelection(mEapCaCertSpinner, enterpriseConfig.getCaCertificateAlias());
        setSelection(mEapUserCertSpinner, enterpriseConfig.getClientCertificateAlias());
        mEapIdentityView.setText(enterpriseConfig.getIdentity());
        mEapAnonymousView.setText(enterpriseConfig.getAnonymousIdentity());
      } else {
        // Choose a default for a new network and show only appropriate
        // fields
        mEapMethodSpinner.setSelection(Eap.PEAP);
        showEapFieldsByMethod(Eap.PEAP);
      }
    } else {
      showEapFieldsByMethod(mEapMethodSpinner.getSelectedItemPosition());
    }
  }
  @Nullable
  @Override
  public View onCreateView(
      final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_login, container, false);

    emailInput = (TextView) view.findViewById(R.id.input_email);
    passwordInput = (TextView) view.findViewById(R.id.input_password);
    loginButton = view.findViewById(R.id.button_login);

    emailInput.addTextChangedListener(textWatcher);
    passwordInput.addTextChangedListener(textWatcher);

    final SharedPreferences preferences =
        PreferenceManager.getDefaultSharedPreferences(getContext());

    emailInput.setText(preferences.getString(MainApplication.PREFERENCE_EMAIL, null));

    if (preferences.getBoolean(MainApplication.PREFERENCE_AUTHENTICATED, false)) {
      startMainActivity();
    }

    view.findViewById(R.id.button_settings)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                View dialogView = inflater.inflate(R.layout.view_settings, null);
                final EditText input = (EditText) dialogView.findViewById(R.id.input_url);

                input.setText(preferences.getString(MainApplication.PREFERENCE_URL, null));

                new AlertDialog.Builder(getContext())
                    .setTitle(R.string.settings_title)
                    .setView(dialogView)
                    .setPositiveButton(
                        android.R.string.yes,
                        new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int which) {
                            String url = input.getText().toString();
                            if (HttpUrl.parse(url) != null) {
                              preferences
                                  .edit()
                                  .putString(MainApplication.PREFERENCE_URL, url)
                                  .apply();
                            } else {
                              Toast.makeText(
                                      getContext(), R.string.error_invalid_url, Toast.LENGTH_LONG)
                                  .show();
                            }
                          }
                        })
                    .setNegativeButton(android.R.string.no, null)
                    .show();
              }
            });

    loginButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            preferences
                .edit()
                .putBoolean(MainApplication.PREFERENCE_AUTHENTICATED, true)
                .putString(MainApplication.PREFERENCE_EMAIL, emailInput.getText().toString())
                .putString(MainApplication.PREFERENCE_PASSWORD, passwordInput.getText().toString())
                .apply();

            startMainActivity();
          }
        });

    return view;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate()");

    mCore = KegbotCore.getInstance(this);
    mFlowManager = mCore.getFlowManager();
    mConfig = mCore.getConfiguration();
    mImageDownloader = mCore.getImageDownloader();

    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
      actionBar.hide();
    }
    setContentView(R.layout.pour_in_progress_activity);

    mTapPager = (ViewPager) findViewById(R.id.tapPager);
    mPouringTapAdapter = new PouringTapAdapter(getFragmentManager());
    mTapPager.setAdapter(mPouringTapAdapter);
    mTapPager.setOnPageChangeListener(mPageChangeListener);

    mControlsFlipper = (ViewFlipper) findViewById(R.id.pour_controls_flipper);
    mClaimPourButton = (Button) findViewById(R.id.claimPourButton);
    mDrinkerName = (TextView) findViewById(R.id.pourDrinkerName);
    mDoneButton = (Button) findViewById(R.id.pourEndButton);
    mDrinkerImage = (ImageView) findViewById(R.id.pourDrinkerImage);
    mShoutText = (TextView) findViewById(R.id.shoutText);

    mClaimPourButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            final Flow flow = getCurrentlyFocusedFlow();
            if (flow == null || flow.isAuthenticated() || flow.isFinished()) {
              return;
            }

            Log.d(TAG, "Attempting to claim flow id=" + flow.getFlowId());
            final Intent intent =
                KegtabCommon.getAuthDrinkerActivityIntent(PourInProgressActivity.this);
            intent.putExtra(EXTRA_FLOW_ID, flow.getFlowId());
            startActivityForResult(intent, REQUEST_AUTH_DRINKER);
          }
        });

    mDoneButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            final FlowManager flowManager = mCore.getFlowManager();
            final Flow flow = getCurrentlyFocusedFlow();
            if (flow == null) {
              return;
            }
            Log.d(TAG, "Done button pressed, ending flow " + flow.getFlowId());
            flowManager.endFlow(flow);

            // If we're finishing a non-dormant flow, and other dormant flows
            // exist, assume those were started optimistically and finish them
            // now.
            if (flow.getVolumeMl() > 0) {
              final AppConfiguration config = mCore.getConfiguration();
              final long minVolume = config.getMinimumVolumeMl();
              for (final Flow suspectFlow : flowManager.getAllActiveFlows()) {
                if (suspectFlow.getVolumeMl() < minVolume) {
                  Log.d(TAG, "Also ending dormant flow: " + suspectFlow.getFlowId());
                  flowManager.endFlow(suspectFlow);
                }
              }
            }
          }
        });

    mShoutText = (EditText) findViewById(R.id.shoutText);
    mShoutText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {
            final Flow flow = getCurrentlyFocusedFlow();
            if (flow == null) {
              Log.w(TAG, "Flow went away, dropping shout.");
              return;
            }
            flow.setShout(s.toString());
            flow.pokeActivity();
          }
        });

    mShowCamera = true;
    mCameraFragment = (CameraFragment) getFragmentManager().findFragmentById(R.id.camera);
    if (!mConfig.getUseCamera()) {
      mShowCamera = false;
      getFragmentManager().beginTransaction().hide(mCameraFragment).commit();
    }

    refreshFlows();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_vak_detail);

    prefs = new CustomSharedPreferences(this);

    final String subjectName = getIntent().getStringExtra("subjectName");
    final DatabaseReceiver databaseReceiver = DatabaseReceiver.getDatabaseReceiver(this);

    final Subject subject = databaseReceiver.getSubject(subjectName);

    // Set all the texts of the variables on the screen.
    final TextView nameView = (TextView) findViewById(R.id.subjectName);
    nameView.setText(subject.getName());

    final TextView ectsView = (TextView) findViewById(R.id.subjectEcts);
    String ects = subject.getEcts() + "";
    ectsView.setText(ects);

    final TextView periodView = (TextView) findViewById(R.id.subjectPeriod);
    String period = subject.getPeriod() + "";
    periodView.setText(period);

    final TextView gradeView = (EditText) findViewById(R.id.grade);

    if (subject.getGrade() == 0.0f) {
      gradeView.setText("");
    } else {
      if (subject.getGrade() > 5.5) {
        gradeView.setTextColor(getResources().getColor(R.color.dark_green));
      } else {
        gradeView.setTextColor(Color.RED);
      }
      String grade = subject.getGrade() + "";
      gradeView.setText(grade);
    }

    // Set color to black again when the text change.
    gradeView.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            gradeView.setTextColor(Color.BLACK);
          }

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });

    // Go back to previous activity when u press on cancel
    Button cancelBtn = (Button) findViewById(R.id.cancelBtn);
    cancelBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });

    final Button saveBtn = (Button) findViewById(R.id.saveBtn);
    saveBtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            subject.setEcts(Integer.parseInt(ectsView.getText().toString()));
            subject.setPeriod(Integer.parseInt(periodView.getText().toString()));

            String grade = gradeView.getText().toString();

            // Return to previous activity if there is nothing filled in.
            if (grade.isEmpty()) {
              finish();
              return;
            } else {
              subject.setGrade(Float.parseFloat(grade));
            }

            if (validateGrade(subject.getGrade(), gradeView)) {
              databaseReceiver.updateSubject(subject);

              if (prefs.isListEmpty("recentIngevoerd")) {
                prefs.putSubject("recentIngevoerd", subject);
              } else {
                ArrayList<Subject> subjectList = new ArrayList<>();
                subjectList.add(subject);

                prefs.putListObject("recentIngevoerd", subjectList);
              }

              finish();
            }
          }
        });
  }
  public void initData() {
    next_stepView.setBackgroundResource(R.color.vd0d0d0);
    next_stepView.setClickable(false);
    Intent intent = getIntent();
    if (intent != null) {
      pid = intent.getIntExtra(Define.PID, 0);
      showProgressDialog();
      loadproductInfo(pid);
    }
    pictureLayout.addOnLayoutChangeListener(
        new View.OnLayoutChangeListener() {

          @Override
          public void onLayoutChange(
              View v,
              int left,
              int top,
              int right,
              int bottom,
              int oldLeft,
              int oldTop,
              int oldRight,
              int oldBottom) {
            if (pictureLayout.getWidth() > hs.getWidth()
                && addTextView1.getVisibility() == View.VISIBLE) {

              pictureLayout.post(
                  new Runnable() {

                    @Override
                    public void run() {
                      addTextView1.setVisibility(View.GONE);
                      taddTextView2.setVisibility(View.VISIBLE);
                      imageshadowImage.setVisibility(View.VISIBLE);
                      if (checkNextClickable()) {
                        next_stepView.setClickable(true);
                        next_stepView.setBackgroundResource(
                            R.drawable.blue_retancle_button_selector);
                      } else {
                        next_stepView.setClickable(false);
                        next_stepView.setBackgroundResource(R.color.vd0d0d0);
                      }
                    }
                  });

            } else if (pictureLayout.getWidth() <= hs.getWidth()) {
              pictureLayout.post(
                  new Runnable() {

                    @Override
                    public void run() {
                      addTextView1.setVisibility(View.VISIBLE);
                      taddTextView2.setVisibility(View.GONE);
                      imageshadowImage.setVisibility(View.GONE);
                      if (checkNextClickable()) {
                        next_stepView.setClickable(true);
                        next_stepView.setBackgroundResource(
                            R.drawable.blue_retancle_button_selector);
                      } else {
                        next_stepView.setClickable(false);
                        next_stepView.setBackgroundResource(R.color.vd0d0d0);
                      }
                    }
                  });
            }
          }
        });
    resource_layout.addOnLayoutChangeListener(
        new View.OnLayoutChangeListener() {

          @Override
          public void onLayoutChange(
              View v,
              int left,
              int top,
              int right,
              int bottom,
              int oldLeft,
              int oldTop,
              int oldRight,
              int oldBottom) {
            if (resource_layout.getWidth() > add_resource_layout.getWidth()
                && add_resource_in.getVisibility() == View.VISIBLE) {

              resource_layout.post(
                  new Runnable() {

                    @Override
                    public void run() {
                      add_resource_in.setVisibility(View.GONE);
                      add_resource.setVisibility(View.VISIBLE);
                      resourceshadowImage.setVisibility(View.VISIBLE);
                      if (checkNextClickable()) {
                        next_stepView.setClickable(true);
                        next_stepView.setBackgroundResource(
                            R.drawable.blue_retancle_button_selector);
                      } else {
                        next_stepView.setClickable(false);
                        next_stepView.setBackgroundResource(R.color.vd0d0d0);
                      }
                    }
                  });

            } else if (resource_layout.getWidth() <= add_resource_layout.getWidth()) {
              resource_layout.post(
                  new Runnable() {

                    @Override
                    public void run() {
                      add_resource_in.setVisibility(View.VISIBLE);
                      add_resource.setVisibility(View.GONE);
                      resourceshadowImage.setVisibility(View.GONE);
                      if (checkNextClickable()) {
                        next_stepView.setClickable(true);
                        next_stepView.setBackgroundResource(
                            R.drawable.blue_retancle_button_selector);
                      } else {
                        next_stepView.setClickable(false);
                        next_stepView.setBackgroundResource(R.color.vd0d0d0);
                      }
                    }
                  });
            }
          }
        });
    putawayableSwitch.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
              if (isChecked) {
                String dateString = DateUtil.timestampToStr(ApiCaller.TimeInService, "yyyy-MM-dd");
                startimeText.setText(dateString);
              }
              startimeText.setClickable(false);
            } else {
              // endtimeText.setText("结束时间");
              // startimeText.setText("起始时间");
              long time = DateUtil.strToTimestamp(productInfo.getEndTime(), Define.FORMAT_YMD);
              if (time > 0) {
                endtimeText.setText(DateUtil.timestampToStr(time, "yyyy-MM-dd"));
              }
              time = DateUtil.strToTimestamp(productInfo.getStartTime(), Define.FORMAT_YMD);
              if (time > 0) {
                startimeText.setText(DateUtil.timestampToStr(time, "yyyy-MM-dd"));
              }
              startimeText.setClickable(true);
            }
          }
        });
    putawayableSwitch.setChecked(false);
    productnameEditText.addTextChangedListener(mTextWatcher);
    productnameEditText.setOnFocusChangeListener(
        new OnFocusChangeListener() {

          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
              if (productnameEditText.getText().length() < 3) {
                showToast("产品名称长度必须大于3!");
              }
            }
          }
        });
    phonenumberEditText.addTextChangedListener(mTextWatcher);
    startimeText.addTextChangedListener(mTextWatcher);
  }
  private void editPatients(final Patients patient) {
    final Dialog d = new Dialog(getActivity());
    d.setTitle("Update Entry");
    d.setContentView(R.layout.input_patient_entry);
    TextView header = (TextView) d.findViewById(R.id.header);
    header.setText("Update Contact Entry");
    final TextView first_name = (TextView) d.findViewById(R.id.fname);
    final TextView middle_name = (TextView) d.findViewById(R.id.mi);
    final TextView last_name = (TextView) d.findViewById(R.id.lname);
    final TextView address = (TextView) d.findViewById(R.id.addr);
    final TextView age = (TextView) d.findViewById(R.id.age);
    final TextView medical_history = (TextView) d.findViewById(R.id.med_hist);
    RadioGroup status_group = (RadioGroup) d.findViewById(R.id.status);
    status_group.setVisibility(RadioGroup.GONE);

    save = (Button) d.findViewById(R.id.add);
    Button cancel = (Button) d.findViewById(R.id.cancel);

    save.setEnabled(false);

    save.setText("Update");
    first_name.setText(patient.getFname());
    middle_name.setText(patient.getMi());
    last_name.setText(patient.getLname());
    address.setText(patient.getAddr());
    age.setText(Integer.toString(patient.getAge()));
    medical_history.setText(patient.getMed_history());

    first_name.addTextChangedListener(this);
    middle_name.addTextChangedListener(this);
    last_name.addTextChangedListener(this);
    address.addTextChangedListener(this);
    age.addTextChangedListener(this);
    medical_history.addTextChangedListener(this);

    save.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            AlertDialog.Builder build = new AlertDialog.Builder(getActivity());
            build.setMessage("Are all edits Correct?");
            build.setCancelable(false);
            build.setPositiveButton(
                "Yes",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    Patients p = patient;
                    p.setFname(first_name.getText().toString());
                    p.setMi(middle_name.getText().toString());
                    p.setLname(last_name.getText().toString());
                    p.setAddr(address.getText().toString());
                    p.setAge(Integer.parseInt(age.getText().toString()));
                    p.setMed_history(medical_history.getText().toString());
                    help.update(p, Helper.NORMAL);
                    d.cancel();
                    Toast.makeText(getActivity(), "Patient Details Updated!", Toast.LENGTH_SHORT)
                        .show();
                    loadPatientMasterList();
                    loadPatientList(patient.getPat_status());
                  }
                });
            build.setNegativeButton(
                "No",
                new DialogInterface.OnClickListener() {

                  public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                  }
                });

            AlertDialog alert = build.create();
            alert.show();
          }
        });
    cancel.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            d.cancel();
          }
        });

    d.show();
  }