public void rateStory(View view) {

    RatingBar ratingBar = (RatingBar) findViewById(R.id.rating_bar);
    int rating = (int) Math.round(ratingBar.getRating());
    System.out.println(rating);

    // Update rating if user hit like button
    try {
      // Store json object with value of user rating
      JSONObject storyRate = getStoryObj();
      storyRate.put("rating", rating);

      System.out.println(storyRate.toString());

      // Post json data with rating to server
      Utility.postJsonData(
          storyRate.toString(), getResources().getString(R.string.server_rate_story));

    } catch (Exception e) {
      getResources().getString(R.string.server_error);
      e.printStackTrace();
    }
    // Go back to main activity after sending rating
    NavUtils.navigateUpFromSameTask(this);
  }
 public void onRateButtonClick(View view) {
   float rating = ratingBar.getRating();
   Intent sendRating = new Intent();
   sendRating.putExtra(Friendsr_Main_Activity.ratingKey, rating);
   sendRating.putExtra(Friendsr_Main_Activity.nameKey, friendName);
   setResult(RESULT_OK, sendRating);
   finish();
 }
 public Student getStudent() {
   student.setFirstName(firstNameField.getText().toString());
   student.setLastName(lastNameField.getText().toString());
   student.setNickname(nicknameField.getText().toString());
   student.setAddress(addressField.getText().toString());
   student.setPhone(phoneField.getText().toString());
   student.setWebsite(websiteField.getText().toString());
   student.setRate(Double.valueOf(ratingField.getRating()));
   return student;
 }
 public void onClick(View v) {
   float rating = ratingBar.getRating();
   String tier = "$$$$".substring(0, (int) rating);
   restaurant.setTier(tier);
   application.updateRestaurant(restaurant);
   Toast.makeText(this, "rating " + rating + " nickname " + (nick.getText()), Toast.LENGTH_LONG)
       .show();
   ((TextView) findViewById(R.id.dialog_raiting)).setText(String.valueOf(restaurant.getTier()));
   setResult(RESULT_OK);
 }
  private void sendRateToAPI(RatingBar r1, RatingBar r2, RatingBar r3, RatingBar r4) {
    params.put("rating1", String.valueOf(r1.getRating()));
    params.put("rating2", String.valueOf(r2.getRating()));
    params.put("rating3", String.valueOf(r3.getRating()));
    params.put("rating4", String.valueOf(r4.getRating()));
    params.put("trainingID", aid);
    params.put("device", "android");
    params.put("mobileNumber", ApplicationLoader.getPreferences().getMobileNumber());

    // post request to server

    Log.d("device", params.get("device").toString());
    ConnectionDetector cd = new ConnectionDetector(TrainingVideo.this);
    Boolean isInternetPresent = cd.isConnectingToInternet(); //
    if (isInternetPresent && params.get("device").equalsIgnoreCase("android")) {
      SendRating checkLoginTask = new SendRating(params, TrainingVideo.this);
      checkLoginTask.execute(com.mobcast.util.Constants.TRAIN_RATE);
    }
  }
 @Override
 public void onClick(View v) {
   Log.v(this.getClass().getSimpleName(), "Clicked");
   feedbackIntent = new Intent(Intent.ACTION_SEND);
   feedbackIntent.setData(Uri.parse("mailto:[email protected]"));
   feedbackIntent.setType("text/plain"); /*
       feedbackIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"*****@*****.**"});*/
   feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, "CSI-DTU Application Feedback");
   String feedbackText = "Rating : " + ratingBar.getRating() + "\n";
   feedbackText += feedback.getText().toString();
   feedbackIntent.putExtra(Intent.EXTRA_TEXT, feedbackText);
   startActivity(feedbackIntent);
 }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.submit:
       if (edit.getText().toString().trim().equals("")) {
         Toast.makeText(getActivity(), "请输入点评内容", Toast.LENGTH_SHORT).show();
         return;
       } else content = edit.getText().toString().trim();
       sendDianPing(content, mark.getRating());
       break;
     default:
       break;
   }
 }
  public void resAdd() {
    String aye = location.getText().toString().substring(5);
    String s = name.getText().toString() + "|" + aye + "|" + cuisine.getSelectedItem().toString();
    if (barkada.getText().toString().equals("")) {
      s = s + "|none provided";
    } else {
      s = s + "|" + barkada.getText().toString();
    }
    s = s + "|" + Float.toString(worth.getRating());
    if (oTime.getText().toString().equals("Click to add")) {
      s = s + "|none provided";
    } else {
      s = s + "|" + oTime.getText().toString();
    }
    if (cTime.getText().toString().equals("Click to add")) {
      s = s + "|none provided";
    } else {
      s = s + "|" + cTime.getText().toString();
    }
    s = s + "|true|none provided|0|0";
    s = s + "" + cost.getText().toString();

    FileWriter out;
    try {
      out = new FileWriter(RESTAURANTFILE, true);
      out.write(s + "\n");
      out.close();
      String[] temp = s.split("\\|");
      int m = kainan.size();
      boolean is = true;
      kainan.add(new Restaurant(temp[0], Double.parseDouble(temp[1])));
      kainan
          .get(m)
          .setRestaurant(
              temp[0],
              Double.parseDouble(temp[1]),
              temp[2],
              temp[3],
              temp[4],
              temp[5],
              temp[6],
              is);
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  public void OnClick(View view) {

    switch (view.getId()) {
      case R.id.save_btn:
        Category taskCat = layer.GetCategoryByName(category.getSelectedItem().toString());

        currentTask.category = taskCat;
        currentTask.importance = (int) rating.getRating();
        currentTask.name = name.getText().toString();
        currentTask.progress = progress.getProgress();

        layer.EditTask(currentTask);
        finish();
        break;

      default:
        break;
    }
  }
  public void ConfirmOrRate(View v) {
    DBManager db = new DBManager(this);
    if (!tConfirmed) {
      db.editTransaction(transactionID, "Confirmed", -1);

      confirmTxt.setVisibility(View.GONE);
      rBar.setVisibility(View.VISIBLE);
      applyButton.setBackgroundResource(R.mipmap.btn_rate);
      tConfirmed = true;
    } else {
      db.editTransaction(transactionID, null, (double) rBar.getRating());

      Intent intent;
      if (from.equals("detailview")) {
        intent = new Intent(this, ViewTransaction.class);
        intent.putExtra("TRANSACTION_ID", transactionID);
      } else {
        intent = new Intent(this, Transactions.class);
      }

      startActivity(intent);
    }
  }
  /** 发布 */
  private void release() {
    final long startTime = System.currentTimeMillis();
    // 作者名称
    String authorName = et_AuthorName.getText().toString();
    if (TextUtils.isEmpty(authorName)) {
      showToast("请填写作者名称");
      return;
    }
    String bookName = et_BookName.getText().toString();
    if (TextUtils.isEmpty(bookName)) {
      showToast("请填写书名");
      return;
    }
    String content = et_Content.getText().toString();
    if (TextUtils.isEmpty(content)) {
      showToast("请填写书籍的主要内容");
      return;
    }
    if (pictureFile == null || !pictureFile.exists()) {
      showToast("请为书籍拍一张照吧!");
      return;
    }
    int rating = (int) ratingBar.getRating();
    // 提交
    proDialog = android.app.ProgressDialog.show(ctx, "发布", "正在发布图书!");

    btn_OK.setEnabled(false);

    Map<String, String> map = new HashMap<String, String>();
    map.put("action", "releaseBook");
    map.put("userId", baseInfo.userId + "");
    map.put("authorName", authorName);
    map.put("bookName", bookName);
    map.put("content", content);
    map.put("rating", rating + "");
    map.put("interest", interest);
    map.put("newOld", newOld);
    map.put("transaction", TYPE[type]);
    map.put("times", times);
    map.put("fileName", pictureFile.getName());
    map.put("fileContent", PictureUtil.bitmapToString(pictureFile.getAbsolutePath()));

    JSONObject jsonObject = new JSONObject(map);
    Log.d(TAG, jsonObject.toString());
    JsonRequest<JSONObject> jsonRequest =
        new JsonObjectRequest(
            Method.POST,
            getAddress(),
            jsonObject,
            new Response.Listener<JSONObject>() {

              @Override
              public void onResponse(final JSONObject response) {

                long tempTime = 1000 + startTime - System.currentTimeMillis();
                if (tempTime > 0) {
                  handler.postDelayed(
                      new Runnable() {

                        @Override
                        public void run() {
                          handler.sendEmptyMessage(DIALOG_DIMSS);
                          releaseBook_Result(response);
                        }
                      },
                      tempTime);
                } else {
                  handler.sendEmptyMessage(DIALOG_DIMSS);
                  releaseBook_Result(response);
                }
              }
            },
            new Response.ErrorListener() {
              @Override
              public void onErrorResponse(final VolleyError error) {
                long tempTime = 1000 + startTime - System.currentTimeMillis();
                if (tempTime > 0) {
                  handler.postDelayed(
                      new Runnable() {
                        @Override
                        public void run() {
                          handler.sendEmptyMessage(DIALOG_DIMSS);
                          showToast(VolleyErrorHelper.getMessage(error, ctx));
                        }
                      },
                      tempTime);
                } else {
                  handler.sendEmptyMessage(DIALOG_DIMSS);
                  showToast(VolleyErrorHelper.getMessage(error, ctx));
                }
              }
            }) {

          @Override
          public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> headers = new HashMap<String, String>();
            headers.put("Accept", "application/json");
            headers.put("Content-Type", "application/json;charset=UTF-8");

            return headers;
          }
        };
    requestQueue.add(jsonRequest);
    Log.d(TAG, "jsonRequest=" + jsonRequest);
  }
  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:)");
  }
Example #13
0
  private boolean validateFields() {

    if (comment.getText().length() == 0 || (int) rateBar.getRating() == 0) return false;
    else return true;
  }
Example #14
0
 static float getRating(final View parentView) {
   final RatingBar ratingBar = ButterKnife.findById(parentView, R.id.gcvoteRating);
   return ratingBar.getRating();
 }
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   float rating = ratingBar.getRating();
   outState.putFloat(Friendsr_Main_Activity.ratingKey, rating);
 }
Example #16
0
  public void onClick(View v) {
    if (v.getId() == R.id.startGame) {
      if (currentUser == null) {
        currentUser = new CurrentUser();
      }
      Bundle getUserInfoBundle = new Bundle();
      getUserInfoBundle.putString("method", "users.getLoggedInUser");
      String uIdResponse = getRenren().request(getUserInfoBundle, "json");
      JSONObject uIdObj;
      try {
        uIdObj = new JSONObject(uIdResponse);
        String uid = uIdObj.get("uid").toString();
        currentUser.setXiaoNeiId(uid);

        getUserInfoBundle = new Bundle();
        getUserInfoBundle.putString("method", "users.getInfo");
        String infoResponse = getRenren().request(getUserInfoBundle, "json");
        JSONArray infoJobj = new JSONArray(infoResponse);
        JSONObject obj = (JSONObject) infoJobj.get(0);
        String userName = (String) obj.get("name");
        String headerUrl = (String) obj.get("headurl");
        currentUser.setUsername(userName);
        currentUser.setHeadurl(headerUrl);
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Dialog dialog =
            new AlertDialog.Builder(this)
                .setTitle("请先点击连接登录人人网")
                .setIcon(R.drawable.lianzhangicon)
                .setMessage("请先点击连接登录人人网")
                // .setItems(str, Test_Dialog.this)// 设置对话框要显示的一个list
                // .setSingleChoiceItems(str, 0, Test_Dialog.this)//
                // 设置对话框显示一个单选的list
                .setPositiveButton(
                    "确定",
                    new android.content.DialogInterface.OnClickListener() {

                      @Override
                      public void onClick(DialogInterface arg0, int arg1) {
                        // TODO Auto-generated method stub
                        arg0.dismiss();
                      }
                    })
                .create();
        dialog.show();
        return;
      }

      StartGameListener startGameListener = new StartGameListener();
      startGameListener.showProgress(this, "加载好友头像资源...", "请耐心等待...");

      GameStarter gameStarter = new GameStarter();

      gameStarter.startGame(this, startGameListener);
    }
    if (v.getId() == R.id.levelBar) {}

    /*if(v.getId()==R.id.levelUpButton){
    	this.runOnUiThread(new Runnable(){
    		 @Override
    		 public void run() {
    				RatingBar ratingBar=(RatingBar)findViewById(R.id.levelBar);
    				if(ratingBar.getRating()<3){
    				ratingBar.setRating((float) (ratingBar.getRating()+0.5));}
    		 }
    	});
    }
    if(v.getId()==R.id.levelDownButton){
    	this.runOnUiThread(new Runnable(){
    		 @Override
    		 public void run() {
    				RatingBar ratingBar=(RatingBar)findViewById(R.id.levelBar);
    				if(ratingBar.getRating()>0){
    				ratingBar.setRating((float) (ratingBar.getRating()-0.5));}
    		 }
    	});

    }*/
    if (v.getId() == R.id.statistics) {
      PaiHangBangListener paiHangBangListener = new PaiHangBangListener(this);
      paiHangBangListener.showProgress(this, "跳转到排行榜", "请耐心等待...");
      float rating = ratingBar.getRating();

      PaiHangBangStarter paiHangBangStarter = new PaiHangBangStarter();
      paiHangBangStarter.startPaiHangBang(paiHangBangListener, (int) (rating * 2));
    }
  }