コード例 #1
0
  View getHeader(List<Object> GUIDs, List<Object> Rates, List<Object> Reviews, int MyReviewPos) {
    // Caculate Average Rate
    float Sum = 0;
    for (int i = 0; i < Rates.size(); i++) {
      try {
        Sum += (double) Rates.get(i);
      } catch (Exception E) {
        Sum += (int) Rates.get(i);
      }
    }
    float Average = Sum / Rates.size();
    View v = (View) getActivity().getLayoutInflater().inflate(R.layout.header_review, null);
    RatingBar AvrRB = (RatingBar) v.findViewById(R.id.rateavr);
    RatingBar MyRB = (RatingBar) v.findViewById(R.id.myrate);
    TextView MyReviewTxt = (TextView) v.findViewById(R.id.myreview);
    AvrRB.setNumStars(5);
    AvrRB.setRating(Average);
    if (MyReviewPos != -1) {
      MyRB.setNumStars(5);
      try {
        double d = (double) Rates.get(MyReviewPos);
        MyRB.setRating((float) d);
      } catch (Exception e) {
        int d = (int) Rates.get(MyReviewPos);
        MyRB.setRating((float) d);
      }

      MyReviewTxt.setText((String) Reviews.get(MyReviewPos));
    }
    return v;
  }
コード例 #2
0
  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());
  }
コード例 #3
0
ファイル: RatingBar.java プロジェクト: BvbKoala/SourceCode
  public RatingBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RatingBar, defStyle, 0);
    final int numStars = a.getInt(R.styleable.RatingBar_numStars, mNumStars);
    setIsIndicator(a.getBoolean(R.styleable.RatingBar_isIndicator, !mIsUserSeekable));
    final float rating = a.getFloat(R.styleable.RatingBar_rating, -1);
    final float stepSize = a.getFloat(R.styleable.RatingBar_stepSize, -1);
    a.recycle();

    if (numStars > 0 && numStars != mNumStars) {
      setNumStars(numStars);
    }

    if (stepSize >= 0) {
      setStepSize(stepSize);
    } else {
      setStepSize(0.5f);
    }

    if (rating >= 0) {
      setRating(rating);
    }

    // A touch inside a star fill up to that fractional area (slightly more
    // than 1 so boundaries round up).
    mTouchProgressOffset = 1.1f;
  }
コード例 #4
0
ファイル: Main.java プロジェクト: cpm2710/cellbank
  // ** 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);*/

  }
コード例 #5
0
    @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;
    }
コード例 #6
0
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewWrapper wrap = null;
    View row = convertView;

    if (convertView == null) {
      LinearLayout layout = new LinearLayout(ctxt);
      RatingBar rate = new RatingBar(ctxt);

      rate.setNumStars(3);
      rate.setStepSize(1.0f);

      View guts = delegate.getView(position, null, parent);

      layout.setOrientation(LinearLayout.HORIZONTAL);

      rate.setLayoutParams(
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT));
      guts.setLayoutParams(
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));

      RatingBar.OnRatingBarChangeListener l =
          new RatingBar.OnRatingBarChangeListener() {
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromTouch) {
              rates[(Integer) ratingBar.getTag()] = rating;
            }
          };

      rate.setOnRatingBarChangeListener(l);

      layout.addView(rate);
      layout.addView(guts);

      wrap = new ViewWrapper(layout);
      wrap.setGuts(guts);
      layout.setTag(wrap);

      rate.setTag(new Integer(position));
      rate.setRating(rates[position]);

      row = layout;
    } else {
      wrap = (ViewWrapper) convertView.getTag();
      wrap.setGuts(delegate.getView(position, wrap.getGuts(), parent));
      wrap.getRatingBar().setTag(new Integer(position));
      wrap.getRatingBar().setRating(rates[position]);
    }

    return (row);
  }
コード例 #7
0
    @Override
    public void setupInnerViewElements(ViewGroup parent, View view) {

      TextView title = (TextView) view.findViewById(R.id.carddemo_gplay_main_inner_title);
      title.setText("FREE");

      TextView subtitle = (TextView) view.findViewById(R.id.carddemo_gplay_main_inner_subtitle);
      subtitle.setText(secondaryTitle);

      RatingBar mRatingBar =
          (RatingBar) parent.findViewById(R.id.carddemo_gplay_main_inner_ratingBar);

      mRatingBar.setNumStars(5);
      mRatingBar.setMax(5);
      mRatingBar.setStepSize(0.5f);
      mRatingBar.setRating(rating);
    }
コード例 #8
0
ファイル: ZRatingBar.java プロジェクト: tinyao/DouMovie
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    ratingBar = (RatingBar) findViewById(R.id.zrb_rating);
    ratingTv = (TextView) findViewById(R.id.ztv_rating);
    ratingBar.setNumStars(numStars);
    ratingBar.setStepSize(stepSize);
    ratingBar.setMax(max);
    ratingBar.setRating(rating);
    ratingBar.setIsIndicator(isIndicator);
    ratingTv.setTextSize(mTextSize / getResources().getDisplayMetrics().density);
    ratingTv.setTextColor(mTextColor);

    LinearLayout.LayoutParams layoutParams =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(0, 0, mSpacing, 0);
    ratingBar.setLayoutParams(layoutParams);
  }
コード例 #9
0
    @Override
    public void setupInnerViewElements(ViewGroup parent, View view) {

      // Retrieve elements
      mTitle = (TextView) parent.findViewById(R.id.carddemo_myapps_main_inner_title);
      mSecondaryTitle =
          (TextView) parent.findViewById(R.id.carddemo_myapps_main_inner_secondaryTitle);
      mRatingBar = (RatingBar) parent.findViewById(R.id.carddemo_myapps_main_inner_ratingBar);

      if (mTitle != null) mTitle.setText(title);

      if (mSecondaryTitle != null) mSecondaryTitle.setText(secondaryTitle);

      if (mRatingBar != null) {
        mRatingBar.setNumStars(5);
        mRatingBar.setMax(5);
        mRatingBar.setStepSize(0.5f);
        mRatingBar.setRating(rating);
      }
    }
コード例 #10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_display_story);

    // Get the message from the intent
    Intent intent = getIntent();
    String jsonStr = intent.getStringExtra(MainActivity.SERVER_STORY);

    // Obtain user story in json data

    String story;
    Integer score = 0, id = 0;
    try {
      // If the json string is empty show the error message
      if (jsonStr.equals("")) {
        story = getResources().getString(R.string.no_story_error);
      } else {
        // Get text, id, score and number of ratings from json
        JSONObject recvStory = new JSONObject(jsonStr);
        story = (String) recvStory.get("text");
        score = (Integer) recvStory.get("score");
        id = (Integer) recvStory.get("id");
        numRatings = (Integer) recvStory.get("nratings");

        // Save id of story for future use (rating)
        storyObj = new JSONObject();
        storyObj.put("id", id);

        // Set the number of ratings the user can give
        RatingBar ratingBar = (RatingBar) findViewById(R.id.rating_bar);
        ratingBar.setNumStars(numRatings - 1);
      }
    } catch (JSONException e) {
      e.printStackTrace();
      story = getResources().getString(R.string.server_error);
    }

    // Save story as read if it was loaded
    if (storyObj != null) {

      // Load shared preferences to mark story as read
      SharedPreferences sharedPref =
          getSharedPreferences(getString(R.string.preference_file), Context.MODE_PRIVATE);

      // Get the set with ids of read stories
      Set<String> read_ids =
          sharedPref.getStringSet(getString(R.string.saved_ids), new HashSet<String>());

      // Append id if story read
      SharedPreferences.Editor editor = sharedPref.edit();
      read_ids.add(id.toString());
      editor.putStringSet(getString(R.string.saved_ids), read_ids);
      editor.commit();

      // Disable rating bar and send button if story not received
    } else {
      Button sendRate = (Button) findViewById(R.id.send_rate);
      sendRate.setEnabled(false);
      sendRate.setTextColor(getResources().getColor(R.color.disabled_button));

      RatingBar ratingBar = (RatingBar) findViewById(R.id.rating_bar);
      ratingBar.setOnTouchListener(
          new OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
              return true;
            }
          });
      ratingBar.setFocusable(false);
      ratingBar.setVisibility(View.GONE);
      TextView scoreView = (TextView) findViewById(R.id.story_score);
      scoreView.setVisibility(View.GONE);
    }

    // Set the text in the story_view to the other user story
    TextView storyView = (TextView) findViewById(R.id.story_view);
    storyView.setText(story);
    // Set the text in the score view to the story rating
    TextView scoreView = (TextView) findViewById(R.id.story_score);
    scoreView.setText(score.toString());
  }