Ejemplo n.º 1
0
  @Override
  public void onClick(View v) {

    switch (v.getId()) {
      case R.id.common_title_btn_back:
        {
          comeBackHome();
        }
        break;
      case R.id.common_title_btn_right:
        if (limitbuyAdapter != null) {
          int tag = (Integer) common_title_btn_right.getTag();
          if (1 == tag) {
            limitbuyAdapter.setBigPictureOrLittlePicture(0);
            common_title_btn_right.setBackgroundResource(R.drawable.bg_hot_prom_pager);
            common_title_btn_right.setTag(0);
          } else if (0 == tag) {
            limitbuyAdapter.setBigPictureOrLittlePicture(1);
            common_title_btn_right.setBackgroundResource(R.drawable.bg_topbar_switch_mini_false);
            common_title_btn_right.setTag(1);
          }
        }
        break;
    }
  }
Ejemplo n.º 2
0
 /**
  * 检测按钮是否有在提醒时间内,是则显示为红色
  *
  * @param alert
  * @param btn
  */
 private void checkAlertsButtonByAlert(FDAlert alert, Button btn) {
   int minute = (Integer) btn.getTag();
   if (alert != null) {
     if (alert.isUseDefault()) { // 使用日历的默认提醒时间
       useCalendarDefaultReminder(btn, minute);
     } else {
       if (alert.getOverrides() != null) {
         for (int j = 0; j < alert.getOverrides().size(); j++) {
           Map<String, String> reminder = alert.getOverrides().get(j);
           if (reminder != null) {
             String minuteString = reminder.get(FDAlert.REMINDERS_KEY_MINUTES);
             if (StringUtil.isNoBlank(minuteString)) {
               try {
                 int reminderMinute = Integer.parseInt(minuteString);
                 checkReminderMinute(btn, minute, reminderMinute);
               } catch (NumberFormatException e) {
                 e.printStackTrace();
               }
             }
           }
         }
       }
     }
   } else if (!isEdit) { // 创建事件时,使用日历的默认提醒时间
     useCalendarDefaultReminder(btn, minute);
   }
 }
Ejemplo n.º 3
0
  @Override
  public void onClick(View v) {
    if (v.getId() != R.id.inBag) {
      if (selectDishCount != v) {
        selectOffButton(selectDishCount);
        selectOnButton((Button) v);
      }
    } else {
      BoxAdapter.object
          .get(mViewPager.getCurrentItem())
          .setCountOrder(Integer.valueOf(String.valueOf(selectDishCount.getTag())));
      AppController.getInstance().addInBag(BoxAdapter.object.get(mViewPager.getCurrentItem()));
      mainActivity.updateBagPrice();

      dialogInBag.show(mainActivity.getFragmentManager(), "dialogInBag");
      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    Thread.sleep(1000);
                  } catch (InterruptedException e) {
                    e.printStackTrace();
                  }
                  dialogInBag.dismiss();
                }
              })
          .start();
    }
  }
Ejemplo n.º 4
0
 @Override
 protected void onSaveInstanceState(Bundle state) {
   super.onSaveInstanceState(state);
   state.putDouble(CURRENT_VALUE, currentVal);
   state.putDouble(VALUE, val);
   state.putInt(OPR, opr);
   state.putSerializable(OPERATION, currentOperation);
   state.putString(TEXT, et.getText().toString());
   state.putInt(CLRBUTTON, (Integer) clearButton.getTag());
 }
  /**
   * Verifica se o usuário preenchou corretamento de acordo com o grupo de processos escolhido na
   * tela principal.
   */
  private void checar() {
    int count = 0;
    int total = params.getInt("Total");
    boolean errado = false;
    String tag = "";

    LinearLayout l = (LinearLayout) findViewById(R.id.direita);
    ArrayList<View> listViews = l.getTouchables();
    Button botaoC;
    for (View bt : listViews) {
      botaoC = (Button) bt;
      tag = botaoC.getTag().toString().trim();

      if (botaoC.getText().equals(getResources().getString(R.string.solicitar_mudancas))
          && (params.getString("Tipo").equals("C") || params.getString("Tipo").equals("D"))) {
        count++;
      } else if (tag.equals(params.getString("Tipo"))) {
        count++;
      } else {
        count = 0;
        errado = true;
        corPadrao = botaoC.getBackground();
        botaoC.setTextColor(getResources().getColor(R.color.cor_errado));
      }
    }

    if (errado) {
      Toast.makeText(
              DiagramaParcial.this,
              getResources().getString(R.string.opcoes_erradas),
              Toast.LENGTH_SHORT)
          .show();
      correto = false;
      invalidateOptionsMenu();
      return;
    }

    if (count == total) {
      Toast.makeText(
              DiagramaParcial.this,
              getResources().getString(R.string.opcoes_corretas),
              Toast.LENGTH_SHORT)
          .show();
      correto = true;
      invalidateOptionsMenu();
    } else {
      Toast.makeText(
              DiagramaParcial.this,
              getResources().getString(R.string.opcoes_faltando),
              Toast.LENGTH_SHORT)
          .show();
      correto = false;
      invalidateOptionsMenu();
    }
  }
Ejemplo n.º 6
0
 private void toggle() {
   Resources res = getResources();
   if ((Boolean) eventTwitterBtn.getTag()) {
     eventTwitterBtn.setTag(false);
     eventTwitterBtn.setTextColor(res.getColor(R.color.red));
     eventHashBtn.setTextColor(res.getColor(R.color.gray));
   } else {
     eventTwitterBtn.setTextColor(res.getColor(R.color.gray));
     eventHashBtn.setTextColor(res.getColor(R.color.red));
   }
 }
Ejemplo n.º 7
0
 @Override
 public void onClick(View v) {
   if (this.btn.getText().equals(getResources().getText(R.string.start))) {
     this.btn.setText(getResources().getText(R.string.stop));
     currentEditText = (EditText) btn.getTag();
     receiveNotifications(true);
   } else {
     this.btn.setText(getResources().getText(R.string.start));
     receiveNotifications(false);
   }
 }
 private ServerList.ServerInfo getSelectedServerInfo() {
   Button serverSelectBtn = Button.class.cast(findViewById(R.id.server_select_btn));
   switch ((ServerList.ServerInfo.ServerName) serverSelectBtn.getTag(SELECTED_SERVER_KEY)) {
     case KR:
       return serverList.getKoreaServer();
     case NA:
       return serverList.getNorthAmericaServer();
     case EUW:
       return serverList.getEuropeWestServer();
   }
   return serverList.getKoreaServer();
 }
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

          if (view.getTag() == null) {
            Calendar c = Calendar.getInstance(Locale.getDefault());
            c.set(Calendar.YEAR, year);
            c.set(Calendar.MONTH, monthOfYear);
            c.set(Calendar.DAY_OF_MONTH, dayOfMonth);

            Date date = c.getTime();
            String string = StringUtil.toDateString(date);
            mClickedButton.setText(string);
            mClickedButton.setTag(c);
          }

          view.setTag(null);

          mStartCalender = (Calendar) mBtnStart.getTag();
          mEndCalender = (Calendar) mBtnEnd.getTag();

          filterAbsense(mStartCalender, mEndCalender);
        }
Ejemplo n.º 10
0
 // 获取按钮集合中的选中数组的标签值
 private float getSelecteBtnsTag(List<Button> btns) {
   for (Button btn : btns) {
     if (btn.isSelected()) {
       Object tag = btn.getTag();
       if (tag != null)
         if (tag instanceof Integer) {
           return (Integer) tag;
         } else {
           return (Float) tag;
         }
     }
   }
   return 0;
 }
        @Override
        public void onClick(View v) {
          Button button = (Button) _panelView.findViewById(R.id.button_play_or_pause);
          boolean isPlaying = (Boolean) button.getTag(R.id.tag_play_state);

          Intent intent = new Intent(_context, OverlayMusicPlayerService.class);
          if (isPlaying) {
            intent.setAction(OverlayMusicPlayerService.ACTION_PAUSE);
          } else {
            intent.setAction(OverlayMusicPlayerService.ACTION_PLAY);
          }
          _context.startService(intent);

          startTimeoutTimer();
        }
        @Override
        public void onClick(final View v) {
          mClickedButton = (Button) v;
          Calendar c = (Calendar) mClickedButton.getTag();
          if (c == null) {
            c = Calendar.getInstance(Locale.getDefault());
          }

          final DatePickerDialog dialog =
              new DatePickerDialog(
                  mActivity,
                  mDateListener,
                  c.get(Calendar.YEAR),
                  c.get(Calendar.MONTH),
                  c.get(Calendar.DAY_OF_MONTH));

          dialog.setButton(
              DialogInterface.BUTTON_NEGATIVE,
              mActivity.getString(R.string.attendance_unlimit),
              new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface d, int which) {
                  Button button = (Button) v;
                  button.setTag(null);
                  button.setText(R.string.attendance_unlimit);
                  dialog.getDatePicker().setTag(R.string.attendance_unlimit);

                  if (v == mBtnStart) {
                    mStartCalender = null;
                  } else {
                    mEndCalender = null;
                  }

                  filterAbsense(mStartCalender, mEndCalender);
                }
              });
          dialog.show();
        }
Ejemplo n.º 13
0
  private void paintCounters() {
    // Iterate through the counters
    for (int k = 0; k < layoutPollUserVotes.getChildCount(); ++k) {
      // Get the user response
      View layoutPollUserVote = layoutPollUserVotes.getChildAt(k);
      Button btnViewPollVote = (Button) layoutPollUserVote.findViewById(R.id.btnViewPollVote);
      Proposal proposal = (Proposal) btnViewPollVote.getTag();

      View layoutPollCounter = layoutPollCounters.getChildAt(k);
      Button btnPollCounter = (Button) layoutPollCounter.findViewById(R.id.btnPollCounter);

      // Get the response of ourselves
      Response response = proposal.getContactResponse(imin.getUser().getPublicUserId());

      // Get number of votes
      List<Contact> attendingContacts = proposal.getContacts(Response.RESPONSE_TYPE_ATTENDING);

      // Set the counter text
      int num_attending_contacts = attendingContacts.size();
      String counter = String.valueOf(num_attending_contacts);
      btnPollCounter.setText(counter);

      if (closing) {
        btnPollCounter.setEnabled(false);
        btnPollCounter.setTextColor(getResources().getColor(R.color.black));
      } else {
        if (response != null && response.getResponseType() == Response.RESPONSE_TYPE_ATTENDING) {
          btnPollCounter.setEnabled(true);
          btnPollCounter.setTextColor(getResources().getColor(R.color.white));
        } else {
          btnPollCounter.setEnabled(false);
          btnPollCounter.setTextColor(getResources().getColor(R.color.black));
        }
      }
    }
  }
Ejemplo n.º 14
0
  /** 将提醒事件值设入事件对象的reminders中 */
  private void setAlertsvalueToEventReminder() {
    try {
      JSONObject remindersJson = new JSONObject();

      JSONArray overridesArray = new JSONArray();
      boolean isUseDefault = true;
      for (Button btnAlert : alertsValueButtons) {
        if (btnAlert.isSelected()) {
          isUseDefault = false;
          JSONObject remminderJson = new JSONObject();
          remminderJson.put(FDAlert.REMINDERS_KEY_METHOD, FDAlert.REMINDERS_MOTHOD_POPUP);
          remminderJson.put(FDAlert.REMINDERS_KEY_MINUTES, btnAlert.getTag());
          overridesArray.put(remminderJson);
        }
      }
      remindersJson.put("useDefault", isUseDefault ? "true" : "false");
      if (overridesArray.length() > 0) {
        remindersJson.put("overrides", overridesArray);
      }
      reminders = remindersJson.toString();
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
  public void addTab(Button button, Class<?> clss, Bundle args) {
    String tag = "tag_" + mIndicators.size();
    int id = 0;
    if (button != null) {
      tag = (String) button.getTag();
      id = button.getId();
    }
    IndicatorInfo info = new IndicatorInfo(tag, clss, args, id);
    mIndicators.put(mIndicators.size(), info);

    // After ADT 22 the PagerAdapter has gotten very strict about calling
    // notifyDataSetChanged() before calling getCount(). It evidently keeps
    // track of what it thinks the count should be and if this is not the
    // same as what getCount() returns it throws this exception. So the
    // solution is simply to call notifyDataSetChanged() on the adapter
    // every time the size of the data
    // changes.(http://stackoverflow.com/questions/16756131/fragmentstatepageradapter-stopped-working-after-updating-to-adt-22)
    notifyDataSetChanged();

    if (button != null) {
      button.setTag(tag);
      button.setOnClickListener(this);
    }
  }
Ejemplo n.º 16
0
  private void onEndSelected(int endMode) {
    mRecurring.setEndMode(endMode);
    mRecurring.setEndSetting(0);

    switch (endMode) {
      case Recurring.END_FOREVER:
        animOut(mEndNumEditText, false, false);
        animOut(mEndNumUnitTextView, false, false);
        animOut(mEndDateButton, false, false);
        break;
      case Recurring.END_UNTIL_DATE:
        animOut(mEndNumEditText, false, true);
        animOut(mEndNumUnitTextView, false, true);
        animIn(mEndDateButton, false);
        mRecurring.setEndDate((Long) mEndDateButton.getTag());
        break;
      case Recurring.END_FOR_EVENT:
        animIn(mEndNumEditText, false);
        animIn(mEndNumUnitTextView, false);
        animOut(mEndDateButton, false, true);
        mRecurring.setEventNumber(Integer.parseInt(mEndNumEditText.getText().toString()));
        break;
    }
  }
  @Override
  public void onClick(View v) {
    Button button = (Button) v;
    int i = (int) button.getTag();
    switch (i) {
      case 0:
        new AchievementUnlocked(this)
            .setTitle("Lilac and Gooseberries")
            .setSubtitleColor(0x80ffffff)
            .setSubTitle("Find the sorceress")
            .setBackgroundColor(Color.parseColor("#C2185B"))
            .setTitleColor(0xffffffff)
            .setIcon(getDrawableFromRes(R.drawable.wand))
            .isLarge(false)
            .build()
            .show();
        break;
      case 1:
        new AchievementUnlocked(this)
            .setTitle("Transhumanist")
            .setSubTitle("Augmented")
            .setTypeface(Typeface.createFromAsset(getApplicationContext().getAssets(), "font.TTF"))
            .setIcon(getDrawableFromRes(R.drawable.mario))
            .setBackgroundDrawable(getDrawableFromRes(R.drawable.custom_bg))
            .isLarge(true)
            .build()
            .show();
        break;
      case 2:
        new AchievementUnlocked(this)
            .setTitle("Pacifist")
            .setSubTitle("They don't deserve death")
            .setIcon(getDrawableFromRes(R.drawable.monster))
            .isRounded(false)
            .isLarge(false)
            .alignTop(false)
            .build()
            .show();
        break;
      case 3:
        new AchievementUnlocked(this)
            .setTitle("I bet mine is bigger")
            .setSubTitle("Upgrade your guns")
            .isLarge(true)
            .alignTop(false)
            .setIcon(getDrawableFromRes(R.drawable.mario))
            .build()
            .show();
        break;
      case 4:
        new AchievementUnlocked(this)
            .setTitle("The Illusive Man")
            .setSubTitle("Shepard, Freedom's Progress won't investigate itself.")
            .setSubtitleColor(0x80000000)
            .setIcon(getDrawableFromRes(R.drawable.chat))
            .isRounded(false)
            .setDuration(2500)
            .isLarge(true)
            .build()
            .show();
        break;
      case 5:
        new AchievementUnlocked(this)
            .setTitle("Eliza Cassan posted on your timeline")
            .setSubtitleColor(0xffffffff)
            .setBackgroundColor(Color.parseColor("#3b5998"))
            .setSubTitle("Where can we meet?")
            .setIcon(getDrawableFromRes(R.drawable.fb))
            .setDuration(2500)
            .setTitleColor(0x80ffffff)
            .isLarge(false)
            .build()
            .show();
        break;
      case 6:
        final AchievementUnlocked achievementUnlocked =
            new AchievementUnlocked(this)
                .setTitle("Faridah Malik is calling...")
                .setTitleColor(0xff000000)
                .setSubTitle("Tap to reject")
                .setSubtitleColor(0x80000000)
                .setIcon(getDrawableFromRes(R.drawable.calling))
                .isPersistent(true)
                .build();

        View iconIV = achievementUnlocked.getIconView();
        ObjectAnimator outX = ObjectAnimator.ofFloat(iconIV, "scaleX", 1f, 0.7f);
        ObjectAnimator outY = ObjectAnimator.ofFloat(iconIV, "scaleY", 1f, 0.7f);
        ObjectAnimator inX = ObjectAnimator.ofFloat(iconIV, "scaleX", 0.7f, 1f);
        ObjectAnimator inY = ObjectAnimator.ofFloat(iconIV, "scaleY", 0.7f, 1f);
        final AnimatorSet Outset = new AnimatorSet();
        final AnimatorSet Ani = new AnimatorSet();
        final AnimatorSet Inset = new AnimatorSet();
        outX.setDuration(1000);
        outY.setDuration(1000);
        inX.setDuration(1000);
        inY.setDuration(1000);
        Ani.addListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                Ani.start();
              }
            });
        Outset.playTogether(outX, outY);
        Inset.playTogether(inX, inY);
        (achievementUnlocked.getAchievementView())
            .setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    achievementUnlocked.dismiss();
                  }
                });
        Ani.play(Outset).before(Inset);
        achievementUnlocked.setAchievementListener(
            new AchievementUnlocked.achievementListener() {
              @Override
              public void onAchievementBeingCreated(
                  AchievementUnlocked achievement, boolean created) {}

              @Override
              public void onAchievementExpanding(
                  AchievementUnlocked achievement, boolean expanded) {
                if (expanded) Ani.start();
              }

              @Override
              public void onAchievementShrinking(
                  AchievementUnlocked achievement, boolean shrunken) {
                if (!shrunken) {
                  if (Ani.isRunning()) Ani.cancel();
                }
              }

              @Override
              public void onAchievementBeingDestroyed(
                  AchievementUnlocked achievement, boolean destroyed) {}
            });
        achievementUnlocked.show();
        break;
      case 7:
        new AchievementUnlocked(this)
            .setTitle("Ghosttown")
            .setIconBG(Color.parseColor("#E67E22"))
            .setBackgroundColor(Color.parseColor("#D35400"))
            .setTitleColor(0xffffffff)
            .setSubTitle("Madonna")
            .setSubtitleColor(0x80ffffff)
            .setIcon(getDrawableFromRes(R.drawable.music))
            .setDuration(1500)
            .isLarge(false)
            .build()
            .show();

        break;

      case 8:
        AchievementUnlocked toast =
            new AchievementUnlocked(this)
                .setTitle("Picture was sent")
                .setBackgroundColor(Color.parseColor("#333333"))
                .setTitleColor(0xffffffff)
                .setIcon(getDrawableFromRes(R.drawable.tick))
                .setDuration(1000)
                .alignTop(false)
                .isLarge(false)
                .build();
        toast.show();
        break;

      case 9:
        int bg = 0xffffffff;
        boolean rounded = false;
        if (Build.VERSION.SDK_INT >= 21) {
          rounded = true;
        }

        final AchievementUnlocked toastCool =
            new AchievementUnlocked(this)
                .isRounded(rounded)
                .setBackgroundColor(bg)
                .isPersistent(true)
                .setTitle("Message is about to be sent")
                .setSubTitle("Tap to cancel, or wait 3 sec until it's sent ")
                .setIcon(getDrawableFromRes(R.drawable.delete))
                .isPersistent(true)
                .build();

        final View popUp = toastCool.getAchievementView();

        final View icon = toastCool.getIconView();
        int delta = toastCool.height;
        final ObjectAnimator transout = ObjectAnimator.ofFloat(icon, "translationY", 0, delta);
        final ObjectAnimator transin = ObjectAnimator.ofFloat(icon, "translationY", -delta, 0);
        transin.setDuration(250);
        transout.setDuration(250);
        final ValueAnimator blue = ValueAnimator.ofObject(new ArgbEvaluator(), bg, 0xff2196F3);
        blue.addUpdateListener(
            new ValueAnimator.AnimatorUpdateListener() {

              @Override
              public void onAnimationUpdate(ValueAnimator animator) {
                if (Build.VERSION.SDK_INT >= 21) {
                  popUp.getBackground().setTint((Integer) animator.getAnimatedValue());
                } else {
                  popUp.setBackgroundColor((Integer) animator.getAnimatedValue());
                }
              }
            });

        final ValueAnimator red = ValueAnimator.ofObject(new ArgbEvaluator(), bg, 0xffF44336);
        red.addUpdateListener(
            new ValueAnimator.AnimatorUpdateListener() {

              @Override
              public void onAnimationUpdate(ValueAnimator animator) {
                if (Build.VERSION.SDK_INT >= 21) {
                  popUp.getBackground().setTint((Integer) animator.getAnimatedValue());
                } else {
                  popUp.setBackgroundColor((Integer) animator.getAnimatedValue());
                }
              }
            });
        popUp.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                if (toastCool.expanded && !blue.isRunning()) {
                  toastCool.dismiss();
                  red.start();
                  transout.addListener(
                      new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                          super.onAnimationEnd(animation);
                          if (Build.VERSION.SDK_INT >= 16) {
                            icon.setBackground(getDrawableFromRes(R.drawable.no));
                          } else {
                            icon.setBackgroundDrawable(getDrawableFromRes(R.drawable.no));
                          }
                          transin.start();
                        }
                      });
                  transout.start();
                }
              }
            });

        toastCool.setAchievementListener(
            new AchievementUnlocked.achievementListener() {
              @Override
              public void onAchievementBeingCreated(
                  AchievementUnlocked achievement, boolean created) {}

              @Override
              public void onAchievementExpanding(
                  AchievementUnlocked achievement, boolean expanded) {
                if (expanded)
                  (new android.os.Handler())
                      .postDelayed(
                          new Runnable() {
                            public void run() {
                              if (toastCool.expanded && !red.isRunning()) {
                                popUp.setOnClickListener(null);
                                toastCool.dismiss();
                                blue.start();

                                transout.addListener(
                                    new AnimatorListenerAdapter() {
                                      @Override
                                      public void onAnimationEnd(Animator animation) {
                                        super.onAnimationEnd(animation);
                                        if (Build.VERSION.SDK_INT >= 16) {
                                          icon.setBackground(getDrawableFromRes(R.drawable.send));
                                        } else {
                                          icon.setBackgroundDrawable(
                                              getDrawableFromRes(R.drawable.send));
                                        }

                                        transin.start();
                                      }
                                    });
                                transout.start();
                              }
                            }
                          },
                          3000);
              }

              @Override
              public void onAchievementShrinking(
                  AchievementUnlocked achievement, boolean shrunken) {
                achievement.getTitleTextView().setVisibility(View.INVISIBLE);

                achievement.getSubtitleTextView().setVisibility(View.INVISIBLE);
              }

              @Override
              public void onAchievementBeingDestroyed(
                  AchievementUnlocked achievement, boolean destroyed) {}
            });

        toastCool.show();

        break;

      case 10:
        AchievementUnlocked gpg =
            new AchievementUnlocked(this)
                .setTitle("Welcome")
                .setTitleColor(0x70444444)
                .setSubTitle("Jane Valderamma")
                .setSubtitleColor(0xff444444)
                .setIcon(getDrawableFromRes(R.drawable.gpg))
                .setDuration(1500)
                .isLarge(false)
                .build();
        final View iconView = gpg.getIconView();
        final Drawable iconViewDefaultBackground = gpg.getIconView().getBackground();
        final ObjectAnimator out = ObjectAnimator.ofFloat(iconView, "alpha", 1f, 0f);
        final ObjectAnimator in = ObjectAnimator.ofFloat(iconView, "alpha", 0f, 1f);

        gpg.setAchievementListener(
            new AchievementUnlocked.achievementListener() {
              @Override
              public void onAchievementBeingCreated(
                  AchievementUnlocked achievement, boolean created) {}

              @Override
              public void onAchievementExpanding(
                  AchievementUnlocked achievement, boolean expanded) {
                if (expanded) {

                  out.addListener(
                      new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                          super.onAnimationEnd(animation);
                          if (Build.VERSION.SDK_INT >= 16) {
                            iconView.setBackground(getDrawableFromRes(R.drawable.jane));
                          } else {
                            iconView.setBackgroundDrawable(getDrawableFromRes(R.drawable.jane));
                          }
                          in.start();
                        }
                      });
                  out.start();
                }
              }

              @Override
              public void onAchievementShrinking(
                  AchievementUnlocked achievement, boolean shrunken) {

                if (!shrunken) {

                  out.addListener(
                      new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                          super.onAnimationEnd(animation);
                          if (Build.VERSION.SDK_INT >= 16) {
                            iconView.setBackground(iconViewDefaultBackground);
                          } else iconView.setBackgroundDrawable(iconViewDefaultBackground);

                          in.start();
                        }
                      });
                  out.start();
                }
              }

              @Override
              public void onAchievementBeingDestroyed(
                  AchievementUnlocked achievement, boolean destroyed) {}
            });
        gpg.show();

        break;
    }
  }
Ejemplo n.º 18
0
 @Override
 public void onClick(View v) {
   et.setTextSize(TypedValue.COMPLEX_UNIT_SP, 100);
   switch (v.getId()) {
     case R.id.oneButton:
       {
         updateText("1");
         break;
       }
     case R.id.twoButton:
       {
         updateText("2");
         break;
       }
     case R.id.threeButton:
       {
         updateText("3");
         break;
       }
     case R.id.fourButton:
       {
         updateText("4");
         break;
       }
     case R.id.fiveButton:
       {
         updateText("5");
         break;
       }
     case R.id.sixButton:
       {
         updateText("6");
         break;
       }
     case R.id.sevenButton:
       {
         updateText("7");
         break;
       }
     case R.id.eightButton:
       {
         updateText("8");
         break;
       }
     case R.id.nineButton:
       {
         updateText("9");
         break;
       }
     case R.id.zeroButton:
       {
         updateText("0");
         break;
       }
     case R.id.commaButton:
       {
         if (opr > 0) {
           et.setText("0.");
         } else {
           if (!(et.getText() + "").contains(".")) {
             et.append(".");
           }
         }
         opr = 0;
         break;
       }
     case R.id.mulButton:
       {
         perform();
         currentOperation = operations.MUL;
         break;
       }
     case R.id.divButton:
       {
         perform();
         currentOperation = operations.DIV;
         break;
       }
     case R.id.plusButton:
       {
         perform();
         currentOperation = operations.ADD;
         break;
       }
     case R.id.minusButton:
       {
         perform();
         currentOperation = operations.SUBTR;
         break;
       }
     case R.id.equalButton:
       {
         opr = 2;
         perform();
         currentOperation = operations.EQ;
         opr = 2;
         break;
       }
     case R.id.signButton:
       {
         currentVal = -Double.parseDouble(et.getText().toString());
         et.setText(fmt(currentVal));
         break;
       }
     case R.id.sqrtButton:
       {
         currentVal = Math.sqrt(Double.parseDouble(et.getText() + ""));
         et.setText(fmt(currentVal));
         opr = 2;
         break;
       }
     case R.id.clearButton:
       {
         Init((Integer) clearButton.getTag() == 1);
         break;
       }
     case R.id.backButton:
       {
         String tempS = et.getText().subSequence(0, et.getText().length() - 1) + "";
         if (tempS.contains("fin") || tempS.contains("N") || tempS.contains("E")) {
           break;
         }
         currentVal = !tempS.equals("") ? Double.valueOf(tempS) : 0;
         et.setText(String.valueOf(fmt(currentVal)));
         break;
       }
   }
 }
Ejemplo n.º 19
0
    @Override
    public boolean onTouch(View v, MotionEvent event) {
      Button pushedButton = (Button) v;
      switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
          pushedButton.setBackground(
              ContextCompat.getDrawable(
                  getApplicationContext(), R.drawable.recordar_btn_highlighted));
          return true;
        case MotionEvent.ACTION_UP:
          pushedButton.setBackground(
              ContextCompat.getDrawable(getApplicationContext(), R.drawable.recordar_btn_normal));

          int comp1 = (int) pushedButton.getTag();
          int comp2 = order[counterOrder];

          if (comp1 == comp2) {
            if (counterOrder < dificultad - 1) {
              counterOrder++;
            } else {
              AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
              alertDialog.setTitle(R.string.ordenar_finTitulo);
              alertDialog.setMessage(getString(R.string.recordar_mensajeFin) + points.toString());
              alertDialog.setButton(
                  AlertDialog.BUTTON_NEUTRAL,
                  getResources().getString(R.string.ordenar_ok_button),
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                      closeActivity(true);
                    }
                  });
              alertDialog.show();
            }

          } else {
            if (points > 75) {
              points -= 75;
              tVPunctuacion.setText(
                  getApplicationContext().getString(R.string.ordenar_Puntos) + points.toString());
              AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
              alertDialog.setTitle(R.string.recordar_reiniciar_titulo);
              alertDialog.setMessage(getString(R.string.recordar_reiniciar));
              alertDialog.setButton(
                  AlertDialog.BUTTON_NEUTRAL,
                  getResources().getString(R.string.ordenar_ok_button),
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                      restartRepetition();
                    }
                  });
              alertDialog.show();
            } else {
              AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
              alertDialog.setTitle(R.string.ordenar_finTitulo);
              alertDialog.setMessage(getString(R.string.ordenar_finPerdidoMensaje));
              alertDialog.setButton(
                  AlertDialog.BUTTON_NEUTRAL,
                  getResources().getString(R.string.ordenar_ok_button),
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                      closeActivity(false);
                    }
                  });
              alertDialog.show();
            }
          }
          return true;
      }
      return false;
    }
  public void onClick(View v) {

    // Check if the answer is correct or not
    if (Integer.parseInt(v.getTag().toString()) == 1) {

      /*Toast.makeText(getBaseContext(),
      String.valueOf("Correct !"),
       Toast.LENGTH_SHORT).show(); */
      Button btn = (Button) v; // cast the view to a button
      btn.setClickable(false);
      btn.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.correct, 0);

      CorrectAnswerListCounter--;

      if (CorrectAnswerListCounter < 1) {

        BtnContinue.setVisibility(View.VISIBLE);
        if (CorrectAnswerReasonInHTML != null && CorrectAnswerReasonInHTML.length() > 0) {
          BtnReason.setVisibility(View.VISIBLE);
        }
        // disable all the buttons
        for (int i = 0; i < ButtonArray.size(); i++) {

          Button btn_all = ButtonArray.get(i);
          btn_all.setEnabled(false);
        }
        cache.setYourCorrectAnswerResult(1); // Add one to result
        // Sound for right Answer
        OtherPreferences sharedPrefs = new OtherPreferences(this.getBaseContext());

        if (sharedPrefs.getPreference("sound").equalsIgnoreCase("on")) {
          LocalCache cache = ((LocalCache) getApplicationContext());
          cache.PlaySound(this, R.raw.clapping);
        }
      } else {
        Toast.makeText(
                getBaseContext(),
                String.valueOf("Select " + CorrectAnswerListCounter.toString() + " more"),
                Toast.LENGTH_SHORT)
            .show();
      }

    } else if (Integer.parseInt(v.getTag().toString()) == 0) {

      /*Toast.makeText(getBaseContext(),
      String.valueOf("Wrong !"),
       Toast.LENGTH_SHORT).show(); */

      for (int i = 0; i < ButtonArray.size(); i++) {

        Button btn = ButtonArray.get(i);
        Object tag = btn.getTag();
        if (Integer.parseInt(tag.toString()) == 1) {
          String LastText =
              CorrectAnswerInHTMLList.get(CorrectAnswerInHTMLListCounter - 1).toString();
          CorrectAnswerInHTMLListCounter--;
          // String LastText = CorrectAnswerInHTML;  //+ " " + "&#10003";
          btn.setText(Html.fromHtml(LastText));
          btn.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.correct, 0);
          btn.setEnabled(false);
        } else {
          btn.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.wrong, 0);
          btn.setEnabled(false);
        }
      }

      BtnContinue.setVisibility(View.VISIBLE);
      if (CorrectAnswerReasonInHTML != null && CorrectAnswerReasonInHTML.length() > 0) {
        BtnReason.setVisibility(View.VISIBLE);
      }
      // Buzz for Wrong Answer
      OtherPreferences sharedPrefs = new OtherPreferences(this.getBaseContext());

      if (sharedPrefs.getPreference("sound").equalsIgnoreCase("on")) {
        LocalCache cache = ((LocalCache) getApplicationContext());
        cache.PlaySound(this, R.raw.cough);
      }

    } else if (Integer.parseInt(v.getTag().toString()) == 3) {
      showDialog(1);
    } else {
      NextQuestion();
    }
  }