@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;
    }
Exemplo n.º 2
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);
   }
 }
Exemplo n.º 3
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();
      }
    }
  }
Exemplo n.º 4
0
  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());
    }
  }
Exemplo n.º 5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_confirm_transaction);

    confirmTxt = (TextView) findViewById(R.id.confirmText);
    rBar = (RatingBar) findViewById(R.id.transactionRating);
    applyButton = (ImageButton) findViewById(R.id.applyConfirmOrRating);

    rBar.setVisibility(View.GONE);
    tConfirmed = false;

    Intent intent = getIntent();
    transactionID = intent.getIntExtra("TRANSACTION_ID", -1);
    from = intent.getStringExtra("FROM");
  }
Exemplo n.º 6
0
  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);
    }
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    HashMap<String, String> map = mylist.get(position);

    if (v == null) {
      LayoutInflater vi =
          (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      v = vi.inflate(R.layout.comment_list, null);
    }
    // Check if there are any comments
    if (!map.get("email").equals("")) {
      TextView email = (TextView) v.findViewById(R.id.tv_user_email);
      TextView comment = (TextView) v.findViewById(R.id.tv_user_comment);
      RatingBar rb = (RatingBar) v.findViewById(R.id.rating);

      // Convert string to float of the rating
      float rating = Float.valueOf(map.get("stars")).floatValue();

      if (email != null) {
        email.setText(map.get("email"));
      }
      if (comment != null) {
        comment.setText(map.get("feedback"));
      }
      if (comment != null) {
        rb.setRating(rating);
      }
    } else {
      // Hide RatingBar and display No comments
      TextView comment = (TextView) v.findViewById(R.id.tv_user_comment);
      RatingBar rb = (RatingBar) v.findViewById(R.id.rating);
      comment.setText("No comments");
      rb.setVisibility(RatingBar.INVISIBLE);
    }
    return v;
  }
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mRoot = inflater.inflate(R.layout.fragment_moviedetail, container, false);
    if (VersionUtils.isJellyBean() && container != null) {
      mRoot.setMinimumHeight(container.getMinimumHeight());
    }
    ButterKnife.inject(this, mRoot);

    if (!VersionUtils.isJellyBean()) {
      mPlayButton.setBackgroundDrawable(
          PixelUtils.changeDrawableColor(
              mPlayButton.getContext(), R.drawable.play_button_circle, sMovie.color));
    } else {
      mPlayButton.setBackground(
          PixelUtils.changeDrawableColor(
              mPlayButton.getContext(), R.drawable.play_button_circle, sMovie.color));
    }

    mTitle.setText(sMovie.title);
    if (!sMovie.rating.equals("-1")) {
      Double rating = Double.parseDouble(sMovie.rating);
      mRating.setProgress(rating.intValue());
      mRating.setVisibility(View.VISIBLE);
    } else {
      mRating.setVisibility(View.GONE);
    }

    String metaDataStr = sMovie.year;
    if (!TextUtils.isEmpty(sMovie.runtime)) {
      metaDataStr += " • ";
      metaDataStr += sMovie.runtime + " " + getString(R.string.minutes);
    }

    if (!TextUtils.isEmpty(sMovie.genre)) {
      metaDataStr += " • ";
      metaDataStr += sMovie.genre;
    }

    mMeta.setText(metaDataStr);

    if (!TextUtils.isEmpty(sMovie.synopsis)) {
      mSynopsis.setText(sMovie.synopsis);
      mSynopsis.post(
          new Runnable() {
            @Override
            public void run() {
              boolean ellipsized = false;
              Layout layout = mSynopsis.getLayout();
              if (layout == null) return;
              int lines = layout.getLineCount();
              if (lines > 0) {
                int ellipsisCount = layout.getEllipsisCount(lines - 1);
                if (ellipsisCount > 0) {
                  ellipsized = true;
                }
              }
              mReadMore.setVisibility(ellipsized ? View.VISIBLE : View.GONE);
            }
          });
    } else {
      mSynopsis.setClickable(false);
      mReadMore.setVisibility(View.GONE);
    }

    mWatchTrailer.setVisibility(
        sMovie.trailer == null || sMovie.trailer.isEmpty() ? View.GONE : View.VISIBLE);

    mSubtitles.setFragmentManager(getFragmentManager());
    mQuality.setFragmentManager(getFragmentManager());
    mSubtitles.setTitle(R.string.subtitles);
    mQuality.setTitle(R.string.quality);

    mSubtitles.setText(R.string.loading_subs);
    mSubtitles.setClickable(false);

    if (sMovie.getSubsProvider() != null) {
      sMovie
          .getSubsProvider()
          .getList(
              sMovie,
              new SubsProvider.Callback() {
                @Override
                public void onSuccess(Map<String, String> subtitles) {
                  if (!mAttached) return;

                  if (subtitles == null) {
                    ThreadUtils.runOnUiThread(
                        new Runnable() {
                          @Override
                          public void run() {
                            mSubtitles.setText(R.string.no_subs_available);
                          }
                        });
                    return;
                  }

                  sMovie.subtitles = subtitles;

                  String[] languages = subtitles.keySet().toArray(new String[subtitles.size()]);
                  Arrays.sort(languages);
                  final String[] adapterLanguages = new String[languages.length + 1];
                  adapterLanguages[0] = "no-subs";
                  System.arraycopy(languages, 0, adapterLanguages, 1, languages.length);

                  String[] readableNames = new String[adapterLanguages.length];
                  for (int i = 0; i < readableNames.length; i++) {
                    String language = adapterLanguages[i];
                    if (language.equals("no-subs")) {
                      readableNames[i] = getString(R.string.no_subs);
                    } else {
                      Locale locale = LocaleUtils.toLocale(language);
                      readableNames[i] = locale.getDisplayName(locale);
                    }
                  }

                  mSubtitles.setListener(
                      new OptionSelector.SelectorListener() {
                        @Override
                        public void onSelectionChanged(int position, String value) {
                          onSubtitleLanguageSelected(adapterLanguages[position]);
                        }
                      });
                  mSubtitles.setData(readableNames);
                  ThreadUtils.runOnUiThread(
                      new Runnable() {
                        @Override
                        public void run() {
                          mSubtitles.setClickable(true);
                        }
                      });

                  String defaultSubtitle =
                      PrefUtils.get(mSubtitles.getContext(), Prefs.SUBTITLE_DEFAULT, null);
                  if (subtitles.containsKey(defaultSubtitle)) {
                    onSubtitleLanguageSelected(defaultSubtitle);
                    mSubtitles.setDefault(Arrays.asList(adapterLanguages).indexOf(defaultSubtitle));
                  } else {
                    onSubtitleLanguageSelected("no-subs");
                    mSubtitles.setDefault(Arrays.asList(adapterLanguages).indexOf("no-subs"));
                  }
                }

                @Override
                public void onFailure(Exception e) {
                  mSubtitles.setData(new String[0]);
                  mSubtitles.setClickable(true);
                }
              });
    } else {
      mSubtitles.setClickable(false);
      mSubtitles.setText(R.string.no_subs_available);
    }

    if (sMovie.torrents.size() > 0) {
      final String[] qualities =
          sMovie.torrents.keySet().toArray(new String[sMovie.torrents.size()]);
      SortUtils.sortQualities(qualities);
      mQuality.setData(qualities);
      mQuality.setListener(
          new OptionSelector.SelectorListener() {
            @Override
            public void onSelectionChanged(int position, String value) {
              mSelectedQuality = value;
              renderHealth();
              updateMagnet();
            }
          });
      String defaultQuality = PrefUtils.get(mQuality.getContext(), Prefs.QUALITY_DEFAULT, "720p");
      int qualityIndex =
          Arrays.asList(qualities).contains(defaultQuality)
              ? Arrays.asList(qualities).indexOf(defaultQuality)
              : qualities.length - 1;
      mSelectedQuality = qualities[qualityIndex];
      mQuality.setText(mSelectedQuality);
      mQuality.setDefault(qualityIndex);
      renderHealth();
      updateMagnet();
    }

    if (mCoverImage != null) {
      Picasso.with(mCoverImage.getContext()).load(sMovie.image).into(mCoverImage);
    }

    return mRoot;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ride_details_passenger);

    initToolbar();
    con = this;
    ride_details_passengers = (ListView) findViewById(R.id.ride_details_passengers);

    FromRegionEnName = (TextView) findViewById(R.id.FromRegionEnName);
    ToRegionEnName = (TextView) findViewById(R.id.ToRegionEnName);

    StartFromTime = (TextView) findViewById(R.id.StartFromTime);
    // EndToTime_ = (TextView) findViewById(R.id.EndToTime_);

    FromEmirateEnName = (TextView) findViewById(R.id.FromEmirateEnName);
    ToEmirateEnName = (TextView) findViewById(R.id.ToEmirateEnName);
    // Pass_rate_Driver_btn= (Button) findViewById(R.id.Pass_rate_Driver_btn);

    NationalityEnName = (TextView) findViewById(R.id.NationalityEnName);
    PrefLanguageEnName = (TextView) findViewById(R.id.PrefLanguageEnName);

    AgeRange = (TextView) findViewById(R.id.AgeRange);
    PreferredGender = (TextView) findViewById(R.id.PreferredGender);
    IsSmoking = (TextView) findViewById(R.id.IsSmoking);
    Join_Ride_btn = (Button) findViewById(R.id.Join_Ride_btn);
    ride_details_day_of_week = (TextView) findViewById(R.id.ride_details_day_of_week);
    Driver_get_Review_lv = (ListView) findViewById(R.id.Driver_get_Review_lv);
    Passenger_Review_Driver_Btn = (Button) findViewById(R.id.Passenger_Review_Driver_Btn);
    Relative_REviews = (RelativeLayout) findViewById(R.id.Relative_REviews);
    Relative_REviews_Address_2 = (TextView) findViewById(R.id.Relative_REviews_Address_2);

    ratingBar = (RatingBar) findViewById(R.id.ratingBar2);
    ratingBar.setStepSize(1);

    Join_Ride_btn.setVisibility(View.INVISIBLE);
    // Pass_rate_Driver_btn.setVisibility(View.INVISIBLE);
    ratingBar.setVisibility(View.GONE);
    Passenger_Review_Driver_Btn.setVisibility(View.GONE);

    // setListViewHeightBasedOnChildren(Driver_get_Review_lv);
    // setSupportActionBar(toolbar);
    // getSupportActionBar().setDisplayShowHomeEnabled(true);
    myPrefs = this.getSharedPreferences("myPrefs", 0);
    Passenger_ID = Integer.parseInt(myPrefs.getString("account_id", "0"));

    Bundle in = getIntent().getExtras();
    Driver_ID = in.getInt("DriverID");
    Route_ID = in.getInt("RouteID");

    //        Pass_rate_Driver_btn.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                final Dialog dialog = new Dialog(RideDetailsPassenger.this);
    //                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    //                dialog.setContentView(R.layout.rate_layout);
    //                Button btn = (Button) dialog.findViewById(R.id.noroute_id);
    //                final RatingBar ratingBar = (RatingBar) dialog.findViewById(R.id.ratingBar);
    //                ratingBar.setStepSize(1);
    //                dialog.show();
    //                btn.setOnClickListener(new View.OnClickListener() {
    //                    @Override
    //                    public void onClick(View v) {
    //                        NoOfStars = (int) ratingBar.getRating();
    //                        Log.d("NoOfStars", String.valueOf(NoOfStars));
    //                        new rateDriver().execute();
    //                        dialog.dismiss();
    //                    }
    //                });
    //            }
    //        });

    try {

      if (in.getInt("FLAG_1") == 1) {
        Join_Ride_btn.setVisibility(View.INVISIBLE);
        ratingBar.setVisibility(View.VISIBLE);
        Passenger_Review_Driver_Btn.setVisibility(View.VISIBLE);

      } else {
        Join_Ride_btn.setVisibility(View.VISIBLE);
        Passenger_Review_Driver_Btn.setVisibility(View.GONE);
      }
    } catch (NullPointerException e) {

    }

    Log.d("Test Driver id", String.valueOf(Driver_ID));
    Log.d("test Route id", String.valueOf(Route_ID));
    Log.d("test Passenger id 2", String.valueOf(Passenger_ID));

    exists = false;
    new back().execute();
  } //  on create
Exemplo n.º 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());
  }