Exemple #1
0
    @Override
    public View getView(int i, View view, ViewGroup group) {
      // TODO Auto-generated method stub
      if (view == null) {
        view = mInflater.inflate(R.layout.sleep_listview_item, null);
      }

      RatingBar ratingBar = (RatingBar) view.findViewById(R.id.listview_rb_score);

      TextView tv_sleeptime = (TextView) view.findViewById(R.id.listview_tv_sleeptime);
      TextView tv_deepsleep = (TextView) view.findViewById(R.id.listview_tv_deepsleep);
      TextView tv_lightsleep = (TextView) view.findViewById(R.id.listview_tv_lightsleep);
      TextView tv_waketime = (TextView) view.findViewById(R.id.listview_tv_waketime);
      TextView tv_wakenum = (TextView) view.findViewById(R.id.listview_tv_wakenum);
      //			TextView tv_commit =(TextView)view.findViewById(R.id.listview_tv_commit);

      HashMap<String, String> hashMap = data_list.get(i);

      ratingBar.setRating((float) Double.parseDouble(hashMap.get("score")));
      tv_sleeptime.setText("时长 " + hashMap.get("listview_tv_sleeptime"));
      tv_deepsleep.setText("深睡˯  " + hashMap.get("listview_tv_deepsleep"));
      tv_lightsleep.setText("浅睡 " + hashMap.get("listview_tv_lightsleep"));
      tv_waketime.setText("中断时长 " + hashMap.get("listview_tv_waketime"));
      tv_wakenum.setText("中断次数 " + hashMap.get("listview_tv_wakenum"));
      //			tv_commit.setText(hashMap.get("listview_tv_commit"));

      return view;
    }
Exemple #2
0
  // ** Called when the activity is first created. *//*
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE); // 隐藏标题
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN); // 设置全屏

    nameHeaderUrlList = new ArrayList<NameHeaderUrlPair>();

    if (apiKey == null || apiSecret == null) {
      Util.showAlert(this, "警告", "人人应用的apiKey和apiSecret必须提供!");
    }

    setContentView(R.layout.main);

    ratingBar = (RatingBar) findViewById(R.id.levelBar);
    ratingBar.setMax(6);
    ratingBar.setNumStars(3);
    ratingBar.setStepSize((float) 0.5);
    ratingBar.setRating((float) 1.5);
    initialRenRen();
    /*Spinner s = (Spinner) findViewById(R.id.friendNumerSpin);
    String []friendNumber=new String[]{"好友人数:10","好友人数:20","好友人数:50","所有好友"};
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
    		android.R.layout.simple_spinner_item, friendNumber);
    s.setAdapter(adapter);*/

  }
  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);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingbar);
    ratingBar.setOnRatingBarChangeListener(
        new RatingBar.OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            float f = ratingBar.getRating();
            Toast.makeText(MainActivity.this, "sucessfully Ratted " + f, Toast.LENGTH_SHORT).show();
          }
        });

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show();
          }
        });
  }
 private void setupViews(View view) {
   mQuestionView = (TextView) view.findViewById(R.id.question);
   mRatingBar = (RatingBar) view.findViewById(R.id.ratingbar);
   mRatingBar.setOnRatingBarChangeListener(
       new RatingBar.OnRatingBarChangeListener() {
         @Override
         public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
           int ratingInt = (int) rating - 1;
           setQandA(ratingInt);
           if (!mInitializing) {
             mListener.onQuestionAnswered(mQuestion.getQuestionNumber(), ratingInt);
             mInitializing = false;
           }
         }
       });
   mRatingBar.setOnTouchListener(
       new View.OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           int ratingInt = (int) mRatingBar.getRating() - 1;
           setQandA(ratingInt);
           return false;
         }
       });
   int persistedResponse = getArguments().getInt(KEY_PERSISTED_RESPONSE);
   if (persistedResponse > -1) {
     mInitializing = true;
     mRatingBar.setRating(persistedResponse + 1);
   }
 }
  public static void initializeRatingBar(
      @NonNull final Geocache cache,
      final View parentView,
      @Nullable final OnRatingChangeListener changeListener) {
    if (GCVote.isVotingPossible(cache)) {
      final RatingBar ratingBar = ButterKnife.findById(parentView, R.id.gcvoteRating);
      final TextView label = ButterKnife.findById(parentView, R.id.gcvoteLabel);
      ratingBar.setVisibility(View.VISIBLE);
      label.setVisibility(View.VISIBLE);
      ratingBar.setOnRatingBarChangeListener(
          new OnRatingBarChangeListener() {

            @Override
            public void onRatingChanged(
                final RatingBar ratingBar, final float stars, final boolean fromUser) {
              // 0.5 is not a valid rating, therefore we must limit
              final float rating = GCVote.isValidRating(stars) ? stars : 0;
              if (rating < stars) {
                ratingBar.setRating(rating);
              }
              label.setText(GCVote.getDescription(rating));
              if (changeListener != null) {
                changeListener.onRatingChanged(rating);
              }
            }
          });
      ratingBar.setRating(cache.getMyVote());
    }
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      convertView =
          LayoutInflater.from(this.getContext())
              .inflate(R.layout.comentario_adapter, (ViewGroup) null);
    }
    ImageView fotoUsuarioListView = (ImageView) convertView.findViewById(R.id.fotoUsuarioListView);
    TextView comentarioUserNameTextView =
        (TextView) convertView.findViewById(R.id.comentarioUserNameTextView);
    TextView comentarioPreviewTextView =
        (TextView) convertView.findViewById(R.id.comentarioPreviewTextView);
    RatingBar comentarioPuntajeRatingBar =
        (RatingBar) convertView.findViewById(R.id.comentarioPuntajeRatingBar);

    Comentario comentario = this.getItem(position);
    Usuario usuario = this.usuarioService.getById(comentario.getUserId());
    fotoUsuarioListView.setImageBitmap(BitmapUtility.getImage(usuario.getFoto()));
    comentarioUserNameTextView.setText(usuario.getUserName());
    comentarioPreviewTextView.setText(comentario.getPreview());
    comentarioPuntajeRatingBar.setRating(comentario.getPuntaje());

    convertView.setBackgroundResource(R.color.default_color);
    return convertView;
  }
Exemple #8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.evaluate);
    mAccountRatingBar = (RatingBar) findViewById(R.id.account_ratingbar2);
    mAccountRatingBar.setOnRatingBarChangeListener(this);
    mExpressageRatingbar = (RatingBar) findViewById(R.id.expressage_ratingbar);
    mExpressageRatingbar.setOnRatingBarChangeListener(this);
    mSellerServiceRatingbar = (RatingBar) findViewById(R.id.Seller_service_ratingbar);
    mSellerServiceRatingbar.setOnRatingBarChangeListener(this);
    mBackButton = (Button) findViewById(R.id.stay_evaluate_backbutton);
    mBackButton.setOnClickListener(this);
    mSubmitEvaluateButton = (Button) findViewById(R.id.submit_evaluate_button);
    mSubmitEvaluateButton.setOnClickListener(this);

    mProNameTextView = (TextView) findViewById(R.id.evaluate_name_textview);
    mPriceTextView = (TextView) findViewById(R.id.evaluate_price_textview);
    mProImageView = (ImageView) findViewById(R.id.evaluate_image_imageview);
    intent = getIntent();
    mPriceTextView.setText(intent.getStringExtra("price"));
    mProNameTextView.setText(intent.getStringExtra("proName"));
    EvaluateAdapter.getUrlImage(mProImageView, intent.getStringExtra("imageUrl"));

    mGoodBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.star_good);
    mBadBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.star_bad);
    mBackGroupBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.star_null);
    mGoodBitmaps = new Bitmap[] {mBackGroupBitmap, mBackGroupBitmap, mGoodBitmap};
    mBadBitmaps = new Bitmap[] {mBackGroupBitmap, mBackGroupBitmap, mBadBitmap};
  }
Exemple #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_seek_bar);

    SeekBar sb = (SeekBar) findViewById(R.id.seekBar);
    sb.setMax(100);
    sb.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {
          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            Log.e("aaa", progress + "");
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
            // Toast.makeText(trySeekBar.this, "SeekBar START", Toast.LENGTH_SHORT).show();
          }

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            // Toast.makeText(trySeekBar.this, "SeekBar END", Toast.LENGTH_SHORT).show();
          }
        });

    RatingBar rb = (RatingBar) findViewById(R.id.ratingBar);
    rb.setMax(5);
    rb.setOnRatingBarChangeListener(
        new RatingBar.OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            Toast.makeText(trySeekBar.this, rating + "", Toast.LENGTH_SHORT).show();
          }
        });
  }
  @Override
  public void bindView(View view, Context context, Cursor cursor) {

    // Set the name of the bottle.
    TextView name = (TextView) view.findViewById(R.id.list_element_name);
    name.setText(
        cursor.getString(cursor.getColumnIndex(DatabaseContract.BottleTable.COLUMN_NAME_NAME)));
    name.setTypeface(Fonts.getFonts(context).chopinScript);

    // Set the vintage of the bottle.
    TextView vintage = (TextView) view.findViewById(R.id.list_element_vintage);
    vintage.setText(
        cursor.getString(cursor.getColumnIndex(DatabaseContract.BottleTable.COLUMN_NAME_VINTAGE)));

    // Set the mark of the bottle.
    RatingBar rating = (RatingBar) view.findViewById(R.id.list_element_mark);
    rating.setRating(
        cursor.getInt(cursor.getColumnIndex(DatabaseContract.BottleTable.COLUMN_NAME_MARK)));

    // Set the quantity of the bottle.
    TextView quantity = (TextView) view.findViewById(R.id.list_element_quantity);
    quantity.setText(
        Integer.toString(
            cursor.getInt(
                cursor.getColumnIndex(DatabaseContract.BottleTable.COLUMN_NAME_QUANTITY))));
  }
  private boolean setRatingView(View view, Cursor cursor, int columnIndex) {

    RatingBar ratingBar = (RatingBar) view;
    int rating = cursor.getInt(columnIndex);
    ratingBar.setRating(rating / Constants.RATING_MULTIPLIER);
    return true;
  }
Exemple #12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.user_taxi_status);
    init();
    bundle = getIntent().getExtras();

    lat = Float.parseFloat(bundle.getString(SRC_LAT));
    lng = Float.parseFloat(bundle.getString(SRC_LNG));

    srcLatLng = new LatLng(lat, lng);

    lat = Float.parseFloat(bundle.getString(DIST_LAT));
    lng = Float.parseFloat(bundle.getString(DIST_LNG));

    distLatLng = new LatLng(lat, lng);

    driverName = bundle.getString(SELECTED_DRIVER_NAME);
    tvDrivername.setText(driverName);
    tvDriverMobile.setText(bundle.getString(SELECTED_DRIVER_MOBILE));
    rating = Float.parseFloat(bundle.getString(SELECTED_DRIVER_RATING));
    driverId = bundle.getString(SELECTED_DRIVER_ID);
    rbDriverRate.setRating(rating + 0.5f);
    rbDriverRate.setRating(rating);

    CustomMapFragmment customMapFragmment =
        (CustomMapFragmment) getFragmentManager().findFragmentById(R.id.map);
    customMapFragmment.setListener(this);
    customMapFragmment.getMapAsync(this);
  }
  public IceTvMovieListItem(Context context, IceMovie theMovie, IceTvGuide guide) {
    super(context);

    this.theMovie = theMovie;
    this.guide = guide;

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.icemovie, this, true);

    this.setOrientation(LinearLayout.HORIZONTAL);

    titleText = (TextView) findViewById(R.id.movie_view_title);
    dateTimeText = (TextView) findViewById(R.id.movie_view_datetime);
    stationText = (TextView) findViewById(R.id.movie_view_station);
    ratingBar = (RatingBar) findViewById(R.id.movie_view_rating);
    previewImage = (ImageView) findViewById(R.id.movie_view_image);

    SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy h:mmaa");

    titleText.setText(theMovie.GetBaseMovieName());
    dateTimeText.setText(formatter.format(theMovie.GetProgram().GetStart()));
    stationText.setText(
        guide.GetStationList().Get(theMovie.GetProgram().GetStation()).GetMainDisplayName());
    ratingBar.setStepSize(0.1f);
    ratingBar.setNumStars(10);
    ratingBar.setRating((float) theMovie.GetRating());
    previewImage.setImageBitmap(theMovie.GetImage());
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View v = null;
      TATomato item = getTomato(position);
      Context context = TATomatoListActivity.this;
      if (convertView == null) {
        v = getLayoutInflater().inflate(R.layout.tomato, null);
      } else {
        v = convertView;
      }

      ((TextView) v.findViewById(R.id.date))
          .setText(item.getString(context, StringFilter.StartDate));
      ((TextView) v.findViewById(R.id.start))
          .setText(item.getString(context, StringFilter.StartTime));
      ((TextView) v.findViewById(R.id.end)).setText(item.getString(context, StringFilter.EndTime));
      ((TextView) v.findViewById(R.id.duration))
          .setText(item.getString(context, StringFilter.Duration));

      String tomatoNote = TATomatoPersistence.loadTomatoNote(context, item.getId());
      if (tomatoNote == null) {
        tomatoNote = "";
      }
      ((TextView) v.findViewById(R.id.note)).setText(tomatoNote);

      if (isActivityForMultiProjects()) {
        String name = TATomatoPersistence.getProjectName(context, item.getId());
        if (name == null) {
          name = "no project";
        }
        ((TextView) v.findViewById(R.id.project)).setText(name);
      }

      Date date = new Date();
      date.setTime(item.startMs);
      date.setHours(0);
      date.setMinutes(0);
      date.setSeconds(0);
      int msPerDay = 1000 * 60 * 60 * 24;
      float x1 = item.startMs - date.getTime();
      x1 /= msPerDay;
      float x2 = item.getDurationMs();
      x2 /= msPerDay;

      setWeight(v, R.id.pastInDay, x1);
      setWeight(v, R.id.nowInDay, x2);
      setWeight(v, R.id.futureInDay, 1 - x1 - x2);

      final RatingBar ratingbar = (RatingBar) v.findViewById(R.id.rating);
      final float rating = TATomatoPersistence.loadTomatoRating(context, item.getId());
      if (rating > 0) {
        ratingbar.setVisibility(View.VISIBLE);
        ratingbar.setNumStars((int) rating);
      } else {
        ratingbar.setVisibility(View.INVISIBLE);
      }
      return v;
    }
  /**
   * Creates and adds a control that shows a review rating score.
   *
   * @param rating Fractional rating out of 5 stars.
   */
  public View addRatingBar(float rating) {
    View ratingLayout =
        LayoutInflater.from(getContext()).inflate(R.layout.infobar_control_rating, this, false);
    addView(ratingLayout, new ControlLayoutParams());

    RatingBar ratingView = (RatingBar) ratingLayout.findViewById(R.id.control_rating);
    ratingView.setRating(rating);
    return ratingView;
  }
  /** 初始化 */
  public void setupViews() {

    intent = getIntent();
    mAppId = intent.getIntExtra("app_id", 0); // 获取对应app 的ID
    mAmount = intent.getIntExtra("amount", 0); // 评论人数
    mUserID = intent.getStringExtra("user_id"); // 用户id
    mHaveBeenEvaluated = intent.getBooleanExtra("isScore", false); // 获取是否评分
    mScoreValue = intent.getFloatExtra("ScoreValue", 0); // 获取已评分数
    if ("-1".equals(mUserID)) { // 祥情里没获取userid,则默认此时已评价(不提交评分信息)
      mHaveBeenEvaluated = true;
    }
    mRatingBar = (RatingBar) findViewById(R.id.ratingBar);
    bar = (LinearLayout) findViewById(R.id.bar);
    mRatingBarText = (TextView) findViewById(R.id.text);
    animationDrawable = (AnimationDrawable) bar.getBackground();
    mCloseButton = (ImageButton) findViewById(R.id.close);
    mTextView1 = (TextView) findViewById(R.id.text_1); // 已有多少人评价
    mTextView2 = (TextView) findViewById(R.id.text_2); // 使用说明

    mRatingBar.setRating(mScoreValue);
    mRatingBar.setOnRatingBarChangeListener(new RatingBarListener());

    //		if(mHaveBeenEvaluated){ //已评价
    //			evaluated();
    //			//mRatingBar.setFocusable(false);//让星星失去焦点
    //			AppLog.d(TAG,"-------------------------id--"+mAppId +"--已评价----------------");
    //		}else{
    //			mRatingBar.setRating(mScoreValue);
    //			mRatingBar.setOnRatingBarChangeListener(new RatingBarListener());
    //			AppLog.d(TAG,"-------------------------id--"+mAppId +"--未评价----------------");
    //		}

    // 每次都让评价
    // mRatingBar.setOnRatingBarChangeListener(new RatingBarListener());

    mCloseButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (v.getId() == R.id.close) {
              finish();
            }
          }
        });
    setCloseFocuseChange(mCloseButton);
    mRatingBar.requestFocus();
    animationDrawable.start();
    mRatingBar.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            mIsSuer = true;
            mTextView1.setText(
                AppAppraisalActivity.this.getString(R.string.app_appraisal_text1, mAmount + 1));
            handler.sendEmptyMessageDelayed(CLOSE, 700);
          }
        });
    setBarFocuseChange(mRatingBar);
  }
  public void editMovie(int mID, String mTitle) {
    LinearLayout viewGroup = (LinearLayout) findViewById(R.id.popupLinearLayout);
    LayoutInflater layoutInflater =
        (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    editMovieLayout = layoutInflater.inflate(R.layout.edit_movie, viewGroup);

    selectedMovie = db.getMovie(mID);

    int popupDimensions = WindowManager.LayoutParams.MATCH_PARENT;

    TextView mName = (TextView) editMovieLayout.findViewById(R.id.editMovieName);
    mName.setText(mTitle);

    final RatingBar mRating = (RatingBar) editMovieLayout.findViewById(R.id.editRating);
    mRating.setRating(selectedMovie.getRating());

    // Creating the PopupWindow
    final PopupWindow popup = new PopupWindow();
    popup.setContentView(editMovieLayout);
    popup.setWidth(popupDimensions);
    popup.setHeight(popupDimensions);
    popup.setFocusable(true);
    // popup.setAnimationStyle(R.style.PopupWindowAnimation);

    // Displaying the popup at the specified location, + offsets.
    popup.showAtLocation(editMovieLayout, Gravity.CENTER, 0, 0);

    ImageButton close = (ImageButton) editMovieLayout.findViewById(R.id.close);
    close.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            popup.dismiss();
          }
        });

    Button save = (Button) editMovieLayout.findViewById(R.id.saveMovieButton);
    save.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            selectedMovie.setRating(mRating.getRating());
            db.updateMovie(selectedMovie);
            try {
              populateMyMovies(lv);
            } catch (ParseException e) {
              e.printStackTrace();
            }
            popup.dismiss();
          }
        });
  }
Exemple #18
0
  private void init() {
    StrictMode.setThreadPolicy(
        new StrictMode.ThreadPolicy.Builder()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork()
            .penaltyLog()
            .build());
    StrictMode.setVmPolicy(
        new StrictMode.VmPolicy.Builder()
            .detectLeakedSqlLiteObjects()
            .detectLeakedClosableObjects()
            .penaltyLog()
            .penaltyDeath()
            .build());

    // set toolbar
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle("");
    setSupportActionBar(mToolbar);
    TextView tvv = (TextView) findViewById(R.id.titlefortoolbar);
    tvv.setText("评价");

    // 添加按钮事件
    /*Button button  =(Button)findViewById(R.id.button_comment_send);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Toast.makeText(getApplicationContext(), "通过setOnClickListener()方法实现",
                    Toast.LENGTH_SHORT).show();
            //Intent intent = new Intent(activity_comment.this, activity_home.class);
            //activity_comment.this.startActivity(intent);
        }
    });*/
    RatingBar ratBar = (RatingBar) findViewById(R.id.ratingBar);
    ratBar.setStepSize(1); // 步进为1
    ratBar.setOnRatingBarChangeListener(
        new RatingBar.OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            // doing actions
            starnum = (int) rating;
            // rating是传入的星级。
          }
        });

    // FAB
    fab();

    sp = this.getSharedPreferences("user_id", MODE_PRIVATE);
    user_id = sp.getInt("user_id", -1);
  }
Exemple #19
0
 public void setRating(float rating) {
   this.rating = rating;
   if (rating == 0) {
     ratingBar.setVisibility(GONE);
     ratingTv.setText(R.string.label_no_rating);
   } else {
     ratingBar.setRating(rating / 2);
     ratingBar.setVisibility(VISIBLE);
     ratingTv.setText("" + rating);
   }
 }
  private void addFeedback(final String username) {
    Log.d("TarotFeedback", "username :: " + username);
    View dialogLayout = LayoutInflater.from(this).inflate(R.layout.feedback_alert_dialog, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
    builder.setView(dialogLayout);
    EditText usernameEditText = (EditText) dialogLayout.findViewById(R.id.user_edittext);
    usernameEditText.setText(username);
    final CommentEditText commentEditText =
        (CommentEditText) dialogLayout.findViewById(R.id.feedback_edittext);
    final RatingBar feedbackRating = (RatingBar) dialogLayout.findViewById(R.id.rating);

    final AlertDialog customAlertDialog = builder.create();
    final Button saveButton = (Button) dialogLayout.findViewById(R.id.feedback_button);

    final Feedback feedbackFromPreference = readFromPreference();
    commentEditText.setText(feedbackFromPreference.getFeedback());
    feedbackRating.setRating((float) feedbackFromPreference.getRating());

    if (!TextUtils.isEmpty(feedbackFromPreference.getObjectId())) {
      saveButton.setText(R.string.update_button_label);
    }
    saveButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            String comment = commentEditText.getText().toString();
            String user = username;
            float rating = feedbackRating.getRating();
            if (TextUtils.isEmpty(comment)) {
              Toast.makeText(
                      TarotFeedbackActivity.this,
                      getString(R.string.save_error_2),
                      Toast.LENGTH_SHORT)
                  .show();
              return;
            }

            if (rating == 0.0f) {
              Toast.makeText(
                      TarotFeedbackActivity.this,
                      getString(R.string.save_error_1),
                      Toast.LENGTH_SHORT)
                  .show();
              return;
            }
            submitFeedback(
                comment, user, rating, feedbackFromPreference.getObjectId(), customAlertDialog);
          }
        });
    customAlertDialog.show();
  }
Exemple #21
0
  protected void update() {
    if (moreButton != null) {
      if (exists || pinned) {
        if (!shaded) {
          moreButton.setImageResource(
              exists ? R.drawable.download_cached : R.drawable.download_pinned);
          shaded = true;
        }
      } else {
        if (shaded) {
          moreButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.download_none));
          shaded = false;
        }
      }
    }

    if (starButton != null) {
      if (isStarred) {
        if (!starred) {
          if (starButton.getDrawable() == null) {
            starButton.setImageDrawable(
                DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star));
          }
          starButton.setVisibility(View.VISIBLE);
          starred = true;
        }
      } else {
        if (starred) {
          starButton.setVisibility(View.GONE);
          starred = false;
        }
      }
    }

    if (ratingBar != null && isRated != rating) {
      if (isRated > 0 && rating == 0) {
        ratingBar.setVisibility(View.VISIBLE);
      } else if (isRated == 0 && rating > 0) {
        ratingBar.setVisibility(View.GONE);
      }

      ratingBar.setRating(isRated);
      rating = isRated;
    }

    if (coverArtView != null && coverArtView instanceof RecyclingImageView) {
      RecyclingImageView recyclingImageView = (RecyclingImageView) coverArtView;
      if (recyclingImageView.isInvalidated()) {
        onUpdateImageView();
      }
    }
  }
Exemple #22
0
  public void calcCantPorTipoCalif() {
    int cantCalif = calificaciones.size(), sumatoriaCalif = 0;

    int cantExc = 0, cantMbn = 0, cantBn = 0, cantReg = 0, cantMal = 0;

    for (int i = 0; i < calificaciones.size(); i++) {
      sumatoriaCalif += calificaciones.get(i);

      switch (calificaciones.get(i)) {
        case 5:
          cantExc++;
          break;
        case 4:
          cantMbn++;
          break;
        case 3:
          cantBn++;
          break;
        case 2:
          cantReg++;
          break;
        case 1:
          cantMal++;
          break;
      }
    }

    System.out.println(
        "SumatoriaCalif = "
            + sumatoriaCalif
            + " Cantidades: "
            + cantExc
            + "   "
            + cantMbn
            + "   "
            + cantBn
            + "   "
            + cantReg
            + "   "
            + cantMal);

    barraEstadisticaExcelente.setProgress((cantExc * 100) / cantCalif);
    barraEstadisticaMuyBueno.setProgress((cantMbn * 100) / cantCalif);
    barraEstadisticaBueno.setProgress((cantBn * 100) / cantCalif);
    barraEstadisticaRegular.setProgress((cantReg * 100) / cantCalif);
    barraEstadisticaMalo.setProgress((cantMal * 100) / cantCalif);

    calificacionGeneralTaxista.setProgress((sumatoriaCalif / cantCalif) * 2);
    calificacionGeneralTaxista.setEnabled(false);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.movie_detail_view);

    // Get intent data
    Intent i = getIntent();

    // Selected image id
    // int position = i.getExtras().getInt("id");
    String InstanceTagLocal =
        getApplicationContext().getResources().getString(R.string.InstanceTag2);
    Film recdFilm = i.getParcelableExtra(InstanceTagLocal);

    /* decide the heights of the controls on the basis of the displayMetrics
     */

    final DisplayMetrics displayMetrics = new DisplayMetrics();
    this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int HeightLocal = displayMetrics.heightPixels;
    // final int WidthLocal = displayMetrics.widthPixels;

    ImageView imageView = (ImageView) findViewById(R.id.MovieDetailView);
    imageView.setMaxHeight((int) Math.round(HeightLocal * 0.30));
    // Film film = imageAdapter.getInstance().films.get(position);
    // imageView.setImageResource(film.getPosterPath());
    Glide.with(this)
        .load(baseImgURL + recdFilm.getPosterPath())
        .error(R.drawable.big_problem)
        .into(imageView);

    TextView title = (TextView) findViewById(R.id.MovieTitle);
    title.setHeight((int) Math.round(HeightLocal * 0.20));
    title.setText(recdFilm.getTitle());

    RatingBar rating = (RatingBar) findViewById(R.id.UserRating);
    // float f = Float.parseFloat( film.getRating().trim() );
    rating.setRating(recdFilm.getRating());

    TextView releaseDate = (TextView) findViewById(R.id.ReleaseDate);

    releaseDate.setText(
        getApplicationContext().getResources().getString(R.string.ReleaseDateLabel)
            + recdFilm.getFormattedDate());

    TextView overView = (TextView) findViewById(R.id.OverView);
    overView.setHeight((int) Math.round(HeightLocal * 0.30));
    overView.setText(recdFilm.getOverview());
  }
Exemple #24
0
  @Override
  public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
    if (rating > 2) {
      ratingBar.setProgressDrawable(buildRatingBarDrawables(mGoodBitmaps));
    } else {
      ratingBar.setProgressDrawable(buildRatingBarDrawables(mBadBitmaps));
    }
    switch (ratingBar.getId()) {
      case R.id.Seller_service_ratingbar:
        break;

      default:
        break;
    }
  }
  /**
   * *************************************************************************************************
   * void addDetails()
   *
   * <p>This method adds all of the recipe details from the query.
   *
   * <p>**************************************************************************************************
   */
  public void addDetails() {

    seekBar.setMax((Integer.parseInt(servings) * 4) - 1);
    seekBar.setProgress(Integer.parseInt(servings) - 1);

    // log.d("RecipeView_addDetails image=", rawImage);
    txtRecipeName.setText(recipeName);
    txtAuthor.setText(author);
    txtNumReviews.setText(numRatings);
    txtIngredientList.setText(getIngredientList(ingredientArray));

    // adding a number before each line in the directions
    String lines[] = cookingDirections.split("\\r?\\n");
    String dir = "";
    for (int i = 0; i < lines.length - 1; i++) {
      dir += Integer.toString(i + 1) + ". " + lines[i] + "\n\n";
    }

    dir += Integer.toString(lines.length) + ". " + lines[lines.length - 1];

    txtCookingDirections.setText(dir);

    txtCookTime.setText(cookTime);
    txtPrepTime.setText(prepTime);
    txtServings.setText(servings);
    if (hasImage == 1) imgLoader.DisplayImage(urlRoot + imageUrl, imgPicture);
    rtbRating.setRating(Float.valueOf(rating) / 2);
  }
  @Test
  public void shouldSupportMultipleOnRatingBarChangeListenersInRatingBar() {
    RatingBar ratingBar = new RatingBar(RuntimeEnvironment.application);
    RatingBarAddOn ratingBarAddOn = new RatingBarAddOn(ratingBar);

    MockOnRatingBarChangeListener listener1 = new MockOnRatingBarChangeListener();
    MockOnRatingBarChangeListener listener2 = new MockOnRatingBarChangeListener();

    ratingBarAddOn.addOnRatingBarChangeListener(listener1);
    ratingBarAddOn.addOnRatingBarChangeListener(listener2);

    ratingBar.setRating(RandomValues.anyFloat());

    assertTrue(listener1.ratingBarEventFired);
    assertTrue(listener2.ratingBarEventFired);
  }
 private View creatCommentView(Comment2 comment) {
   View item = getLayoutInflater().inflate(R.layout.item_comment_list, null);
   RatingBar itemRatingBar = (RatingBar) item.findViewById(R.id.item_comment_point);
   TextView txtCommenter = (TextView) item.findViewById(R.id.item_commenter);
   TextView txtCommentTime = (TextView) item.findViewById(R.id.item_comment_time);
   TextView txtCommentContent = (TextView) item.findViewById(R.id.item_comment_content);
   itemRatingBar.setRating(comment.getPoint());
   if (comment.isAnonymous() || null == comment.getCreatorName()) {
     txtCommenter.setText("匿名");
   } else {
     txtCommenter.setText(comment.getCreatorName());
   }
   txtCommentTime.setText(comment.getCreatTime());
   txtCommentContent.setText(comment.getContent());
   return item;
 }
  private void updateStats() {
    StatisticsCalculator statCalculator = new StatisticsCalculator(getActivity());
    DeckStatistics stats = statCalculator.getDeckStatistics(deckID);
    DecimalFormat df = new DecimalFormat("###.#");

    tvCurrentWins.setText(String.valueOf(stats.getCurrentWins()));
    tvCurrentLosses.setText(String.valueOf(stats.getCurrentLosses()));
    tvCurrentWinPc.setText(String.valueOf(df.format(stats.getCurrentWinpc())));
    tvTotalWins.setText(String.valueOf(stats.getTotalWins()));
    tvTotalLosses.setText(String.valueOf(stats.getTotalLosses()));
    tvTotalWinPc.setText(String.valueOf(df.format(stats.getTotalWinpc())));

    // Version 3.6
    // setMostCommonManaSymbol(imgCommonWin, stats.getCommonwin());
    // setMostCommonManaSymbol(imgCommonLoss, stats.getCommonloss());

    // Version 2.1
    // slPerformanceRating.setProgress(stats.getPerformanceRating());
    // slPerformanceRating.setEnabled(false);

    // Version 3.0
    PerformanceRating performanceRating = new PerformanceRating();
    performanceRating.setPerformanceRatingFromRaw(stats.getPerformanceRating());
    rBarDeckPerformanceRating.setRating(performanceRating.getPerformanceRatingAsStars());

    // Version 3.6
    grWinrateHistory.drawGraph(stats.getWinrateHistory());
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_task_frag);

    name = (EditText) findViewById(R.id.edit_task_name);
    category = (Spinner) findViewById(R.id.spinner_txt);

    progress = (SeekBar) findViewById(R.id.seekBar1);
    rating = (RatingBar) findViewById(R.id.rating_task);
    saveButton = (Button) findViewById(R.id.save_btn);

    Intent intent = getIntent();
    long idTask = intent.getLongExtra("idTask", 0);

    layer = new TaskLayer(getApplication());

    currentTask = layer.GetTask(idTask);

    ArrayAdapter<String> spinnerAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, getCategories());
    category.setAdapter(spinnerAdapter);
    category.setSelection(safeLongToInt(currentTask.category.getId() - 1));
    ;
    name.setText(currentTask.name);
    progress.setProgress(currentTask.progress);
    rating.setRating(currentTask.importance);
  }
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   // 星型拖拉条被拉动的处理代码
   RatingBar rb = (RatingBar) findViewById(R.id.RatingBar01);
   rb.setOnRatingBarChangeListener(
       new RatingBar.OnRatingBarChangeListener() {
         @Override
         public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
           ProgressBar pb = (ProgressBar) findViewById(R.id.ProgressBar01);
           RatingBar rb = (RatingBar) findViewById(R.id.RatingBar01);
           float rate = rb.getRating();
           pb.setProgress((int) (rate / MAX_STAR * MAX)); // 将0-5星星数折算成0-100的进度值
         }
       });
 }