@Override
  public void onLocationChanged(Location location) {
    double lati, longi;
    lati = location.getLatitude();
    longi = location.getLongitude();

    textLati.setText(lati + "");
    textLong.setText(longi + "");
    String url =
        "https://www.google.co.in/maps/@"
            + textLati.getText().toString()
            + ","
            + textLong.getText().toString()
            + ",15z?hl=en";

    Toast.makeText(MainActivity.this, "hiiiiii", Toast.LENGTH_LONG).show();

    try {
      FileWriter writer = new FileWriter(filePath, false);
      writer.write(url);
      writer.flush();
      writer.close();

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
    /**
     * Appends three jumping dots to the end of a TextView text.
     *
     * <p>This implies that the animation will by default be a wave.
     *
     * <p>If the TextView has no text, the resulting TextView text will consist of the three dots
     * only.
     *
     * <p>The TextView text is cached to the current value at this time and set again in the {@link
     * #build()} method, so any change to the TextView text done in the meantime will be lost. This
     * means that <b>you should do all changes to the TextView text <i>before</i> you begin using
     * this builder.</b>
     *
     * <p>Call the {@link #build()} method once you're done to get the resulting {@link
     * net.frakbot.jumpingbeans.JumpingBeans}.
     *
     * @param textView The TextView whose text is to be animated
     * @param startPos The position of the first character to animate
     * @param endPos The position after the one the animated range ends at (just like in
     *     String#substring())
     * @see #setIsWave(boolean)
     */
    public Builder makeTextJump(TextView textView, int startPos, int endPos) {
      if (textView == null || textView.getText() == null) {
        throw new NullPointerException("The textView and its text must not be null");
      }

      if (endPos < startPos) {
        throw new IllegalArgumentException(
            "The start position must be smaller than the end position");
      }

      if (startPos < 0) {
        throw new IndexOutOfBoundsException("The start position must be non-negative");
      }

      this.text = textView.getText();
      if (endPos > text.length()) {
        throw new IndexOutOfBoundsException(
            "The end position must be smaller than the text length");
      }

      this.wave = true;
      this.textView = textView;
      this.startPos = startPos;
      this.endPos = endPos;
      return this;
    }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.shareqq_commit: // 提交
       final Bundle params = new Bundle();
       params.putString(GameAppOperation.QQFAV_DATALINE_APPNAME, appName.getText().toString());
       params.putString(GameAppOperation.QQFAV_DATALINE_TITLE, title.getText().toString());
       params.putString(GameAppOperation.QQFAV_DATALINE_DESCRIPTION, summary.getText().toString());
       params.putString(GameAppOperation.TROOPBAR_ID, troopbarId.getText().toString());
       String srFileData = imageUrl.getText().toString();
       if (!TextUtils.isEmpty(srFileData)) {
         ArrayList<String> fileDataList = new ArrayList<String>();
         srFileData.replace(" ", "");
         String[] filePaths = srFileData.split(";");
         int size = filePaths.length;
         for (int i = 0; i < size; i++) {
           String path = filePaths[i].trim();
           if (!TextUtils.isEmpty(path)) {
             fileDataList.add(path);
           }
         }
         params.putStringArrayList(GameAppOperation.QQFAV_DATALINE_FILEDATA, fileDataList);
       }
       doShareToTroopBar(params);
       return;
     case R.id.radioBtn_local_image: // 本地图片
       startPickLocaleImage(this);
       return;
     default:
       break;
   }
 }
Example #4
0
  public void addToMySchedule(View v) {
    scheduleTitle = (TextView) findViewById(R.id.title);
    String schedule_title = (String) scheduleTitle.getText();
    scheduleTime = (TextView) findViewById(R.id.duration);
    String schedule_time = (String) scheduleTime.getText();
    scheduleLocation = (TextView) findViewById(R.id.artist);
    String schedule_location = (String) scheduleLocation.getText();
    // imageOne = (ImageButton) findViewById(R.id.thumbnail);
    // imageTwo = (ImageButton) findViewById(R.id.thumbnail2);

    /** ***************inserting into my_schedule table******************* */
    // initializing database
    DatabaseHelper dbHelper2 = new DatabaseHelper(this);

    Log.d(HOMESCREEN, "Inserting Schedule Items to MyScheduleTable");
    // TODO: Add Loading Spinner until this process is complete
    //      and/or start a new thread to Handle this
    // initializing Schedule Table and
    // inserting all items into schedule Table

    my_scheduleItem =
        new MyScheduleItem(schedule_time, " ", schedule_title, " ", " ", schedule_location);
    // Inserting ScheduleItems to Database
    Log.d(HOMESCREEN, "Inserting Master Schedule Items");
    // Log.d(HOMESCREEN, ((startTimesArray.length)-1).toString());
    Log.d(HOMESCREEN, "StartTime:" + my_scheduleItem.getStartTime().toString());
    Log.d(HOMESCREEN, "Location:" + my_scheduleItem.getPanelTitle().toString());
    schedItem_id = dbHelper2.createMyScheduleItem(my_scheduleItem, null);

    /** ***************************************************************** */
    Toast.makeText(HomeScreen.this, "Item Added to MySchedule", Toast.LENGTH_SHORT).show();
  }
Example #5
0
  public void guardarGasto(View view) {
    if (tvMonto.getText().toString().equals("")) return;

    int monto = Integer.parseInt(tvMonto.getText().toString());
    Spinner spinnerCategoria = (Spinner) findViewById(R.id.categoria);
    Categoria categoria = categorias.get(spinnerCategoria.getSelectedItemPosition());
    TextView tvSubcategoria = (TextView) findViewById(R.id.subcategoria);
    String subcategoria = tvSubcategoria.getText().toString();

    subcategoria = subcategoria.toLowerCase();
    subcategoria = subcategoria.trim();

    gasto.setMonto(monto);
    gasto.setCategoria(categoria);
    gasto.setSubcategoria(subcategoria);
    gasto.setSincronizado(false);

    GastosDbAdapter gastosDbAdapter = new GastosDbAdapter(this);
    gastosDbAdapter.abrir();
    gastosDbAdapter.actualizarGasto(gasto);
    gastosDbAdapter.cerrar();

    tvMonto.setText("");
    spinnerCategoria.setSelection(0);
    tvSubcategoria.setText("");

    tvMonto.clearFocus();

    Toast.makeText(this, "Gasto guardado ", Toast.LENGTH_LONG).show();
    this.finish();
  }
 private boolean passwordEditTextFieldIsValid() {
   if (mPasswordEditText.getText() == null) {
     return false;
   } else {
     return (mPasswordEditText.getText().length() > 5);
   }
 }
Example #7
0
  public void testLocationHandling() {
    solo.clickOnToggleButton(startStopButton.getText().toString());

    solo.sleep(1000);
    System.out.println("DEBUG: CLICKED");
    Location locationA = createLocation((float) 47.058765, (float) 15.459198, 355.112);
    System.out.println("DEBUG: Send first Location");
    sendLocation(locationA);

    solo.sleep(1100);

    assertEquals("Is first Location send", "0.0m", distanceTextView.getText().toString());
    assertEquals("Is altitude set correct", "0.0m", altitudeTextView.getText().toString());

    Location locationB = createLocation((float) 47.069523, (float) 15.450572, 354.110);
    sendLocation(locationB);
    solo.sleep(1000);

    double altitude = 355.112 - 354.110;
    System.out.println("DEBUG: expected distance " + locationB.distanceTo(locationA));
    assertEquals(
        "Is second Location send",
        locationB.distanceTo(locationA) + "m",
        distanceTextView.getText().toString());
    assertEquals(
        "Is altitude calculated correct?", altitude + "m", altitudeTextView.getText().toString());
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 5) {
      if (resultCode == RESULT_OK) {
        if ((data.getIntExtra("expPoints", 0) != 0)
            && (data.getIntExtra("exercises_cmplt", 0) != 0)) {
          int got_exp = data.getIntExtra("expPoints", 0);
          int got_exs = data.getIntExtra("exercises_cmplt", 0);
          increaseProgressBy(got_exp);
          exsCmplt.setText(
              String.valueOf(Integer.parseInt(exsCmplt.getText().toString()) + got_exs));
          saveProgressInfo("EXSCMPLT", exsCmplt.getText().toString());
          // weight.setText(String.valueOf(got_exp));
        }
        // int tabNumber = Integer.parseInt(data.getStringExtra("tabNo"));
        // tabHost.setCurrentTab(tabNumber);
      }
    }

    if (requestCode == 6) {
      if (resultCode == RESULT_OK) {
        if ((data.getIntExtra("expPoints", 0) != 0) && (data.getIntExtra("qAnswered", 0) != 0)) {
          int got_exp = data.getIntExtra("expPoints", 0);
          int answered = data.getIntExtra("qAnswered", 0);
          qAnswered = answered;
          increaseProgressBy(got_exp);
          saveProgressInfo("QANSWERED", answered);
        }
      }
    }
    new pushToServer().execute();
  }
Example #9
0
  public void setLocation(View view) throws IOException {

    // checks to see if address text edit box is not empty
    if (!addr.getText().toString().equals("")) {

      // This segment translates a string address into latitude and longitude coordinates
      List<Address> foundGeocode = null;
      foundGeocode = new Geocoder(this).getFromLocationName(addr.getText().toString(), 1);
      latitude = foundGeocode.get(0).getLatitude();
      longitude = foundGeocode.get(0).getLongitude();

      // checks to make sure coordinates values determined are legitimate
      if ((latitude <= 90 && latitude >= -90) && (longitude <= 180 && longitude >= -180)) {

        info.setLatitude(latitude);
        info.setLongitude(longitude);
        Toast.makeText(getBaseContext(), "Location Updated!", Toast.LENGTH_LONG).show();
      } else {
        Toast.makeText(
                getBaseContext(),
                "Out of Bounds Error with latitude/longitude coordinates",
                Toast.LENGTH_LONG)
            .show();
      }

    } else {
      Toast.makeText(getBaseContext(), "You must enter in a valid adddress", Toast.LENGTH_LONG)
          .show();
    }
  }
  @Override
  public void onOtherButtonClick(ActionSheet actionSheet, int index) {
    if (msgData == null) return;
    String picURL = "";
    if (!TextUtils.isEmpty(msgData.getPic())) {
      picURL = Pub_HttpUtils.BASE_URL + msgData.getPic();
    }

    if (index == 0) { // 海航圈
      doShare(
          picURL,
          msgData.getTitle(),
          msgData.getId(),
          text.getText().toString(),
          url,
          "点击这里查看详情",
          "海航公众平台");
    } else if (index == 1) { // 海航好友
      String customshareInfoString =
          ShareUtil.getShareLinkParameters(
              url, msgData.getTitle(), text.getText().toString(), picURL);
      ShareUtil.gotoShare_UserListActivity(
          this,
          customshareInfoString,
          text.getText().toString(),
          msgData.getTitle(),
          picURL,
          false);
    } else if (index == 2) { // 微信朋友圈
      senWechatReq(1, url, text.getText().toString(), msgData.getTitle(), picURL);
    } else if (index == 3) { // 微信好友
      senWechatReq(0, url, text.getText().toString(), msgData.getTitle(), picURL);
    }
  }
  public void testPreConditions() throws Exception {
    // the two taps should be off
    boolean expected = false;
    assertEquals(expected, imageView1.isPressed());
    assertEquals(expected, imageView2.isPressed());

    // background images are showing for the imageView
    boolean isImageShowing = true;
    assertEquals(isImageShowing, imageView1.getBackground() != null);
    assertEquals(isImageShowing, imageView2.getBackground() != null);

    // check if Hot and Cold text under the images is shown
    boolean expected_text1 = true;
    boolean expected_text2 = true;
    boolean actual_text1 = textView1.getText().toString().equalsIgnoreCase("HOT");
    boolean actual_text2 = textView2.getText().toString().equalsIgnoreCase("COLD");
    assertEquals(expected_text1, actual_text1);
    assertEquals(expected_text2, actual_text2);

    // check if our custom bath view is enabled and showing
    boolean expected_view = true;
    boolean actual_view = bathView.isEnabled();
    assertEquals(expected_view, actual_view);

    // check if a network connection is available to fetch data from json file
    boolean expected_network = true;
    boolean actual_network = netUtil.isMobileDataEnabled() | netUtil.isWifiConnected();
    assertEquals(expected_network, actual_network);
  }
  // Check whether all information needed for offering a ride
  // has been typed in by user
  public boolean inputValid() {
    boolean checkBelong = false, checkStart = false, checkEnd = false;
    if (isGroup || isEvent) {
      checkBelong = true;
    } else {
      System.out.println("Have not choose any group or event!!");
      Toast.makeText(
              getApplicationContext(), "Must select a group or an event!", Toast.LENGTH_SHORT)
          .show();
    }
    if (!EditStart.getText().toString().isEmpty()
        || isFromEvent
        || FromCurrentLocation.isChecked()) {
      checkStart = true;
    } else {
      System.out.println("Have not input start point!!");
      Toast.makeText(getApplicationContext(), "Must set start point!", Toast.LENGTH_SHORT).show();
    }
    if (!EditEnd.getText().toString().isEmpty() || isToEvent || ToCurrentLocation.isChecked()) {
      checkEnd = true;
    } else {
      System.out.println("Have not input end point!!");
      Toast.makeText(getApplicationContext(), "Must set end point!", Toast.LENGTH_SHORT).show();
    }

    return !((!checkBelong)
        || displayDate.getText().toString().isEmpty()
        || (displayStartTime.getText().toString().isEmpty() && !isFind)
        || displayArrivalTime.getText().toString().isEmpty()
        || (!checkStart)
        || (!checkEnd));
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 3000 && resultCode == Activity.RESULT_OK) {
      for (int i = 0; i < Constants.list_right.size(); i++) {
        if (tv_llry
            .getText()
            .toString()
            .trim()
            .contains(Constants.list_right.get(i).getUserName())) {
          continue;
        }
        if (i == Constants.list_right.size() - 1) {
          if (tv_llry.getText().toString() != null && !tv_llry.getText().toString().equals("")) {
            cxry_username.append("," + Constants.list_right.get(i).getUserName());
            cxry_usercode.append("," + Constants.list_right.get(i).getUserCode());
          } else {
            cxry_username.append(Constants.list_right.get(i).getUserName());
            cxry_usercode.append(Constants.list_right.get(i).getUserCode());
          }

        } else {
          if (tv_llry.getText().toString() != null && !tv_llry.getText().toString().equals("")) {
            cxry_username.append("," + Constants.list_right.get(i).getUserName());
            cxry_usercode.append("," + Constants.list_right.get(i).getUserCode());
          } else {
            cxry_username.append(Constants.list_right.get(i).getUserName() + ",");
            cxry_usercode.append(Constants.list_right.get(i).getUserCode() + ",");
          }
        }
      }
      tv_llry.setText(cxry_username);
    }
  }
  public boolean validarCampos() {

    if (modelo.getText().toString() == null || modelo.getText().toString().equals("")) {
      modelo.requestFocus();
      msg("Campo obrigatorio");
      return false;
    }
    if (marca.getText().toString() == null || marca.getText().toString().equals("")) {
      marca.requestFocus();
      msg("Campo obrigatorio");
      return false;
    }
    if (ano.getText().toString() == null || ano.getText().toString().equals("")) {
      ano.requestFocus();
      msg("Campo obrigatorio");
      return false;
    }
    if (km.getText().toString() == null || km.getText().toString().equals("")) {
      km.requestFocus();
      msg("Campo obrigatorio");
      return false;
    }
    if (potencia.getText().toString() == null || potencia.getText().toString().equals("")) {
      potencia.requestFocus();
      msg("Campo obrigatorio");
      return false;
    }

    return true;
  }
Example #15
0
 public void siguiente(View v) {
   dato[10] = de.getText().toString();
   dato[11] = iz.getText().toString();
   Intent intento = new Intent(getApplicationContext(), Frecuencia.class);
   intento.putExtra("1 2 3", dato);
   startActivity(intento);
 }
 private void check() {
   if (!TextUtils.isEmpty(weekTextView.getText())
       && !TextUtils.isEmpty(startTimeTextView.getText())
       && !TextUtils.isEmpty(endTimeTextView.getText())) {
     saveTime.setEnabled(true);
   }
 }
Example #17
0
  public void callAppForSentEmail() {
    String to[] = {"*****@*****.**"};
    String subject = "ATA App: Servicing Booking";
    String message =
        "Service Type: %s\n"
            + "Other Work: %s\n"
            + "Booking Date: %s\n"
            + "Name: %s\n"
            + "Rego: %s\n"
            + "Make: %s\n"
            + "Model: %s\n"
            + "Phone: %s\n"
            + "Address: %s\n"
            + "Rego Date: %s\n";

    message =
        String.format(
            message,
            tvDistance.getText().toString(),
            tvOtherWork.getText().toString(),
            tvBookDate.getText().toString(),
            etName.getText().toString(),
            edtRego.getText().toString(),
            edtMake.getText().toString(),
            edtModel.getText().toString(),
            edtPhone.getText().toString(),
            edtAddress.getText().toString(),
            edtRegoDate.getText().toString());
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
    emailIntent.putExtra(Intent.EXTRA_TEXT, message);
    emailIntent.setType("message/rfc822");
    startActivity(Intent.createChooser(emailIntent, "email"));
  }
 @Override
 public void onClick(View v) {
   if (ConnectionUtils.isOnline(this)) {
     EditText txName = (EditText) registerDialog.findViewById(R.id.txName);
     EditText txSurname = (EditText) registerDialog.findViewById(R.id.txSurname);
     TextView txEmailAddress = (TextView) registerDialog.findViewById(R.id.txEmailAddress);
     EditText txUserName = (EditText) registerDialog.findViewById(R.id.txUserName);
     EditText txPass1 = (EditText) registerDialog.findViewById(R.id.txPass1);
     EditText txPass2 = (EditText) registerDialog.findViewById(R.id.txPass2);
     if (validRegisterForm(
         txEmailAddress.getText().toString(),
         txName.getText().toString(),
         txSurname.getText().toString(),
         txUserName.getText().toString(),
         txPass1.getText().toString(),
         txPass2.getText().toString())) {
       registerDialog.cancel();
       dialog = ProgressDialog.show(this, "", "Creating account", true);
       dialog.show();
       createAccount(
           txEmailAddress.getText().toString(),
           txName.getText().toString(),
           txSurname.getText().toString(),
           txUserName.getText().toString(),
           txPass1.getText().toString());
     }
   } else {
     Toast.makeText(this, "Sorry.No internet access available.", Toast.LENGTH_SHORT).show();
   }
 }
  /*
   * gets user input from pop u p dialog
   *
   * @param title of the dialog
   *
   * @param message for dialog
   *
   * @param text firld to be assign data
   */
  private void getInputToField(String title, String message, final TextView field) {

    final EditText input = new EditText(this);
    input.setText(field.getText());
    input.setSelection(field.getText().length());
    new AlertDialog.Builder(this)
        .setTitle(title)
        .setMessage(message)
        .setView(input)
        .setPositiveButton(
            "Ok",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {

                field.setText(input.getText().toString());
              }
            })
        .setNegativeButton(
            "Cancel",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {
                // Do nothing.
              }
            })
        .show();
  }
 private String checkRight() {
   if (this.count == 0) {
     Toast.makeText(this, "您还没有选择张数", 0).show();
     return "您还没有选择张数";
   }
   TextView localTextView = (TextView) this.bNameItem.findViewById(R.id.itemInput);
   this.bName = localTextView.getText().toString().trim();
   if (TextUtils.isEmpty(this.bName)) {
     localTextView.setError(Html.fromHtml("<font color=#ff0000>取票人不能为空</font>"));
     localTextView.requestFocus();
     return "取票人不能为空";
   }
   localTextView = (TextView) this.bPhoneNoItem.findViewById(R.id.itemInput);
   this.bPhoneNo = localTextView.getText().toString().trim();
   if (TextUtils.isEmpty(this.bPhoneNo)) {
     localTextView.setError(Html.fromHtml("<font color=#ff0000>手机号不能为空</font>"));
     localTextView.requestFocus();
     return "手机号不能为空";
   }
   if ((this.bPhoneNo != null) && (this.bPhoneNo.length() < 11)) {
     localTextView.setError(Html.fromHtml("<font color=#ff0000>手机号错误</font>"));
     localTextView.requestFocus();
     return "手机号错误";
   }
   return null;
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == android.R.id.home) {
      finish();
      return true;
    }

    if (id == R.id.action_distribute) {
      if (tv_executor.getText().toString().equals("")) {
        ToastUtil.showToast(this, "请选择施工员", Toast.LENGTH_SHORT);
        return true;
      }

      if (tv_deadline.getText().toString().equals("")) {
        ToastUtil.showToast(this, "请选择工程期限", Toast.LENGTH_SHORT);
        return true;
      }
      distribute();
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
Example #22
0
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    String[] arrContDesc = getTxtView.getContentDescription().toString().split("=");
    int contentDescription = Integer.valueOf(arrContDesc[0]);

    switch (item.getItemId()) {
      case EDIT:
        Intent intent = new Intent(MainActivity.this, EditCelebActivity.class);
        Bundle extras = new Bundle();
        extras.putInt("ID", contentDescription);
        extras.putString("DATE", arrContDesc[1]);
        extras.putString("DESCRIPTION", getTxtView.getText().toString());
        intent.putExtras(extras);
        startActivityForResult(intent, 2);
        break;
      case DELETE:
        if (db.deleteTitle(contentDescription)) {
          getInfo();
          doingListViewAdapter();
          Toast.makeText(
                  this,
                  "You deleted " + getTxtView.getText().toString() + " notation",
                  Toast.LENGTH_SHORT)
              .show();
        } else
          Toast.makeText(this, "Your notation wasn't deleted, try again", Toast.LENGTH_SHORT)
              .show();

        break;
    }
    return super.onContextItemSelected(item);
  }
Example #23
0
  private void submit() {

    String hospital = mEtHospital.getText().toString();
    if (TextUtils.isEmpty(hospital)) {
      mActivity.showToast("请填写医疗机构");
      return;
    }
    String checkDate = DateFormatUtils.timeToLongString(mTvDate.getText().toString());
    PostAddReportItem postAddReportItem = new PostAddReportItem();
    if (mImageFilePaths.size() > 0) {
      List<File> files = new LinkedList<>();
      for (int i = 0; i < mImageFilePaths.size() - 1; i++) // -1的目的去除默认的+
      {
        File file = new File(mImageFilePaths.get(i));
        if (file != null && file.exists()) {
          files.add(file);
        }
      }
      postAddReportItem.files = files;
    }
    postAddReportItem.checkTime = checkDate;
    postAddReportItem.name = mTvDate.getText().toString() + "的检查报告";
    postAddReportItem.institution = hospital;
    postAddReportItem.userId = RSAUtil.clientEncrypt(mActivity.getLoginSuccessItem().id);
    SubmitAddReportPresenter submitAddReportPresenter =
        new SubmitAddReportPresenterImpl(mActivity, this, REQUEST_SUBMIT_TAG);
    submitAddReportPresenter.doAddReport(postAddReportItem);
  }
Example #24
0
  /**
   * 关于微博的文本处理: @、##、http://t.cn/....
   *
   * @param tv
   */
  public static void textFormat(TextView tv) {

    Spannable sp = (Spannable) tv.getText();
    String text = tv.getText().toString();

    Matcher m1 = Pattern.compile("http://t.cn/[a-zA-Z0-9]+").matcher(text);
    Matcher m2 = Pattern.compile("@[^:||^:||\\s]+").matcher(text);
    Matcher m3 = Pattern.compile("#[^#]+#").matcher(text);

    // 下面使用正则表达式
    while (m1.find()) {
      int start, end;
      start = m1.start();
      end = m1.end();
      sp.setSpan(
          new ForegroundColorSpan(0xff444444), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    while (m2.find()) {
      int start, end;
      start = m2.start();
      end = m2.end();
      sp.setSpan(
          new ForegroundColorSpan(0xff444444), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    while (m3.find()) {
      int start, end;
      start = m3.start();
      end = m3.end();
      sp.setSpan(
          new ForegroundColorSpan(0xff444444), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
  }
 @Override
 public void onClick(View v) {
   Employer employer = (Employer) spnEmployer.getSelectedItem();
   //            Toast.makeText(
   //                AddJob.this,
   //                String.format(
   //                    "Employer: %s (%d)\nTitle: %s\nDesc: %s",
   //                    employer.employerName,
   //                    employer.id,
   //                    txtTitle.getText(),
   //                    txtDescription.getText()
   //                ),
   //                Toast.LENGTH_SHORT
   //            ).show();
   if ((employer.id < 0)
       || (txtTitle.getText().length() == 0)
       || (txtDescription.getText().length() == 0)) {
     Toast.makeText(AddJob.this, "Fill out the form completely first.", Toast.LENGTH_LONG)
         .show();
   } else {
     db.addJob(
         employer.id, txtTitle.getText().toString(), txtDescription.getText().toString());
     Toast.makeText(AddJob.this, "Job added", Toast.LENGTH_SHORT).show();
     // spnEmployer.setSelection(0); // select "choose an employer"
     txtTitle.setText("");
     txtDescription.setText("");
   }
 }
  /*
   * calculate team's score
   */
  private void caculTeamTP() {
    TextView txt_AP = (TextView) rootView.findViewById(R.id.txt_team_AP);
    TextView txt_DP = (TextView) rootView.findViewById(R.id.txt_team_DP);
    TextView txt_HP = (TextView) rootView.findViewById(R.id.txt_team_HP);
    int AP = Integer.parseInt(txt_AP.getText().toString());
    int DP = Integer.parseInt(txt_DP.getText().toString());
    int HP = Integer.parseInt(txt_HP.getText().toString());

    int NumberArr[] = {0, 4, 8, 13, 18, 22, 27, 32, 38, 43, 50, 58};
    String scoreArr[] = {"D", "C", "B", "A", "S", "SS", "SSS", "X", "XD", "XC", "XB", "XA"};
    int TP = AP * 2 + DP * 5 + HP;

    // binary search
    int last = NumberArr.length;
    int begin = 0;
    int pivot = (last + begin) / 2;
    while (true) {
      if (TP / 10000 > NumberArr[pivot]) {
        begin = pivot;
        pivot = (last + begin) / 2;
      } else {
        last = pivot;
        pivot = (last + begin) / 2;
      }
      if (last - begin == 1) break;
    }
    String score = scoreArr[begin];
    // set text
    TextView txt_TP = (TextView) rootView.findViewById(R.id.txt_team_TP);
    txt_TP.setText(score);
  }
  /** 结束时间 */
  @Click(R.id.tv_endtime)
  void onJssjClick() {
    if (!startimeText.getText().toString().equals("起始时间")) {
      Date dt =
          new Date(DateUtil.strToTimestamp(startimeText.getText().toString(), "yyyy-MM-dd") * 1000);
      if (!endtimeText.getText().toString().equals("结束时间")) {
        dt =
            new Date(
                DateUtil.strToTimestamp(endtimeText.getText().toString(), "yyyy-MM-dd") * 1000);
      }
      datePickerDialog =
          new KooniaoDatePickerDialog(
              ProductEditActivity.this,
              new DatePickerDialog.OnDateSetListener() {

                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                  String timeString = year + "-" + (monthOfYear + 1) + "-" + dayOfMonth;
                  endtimeText.setText(timeString);
                }
              },
              dt.getYear() + 1900,
              dt.getMonth(),
              dt.getDate());
      datePickerDialog.getDatePicker().setMinDate(ApiCaller.TimeInService * 1000);
      datePickerDialog.show();
    } else {
      showToast("请您选择自动上架的起始时间!");
    }
  }
  public void onSaveClick(View button) {

    AndroidDeferredManager deferredManager = new AndroidDeferredManager();
    deferredManager.setAutoSubmit(true);

    Data data = new Data();

    Spinner spinna = (Spinner) findViewById(R.id.user_name);
    data.name = spinna.getSelectedItem().toString();

    TextView view;
    view = (TextView) findViewById(R.id.location_name);
    data.location = view.getText().toString();

    view = (TextView) findViewById(R.id.booty_name);
    data.booty = view.getText().toString();

    final TextView errorView = (TextView) findViewById(R.id.error_view);

    deferredManager.when(postYourBooty(data)).always(logger());

    if (errorView != null) {
      errorView.setText("Posting data");
    }
  }
Example #29
0
 public void run(View view) {
   Bundle extras = getIntent().getExtras();
   if (extras != null) {
     int Value = extras.getInt("id");
     if (Value > 0) {
       if (mydb.updateContact(
           id_To_Update,
           name.getText().toString(),
           phone.getText().toString(),
           email.getText().toString(),
           street.getText().toString(),
           place.getText().toString())) {
         Toast.makeText(getApplicationContext(), "Updated", Toast.LENGTH_SHORT).show();
         Intent intent = new Intent(getApplicationContext(), com.example.myapp.MainActivity.class);
         startActivity(intent);
       } else {
         Toast.makeText(getApplicationContext(), "not Updated", Toast.LENGTH_SHORT).show();
       }
     } else {
       if (mydb.insertContact(
           name.getText().toString(),
           phone.getText().toString(),
           email.getText().toString(),
           street.getText().toString(),
           place.getText().toString())) {
         Toast.makeText(getApplicationContext(), "done", Toast.LENGTH_SHORT).show();
       } else {
         Toast.makeText(getApplicationContext(), "not done", Toast.LENGTH_SHORT).show();
       }
       Intent intent = new Intent(getApplicationContext(), com.example.myapp.MainActivity.class);
       startActivity(intent);
     }
   }
 }
 private Boolean isHeader(TextView prev, TextView act) {
   if (isSameChar(prev.getText().charAt(0), act.getText().charAt(0))) {
     return Boolean.FALSE;
   } else {
     return Boolean.TRUE;
   }
 }