示例#1
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"));
  }
  /**
   * 验证信息是否为空
   *
   * @return
   */
  private boolean verification() {
    name = et_user_name.getText().toString();
    idcard = et_user_card.getText().toString();
    bankid = et_user_ban.getText().toString();
    phone = et_user_phone.getText().toString();
    bankname = tv_bank_name.getText().toString();

    if ("".equals(bankname)) {
      TXWLApplication.getInstance().showTextToast("银行不能为空");
      return false;
    }
    if (DataVeri.isBlank(name)) {
      TXWLApplication.getInstance().showTextToast("真实姓名不能为空");
      return false;
    }
    if (DataVeri.isBlank(idcard)) {
      TXWLApplication.getInstance().showTextToast("证件号码不能为空");
      return false;
    }
    if (DataVeri.isBlank(bankid)) {
      TXWLApplication.getInstance().showTextToast("银行卡号不能为空");
      return false;
    }
    return !DataVeri.isMobileNum(phone);
  }
示例#3
0
 public ArrayList<ServiceType> fakeServiceType(TextView tvServiceType) {
   serviceTypeArrayList = new ArrayList<ServiceType>();
   ServiceType serviceType;
   for (int i = 0; i <= 100; i++) {
     if ((Integer.toString(5 + 5 * i) + ",000 km").equals(tvServiceType.getText().toString())) {
       serviceType = new ServiceType((Integer.toString(5 + 5 * i) + ",000 km"), true);
     } else {
       serviceType = new ServiceType((Integer.toString(5 + 5 * i) + ",000 km"), false);
     }
     serviceTypeArrayList.add(serviceType);
   }
   return serviceTypeArrayList;
 }
 public void testOverallProsCons() {
   assertNotNull(overallProsConsTable);
   assertEquals("care about patient", overallPros1.getText());
   assertEquals("quick diagnosis", overallPros2.getText());
   assertEquals("easy for parking", overallPros3.getText());
   assertEquals("don't care about patient", overallCons1.getText());
   assertEquals("slow diagnosis", overallCons2.getText());
   assertEquals("hard for parking", overallCons3.getText());
 }
示例#5
0
  public final void reset() {
    //        if (null != mHeaderText) {
    //            mHeaderText.setText(mPullLabel);
    //        }
    mHeaderImage.setVisibility(View.VISIBLE);

    if (mUseIntrinsicAnimation) {
      ((AnimationDrawable) mHeaderImage.getDrawable()).stop();
    } else {
      // Now call the callback
      resetImpl();
    }

    if (null != mSubHeaderText) {
      if (TextUtils.isEmpty(mSubHeaderText.getText())) {
        mSubHeaderText.setVisibility(View.GONE);
      } else {
        mSubHeaderText.setVisibility(View.VISIBLE);
      }
    }
  }
示例#6
0
  @Override
  public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
    Log.d(TAG, "onEditorAction: actionId: " + actionId + ", keyEvent: " + keyEvent);

    if ((actionId == EditorInfo.IME_ACTION_DONE)
        || ((keyEvent != null) && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
      Log.d(TAG, "onEditorAction: IME_ACTION_DONE || KEYCODE_ENTER");
      String input = textView.getText().toString().trim();

      if (input.length() > 0) {
        String result = "";

        try {
          result += calculator.calculate(input);
        } catch (Exception e) {
          result = "no result (" + e.getMessage() + ")";
        }

        if (listAdapter.getCount() > 0) {
          listAdapter.add("");
        }

        listAdapter.add(input + " =");
        if (input.indexOf("@") > -1) {
          listAdapter.add(calculator.getEquation() + " =");
        }
        listAdapter.add(result);
        listAdapter.notifyDataSetChanged();

        inputView.endBatchEdit();
        inputView.setText("");
        hideKeyboard();
      }
    }

    return false;
  }
 public void testRating() {
   assertEquals("3.0", rating.getText());
 }
 public void testPhone() {
   assertEquals("(215)662-3228", phone.getText());
 }
 public void testAddress() {
   assertEquals("3400 Spruce Street, Philadelphia, PA  19104", address.getText());
 }
示例#10
0
 public void testName() {
   assertEquals("testProvider", name.getText());
 }
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View view =
          LayoutInflater.from(BookDescriptionActivity.this).inflate(R.layout.book_desc_data, null);
      // initiate widgets
      TextView description = (TextView) view.findViewById(R.id.book_desc_txt);
      TextView verseNo = (TextView) view.findViewById(R.id.book_desc_verseno_txt);
      // set the verse string to show
      verseNo.setText(EBibleConstants.verseListToHighlight.get(position));
      description.setText(
          EBibleConstants.contentListToHighlight.get(position), BufferType.SPANNABLE);

      /*Log.i("vesre contains in adapter",""+highlightedMatchedVerseArr.contains(EBibleConstants.verseListToHighlight.get(position)));
      Log.i("db saved verse at position",""+highlightedMatchedVerseArr.get(position));
      Log.i("saved verse at position",""+EBibleConstants.verseListToHighlight.get(position));
      Log.i("verse position matched",""+(highlightedMatchedVerseArr.get(position).equalsIgnoreCase((EBibleConstants.verseListToHighlight.get(position)))));*/
      // highlight functionality if found
      Spannable textToSpan = (Spannable) description.getText();
      if ((highlightedMatchedDescriptionArr.size() > 0)) {
        for (int count = 0; count < highlightedMatchedDescriptionArr.size(); count++) {
          if (highlightedMatchedDescriptionArr.get(count) != null /*&&
					(highlightedMatchedVerseArr.get(position).equalsIgnoreCase(
							(EBibleConstants.verseListToHighlight.get(position))))*/) {
            /*Log.i("verse matched desc in loop",""+highlightedMatchedDescriptionArr.get(count).equalsIgnoreCase
            			(highlightedMatchedVerseArr.get(position)));
            if(highlightedMatchedDescriptionArr.get(count).equalsIgnoreCase
            		(highlightedMatchedVerseArr.get(position)))
            {*/
            int index =
                EBibleConstants.contentListToHighlight
                    .get(position)
                    .indexOf(highlightedMatchedDescriptionArr.get(count), 0);
            // .indexOf(highlightedMatchedDescriptionArr.get(count));
            Log.i("index", "" + index);
            if (index > -1
                && (highlightedMatchedVerseArr
                    .get(count)
                    .equalsIgnoreCase(EBibleConstants.verseListToHighlight.get(position)))) {
              textToSpan.setSpan(
                  new BackgroundColorSpan(
                      Integer.parseInt(highlightedMatchedColorCodeArr.get(count))),
                  index,
                  (index + highlightedMatchedDescriptionArr.get(count).length()),
                  Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

              // check for underline
              if (highlightedMatchedUnderlineArr.get(count).equalsIgnoreCase("1")) {
                textToSpan.setSpan(
                    new UnderlineSpan(),
                    index,
                    (index + highlightedMatchedDescriptionArr.get(count).length()),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
              }
            }
          }
          // }
        }
        description.setText(textToSpan);
      }

      // set the buttons state as enable or disable respect to data fetched from file
      if (EBibleConstants.pageNumber < (EBibleConstants.lastParaValue)) {
        next.setEnabled(true);
      } else {
        next.setEnabled(false);
      }
      if (EBibleConstants.pageNumber == (EBibleConstants.startParaNumber)) {
        previous.setEnabled(false);
      } else {
        previous.setEnabled(true);
      }

      description.setOnLongClickListener(
          new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
              Log.i("", "selected chapter " + selectedChapterName);
              versePositionToHighlighten = position;
              verseHighlightedPositionToStore = EBibleConstants.verseListToHighlight.get(position);
              // start the highlight view dialog
              new HighlightDialog(
                  BookDescriptionActivity.this,
                  selectedBookName,
                  selectedChapterPosition,
                  position);
              return false;
            }
          });

      return view;
    }
示例#12
0
  @Override
  public void onClick(View v) {
    TextView txtManageLabel, txtBrowseLabel, txtRefreshLabel, txtSearchLabel;
    txtManageLabel = (TextView) findViewById(R.id.txt_manage_label);
    txtBrowseLabel = (TextView) findViewById(R.id.txt_browse_label);
    txtRefreshLabel = (TextView) findViewById(R.id.txt_refresh_label);
    txtSearchLabel = (TextView) findViewById(R.id.txt_search_label);
    txtSearch.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            new AsyncTask<String, Void, ArrayList<RssItem>>() {
              @Override
              protected ArrayList<RssItem> doInBackground(String... params) {
                return dbQuery.searchRssItem(params[0]);
              }

              @Override
              protected void onPostExecute(ArrayList<RssItem> result) {
                rssList.clear();
                rssList.addAll(result);
                rssAdapter.config().notifyDataSetChanged();
              }
            }.execute(s.toString());
          }

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

          @Override
          public void afterTextChanged(Editable s) {}
        });
    txtSearch.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) return true;
            return false;
          }
        });
    switch (v.getId()) {
      case R.id.btn_manage:
        startActivityForResult(
            new Intent(RssReaderActivity.this, RssManageActivity.class), REQ_RSS_MANAGE);
        break;

      case R.id.btn_browse:
        rssProvider = dbQuery.getRssProviderList(null);
        int length = rssProvider.getProviderNames().length;
        if (length == 0) break;

        String[] providers = new String[length + 1];
        providers[0] = "All";
        for (int i = 0; i < length; i++) providers[i + 1] = rssProvider.getProviderNames()[i];
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder
            .setTitle(R.string.rss_choose_provider)
            .setItems(
                providers,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int item) {
                    if (item == 0) {
                      loadData(null, true, false, false);
                      return;
                    }
                    loadData(rssProvider.getProviderNames()[item - 1], false, false, false);
                    curProvider = item - 1;
                    updateListView();
                  }
                });
        builder.create().show();
        break;

      case R.id.btn_refresh:
        if (curProvider == -1) loadData(null, true, true, true);
        else
          loadData(
              dbQuery.getRssProviderList(null).getProviderNames()[curProvider], false, true, true);
        break;

      case R.id.btn_search:
        if (txtSearchLabel.getText().toString().equals(getString(R.string.btn_search_text))) {
          btnManage.setVisibility(View.GONE);
          txtManageLabel.setVisibility(View.GONE);
          btnBrowse.setVisibility(View.GONE);
          txtBrowseLabel.setVisibility(View.GONE);
          btnRefresh.setVisibility(View.GONE);
          txtRefreshLabel.setVisibility(View.GONE);
          btnSearch.setBackgroundResource(R.drawable.btn_done_background);
          txtSearchLabel.setText(R.string.btn_done_text);
          txtSearch.setVisibility(View.VISIBLE);
          txtSearch.requestFocus();
        } else {
          btnManage.setVisibility(View.VISIBLE);
          txtManageLabel.setVisibility(View.VISIBLE);
          btnBrowse.setVisibility(View.VISIBLE);
          txtBrowseLabel.setVisibility(View.VISIBLE);
          btnRefresh.setVisibility(View.VISIBLE);
          txtRefreshLabel.setVisibility(View.VISIBLE);
          btnSearch.setBackgroundResource(R.drawable.btn_search_background);
          txtSearchLabel.setText(R.string.btn_search_text);
          txtSearch.setVisibility(View.GONE);
          txtSearch.setText("");
          loadData(null, true, false, false);
        }
        break;
      default:
        break;
    }
  }
示例#13
0
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case TIME_1S:
              int timeLeft = Integer.parseInt(timeText.getText().toString()) - 1;
              timeText.setText(Integer.toString(timeLeft));
              if (timeLeft == 0) {
                timer.cancel();
                gameOver.setMessage("Time is up! Again ?");
                gameOver.show();
              }
              break;
            case RESET_TIME:
              timeText.setText("100");
              timer = new Timer();

              timerTask =
                  new TimerTask() {
                    public void run() {
                      Message msg = new Message();
                      msg.what = TIME_1S;
                      handler.sendMessage(msg);
                    }
                  };
              timer.schedule(timerTask, 1000, 1000);
              break;

            case MOVE_IMAGE:
              if ((speedX > 0 && acceleratorX < 0) || (speedX < 0 && acceleratorX > 0))
                speedX -= 2 * acceleratorX;
              else speedX -= 0.1 * acceleratorX;

              if ((speedY > 0 && acceleratorY < 0) || (speedY < 0 && acceleratorY > 0))
                speedY += 2 * acceleratorY;
              else speedY += 0.1 * acceleratorY;

              int dx = (int) (speedX * 0.05);
              int dy = (int) (speedY * 0.05);
              View v = findViewById(R.id.image);
              int left = v.getLeft() + dx;
              int top = v.getTop() + dy;
              int right = v.getRight() + dx;
              int bottom = v.getBottom() + dy;

              if (left < 20) {
                left = 20;
                right = left + v.getWidth();
                speedX = 0;
              }
              if (right > screenWidth - 20) {
                right = screenWidth - 20;
                left = right - v.getWidth();
                speedX = 0;
              }
              if (top < 100) {
                top = 100;
                bottom = top + v.getHeight();
                speedY = 0;
              }
              if (bottom > screenHeight - 20) {
                bottom = screenHeight - 20;
                top = bottom - v.getHeight();
                speedY = 0;
              }

              if (arrayMap.isCollision(left, top, right, bottom) != 0) {

                MessageSend(COLLISION);
                top = v.getTop();
                bottom = v.getBottom();

                if (arrayMap.isCollision(left, top, right, bottom) == 1) {
                  speedY = 0;
                  top = v.getTop();
                  bottom = v.getBottom();
                } else if (arrayMap.isCollision(left, top, right, bottom) == 2) {
                  speedX = 0;
                  left = v.getLeft();
                  right = v.getRight();
                }
              } else if (arrayMap.isArrive(left, top, right, bottom)) {
                MessageSend(NEXT_LEVEL);
                left = v.getLeft();
                top = v.getTop();
                right = v.getRight();
                bottom = v.getBottom();

                LinearLayout map = (LinearLayout) findViewById(R.id.map);
                map.removeAllViews();

                speedX = speedY = 0;
              } else if (arrayMap.isDead(left, top, right, bottom)) {
                left = v.getLeft();
                top = v.getTop();
                right = v.getRight();
                bottom = v.getBottom();
                speedX = speedY = 0;
                removeImage();
                gameOver.show();
                MessageSend(ACCELERATOR_STOP);
              }

              v.layout(left, top, right, bottom);
              break;
            case NEXT_LEVEL:
              LevelDatabaseHelper dbhelper = new LevelDatabaseHelper(OnGame.this, "LevelData", 1);
              SQLiteDatabase db = dbhelper.getReadableDatabase();
              //	    			db.execSQL("update levellock set lock=? where difficulty=? and level=?",
              //	    					new Object[]{0,difficulty,level+1});
              LevelDatabaseHelper.Unlock(db, level, difficulty);
              nextLevel.show();
              break;
            case BALL_START:
              //	    			BallStart();
              break;
            case ACCELERATOR_STOP:
              SManager.unregisterListener(listener);
              acceleratorX = 0;
              acceleratorY = 0;
              speedX = 0;
              speedY = 0;
              break;
          }
        }
示例#14
0
 public String getMessage() {
   return message.getText().toString();
 }
示例#15
0
  public void testRatings() {
    titleView = expandableListView.getChildAt(0);
    stars = (RatingBar) titleView.findViewById(R.id.providerpf_comment_stars);
    date = (TextView) titleView.findViewById(R.id.providerpf_comment_date);
    userName = (TextView) titleView.findViewById(R.id.providerpf_user_name);
    assertEquals("By username1", userName.getText());
    assertEquals("2012-12-12 ", date.getText());
    assertEquals(5.0, stars.getRating(), 0.0);

    titleView = expandableListView.getChildAt(1);
    stars = (RatingBar) titleView.findViewById(R.id.providerpf_comment_stars);
    date = (TextView) titleView.findViewById(R.id.providerpf_comment_date);
    userName = (TextView) titleView.findViewById(R.id.providerpf_user_name);
    assertEquals("By username2", userName.getText());
    assertEquals("2012-11-12 ", date.getText());
    assertEquals(3.0, stars.getRating(), 0.0);

    titleView = expandableListView.getChildAt(2);
    stars = (RatingBar) titleView.findViewById(R.id.providerpf_comment_stars);
    date = (TextView) titleView.findViewById(R.id.providerpf_comment_date);
    userName = (TextView) titleView.findViewById(R.id.providerpf_user_name);
    assertEquals("By username3", userName.getText());
    assertEquals("2012-10-12 ", date.getText());
    assertEquals(3.0, stars.getRating(), 0.0);

    titleView = expandableListView.getChildAt(3);
    stars = (RatingBar) titleView.findViewById(R.id.providerpf_comment_stars);
    date = (TextView) titleView.findViewById(R.id.providerpf_comment_date);
    userName = (TextView) titleView.findViewById(R.id.providerpf_user_name);
    assertEquals("By username4", userName.getText());
    assertEquals("2012-09-12 ", date.getText());
    assertEquals(4.0, stars.getRating(), 0.0);

    listAdapter = expandableListView.getExpandableListAdapter();
    listView = listAdapter.getChildView(0, 0, true, null, null);
    tv_provider_summary = (TextView) listView.findViewById(R.id.providerpf_rate_review_summary);
    assertEquals(tv_provider_summary.getText(), "Very Good");
    tv_pro1 = (TextView) listView.findViewById(R.id.providerpf_review_pro1);
    assertEquals(tv_pro1.getText(), "care about patient");
    tv_pro2 = (TextView) listView.findViewById(R.id.providerpf_review_pro2);
    assertEquals(tv_pro2.getText(), "quick diagnosis");
    tv_pro3 = (TextView) listView.findViewById(R.id.providerpf_review_pro3);
    assertEquals(tv_pro3.getText(), "easy for parking");
    tv_con1 = (TextView) listView.findViewById(R.id.providerpf_review_con1);
    assertEquals(tv_con1.getText(), "don't care about patient");
    tv_con2 = (TextView) listView.findViewById(R.id.providerpf_review_con2);
    assertEquals(tv_con2.getText(), "slow diagnosis");
    tv_con3 = (TextView) listView.findViewById(R.id.providerpf_review_con3);
    assertEquals(tv_con3.getText(), "hard for parking");
    tv_provider_desc = (TextView) listView.findViewById(R.id.providerpf_comment_review);
    assertEquals(tv_provider_desc.getText(), "A good doctor!");
    listView = listAdapter.getChildView(1, 0, true, null, null);
    tv_provider_summary = (TextView) listView.findViewById(R.id.providerpf_rate_review_summary);
    assertEquals(tv_provider_summary.getText(), "");
    tv_pro1 = (TextView) listView.findViewById(R.id.providerpf_review_pro1);
    assertEquals(tv_pro1.getText(), "care about patient");
    tv_pro2 = (TextView) listView.findViewById(R.id.providerpf_review_pro2);
    assertEquals(tv_pro2.getText(), "quick diagnosis");
    tv_pro3 = (TextView) listView.findViewById(R.id.providerpf_review_pro3);
    assertEquals(tv_pro3.getText(), "");
    tv_con1 = (TextView) listView.findViewById(R.id.providerpf_review_con1);
    assertEquals(tv_con1.getText(), "don't care about patient");
    tv_con2 = (TextView) listView.findViewById(R.id.providerpf_review_con2);
    assertEquals(tv_con2.getText(), "");
    tv_con3 = (TextView) listView.findViewById(R.id.providerpf_review_con3);
    assertEquals(tv_con3.getText(), "");
    tv_provider_desc = (TextView) listView.findViewById(R.id.providerpf_comment_review);
    assertEquals(tv_provider_desc.getText(), "");
    listView = listAdapter.getChildView(2, 0, true, null, null);
    tv_provider_summary = (TextView) listView.findViewById(R.id.providerpf_rate_review_summary);
    assertEquals(tv_provider_summary.getText(), "Fair");
    tv_pro1 = (TextView) listView.findViewById(R.id.providerpf_review_pro1);
    assertEquals(tv_pro1.getText(), "adequate parking");
    tv_pro2 = (TextView) listView.findViewById(R.id.providerpf_review_pro2);
    assertEquals(tv_pro2.getText(), "availability of appointments");
    tv_pro3 = (TextView) listView.findViewById(R.id.providerpf_review_pro3);
    assertEquals(tv_pro3.getText(), "cleanliness/attractiveness of office");
    tv_con1 = (TextView) listView.findViewById(R.id.providerpf_review_con1);
    assertEquals(tv_con1.getText(), "");
    tv_con2 = (TextView) listView.findViewById(R.id.providerpf_review_con2);
    assertEquals(tv_con2.getText(), "");
    tv_con3 = (TextView) listView.findViewById(R.id.providerpf_review_con3);
    assertEquals(tv_con3.getText(), "");
    tv_provider_desc = (TextView) listView.findViewById(R.id.providerpf_comment_review);
    assertEquals(tv_provider_desc.getText(), "Hard to say - just so so");
    listView = listAdapter.getChildView(3, 0, true, null, null);
    tv_provider_summary = (TextView) listView.findViewById(R.id.providerpf_rate_review_summary);
    assertEquals(tv_provider_summary.getText(), "Good");
    tv_pro1 = (TextView) listView.findViewById(R.id.providerpf_review_pro1);
    assertEquals(tv_pro1.getText(), "");
    tv_pro2 = (TextView) listView.findViewById(R.id.providerpf_review_pro2);
    assertEquals(tv_pro2.getText(), "");
    tv_pro3 = (TextView) listView.findViewById(R.id.providerpf_review_pro3);
    assertEquals(tv_pro3.getText(), "");
    tv_con1 = (TextView) listView.findViewById(R.id.providerpf_review_con1);
    assertEquals(tv_con1.getText(), "");
    tv_con2 = (TextView) listView.findViewById(R.id.providerpf_review_con2);
    assertEquals(tv_con2.getText(), "");
    tv_con3 = (TextView) listView.findViewById(R.id.providerpf_review_con3);
    assertEquals(tv_con3.getText(), "");
    tv_provider_desc = (TextView) listView.findViewById(R.id.providerpf_comment_review);
    assertEquals(tv_provider_desc.getText(), "He is so handsome:)");
  }
  @Override
  public void onClick(View view) {
    switch (view.getId()) {
      case R.id.backBtn:
        DeviceRestActivity.this.finish();
        break;
      case R.id.button1:
        try {
          String startTime = startTimeTV.getText().toString();
          String endTime = endTimeTV.getText().toString();
          StringBuffer bufferOne = new StringBuffer();
          StringBuffer bufferTwo = new StringBuffer();
          if (checkTVOne1.isChecked()) {
            bufferOne.append("1");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne2.isChecked()) {
            bufferOne.append("2");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne3.isChecked()) {
            bufferOne.append("3");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne4.isChecked()) {
            bufferOne.append("4");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne5.isChecked()) {
            bufferOne.append("5");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne6.isChecked()) {
            bufferOne.append("6");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne7.isChecked()) {
            bufferOne.append("7");
          } else {
            bufferOne.append("0");
          }

          if (checkTV1.isChecked()) {
            bufferTwo.append("1");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV2.isChecked()) {
            bufferTwo.append("2");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV3.isChecked()) {
            bufferTwo.append("3");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV4.isChecked()) {
            bufferTwo.append("4");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV5.isChecked()) {
            bufferTwo.append("5");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV6.isChecked()) {
            bufferTwo.append("6");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV7.isChecked()) {
            bufferTwo.append("7");
          } else {
            bufferTwo.append("0");
          }
          String content =
              String.format(
                  "%s-%s,%s,%s-%s,%s",
                  startTimeTV.getText().toString(),
                  endTimeTV.getText().toString(),
                  bufferOne,
                  startTimeTV1.getText().toString(),
                  endTimeTV1.getText().toString(),
                  bufferTwo);
          // String content =
          // startTime+"-"+endTime+","+startTime+"-"+endTime+","+bufferTwo.toString();
          content = content.replace(":", "");
          if (Session.getInstance().getDevice() != null) {
            sendCommand(content);
          }
          //					addFence(object);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;
      case R.id.checkTV1:
        if (checkTV1.isChecked()) {
          checkTV1.setChecked(false);
        } else {
          checkTV1.setChecked(true);
        }
        break;
      case R.id.checkTV2:
        if (checkTV2.isChecked()) {
          checkTV2.setChecked(false);
        } else {
          checkTV2.setChecked(true);
        }
        break;
      case R.id.checkTV3:
        if (checkTV3.isChecked()) {
          checkTV3.setChecked(false);
        } else {
          checkTV3.setChecked(true);
        }
        break;
      case R.id.checkTV4:
        if (checkTV4.isChecked()) {
          checkTV4.setChecked(false);
        } else {
          checkTV4.setChecked(true);
        }
        break;
      case R.id.checkTV5:
        if (checkTV5.isChecked()) {
          checkTV5.setChecked(false);
        } else {
          checkTV5.setChecked(true);
        }
        break;
      case R.id.checkTV6:
        if (checkTV6.isChecked()) {
          checkTV6.setChecked(false);
        } else {
          checkTV6.setChecked(true);
        }
        break;
      case R.id.checkTV7:
        if (checkTV7.isChecked()) {
          checkTV7.setChecked(false);
        } else {
          checkTV7.setChecked(true);
        }
        break;
      case R.id.checkTV_all:
        if (checkTVAll.isChecked()) {
          checkTV1.setChecked(false);
          checkTV2.setChecked(false);
          checkTV3.setChecked(false);
          checkTV4.setChecked(false);
          checkTV5.setChecked(false);
          checkTV6.setChecked(false);
          checkTV7.setChecked(false);
          checkTVAll.setChecked(false);
        } else {
          checkTV1.setChecked(true);
          checkTV2.setChecked(true);
          checkTV3.setChecked(true);
          checkTV4.setChecked(true);
          checkTV5.setChecked(true);
          checkTV6.setChecked(true);
          checkTV7.setChecked(true);
          checkTVAll.setChecked(true);
        }
        break;

      case R.id.checkTV_one_1:
        if (checkTVOne1.isChecked()) {
          checkTVOne1.setChecked(false);
        } else {
          checkTVOne1.setChecked(true);
        }
        break;
      case R.id.checkTV_one_2:
        if (checkTVOne2.isChecked()) {
          checkTVOne2.setChecked(false);
        } else {
          checkTVOne2.setChecked(true);
        }
        break;
      case R.id.checkTV_one_3:
        if (checkTVOne3.isChecked()) {
          checkTVOne3.setChecked(false);
        } else {
          checkTVOne3.setChecked(true);
        }
        break;
      case R.id.checkTV_one_4:
        if (checkTVOne4.isChecked()) {
          checkTVOne4.setChecked(false);
        } else {
          checkTVOne4.setChecked(true);
        }
        break;
      case R.id.checkTV_one_5:
        if (checkTVOne5.isChecked()) {
          checkTVOne5.setChecked(false);
        } else {
          checkTVOne5.setChecked(true);
        }
        break;
      case R.id.checkTV_one_6:
        if (checkTVOne6.isChecked()) {
          checkTVOne6.setChecked(false);
        } else {
          checkTVOne6.setChecked(true);
        }
        break;
      case R.id.checkTV_one_7:
        if (checkTVOne7.isChecked()) {
          checkTVOne7.setChecked(false);
        } else {
          checkTVOne7.setChecked(true);
        }
        break;
      case R.id.checkTV_one_all:
        if (checkTVOneAll.isChecked()) {
          checkTVOne1.setChecked(false);
          checkTVOne2.setChecked(false);
          checkTVOne3.setChecked(false);
          checkTVOne4.setChecked(false);
          checkTVOne5.setChecked(false);
          checkTVOne6.setChecked(false);
          checkTVOne7.setChecked(false);
          checkTVOneAll.setChecked(false);
        } else {
          checkTVOne1.setChecked(true);
          checkTVOne2.setChecked(true);
          checkTVOne3.setChecked(true);
          checkTVOne4.setChecked(true);
          checkTVOne5.setChecked(true);
          checkTVOne6.setChecked(true);
          checkTVOne7.setChecked(true);
          checkTVOneAll.setChecked(true);
        }
        break;

      case R.id.startTimeTV:
        showTimeDialog(startTimeTV.getText().toString(), (TextView) view);
        break;
      case R.id.endTimeTV:
        showTimeDialog(endTimeTV.getText().toString(), (TextView) view);
        break;
      case R.id.startTimeTV2:
        showTimeDialog(startTimeTV1.getText().toString(), (TextView) view);
        break;
      case R.id.endTimeTV2:
        showTimeDialog(endTimeTV1.getText().toString(), (TextView) view);
        break;
    }
  }
示例#17
0
    public void setAVT(FormIndex index, String selectionDesignator, TextView text, String audioURI, String imageURI, String videoURI,
            final String bigImageURI) {
    	mSelectionDesignator = selectionDesignator;
    	mIndex = index;
        mView_Text = text;
        mView_Text.setId(QuestionWidget.newUniqueId());
        mVideoURI = videoURI;

        // Layout configurations for our elements in the relative layout
        RelativeLayout.LayoutParams textParams =
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        RelativeLayout.LayoutParams audioParams =
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        RelativeLayout.LayoutParams imageParams =
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        RelativeLayout.LayoutParams videoParams =
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

        // First set up the audio button
        if (audioURI != null) {
            // An audio file is specified
            mAudioButton = new AudioButton(getContext(), mIndex, mSelectionDesignator, audioURI);
            mAudioButton.setId(QuestionWidget.newUniqueId()); // random ID to be used by the
                                                                      // relative layout.
        } else {
            // No audio file specified, so ignore.
        }

        // Then set up the video button
        if (videoURI != null) {
            // An video file is specified
            mVideoButton = new ImageButton(getContext());
            Bitmap b =
                    BitmapFactory.decodeResource(getContext().getResources(),
                        android.R.drawable.ic_media_play);
            mVideoButton.setImageBitmap(b);
            mVideoButton.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                	Collect.getInstance().getActivityLogger().logInstanceAction(this, "onClick", "playVideoPrompt"+mSelectionDesignator, mIndex);
                	MediaLayout.this.playVideo();
                }

            });
            mVideoButton.setId(QuestionWidget.newUniqueId());
        } else {
            // No video file specified, so ignore.
        }

        // Now set up the image view
        String errorMsg = null;
        final int imageId = QuestionWidget.newUniqueId();
        if (imageURI != null) {
            try {
                String imageFilename = ReferenceManager._().DeriveReference(imageURI).getLocalURI();
                final File imageFile = new File(imageFilename);
                if (imageFile.exists()) {
                    Display display =
                        ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
                                .getDefaultDisplay();
                    int screenWidth = display.getWidth();
                    int screenHeight = display.getHeight();
                    Bitmap b = FileUtils.getBitmapScaledToDisplay(imageFile, screenHeight, screenWidth);
                    if (b != null) {
                        mImageView = new ImageView(getContext());
                        mImageView.setPadding(2, 2, 2, 2);
                        mImageView.setBackgroundColor(Color.WHITE);
                        mImageView.setImageBitmap(b);
                        mImageView.setId(imageId);

                        if (bigImageURI != null) {
                            mImageView.setOnClickListener(new OnClickListener() {
                            	String bigImageFilename = ReferenceManager._()
                                        .DeriveReference(bigImageURI).getLocalURI();
                                File bigImage = new File(bigImageFilename);


                                @Override
                                public void onClick(View v) {
                                	Collect.getInstance().getActivityLogger().logInstanceAction(this, "onClick", "showImagePromptBigImage"+mSelectionDesignator, mIndex);

                                    Intent i = new Intent("android.intent.action.VIEW");
                                    i.setDataAndType(Uri.fromFile(bigImage), "image/*");
                                    try {
                                        getContext().startActivity(i);
                                    } catch (ActivityNotFoundException e) {
                                        Toast.makeText(
                                            getContext(),
                                            getContext().getString(R.string.activity_not_found,
                                                "view image"), Toast.LENGTH_SHORT).show();
                                    }
                                }
                            });
                        }
                    } else {
                        // Loading the image failed, so it's likely a bad file.
                        errorMsg = getContext().getString(R.string.file_invalid, imageFile);
                    }
                } else {
                    // We should have an image, but the file doesn't exist.
                    errorMsg = getContext().getString(R.string.file_missing, imageFile);
                }

                if (errorMsg != null) {
                    // errorMsg is only set when an error has occurred
                    Log.e(t, errorMsg);
                    mMissingImage = new TextView(getContext());
                    mMissingImage.setText(errorMsg);
                    mMissingImage.setPadding(10, 10, 10, 10);
                    mMissingImage.setId(imageId);
                }
            } catch (InvalidReferenceException e) {
                Log.e(t, "image invalid reference exception");
                e.printStackTrace();
            }
        } else {
            // There's no imageURI listed, so just ignore it.
        }

        // e.g., for TextView that flag will be true
        boolean isNotAMultipleChoiceField = !RadioButton.class.isAssignableFrom(text.getClass()) && !CheckBox.class.isAssignableFrom(text.getClass());

        // Determine the layout constraints...
        // Assumes LTR, TTB reading bias!
        if (mView_Text.getText().length() == 0 && (mImageView != null || mMissingImage != null)) {
            // No text; has image. The image is treated as question/choice icon.
            // The Text view may just have a radio button or checkbox. It
            // needs to remain in the layout even though it is blank.
            //
            // The image view, as created above, will dynamically resize and
            // center itself. We want it to resize but left-align itself
            // in the resized area and we want a white background, as otherwise
            // it will show a grey bar to the right of the image icon.
            if (mImageView != null) {
                mImageView.setScaleType(ScaleType.FIT_START);
            }
            //
            // In this case, we have:
            // Text upper left; image upper, left edge aligned with text right edge;
            // audio upper right; video below audio on right.
            textParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            textParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            if (isNotAMultipleChoiceField) {
                imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
            } else {
                imageParams.addRule(RelativeLayout.RIGHT_OF, mView_Text.getId());
            }
            imageParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            if (mAudioButton != null && mVideoButton == null) {
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                imageParams.addRule(RelativeLayout.LEFT_OF, mAudioButton.getId());
            } else if (mAudioButton == null && mVideoButton != null) {
                videoParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                imageParams.addRule(RelativeLayout.LEFT_OF, mVideoButton.getId());
            } else if (mAudioButton != null && mVideoButton != null) {
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                imageParams.addRule(RelativeLayout.LEFT_OF, mAudioButton.getId());
                videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                videoParams.addRule(RelativeLayout.BELOW, mAudioButton.getId());
                imageParams.addRule(RelativeLayout.LEFT_OF, mVideoButton.getId());
            } else {
                // the image will implicitly scale down to fit within parent...
                // no need to bound it by the width of the parent...
                if (!isNotAMultipleChoiceField) {
                    imageParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                }
            }
            imageParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        } else {
            // We have a non-blank text label -- image is below the text.
            // In this case, we want the image to be centered...
            if (mImageView != null) {
                mImageView.setScaleType(ScaleType.FIT_START);
            }
            //
            // Text upper left; audio upper right; video below audio on right.
            // image below text, audio and video buttons; left-aligned with text.
            textParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            textParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            if (mAudioButton != null && mVideoButton == null) {
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                textParams.addRule(RelativeLayout.LEFT_OF, mAudioButton.getId());
          } else if (mAudioButton == null && mVideoButton != null) {
                videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                textParams.addRule(RelativeLayout.LEFT_OF, mVideoButton.getId());
            } else if (mAudioButton != null && mVideoButton != null) {
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                textParams.addRule(RelativeLayout.LEFT_OF, mAudioButton.getId());
                videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                videoParams.addRule(RelativeLayout.BELOW, mAudioButton.getId());
            } else {
                textParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            }

            if (mImageView != null || mMissingImage != null) {
                imageParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
                imageParams.addRule(RelativeLayout.BELOW, mView_Text.getId());
            } else {
                textParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            }
        }

        addView(mView_Text, textParams);
        if (mAudioButton != null)
            addView(mAudioButton, audioParams);
        if (mVideoButton != null)
            addView(mVideoButton, videoParams);
        if (mImageView != null)
            addView(mImageView, imageParams);
        else if (mMissingImage != null)
            addView(mMissingImage, imageParams);
    }