Beispiel #1
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};
  }
Beispiel #2
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
  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);
   }
 }
Beispiel #5
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());
    }
  }
  /** 初始化 */
  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);
  }
 /** Metoda dodaje funkcionalnost RatingBar - u koji se odnosi na postavljanje prioriteta cilja. */
 private void setRbPriority() {
   rbPriority = (RatingBar) findViewById(com.foi.air.goalsettingassistant.app.R.id.rbPriority);
   rbPriority.setOnRatingBarChangeListener(
       new RatingBar.OnRatingBarChangeListener() {
         @Override
         public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
           priority = (int) rating;
         }
       });
 }
Beispiel #8
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);
  }
Beispiel #9
0
 private void initialize() {
   // TODO Auto-generated method stub
   call = (Button) findViewById(R.id.bCall);
   email = (Button) findViewById(R.id.bEmail);
   sms = (Button) findViewById(R.id.bSMS);
   getRatingBar = (RatingBar) findViewById(R.id.ratingBar1);
   getRatingBar.setOnRatingBarChangeListener(this);
   sms.setOnClickListener(this);
   call.setOnClickListener(this);
   email.setOnClickListener(this);
 }
  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);
  }
 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的进度值
         }
       });
 }
  private void startRating(final int pos) {

    fav.setOnRatingBarChangeListener(
        new RatingBar.OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar rb, float rating, boolean userBool) {

            if (userBool) {
              // QUITAR IPSO FACTO LA PARTE QUE MUESTRA LA POSICION, NO HACE FALTA
              /* Toast.makeText(context, "Añadido a favoritos el elemento " + Integer.toString(pos) + " con una puntuacion de"
              + Float.toString(rating) + ".\n", Toast.LENGTH_SHORT).show();*/
              setBaggFav(pos, rating);
            }
          }
        });
  }
  private void initialize() {
    index = 0;
    bFirst = (Button) findViewById(R.id.bFirst);
    bPrev = (Button) findViewById(R.id.bPrev);
    bNext = (Button) findViewById(R.id.bNext);
    bLast = (Button) findViewById(R.id.bLast);
    tvWord = (TextView) findViewById(R.id.tvWord);
    tvDefinition = (TextView) findViewById(R.id.tvDefinition);
    pbProgress = (ProgressBar) findViewById(R.id.pbProgress);
    rbMyRating = (RatingBar) findViewById(R.id.rbMyRating);

    bFirst.setOnClickListener(this);
    bPrev.setOnClickListener(this);
    bNext.setOnClickListener(this);
    bLast.setOnClickListener(this);
    rbMyRating.setOnRatingBarChangeListener(this);

    // Database activities
    dbh = new FlashCardDBHelper(this);
    db = dbh.getWritableDatabase();

    // Settings
    settings = PreferenceManager.getDefaultSharedPreferences(this);

    // Gestures
    gestureScanner = new GestureDetector(getBaseContext(), this);

    // Text to Voice and Voice to Text
    tts =
        new TextToSpeech(
            this,
            new TextToSpeech.OnInitListener() {

              @Override
              public void onInit(int status) {
                if (status != TextToSpeech.ERROR) {
                  tts.setLanguage(Locale.getDefault());
                }
              }
            });
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final Button button = (Button) findViewById(R.id.button);
    final EditText edittext = (EditText) findViewById(R.id.edittext);
    final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
    final RadioButton radio_red = (RadioButton) findViewById(R.id.radio_red);
    final RadioButton radio_blue = (RadioButton) findViewById(R.id.radio_blue);
    final ToggleButton togglebutton = (ToggleButton) findViewById(R.id.togglebutton);
    final RatingBar ratingbar = (RatingBar) findViewById(R.id.ratingbar);

    button.setOnClickListener(button_listener);
    edittext.setOnKeyListener(edittext_listener);
    checkbox.setOnClickListener(checkbox_listener);
    radio_red.setOnClickListener(radio_listener);
    radio_blue.setOnClickListener(radio_listener);
    togglebutton.setOnClickListener(togglebutton_listener);
    ratingbar.setOnRatingBarChangeListener(ratingbar_listener);
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_cia_01_27_ratingbar_test);
   img01 = (ImageView) findViewById(R.id.cia_ratingbar_img);
   ratingBar = (RatingBar) findViewById(R.id.cia_ratingbar);
   ratingBar.setOnRatingBarChangeListener(
       new RatingBar.OnRatingBarChangeListener() {
         @Override
         public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
           Log.e("Jienan", String.valueOf(rating));
           switch (String.valueOf(rating)) {
             case "0.0":
               img01.setImageResource(imgs[0]);
               break;
             case "0.5":
               img01.setImageResource(imgs[1]);
               break;
             case "1.0":
               img01.setImageResource(imgs[2]);
               break;
             case "1.5":
               img01.setImageResource(imgs[3]);
               break;
             case "2.0":
               img01.setImageResource(imgs[4]);
               break;
             case "2.5":
               img01.setImageResource(imgs[5]);
               break;
             case "3.0":
               img01.setImageResource(imgs[6]);
               break;
             default:
               break;
           }
         }
       });
 }
  @Override
  public void call(final Subscriber<? super RatingBarChangeEvent> subscriber) {
    checkUiThread();

    RatingBar.OnRatingBarChangeListener listener =
        new RatingBar.OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            if (!subscriber.isUnsubscribed()) {
              subscriber.onNext(RatingBarChangeEvent.create(ratingBar, rating, fromUser));
            }
          }
        };

    subscriber.add(
        new MainThreadSubscription() {
          @Override
          protected void onUnsubscribe() {
            view.setOnRatingBarChangeListener(null);
          }
        });

    view.setOnRatingBarChangeListener(listener);
  }
Beispiel #17
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Using Buttons
    final Button button = (Button) findViewById(R.id.button);
    button.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // Perform action on clicks
            Toast.makeText(HelloViews.this, "Yay! Boton presionado", Toast.LENGTH_SHORT).show();
          }
        });

    // Using EditText
    final EditText edittext = (EditText) findViewById(R.id.edittext);
    edittext.setOnKeyListener(
        new OnKeyListener() {

          public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
              // Perform action on key press
              Toast.makeText(HelloViews.this, edittext.getText(), Toast.LENGTH_SHORT).show();
              return true;
            }
            return false;
          }
        });

    // Using CheckBox
    final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
    checkbox.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // Perform action on clicks, depending on whether it's now checked
            if (((CheckBox) v).isChecked()) {
              Toast.makeText(HelloViews.this, "Seleccionado", Toast.LENGTH_SHORT).show();
            } else {
              Toast.makeText(HelloViews.this, "No seleccionado", Toast.LENGTH_SHORT).show();
            }
          }
        });

    // Using Radio Buttons
    OnClickListener radio_listener =
        new OnClickListener() {
          public void onClick(View v) {
            // Perform action on clicks
            RadioButton rb = (RadioButton) v;
            Toast.makeText(HelloViews.this, rb.getText(), Toast.LENGTH_SHORT).show();
          }
        };

    final RadioButton radio_red = (RadioButton) findViewById(R.id.radio_red);
    final RadioButton radio_blue = (RadioButton) findViewById(R.id.radio_blue);
    radio_red.setOnClickListener(radio_listener);
    radio_blue.setOnClickListener(radio_listener);

    // Using Toggle Button

    final ToggleButton togglebutton = (ToggleButton) findViewById(R.id.togglebutton);
    togglebutton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // Perform action on clicks
            if (togglebutton.isChecked()) {
              Toast.makeText(HelloViews.this, "Encendido", Toast.LENGTH_SHORT).show();
            } else {
              Toast.makeText(HelloViews.this, "Apagado", Toast.LENGTH_SHORT).show();
            }
          }
        });

    // Using Rating Bar

    final RatingBar ratingbar = (RatingBar) findViewById(R.id.ratingbar);
    ratingbar.setOnRatingBarChangeListener(
        new OnRatingBarChangeListener() {
          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            Toast.makeText(HelloViews.this, "Nueva Puntuacion: " + rating, Toast.LENGTH_SHORT)
                .show();
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getTime = (Button) findViewById(R.id.button);
    imageView = (ImageView) findViewById(R.id.imageView);
    spinner = (Spinner) findViewById(R.id.spinner);
    timeView = (TextView) findViewById(R.id.timeView);
    checkBox = (CheckBox) findViewById(R.id.checkBox);
    ratingBar = (RatingBar) findViewById(R.id.ratingBar);
    back = (Button) findViewById(R.id.exit);
    final Calendar c = Calendar.getInstance();
    hour = c.get(Calendar.HOUR_OF_DAY);
    minute = c.get(Calendar.MINUTE);
    list.add("Bangalore");
    list.add("Chennai");
    list.add("Hyderabad");
    list.add("Pune");
    dataAdapter =
        new ArrayAdapter<String>(RelativeLayout.this, android.R.layout.simple_list_item_1, list);
    spinner.setAdapter(dataAdapter);
    getTime.setOnClickListener(
        new OnClickListener() {
          @SuppressWarnings("deprecation")
          @Override
          public void onClick(View arg0) {
            showDialog(TIME_DIALOG_ID);
          }
        });
    spinner.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            Toast.makeText(
                    RelativeLayout.this,
                    "Selected City:" + dataAdapter.getItem(arg2),
                    Toast.LENGTH_LONG)
                .show();
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });
    checkBox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
              Toast.makeText(RelativeLayout.this, "You checked:", Toast.LENGTH_LONG).show();
            } else {
              Toast.makeText(RelativeLayout.this, "You unchecked", Toast.LENGTH_LONG).show();
            }
          }
        });
    ratingBar.setOnRatingBarChangeListener(
        new OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            Toast.makeText(RelativeLayout.this, "You rated:" + rating, Toast.LENGTH_LONG).show();
          }
        });
    back.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            AlertDialog.Builder alert_dialog = new AlertDialog.Builder(RelativeLayout.this);
            alert_dialog.setTitle("Confirmation...");
            alert_dialog.setNegativeButton(
                "Cancel",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {}
                });
            alert_dialog.setPositiveButton(
                "Leavecurrent",
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    finish();
                  }
                });
            alert_dialog.show();
          }
        });
  }
Beispiel #19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_details);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Get the intent from MainActivity.
    final int id = getIntent().getIntExtra("id", -1);

    final NeighborhoodSQLOpenHelper helper =
        NeighborhoodSQLOpenHelper.getInstance(DetailsActivity.this);

    // Set the activity title based on the name of the item we're viewing.
    if (helper.getLocationNameByID(id) != null) {
      setTitle(helper.getLocationNameByID(id));
    } else {
      setTitle("Details");
    }

    mImage = (ImageView) findViewById(R.id.place_image);
    mAddress = (TextView) findViewById(R.id.address_detailsActivity);
    mType = (TextView) findViewById(R.id.type_detailsActivity);
    mDesc = (TextView) findViewById(R.id.description_textView);
    mRating = (RatingBar) findViewById(R.id.ratingBar);

    String placeAddress = helper.getLocationAddressByID(id);
    String placeDesc = helper.getLocationDescByID(id);
    String placeType = helper.getTypeByID(id);

    mImage.setImageResource(Neighborhood.getDrawableValue(helper.getLocationNameByID(id)));
    mAddress.setText(placeAddress);
    mDesc.setText(placeDesc);
    mType.setText(placeType);
    mRating.setRating(helper.getRatingByID(id)); // Gets the stored rating for the current place.

    // Check if the place is also in the favorites list, and show the proper heart icon in response.
    ImageView fab = (FloatingActionButton) findViewById(R.id.fab);
    if (helper.getFavoritesByID(id) == 1) {
      fab.setImageResource(R.drawable.favorite_full);
    } else {
      fab.setImageResource(R.drawable.favorite_empty);
    }

    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            ImageView faveButton = (ImageView) findViewById(R.id.fab);
            SQLiteDatabase db = helper.getReadableDatabase();

            if (helper.getFavoritesByID(id) == 0) {
              // Change heart icon to be a filled heart and add item to the favorites list.
              faveButton.setImageResource(R.drawable.favorite_full);
              helper.updateFavoriteByID(id, 1);

              Toast.makeText(
                      DetailsActivity.this,
                      helper.getLocationNameByID(id) + " added to favorites",
                      Toast.LENGTH_SHORT)
                  .show();
            } else {
              // Change heart icon to be empty and remove from the favorites list.
              faveButton.setImageResource(R.drawable.favorite_empty);
              helper.updateFavoriteByID(id, 0);

              Toast.makeText(
                      DetailsActivity.this,
                      helper.getLocationNameByID(id) + " removed from favorites",
                      Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });

    // Change the star rating of a database item.
    mRating.setOnRatingBarChangeListener(
        new RatingBar.OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            helper.updateRatingByID(id, rating);
            Toast.makeText(DetailsActivity.this, "Rated " + rating + " stars", Toast.LENGTH_SHORT)
                .show();
          }
        });
  }
  void updateData() {
    TextView txt = (TextView) findViewById(R.id.detailName);
    txt.setText(lastResult.itemName);

    txt = (TextView) findViewById(R.id.detailProductNumber);
    txt.setText(Html.fromHtml("<b>LCBO#</b> " + lastResult.itemNumber));

    txt = (TextView) findViewById(R.id.detailPrice);
    if (lastResult.regularPrice != null
        && !lastResult.price.equalsIgnoreCase(lastResult.regularPrice)) {
      txt.setText(
          Html.fromHtml(
              "<b>" + lastResult.price + "</b> <i>WAS " + lastResult.regularPrice + "</i>"));

    } else {
      txt.setText(Html.fromHtml("<b>" + lastResult.price + "</b>"));
    }

    txt = (TextView) findViewById(R.id.detailVolume);
    txt.setText(lastResult.productSize);

    txt = (TextView) findViewById(R.id.detailRegion);
    String region = "";
    if (null != lastResult.producingRegion
        && !lastResult.producingRegion.equalsIgnoreCase("Region Not Specified"))
      region = lastResult.producingRegion;
    if (null != lastResult.producingCountry) {
      if (region.length() > 0) region += ", ";
      region += lastResult.producingCountry;
      region = region.replace(", Region Not Specified", "");
    }
    if (region.length() != 0) region = "<b>From</b> " + region;
    txt.setText(Html.fromHtml(region));

    txt = (TextView) findViewById(R.id.detailStockType);
    if (lastResult.wineVerietal != null && !lastResult.wineVerietal.isEmpty()) {
      String s = "<b>Varietal</b> is " + lastResult.wineVerietal;
      if (lastResult.stock_type != null && !lastResult.stock_type.equalsIgnoreCase("LCBO"))
        s += " (" + lastResult.stock_type + ")";
      txt.setText(Html.fromHtml(s));
    } else {
      txt.setText(lastResult.stock_type);
      if (lastResult.primary_category != null)
        txt.setText(txt.getText() + " . " + lastResult.primary_category);
      if (lastResult.secondary_category != null)
        txt.setText(txt.getText() + " . " + lastResult.secondary_category);
      if (lastResult.tertiary_category != null)
        txt.setText(txt.getText() + " . " + lastResult.tertiary_category);
    }

    txt = (TextView) findViewById(R.id.detailSweetnessDescriptor);
    if (lastResult.sweetnessDescriptor != null)
      txt.setText(Html.fromHtml("<b>Sweetness</b> is " + lastResult.sweetnessDescriptor));
    else txt.setText("");

    txt = (TextView) findViewById(R.id.detailWineStyle);
    txt.setText("");
    if (null != lastResult.wineStyle) {
      txt.setText(Html.fromHtml("<b>Style</b> is " + Html.fromHtml(lastResult.wineStyle)));
    }

    txt = (TextView) findViewById(R.id.detailServingSuggestion);
    txt.setText("");
    if (null != lastResult.serving_suggestion) {
      txt.setText(Html.fromHtml("<b>Pairing:</b> " + lastResult.serving_suggestion));
    }

    txt = (TextView) findViewById(R.id.detailItemDescription);
    txt.setText("");
    if (null != lastResult.itemDescription) {
      txt.setText(Html.fromHtml(lastResult.itemDescription));
    }

    RatingBar bar = (RatingBar) findViewById(R.id.detailRatingBar);
    if (Utils.getRatingsHashMap(this).containsKey(lastResult.itemNumber)) {
      bar.setRating(Utils.getRatingsHashMap(this).get(lastResult.itemNumber).userRating);
    }
    bar.setOnRatingBarChangeListener(
        new RatingBar.OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar ratingBar, float v, boolean fromUser) {
            if (fromUser) {
              HashMap<String, LCBOEntity> RatingsMap =
                  Utils.getRatingsHashMap(ProductDetailActivity.this);
              if (RatingsMap.containsKey(lastResult.itemNumber)) {
                LCBOEntity Ent = RatingsMap.get(lastResult.itemNumber);
                Ent.userRating = v;
              } else {
                lastResult.userRating = v;
                RatingsMap.put(lastResult.itemNumber, lastResult);
              }
              Utils.writeRatings(ProductDetailActivity.this);
            }
          }
        });
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View view = getActivity().getLayoutInflater().inflate(R.layout.detalle_estacionamiento, null);
    TextView titulo = (TextView) view.findViewById(R.id.nombreEstacionamiento);
    desc = (TextView) view.findViewById(R.id.descripcionEstacionamiento);
    mComentarioView = (EditText) view.findViewById(R.id.comentario);
    horarios = (TableLayout) view.findViewById(R.id.horarios);
    comentarios = (Button) view.findViewById(R.id.comentarios);
    title = getArguments().getString("title");
    if (getArguments().getString("descripcion") != null) {
      descripcion = getArguments().getString("descripcion");
    }

    RatingBar puntaje = (RatingBar) view.findViewById(R.id.ratingBar);
    puntaje.setOnRatingBarChangeListener(
        new RatingBar.OnRatingBarChangeListener() {
          @Override
          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            if (fromUser) {
              checkFacebookSession();
              puntajeActual = rating;
              mComentarioView.setVisibility(View.VISIBLE);
              desc.setVisibility(View.GONE);
              horarios.setVisibility(View.GONE);
              comentarios.setVisibility(View.GONE);
            }
          }
        });
    puntajeActual = getArguments().getDouble("puntaje");
    puntaje.setRating((float) puntajeActual);
    titulo.setText(title);
    desc.setText(descripcion);

    comentarios.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent verComentarios = new Intent(getContext(), VerComentariosActivity.class);
            verComentarios.putExtra(
                VerComentariosActivity.ARG_ID_ESTACIONAMIENTO, getArguments().getString("title"));
            startActivity(verComentarios);
          }
        });

    for (Estacionamiento est : RecorridoHolder.getInstance().getEstacionamientos()) {
      if (est.getNombre().equals(title)) {
        for (Tarifa tarifa : est.getTarifas()) {

          TableRow newRow = new TableRow(getContext());
          TextView vehiculo = new TextView(getContext());
          TextView tarifaHora = new TextView(getContext());
          TextView tarifaDia = new TextView(getContext());

          TableRow.LayoutParams llp =
              new TableRow.LayoutParams(
                  TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
          llp.setMargins(12, 0, 0, 0); // llp.setMargins(left, top, right, bottom);

          vehiculo.setPadding(3, 3, 3, 3);
          vehiculo.setLayoutParams(llp);
          tarifaHora.setPadding(3, 3, 3, 3);
          tarifaHora.setLayoutParams(llp);
          tarifaDia.setPadding(3, 3, 3, 3);
          tarifaDia.setLayoutParams(llp);

          vehiculo.setText(tarifa.getDescripcion());
          tarifaHora.setText("$" + tarifa.getPrecioHora());
          tarifaDia.setText("$" + tarifa.getPrecioDia());

          newRow.addView(vehiculo, 0);
          newRow.addView(tarifaHora, 1);
          newRow.addView(tarifaDia, 2);

          horarios.addView(newRow);
        }
        break;
      }
    }

    builder
        .setView(view)
        // Add action buttons
        .setPositiveButton(
            R.string.accept,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                if (mComentarioView.getVisibility() == View.VISIBLE)
                  EstacionamientosServices.calificar(
                      title,
                      puntajeActual,
                      mComentarioView.getText().toString(),
                      User.getCurrentUser().getName());
              }
            });

    return builder.create();
  }
Beispiel #22
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_pre_snackin);

    EasyTracker.getInstance().setContext(getApplicationContext());

    /* Instantiation of UI widgets */
    snackAgainButton = (TextView) findViewById(R.id.presnack_button_again);
    realSnackInButton = (Button) findViewById(R.id.presnack_button_Snack);
    backButton = (Button) findViewById(R.id.backButton);
    image = (ImageView) findViewById(R.id.presnack_imageview_add);
    ratingBar = (RatingBar) findViewById(R.id.ratingBar);
    commentBox = (EditText) findViewById(R.id.presnack_edittext_comment);
    titleName = (TextView) findViewById(R.id.presnack_textview_tittle);

    sendSnackin = new SendSnackIn();

    session = getSharedPreferences(ConstantValues.USER_DATA, MODE_PRIVATE);

    obtainedCode = getIntent().getStringExtra("BARCODE");
    productId = getIntent().getStringExtra("PRODUCT_ID");
    productName = getIntent().getStringExtra("PRODUCT_NAME");
    productPhoto = getIntent().getStringExtra("PRODUCT_PHOTO");

    titleName.setText(productName);

    ratingBar.setRating(0);
    ratingValue = "0";
    ratingBar.setOnRatingBarChangeListener(
        new OnRatingBarChangeListener() {

          public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            ratingBarValueChanged = true;
            ratingValue = String.valueOf(rating);
          }
        });

    //		loadPhoto = new LoadPhoto();

    //		if(savedInstanceState != null){
    //			boolean imageWasLoaded = savedInstanceState.getBoolean("loadingStatus");
    //			if(imageWasLoaded){
    //				String path = savedInstanceState.getString("ImagePath");
    //				if(!path.isEmpty()){
    //					decodeFile(path, 200, 200);
    //				}
    //			}else{
    //				imageLoader.DisplayImage(ConstantValues.URL+"/ws/productphoto/"+ productId
    // +"/thumbnails/"+productPhoto, image, false);
    //				//loadPhoto.execute();
    //			}
    //		}
    //		else{
    //			imageLoader.DisplayImage(ConstantValues.URL+"/ws/productphoto/"+ productId
    // +"/thumbnails/"+productPhoto, image, false);
    //			//loadPhoto.execute();
    //		}

    userId = session.getString("user_id", "No user");

    /* Instantiation and button event association */
    snackAgainButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Log.d("MAIN", "Click en snackAgainButton");
            Intent intent = new Intent(getApplicationContext(), CaptureActivity.class);
            startActivity(intent);
            finish();
          }
        });

    backButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            finish();
          }
        });

    realSnackInButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            if (ConstantValues.getConnectionStatus(getApplicationContext())) {
              sendSnackin.execute();
              realSnackInButton.setClickable(false);
            } else {
              Toast.makeText(
                      getApplicationContext(),
                      "Looks like you have no connection, please check it and try again",
                      Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Pick image from");
    LayoutInflater inflater = (LayoutInflater) getSystemService(this.LAYOUT_INFLATER_SERVICE);
    View new_layout = inflater.inflate(R.layout.pick_photo, null);
    builder.setView(new_layout);
    final AlertDialog choosePictureDialog = builder.create();

    Button cameraButton = (Button) new_layout.findViewById(R.id.launch_camera_button);
    Button galleryButton = (Button) new_layout.findViewById(R.id.choose_from_gallery_button);

    cameraButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile()));
            startActivityForResult(cameraIntent, CAMERA_RESULT);
            choosePictureDialog.dismiss();
          }
        });

    galleryButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent galleryIntent =
                new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(galleryIntent, GALLERY_RESULT);
            choosePictureDialog.dismiss();
          }
        });

    //		image.setClickable(true);
    //		image.setOnClickListener(new OnClickListener() {
    //
    //			public void onClick(View v) {
    //				choosePictureDialog.show();
    //			}
    //		});

    imageLoader = new ImageLoader(getApplicationContext(), 16);

    if (savedInstanceState != null) {
      String tmp = savedInstanceState.getString("path");
      String[] tmpArray = tmp.split("/");
      if (tmpArray.length != 8) {
        decodeFile(tmp, 100, 100);
      } else {
        finalImagePath =
            ConstantValues.URL + "/ws/productphoto/" + productId + "/thumbnails/" + productPhoto;
        imageLoader.DisplayImage(finalImagePath, image, false, false);
      }
    } else {
      finalImagePath =
          ConstantValues.URL + "/ws/productphoto/" + productId + "/thumbnails/" + productPhoto;
      imageLoader.DisplayImage(finalImagePath, image, false, false);
    }

    imgpath = ConstantValues.URL + "/ws/productphoto/" + productId + "/thumbnails/" + productPhoto;

    developmentSession = getSharedPreferences(ConstantValues.USER_DATA, MODE_PRIVATE);
    id = developmentSession.getString("user_id", "-1");
    realId = Integer.parseInt(id);
  }