public HierarchyElementView(Context context, HierarchyElement it) {
    super(context);

    setColor(it.getColor());

    mIcon = new ImageView(context);
    mIcon.setImageDrawable(it.getIcon());
    mIcon.setId(1);
    mIcon.setPadding(0, 15, 5, 0);
    addView(
        mIcon,
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    mPrimaryTextView = new TextView(context);
    mPrimaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Large);
    mPrimaryTextView.setText(it.getPrimaryText());
    mPrimaryTextView.setPadding(0, 7, 0, 0);
    mPrimaryTextView.setId(2);
    LayoutParams l =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    l.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mPrimaryTextView, l);

    mSecondaryTextView = new TextView(context);
    mSecondaryTextView.setText(it.getSecondaryText());
    mSecondaryTextView.setPadding(0, 0, 0, 7);
    mSecondaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Small);
    LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.BELOW, mPrimaryTextView.getId());
    lp.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mSecondaryTextView, lp);
  }
        @Override
        public boolean onLongClick(View v) {

          int nBtnID = v.getId();
          // If the mode is not changed, open the setting view. If the mode is same, close the
          // setting view.
          if (nBtnID == mPenBtn.getId()) {
            mSCanvas.setSettingViewSizeOption(
                SCanvasConstants.SCANVAS_SETTINGVIEW_PEN,
                SCanvasConstants.SCANVAS_SETTINGVIEW_SIZE_MINI);
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_PEN) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_PEN);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_PEN);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_PEN, true);
              updateModeState();
            }
            return true;
          } else if (nBtnID == mEraserBtn.getId()) {
            mSCanvas.setSettingViewSizeOption(
                SCanvasConstants.SCANVAS_SETTINGVIEW_ERASER,
                SCanvasConstants.SCANVAS_SETTINGVIEW_SIZE_MINI);
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_ERASER) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_ERASER);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_ERASER);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_ERASER, true);
              updateModeState();
            }
            return true;
          } else if (nBtnID == mTextBtn.getId()) {
            mSCanvas.setSettingViewSizeOption(
                SCanvasConstants.SCANVAS_SETTINGVIEW_TEXT,
                SCanvasConstants.SCANVAS_SETTINGVIEW_SIZE_MINI);
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_TEXT) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_TEXT);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_TEXT);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_TEXT, true);
              updateModeState();
              Toast.makeText(mContext, "Tap Canvas to insert Text", Toast.LENGTH_SHORT).show();
            }
            return true;
          } else if (nBtnID == mFillingBtn.getId()) {
            mSCanvas.setSettingViewSizeOption(
                SCanvasConstants.SCANVAS_SETTINGVIEW_FILLING,
                SCanvasConstants.SCANVAS_SETTINGVIEW_SIZE_MINI);
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_FILLING) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_FILLING);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_FILLING);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_FILLING, true);
              updateModeState();
              Toast.makeText(mContext, "Tap Canvas to fill color", Toast.LENGTH_SHORT).show();
            }
            return true;
          }

          return false;
        }
  @Before
  public void setUp() throws Exception {
    Activity context = Robolectric.buildActivity(Activity.class).create().get();
    relativeLayout = new RelativeLayout(context);
    relativeLayout.setId((int) Utils.generateUniqueId());
    viewGroup = new LinearLayout(context);

    BaseForwardingNativeAd baseForwardingNativeAd = new BaseForwardingNativeAd() {};
    baseForwardingNativeAd.setTitle("test title");
    baseForwardingNativeAd.setText("test text");
    baseForwardingNativeAd.setCallToAction("test call to action");
    baseForwardingNativeAd.setClickDestinationUrl("destinationUrl");

    nativeResponse =
        new NativeResponse(
            context,
            "impressionTrackerUrl",
            "clickTrackerUrl",
            "test ID",
            baseForwardingNativeAd,
            mock(MoPubNative.MoPubNativeListener.class));

    titleView = new TextView(context);
    titleView.setId((int) Utils.generateUniqueId());
    textView = new TextView(context);
    textView.setId((int) Utils.generateUniqueId());
    callToActionView = new Button(context);
    callToActionView.setId((int) Utils.generateUniqueId());
    mainImageView = new ImageView(context);
    mainImageView.setId((int) Utils.generateUniqueId());
    iconImageView = new ImageView(context);
    iconImageView.setId((int) Utils.generateUniqueId());
    badView = new ImageView(context);
    badView.setId((int) Utils.generateUniqueId());

    relativeLayout.addView(titleView);
    relativeLayout.addView(textView);
    relativeLayout.addView(callToActionView);
    relativeLayout.addView(mainImageView);
    relativeLayout.addView(iconImageView);
    relativeLayout.addView(badView);

    viewBinder =
        new ViewBinder.Builder(relativeLayout.getId())
            .titleId(titleView.getId())
            .textId(textView.getId())
            .callToActionId(callToActionView.getId())
            .mainImageId(mainImageView.getId())
            .iconImageId(iconImageView.getId())
            .build();

    subject = new MoPubNativeAdRenderer(viewBinder);
  }
 public boolean onTouch(View v, MotionEvent event) {
   if (event.getAction() == MotionEvent.ACTION_DOWN) {
     if (v.getId() == _imgSourceLang.getId()) {
       ShowFlags(RESULT_FLAG_SOURCE);
     } else if (v.getId() == _imgDestLang.getId()) {
       ShowFlags(RESULT_FLAG_DEST);
     } else if (v.getId() == _imgAccept.getId()) Accept();
     else if (v.getId() == _txtEmail.getId()) ShowContactsList(true);
     else if (v.getId() == _txtSms.getId()) ShowContactsList(false);
   }
   return true;
 }
  public void setProgressViewHidden(boolean hidden) {
    RelativeLayout.LayoutParams layoutParams =
        new RelativeLayout.LayoutParams(mTextView.getLayoutParams());
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    layoutParams.addRule(
        RelativeLayout.LEFT_OF, hidden ? mLearningStatisticImageView.getId() : mImageView.getId());
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.leftMargin = (int) (10 * mScale);
    layoutParams.rightMargin = (int) (20 * mScale);
    layoutParams.bottomMargin = (int) (20 * mScale);
    layoutParams.topMargin = (int) (20 * mScale);
    mWrapper.setLayoutParams(layoutParams);

    mProgressBar.setVisibility(hidden ? View.GONE : View.VISIBLE);
  }
 @Override
 public void onClick(View v) {
   int nBtnID = v.getId();
   // If the mode is not changed, open the setting view. If the mode is same, close the
   // setting view.
   if (nBtnID == mPenBtn.getId()) {
     mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_ERASER);
     mSCanvas.setSettingViewStrokeInfo(mStrokeInfoScratch);
     updateModeState();
   } else if (nBtnID == mEraserBtn.getId()) {
     mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_PEN);
     mSCanvas.setSettingViewStrokeInfo(mStrokeInfoEraser);
     updateModeState();
   }
 }
 @Override
 public void onClick(View v) {
   if ((v.getId() == editProfileImageText.getId()) || (v.getId() == profileImage.getId())) {
     popupMenu = new PopupMenu(getActivity(), v);
     popupMenu
         .getMenuInflater()
         .inflate(R.menu.edit_profile_edit_picture_dropdown, popupMenu.getMenu());
     popupMenu.setOnMenuItemClickListener(
         new OnMenuItemClickListener() {
           @Override
           public boolean onMenuItemClick(MenuItem item) {
             if (item.getTitle().toString().equalsIgnoreCase("From Camera")) {
               /* TODO */
             } else if (item.getTitle().toString().equalsIgnoreCase("From Gallery")) {
               /* TODO */
             }
             popupMenu.dismiss();
             return true;
           }
         });
     popupMenu.show();
   } else if (v.getId() == submitButton.getId()) {
     if (IsValid()) {
       PostToServer();
     }
   }
 }
 @Override
 protected void onPostExecute(Bitmap result) {
   imageView.setImageBitmap(result);
   Log.w("qd", "Set IMG to ImageView in main layout OK, ViewID=" + imageView.getId());
   // show status
   Show_Load_IMG_Status(load_from_cache);
 }
  /**
   * ****************************************************************************************************************************************
   * Populate List
   *
   * <p>Populates the individual species the user clicked on
   * *****************************************************************************************************************************************
   *
   * @param mView The view the user clicked
   * @param mImage The image the user clicked
   *     ****************************************************************************************************************************************
   */
  private void populateList(View mView, ImageView mImage) {

    // Next 5 lines give a short fade-in animation for the single photo
    Welcome welcome = Welcome.getInstance();
    int mShortAnimationDuration = getResources().getInteger(android.R.integer.config_longAnimTime);
    mShortAnimationDuration *= 2;
    welcome.fadeIn(mView, mShortAnimationDuration);
    mView.findViewById(R.id.single_photo).setVisibility(View.VISIBLE);

    ImageView singleImage = (ImageView) mView.findViewById(R.id.single_img);
    Picasso.with(getActivity()).load(photosList.get(mImage.getId())).into(singleImage);

    /** ********************************** 1.) Species Name ********************************** */
    TextView text = (TextView) mView.findViewById(R.id.species_name);
    Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Walkway_Bold.ttf");
    String jsonText = (jsonArray.get(mImage.getId()).getName());
    // text.setText(Html.fromHtml(singleText));
    text.setText(jsonText);
    text.setTypeface(font);
    /** ********************************** 2.) Scientific Name ********************************** */
    text = (TextView) mView.findViewById(R.id.scientific);
    jsonText = ("Scientific Name: " + jsonArray.get(mImage.getId()).getScientificName());
    text.setText(jsonText);
    /** ********************************** 3.) Common Name ********************************** */
    text = (TextView) mView.findViewById(R.id.common);
    jsonText = ("Common Name: " + jsonArray.get(mImage.getId()).getCommonName());
    text.setText(jsonText);
    /**
     * ********************************** 4.) Individual Limits **********************************
     */
    text = (TextView) mView.findViewById(R.id.individual);
    jsonText = ("Individual Limit: \n" + jsonArray.get(mImage.getId()).getIndividualLimit());
    text.setText(jsonText);
    /**
     * ********************************** 5.) Aggregate Limits **********************************
     */
    text = (TextView) mView.findViewById(R.id.aggregate);
    jsonText = ("Aggregate Limit: \n" + jsonArray.get(mImage.getId()).getAggregateLimit());
    text.setText(jsonText);
    /** ********************************** 6.) Minimum ********************************** */
    text = (TextView) mView.findViewById(R.id.minimum);
    jsonText = ("Size Limits: \n" + jsonArray.get(mImage.getId()).getSizeLimit());
    text.setText(jsonText);
    /** ********************************** 7.) Season ********************************** */
    text = (TextView) mView.findViewById(R.id.season);
    jsonText = ("Season: \n" + jsonArray.get(mImage.getId()).getSeason());
    text.setText(jsonText);
    /** ********************************** 8.) Records ********************************** */
    text = (TextView) mView.findViewById(R.id.record);
    jsonText = ("Records: \n" + jsonArray.get(mImage.getId()).getRecords());
    text.setText(jsonText);
  }
  public void renderAdView_withFailedViewBinder_shouldReturnEmptyViews() {
    viewBinder =
        new ViewBinder.Builder(relativeLayout.getId())
            .titleId(titleView.getId())
            .textId(badView.getId())
            .callToActionId(callToActionView.getId())
            .mainImageId(mainImageView.getId())
            .iconImageId(iconImageView.getId())
            .build();

    subject = new MoPubNativeAdRenderer(viewBinder);
    subject.renderAdView(relativeLayout, nativeResponse);

    assertThat(((TextView) relativeLayout.findViewById(titleView.getId())).getText()).isEqualTo("");
    assertThat(((TextView) relativeLayout.findViewById(textView.getId())).getText()).isEqualTo("");
    assertThat(((TextView) relativeLayout.findViewById(callToActionView.getId())).getText())
        .isEqualTo("");
  }
 public void onClick(View v) {
   // TODO Auto-generated method stub
   ImageView image = (ImageView) v;
   switch (image.getId()) {
     case R.id.imageview10:
       Intent intent1 = new Intent(Goods_Rank_Show.this, GoodsIntroduce.class);
       intent1.putExtra("index", goodsid[t + 0]);
       startActivity(intent1);
       break;
     case R.id.imageview11:
       Intent intent2 = new Intent(Goods_Rank_Show.this, GoodsIntroduce.class);
       intent2.putExtra("index", goodsid[t + 1]);
       startActivity(intent2);
       break;
     case R.id.imageview12:
       Intent intent3 = new Intent(Goods_Rank_Show.this, GoodsIntroduce.class);
       intent3.putExtra("index", goodsid[t + 2]);
       startActivity(intent3);
       break;
     case R.id.imageview13:
       Intent intent4 = new Intent(Goods_Rank_Show.this, GoodsIntroduce.class);
       intent4.putExtra("index", goodsid[t + 3]);
       startActivity(intent4);
       break;
     case R.id.imageview14:
       Intent intent5 = new Intent(Goods_Rank_Show.this, GoodsIntroduce.class);
       intent5.putExtra("index", goodsid[t + 4]);
       startActivity(intent5);
       break;
     case R.id.imageview15:
       Intent intent6 = new Intent(Goods_Rank_Show.this, GoodsIntroduce.class);
       intent6.putExtra("index", goodsid[t + 5]);
       startActivity(intent6);
       break;
     case R.id.imageview16:
       Intent intent7 = new Intent(Goods_Rank_Show.this, GoodsIntroduce.class);
       intent7.putExtra("index", goodsid[t + 6]);
       startActivity(intent7);
       break;
     case R.id.imageview17:
       Intent intent8 = new Intent(Goods_Rank_Show.this, GoodsIntroduce.class);
       intent8.putExtra("index", goodsid[t + 7]);
       startActivity(intent8);
       break;
     case R.id.imageview18:
       Intent intent9 = new Intent(Goods_Rank_Show.this, GoodsIntroduce.class);
       intent9.putExtra("index", goodsid[t + 8]);
       startActivity(intent9);
       break;
     default:
       break;
   }
 }
Exemple #12
0
  @OnClick({R.id.gu, R.id.tyo, R.id.pa})
  public void janken(ImageView hand) {
    int myHand = 0;
    int tekiHand = 0;
    int syouhai = 0;

    // 自分の出した手はなんですか
    switch (hand.getId()) {
      case R.id.gu:
        Toast.makeText(this, "あなたはぐぅを出した", Toast.LENGTH_SHORT).show();
        myHand = 0;
        break;

      case R.id.tyo:
        Toast.makeText(this, "あなたはちょきを出した", Toast.LENGTH_SHORT).show();
        myHand = 1;
        break;

      case R.id.pa:
        Toast.makeText(this, "あなたはぱぁを出した", Toast.LENGTH_SHORT).show();
        myHand = 2;
        break;
    }

    // 相手の出した手はなんですか
    Random random = new Random();
    tekiHand = random.nextInt(3);
    switch (tekiHand) {
      case 0:
        teki.setImageResource(R.drawable.gu);
        break;
      case 1:
        teki.setImageResource(R.drawable.tyo);
        break;
      case 2:
        teki.setImageResource(R.drawable.pa);
        break;
    }

    // 勝敗はどうなってるんですか
    syouhai = ((myHand - tekiHand) + 3) % 3;
    switch (syouhai) {
      case 0:
        text.setText("あいこ");
        break;
      case 1:
        text.setText("まけた");
        break;
      case 2:
        text.setText("かった");
        break;
    }
  }
Exemple #13
0
 public void setReflect(ImageView imageView) {
   switch (imageView.getId()) {
     case R.id.mygame1_logo:
       break;
     case R.id.mygame2_logo:
       break;
     case R.id.mygame3_logo:
       break;
     case R.id.mygame4_logo:
       break;
     default:
       break;
   }
 }
        @Override
        public void onClick(View v) {

          int nBtnID = v.getId();
          // If the mode is not changed, open the setting view. If the mode is same, close the
          // setting view.
          if (nBtnID == mPenBtn.getId()) {
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_PEN) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_PEN);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_PEN);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_PEN, false);
              updateModeState();
            }
          } else if (nBtnID == mEraserBtn.getId()) {
            if (mSCanvas.getCanvasMode() == SCanvasConstants.SCANVAS_MODE_INPUT_ERASER) {
              mSCanvas.toggleShowSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_ERASER);
            } else {
              mSCanvas.setCanvasMode(SCanvasConstants.SCANVAS_MODE_INPUT_ERASER);
              mSCanvas.showSettingView(SCanvasConstants.SCANVAS_SETTINGVIEW_ERASER, false);
              updateModeState();
            }
          }
        }
Exemple #15
0
  private RelativeLayout initializeContentView(final Resources resources) {
    RelativeLayout contentView = new RelativeLayout(this.activity);
    contentView.setLayoutParams(
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));

    // set padding
    int padding = this.style.paddingInPixels;

    // if a padding dimension has been set, this will overwrite any padding
    // in pixels
    if (this.style.paddingDimensionResId > 0) {
      padding = resources.getDimensionPixelSize(this.style.paddingDimensionResId);
    }
    contentView.setPadding(padding, padding, padding, padding);

    // only setup image if one is requested
    ImageView image = null;
    if ((null != this.style.imageDrawable) || (0 != this.style.imageResId)) {
      image = initializeImageView();
      contentView.addView(image, image.getLayoutParams());
    }

    TextView text = initializeTextView(resources);

    RelativeLayout.LayoutParams textParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    if (null != image) {
      textParams.addRule(RelativeLayout.RIGHT_OF, image.getId());
    }

    if ((this.style.gravity & Gravity.CENTER) != 0) {
      textParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    } else if ((this.style.gravity & Gravity.CENTER_VERTICAL) != 0) {
      textParams.addRule(RelativeLayout.CENTER_VERTICAL);
    } else if ((this.style.gravity & Gravity.CENTER_HORIZONTAL) != 0) {
      textParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    }
    // 显示内容过长则居左显示
    if (text.length() > 20) {
      text.setGravity(Gravity.LEFT);
    }

    contentView.addView(text, textParams);
    return contentView;
  }
        @Override
        public boolean onTouch(View v, MotionEvent event) {

          switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
              {
                ImageView view = (ImageView) v.findViewById(R.id.image);
                // overlay is black with transparency of 0x77 (119)
                view.getDrawable().setColorFilter(0x99000000, PorterDuff.Mode.SRC_ATOP);
                Log.d("check", " " + view.getId());
                view.invalidate();
                TextView text = (TextView) v.findViewById(R.id.text);
                text.setBackgroundColor(Color.LTGRAY);
                text.invalidate();
                break;
              }
            case MotionEvent.ACTION_UP:
              {
                ImageView view = (ImageView) v.findViewById(R.id.image);
                // clear the overlay
                view.getDrawable().clearColorFilter();
                view.invalidate();
                TextView text = (TextView) v.findViewById(R.id.text);
                text.setBackgroundColor(Color.TRANSPARENT);
                text.invalidate();

                v.performClick();
                break;
              }
            case MotionEvent.ACTION_CANCEL:
              {
                ImageView view = (ImageView) v.findViewById(R.id.image);
                // clear the overlay
                view.getDrawable().clearColorFilter();
                view.invalidate();
                TextView text = (TextView) v.findViewById(R.id.text);
                text.setBackgroundColor(Color.TRANSPARENT);
                text.invalidate();
                break;
              }
          }
          return true;
        }
 /**
  * This adds a divider at the bottom of this layout. Used to separate fields in lists.
  * 
  * @param v
  */
 public void addDivider(ImageView v) {
     RelativeLayout.LayoutParams dividerParams =
         new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
     if (mImageView != null) {
         dividerParams.addRule(RelativeLayout.BELOW, mImageView.getId());
     } else if (mMissingImage != null) {
         dividerParams.addRule(RelativeLayout.BELOW, mMissingImage.getId());
     } else if (mVideoButton != null) {
         dividerParams.addRule(RelativeLayout.BELOW, mVideoButton.getId());
     } else if (mAudioButton != null) {
         dividerParams.addRule(RelativeLayout.BELOW, mAudioButton.getId());
     } else if (mView_Text != null) {
         // No picture
         dividerParams.addRule(RelativeLayout.BELOW, mView_Text.getId());
     } else {
         Log.e(t, "Tried to add divider to uninitialized ATVWidget");
         return;
     }
     addView(v, dividerParams);
 }
  @Override
  public void onClick(View v) {

    int id = v.getId();

    if (id == mBackLayout.getId() || id == mTitleTextView.getId()) {

      mMediaPlayerController.onBackPress(MediaPlayMode.PLAYMODE_WINDOW);

    } else if (id == mPlaybackImageView.getId()) {

      if (mMediaPlayerController.isPlaying()) {
        mMediaPlayerController.pause();
        show(0);
      } else if (!mMediaPlayerController.isPlaying()) {
        mMediaPlayerController.start();
        show();
      }
    }
  }
 /**
  * Used to set the play and draw buttons to enable or disabled Also if it is the player's turn
  * then set the cards to be greyed out if they are not playable. if it is not the player's turn
  * then do not grey out any cards
  *
  * @param isEnabled
  */
 private void setButtonsEnabled(boolean isEnabled) {
   play.setEnabled(isEnabled);
   bet.setEnabled(isEnabled);
   goAlone.setEnabled(isEnabled);
   if (isEnabled && currentState == MSG_PLAY_CARD) {
     // it is your turn grey out cards
     for (Card c : cardHand) {
       boolean isPlayable = gameRules.checkCard(c, trumpSuit, cardLead, cardHand);
       playerContext.setCardPlayable(
           c.getIdNum(),
           isPlayable || currentState == PICK_IT_UP || currentState == PLAY_LEAD_CARD);
     }
   } else {
     // it is not your turn make cards normal
     if (playerHandLayout != null) {
       for (int i = 0; i < playerHandLayout.getChildCount(); i++) {
         ImageView v = (ImageView) playerHandLayout.getChildAt(i);
         playerContext.setCardPlayable(v.getId(), true);
       }
     }
   }
 }
  private void initOtherViews() {
    RelativeLayout.LayoutParams captureButtonParams =
        new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
    captureButtonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    captureButtonParams.topMargin = screenHeight / 30;
    captureButton.setLayoutParams(captureButtonParams);
    captureText.setLayoutParams(captureButtonParams);
    captureText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 40);

    RelativeLayout.LayoutParams nameEditParams =
        new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
    nameEditParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    nameEditParams.addRule(RelativeLayout.BELOW, captureButton.getId());
    nameEditParams.topMargin = screenHeight / 30;
    nameEdit.setLayoutParams(nameEditParams);
    nameEdit.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 42);
    nameEdit.setTextColor(Color.BLACK);

    RelativeLayout.LayoutParams saveButtonParams =
        new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
    saveButtonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    saveButtonParams.addRule(RelativeLayout.BELOW, nameEdit.getId());
    saveButtonParams.topMargin = screenHeight / 30;
    saveButton.setLayoutParams(saveButtonParams);
    saveButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 40);

    if (!isTraining) {
      deleteButtonFirstPos = screenHeight / 8 + screenHeight / 15;
      deleteButtonSecondPos = 3 * screenHeight / 8 + 2 * screenHeight / 15;
      RelativeLayout.LayoutParams deleteButtonParams =
          new RelativeLayout.LayoutParams(3 * screenWidth / 10, screenHeight / 8);
      deleteButtonParams.topMargin = deleteButtonFirstPos;
      deleteButtonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      deleteButton.setLayoutParams(deleteButtonParams);
      deleteButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, screenHeight / 42);
    }
  }
  public void setBackgroundGlow(ImageView imgview, int r, int g, int b) {
    // An added margin to the initial image
    int margin = 24;
    int halfMargin = margin / 2;
    // the glow radius
    int glowRadius = 40;

    // the glow color
    int glowColor = Color.rgb(r, g, b);

    // The original image to use
    Bitmap src = BitmapFactory.decodeResource(getResources(), imgview.getId());

    // extract the alpha from the source image
    Bitmap alpha = src.extractAlpha();

    // The output bitmap (with the icon + glow)
    Bitmap bmp =
        Bitmap.createBitmap(
            src.getWidth() + margin, src.getHeight() + margin, Bitmap.Config.ARGB_8888);

    // The canvas to paint on the image
    Canvas canvas = new Canvas(bmp);

    Paint paint = new Paint();
    paint.setColor(glowColor);

    // outer glow
    paint.setMaskFilter(
        new BlurMaskFilter(glowRadius, Blur.OUTER)); // For Inner glow set Blur.INNER
    canvas.drawBitmap(alpha, halfMargin, halfMargin, paint);

    // original icon
    canvas.drawBitmap(src, halfMargin, halfMargin, null);

    imgview.setImageBitmap(bmp);
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.startgame);

    imgView41 = (ImageView) findViewById(R.id.image41);
    imgView42 = (ImageView) findViewById(R.id.image42);
    imgView43 = (ImageView) findViewById(R.id.image43);
    imgView44 = (ImageView) findViewById(R.id.image44);
    imgView45 = (ImageView) findViewById(R.id.image45);
    imgView46 = (ImageView) findViewById(R.id.image46);
    imgView47 = (ImageView) findViewById(R.id.image47);
    imgView48 = (ImageView) findViewById(R.id.image48);
    imgView49 = (ImageView) findViewById(R.id.image49);
    imgView410 = (ImageView) findViewById(R.id.image410);
    imgView411 = (ImageView) findViewById(R.id.image411);
    imgView412 = (ImageView) findViewById(R.id.image412);
    imgView413 = (ImageView) findViewById(R.id.image413);
    imgView414 = (ImageView) findViewById(R.id.image414);
    imgView415 = (ImageView) findViewById(R.id.image415);
    imgView416 = (ImageView) findViewById(R.id.image416);
    image1 = (ImageView) findViewById(R.id.imageView1);
    image1.setImageResource(IMG1[0]);

    try {

      Bitmap bitmap =
          BitmapFactory.decodeStream(
              (InputStream) new URL("http://savagelook.com/misc/sl_drop2.png").getContent());
      image1.setImageBitmap(bitmap);
    } catch (MalformedURLException e) {

    } catch (IOException e) {

    }

    Home1 = (Button) findViewById(R.id.Home1);
    Home1.setText("Home");
    Home1.setOnClickListener(new Home1buttonHandler());

    changeimage(0);

    empty = imgView416.getId();
    // setting original image to ImageView
    image1.setClickable(true);
    image1.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            Random rand = new Random();
            int rand1 = rand.nextInt(5);
            changeimage(rand1);
          }
        });
    // For 4*4
    // setting cropped images add to Table ImageViews
    imgView41.setClickable(true);
    imgView41.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView42.setClickable(true);
    imgView42.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView43.setClickable(true);
    imgView43.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView44.setClickable(true);
    imgView44.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView45.setClickable(true);
    imgView45.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView46.setClickable(true);
    imgView46.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView47.setClickable(true);
    imgView47.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView48.setClickable(true);
    imgView48.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView49.setClickable(true);
    imgView49.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });

    imgView410.setClickable(true);
    imgView410.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView411.setClickable(true);
    imgView411.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView412.setClickable(true);
    imgView412.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView413.setClickable(true);
    imgView413.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView414.setClickable(true);
    imgView414.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView415.setClickable(true);
    imgView415.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
    imgView416.setClickable(true);
    imgView416.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            swap1(v.getId(), empty);
          }
        });
  }
    @Override
    public boolean onDrag(View v, DragEvent event) {
      switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
          // no action necessary
          break;
        case DragEvent.ACTION_DRAG_ENTERED:
          // no action necessary
          break;
        case DragEvent.ACTION_DRAG_EXITED:
          // no action necessary
          break;
        case DragEvent.ACTION_DROP:
          // handle the dragged view being dropped over a drop view
          View view = (View) event.getLocalState();
          // stop displaying the view where it was before it was dragged
          // view.setVisibility(View.INVISIBLE);
          // view dragged item is being dropped on
          ImageView dropTarget = (ImageView) v;
          // view being dragged and dropped
          ImageView dropped = (ImageView) view;
          // update the text in the target view to reflect the data being dropped

          switch (dropTarget.getId()) {
            case R.id.myanswer5:
              switch (dropped.getId()) {
                case R.id.myimage1:
                  dropTarget.setImageResource(R.drawable.a);
                  s = false;
                  break;
                case R.id.myimage2:
                  dropTarget.setImageResource(R.drawable.b);
                  s = false;
                  break;
                case R.id.myimage3:
                  dropTarget.setImageResource(R.drawable.c);
                  s = false;
                  break;
                case R.id.myimage4:
                  dropTarget.setImageResource(R.drawable.d);
                  s = false;
                  break;
                case R.id.myimage5:
                  dropTarget.setImageResource(R.drawable.e);
                  s = false;
                  break;
                case R.id.myimage6:
                  dropTarget.setImageResource(R.drawable.f);
                  s = false;
                  break;
                case R.id.myimage7:
                  dropTarget.setImageResource(R.drawable.g);
                  s = false;
                  break;
                case R.id.myimage8:
                  dropTarget.setImageResource(R.drawable.h);
                  s = false;
                  break;
                case R.id.myimage9:
                  dropTarget.setImageResource(R.drawable.i);
                  s = false;
                  break;
                case R.id.myimage10:
                  dropTarget.setImageResource(R.drawable.j);
                  s = false;
                  break;
                case R.id.myimage11:
                  dropTarget.setImageResource(R.drawable.k);
                  s = false;
                  break;
                case R.id.myimage12:
                  dropTarget.setImageResource(R.drawable.l);
                  s = false;
                  break;
                case R.id.myimage13:
                  dropTarget.setImageResource(R.drawable.m);
                  s = false;
                  break;
                case R.id.myimage14:
                  dropTarget.setImageResource(R.drawable.n);
                  s = false;
                  break;
                case R.id.myimage15:
                  dropTarget.setImageResource(R.drawable.o);
                  s = false;
                  break;
                case R.id.myimage16:
                  dropTarget.setImageResource(R.drawable.p);
                  s = false;
                  break;
                case R.id.myimage17:
                  dropTarget.setImageResource(R.drawable.q);
                  s = false;
                  break;
                case R.id.myimage18:
                  dropTarget.setImageResource(R.drawable.r);
                  s = false;
                  break;
                case R.id.myimage19:
                  dropTarget.setImageResource(R.drawable.s);
                  s = true;
                  break;
                case R.id.myimage20:
                  dropTarget.setImageResource(R.drawable.t);
                  s = false;
                  break;
                case R.id.myimage21:
                  dropTarget.setImageResource(R.drawable.u);
                  s = false;
                  break;
                case R.id.myimage22:
                  dropTarget.setImageResource(R.drawable.v);
                  s = false;
                  break;
                case R.id.myimage23:
                  dropTarget.setImageResource(R.drawable.w);
                  s = false;
                  break;
                case R.id.myimage24:
                  dropTarget.setImageResource(R.drawable.x);
                  s = false;
                  break;
                case R.id.myimage25:
                  dropTarget.setImageResource(R.drawable.y);
                  s = false;
                  break;
                case R.id.myimage26:
                  dropTarget.setImageResource(R.drawable.z);
                  s = false;
                  break;
              }
              break;
            case R.id.myanswer6:
              switch (dropped.getId()) {
                case R.id.myimage1:
                  dropTarget.setImageResource(R.drawable.a);
                  i = false;
                  break;
                case R.id.myimage2:
                  dropTarget.setImageResource(R.drawable.b);
                  i = false;
                  break;
                case R.id.myimage3:
                  dropTarget.setImageResource(R.drawable.c);
                  i = false;
                  break;
                case R.id.myimage4:
                  dropTarget.setImageResource(R.drawable.d);
                  i = false;
                  break;
                case R.id.myimage5:
                  dropTarget.setImageResource(R.drawable.e);
                  i = false;
                  break;
                case R.id.myimage6:
                  dropTarget.setImageResource(R.drawable.f);
                  i = false;
                  break;
                case R.id.myimage7:
                  dropTarget.setImageResource(R.drawable.g);
                  i = false;
                  break;
                case R.id.myimage8:
                  dropTarget.setImageResource(R.drawable.h);
                  i = false;
                  break;
                case R.id.myimage9:
                  dropTarget.setImageResource(R.drawable.i);
                  i = true;
                  break;
                case R.id.myimage10:
                  dropTarget.setImageResource(R.drawable.j);
                  i = false;
                  break;
                case R.id.myimage11:
                  dropTarget.setImageResource(R.drawable.k);
                  i = false;
                  break;
                case R.id.myimage12:
                  dropTarget.setImageResource(R.drawable.l);
                  i = false;
                  break;
                case R.id.myimage13:
                  dropTarget.setImageResource(R.drawable.m);
                  i = false;
                  break;
                case R.id.myimage14:
                  dropTarget.setImageResource(R.drawable.n);
                  i = false;
                  break;
                case R.id.myimage15:
                  dropTarget.setImageResource(R.drawable.o);
                  i = false;
                  break;
                case R.id.myimage16:
                  dropTarget.setImageResource(R.drawable.p);
                  i = false;
                  break;
                case R.id.myimage17:
                  dropTarget.setImageResource(R.drawable.q);
                  i = false;
                  break;
                case R.id.myimage18:
                  dropTarget.setImageResource(R.drawable.r);
                  i = false;
                  break;
                case R.id.myimage19:
                  dropTarget.setImageResource(R.drawable.s);
                  i = false;
                  break;
                case R.id.myimage20:
                  dropTarget.setImageResource(R.drawable.t);
                  i = false;
                  break;
                case R.id.myimage21:
                  dropTarget.setImageResource(R.drawable.u);
                  i = false;
                  break;
                case R.id.myimage22:
                  dropTarget.setImageResource(R.drawable.v);
                  i = false;
                  break;
                case R.id.myimage23:
                  dropTarget.setImageResource(R.drawable.w);
                  i = false;
                  break;
                case R.id.myimage24:
                  dropTarget.setImageResource(R.drawable.x);
                  i = false;
                  break;
                case R.id.myimage25:
                  dropTarget.setImageResource(R.drawable.y);
                  i = false;
                  break;
                case R.id.myimage26:
                  dropTarget.setImageResource(R.drawable.z);
                  i = false;
                  break;
              }
              break;
            case R.id.myanswer7:
              switch (dropped.getId()) {
                case R.id.myimage1:
                  dropTarget.setImageResource(R.drawable.a);
                  n = false;
                  break;
                case R.id.myimage2:
                  dropTarget.setImageResource(R.drawable.b);
                  n = false;
                  break;
                case R.id.myimage3:
                  dropTarget.setImageResource(R.drawable.c);
                  n = false;
                  break;
                case R.id.myimage4:
                  dropTarget.setImageResource(R.drawable.d);
                  n = false;
                  break;
                case R.id.myimage5:
                  dropTarget.setImageResource(R.drawable.e);
                  n = false;
                  break;
                case R.id.myimage6:
                  dropTarget.setImageResource(R.drawable.f);
                  n = false;
                  break;
                case R.id.myimage7:
                  dropTarget.setImageResource(R.drawable.g);
                  n = false;
                  break;
                case R.id.myimage8:
                  dropTarget.setImageResource(R.drawable.h);
                  n = false;
                  break;
                case R.id.myimage9:
                  dropTarget.setImageResource(R.drawable.i);
                  n = false;
                  break;
                case R.id.myimage10:
                  dropTarget.setImageResource(R.drawable.j);
                  n = false;
                  break;
                case R.id.myimage11:
                  dropTarget.setImageResource(R.drawable.k);
                  n = false;
                  break;
                case R.id.myimage12:
                  dropTarget.setImageResource(R.drawable.l);
                  n = false;
                  break;
                case R.id.myimage13:
                  dropTarget.setImageResource(R.drawable.m);
                  n = false;
                  break;
                case R.id.myimage14:
                  dropTarget.setImageResource(R.drawable.n);
                  n = true;
                  break;
                case R.id.myimage15:
                  dropTarget.setImageResource(R.drawable.o);
                  n = false;
                  break;
                case R.id.myimage16:
                  dropTarget.setImageResource(R.drawable.p);
                  n = false;
                  break;
                case R.id.myimage17:
                  dropTarget.setImageResource(R.drawable.q);
                  n = false;
                  break;
                case R.id.myimage18:
                  dropTarget.setImageResource(R.drawable.r);
                  n = false;
                  break;
                case R.id.myimage19:
                  dropTarget.setImageResource(R.drawable.s);
                  n = false;
                  break;
                case R.id.myimage20:
                  dropTarget.setImageResource(R.drawable.t);
                  n = false;
                  break;
                case R.id.myimage21:
                  dropTarget.setImageResource(R.drawable.u);
                  n = false;
                  break;
                case R.id.myimage22:
                  dropTarget.setImageResource(R.drawable.v);
                  n = false;
                  break;
                case R.id.myimage23:
                  dropTarget.setImageResource(R.drawable.w);
                  n = false;
                  break;
                case R.id.myimage24:
                  dropTarget.setImageResource(R.drawable.x);
                  n = false;
                  break;
                case R.id.myimage25:
                  dropTarget.setImageResource(R.drawable.y);
                  n = false;
                  break;
                case R.id.myimage26:
                  dropTarget.setImageResource(R.drawable.z);
                  n = false;
                  break;
              }
              break;
            case R.id.myanswer8:
              switch (dropped.getId()) {
                case R.id.myimage1:
                  dropTarget.setImageResource(R.drawable.a);
                  g = false;
                  break;
                case R.id.myimage2:
                  dropTarget.setImageResource(R.drawable.b);
                  g = false;
                  break;
                case R.id.myimage3:
                  dropTarget.setImageResource(R.drawable.c);
                  g = false;
                  break;
                case R.id.myimage4:
                  dropTarget.setImageResource(R.drawable.d);
                  g = false;
                  break;
                case R.id.myimage5:
                  dropTarget.setImageResource(R.drawable.e);
                  g = false;
                  break;
                case R.id.myimage6:
                  dropTarget.setImageResource(R.drawable.f);
                  g = false;
                  break;
                case R.id.myimage7:
                  dropTarget.setImageResource(R.drawable.g);
                  g = true;
                  break;
                case R.id.myimage8:
                  dropTarget.setImageResource(R.drawable.h);
                  g = false;
                  break;
                case R.id.myimage9:
                  dropTarget.setImageResource(R.drawable.i);
                  g = false;
                  break;
                case R.id.myimage10:
                  dropTarget.setImageResource(R.drawable.j);
                  g = false;
                  break;
                case R.id.myimage11:
                  dropTarget.setImageResource(R.drawable.k);
                  g = false;
                  break;
                case R.id.myimage12:
                  dropTarget.setImageResource(R.drawable.l);
                  g = false;
                  break;
                case R.id.myimage13:
                  dropTarget.setImageResource(R.drawable.m);
                  g = false;
                  break;
                case R.id.myimage14:
                  dropTarget.setImageResource(R.drawable.n);
                  g = false;
                  break;
                case R.id.myimage15:
                  dropTarget.setImageResource(R.drawable.o);
                  g = false;
                  break;
                case R.id.myimage16:
                  dropTarget.setImageResource(R.drawable.p);
                  g = false;
                  break;
                case R.id.myimage17:
                  dropTarget.setImageResource(R.drawable.q);
                  g = false;
                  break;
                case R.id.myimage18:
                  dropTarget.setImageResource(R.drawable.r);
                  g = false;
                  break;
                case R.id.myimage19:
                  dropTarget.setImageResource(R.drawable.s);
                  g = false;
                  break;
                case R.id.myimage20:
                  dropTarget.setImageResource(R.drawable.t);
                  g = false;
                  break;
                case R.id.myimage21:
                  dropTarget.setImageResource(R.drawable.u);
                  g = false;
                  break;
                case R.id.myimage22:
                  dropTarget.setImageResource(R.drawable.v);
                  g = false;
                  break;
                case R.id.myimage23:
                  dropTarget.setImageResource(R.drawable.w);
                  g = false;
                  break;
                case R.id.myimage24:
                  dropTarget.setImageResource(R.drawable.x);
                  g = false;
                  break;
                case R.id.myimage25:
                  dropTarget.setImageResource(R.drawable.y);
                  g = false;
                  break;
                case R.id.myimage26:
                  dropTarget.setImageResource(R.drawable.z);
                  g = false;
                  break;
              }
              break;
          }

          // dropTarget.setImageResource(dropped.getId());
          // make it bold to highlight the fact that an item has been dropped
          // dropTarget.setTypeface(Typeface.DEFAULT_BOLD);
          // if an item has already been dropped here, there will be a tag
          Object tag = dropTarget.getTag();
          // if there is already an item here, set it back visible in its original place
          if (tag != null) { //
            // the tag is the view id already dropped here
            int existingID = (Integer) tag;
            // set the original view visible again
            findViewById(existingID).setVisibility(View.VISIBLE);
          }
          // set the tag in the target view being dropped on - to the ID of the view being dropped
          dropTarget.setTag(dropped.getId());

          if (s && i && n && g) {
            nextGame();
          }

          break;
        case DragEvent.ACTION_DRAG_ENDED:
          // no action necessary
          break;
        default:
          break;
      }
      return true;
    }
 public void onFocusChange(View v, boolean hasFocus) {
   if (v.getId() == _imgAccept.getId()) {
     if (hasFocus) _imgAccept.setImageResource(R.drawable.accept_f);
     else _imgAccept.setImageResource(R.drawable.accept);
   }
 }
 public void onClick(View v) {
   if (v.getId() == _togAskSend.getId()) _bAskSend = !_bAskSend;
   else if (v.getId() == _imgAccept.getId()) Accept();
   else if (v.getId() == _txtEmail.getId()) ShowContactsList(true);
   else if (v.getId() == _txtSms.getId()) ShowContactsList(false);
 }
Exemple #26
0
 private void startBlinkingImage(ImageView imageView) {
     blinkingImageViews.add(imageView.getId());
     blinkImage(imageView, true);
 }
  /** Display the custom ad. */
  public void displayCustom() {
    AdFlakeLayout adFlakeLayout = _adFlakeLayoutReference.get();
    if (adFlakeLayout == null) {
      return;
    }

    Activity activity = adFlakeLayout.activityReference.get();
    if (activity == null) {
      return;
    }

    // This may be incorrect and need to be adjusted for density.
    double density = AdFlakeUtil.getDensity(activity);
    double px320 = AdFlakeUtil.convertToScreenPixels(320, density);
    double px50 = AdFlakeUtil.convertToScreenPixels(50, density);

    // NOTE: FILL_PARENT (renamed MATCH_PARENT in API Level 8 and
    // higher),
    // which means that the view wants to be as big as its parent
    // (minus padding)
    @SuppressWarnings("deprecation")
    final int layoutTypeFillParent = android.view.ViewGroup.LayoutParams.FILL_PARENT;

    switch (adFlakeLayout.currentCustom.type) {
      case AdFlakeUtil.CUSTOM_TYPE_BANNER:
        Log.d(AdFlakeUtil.ADFLAKE, "Serving custom type: banner");

        if (adFlakeLayout.currentCustom.image == null) {
          adFlakeLayout.rotateThreadedNow();
          return;
        }

        RelativeLayout bannerView = new RelativeLayout(activity);
        bannerView.setLayoutParams(new LayoutParams((int) px320, (int) px50));

        ImageView bannerImageView = new ImageView(activity);
        bannerImageView.setImageDrawable(adFlakeLayout.currentCustom.image);

        RelativeLayout.LayoutParams viewParams =
            new RelativeLayout.LayoutParams(layoutTypeFillParent, layoutTypeFillParent);
        bannerView.addView(bannerImageView, viewParams);

        adFlakeLayout.pushSubView(bannerView);
        break;

      case AdFlakeUtil.CUSTOM_TYPE_ICON:
        Log.d(AdFlakeUtil.ADFLAKE, "Serving custom type: icon");
        RelativeLayout iconView = new RelativeLayout(activity);
        if (adFlakeLayout.currentCustom.image == null) {
          adFlakeLayout.rotateThreadedNow();
          return;
        }

        double px4 = AdFlakeUtil.convertToScreenPixels(4, density);
        double px6 = AdFlakeUtil.convertToScreenPixels(6, density);

        // This may be incorrect and need to be adjusted for density.
        iconView.setLayoutParams(new LayoutParams((int) px320, (int) px50));

        int gradientBottomColor =
            Color.rgb(
                adFlakeLayout.extra.bgRed, adFlakeLayout.extra.bgGreen, adFlakeLayout.extra.bgBlue);
        int gradientTopColor = Color.WHITE;

        ImageView blendView = new ImageView(activity);
        GradientDrawable blend =
            new GradientDrawable(
                Orientation.TOP_BOTTOM,
                new int[] {
                  gradientTopColor, gradientBottomColor, gradientBottomColor, gradientBottomColor
                });

        // NOTE: This method was deprecated in API level 16. Use
        // setBackground(Drawable) instead
        try {
          // blendView.setBackgroundDrawable(blend);
          blendView
              .getClass()
              .getMethod(
                  android.os.Build.VERSION.SDK_INT >= 16
                      ? "setBackground"
                      : "setBackgroundDrawable",
                  Drawable.class)
              .invoke(blendView, blend);
        } catch (Exception ex) {
          // do nothing
        }
        RelativeLayout.LayoutParams blendViewParams =
            new RelativeLayout.LayoutParams(layoutTypeFillParent, layoutTypeFillParent);
        iconView.addView(blendView, blendViewParams);

        ImageView iconImageView = new ImageView(activity);
        iconImageView.setImageDrawable(adFlakeLayout.currentCustom.image);
        iconImageView.setId(10);
        iconImageView.setPadding((int) px4, 0, (int) px6, 0);
        iconImageView.setScaleType(ScaleType.CENTER);

        RelativeLayout.LayoutParams iconViewParams =
            new RelativeLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT, layoutTypeFillParent);
        iconView.addView(iconImageView, iconViewParams);

        ImageView frameImageView = new ImageView(activity);
        InputStream drawableStream =
            getClass().getResourceAsStream("/com/adflake/assets/ad_frame.gif");

        Drawable adFrameDrawable = new BitmapDrawable(activity.getResources(), drawableStream);
        frameImageView.setImageDrawable(adFrameDrawable);
        frameImageView.setPadding((int) px4, 0, (int) px6, 0);
        frameImageView.setScaleType(ScaleType.CENTER);

        RelativeLayout.LayoutParams frameViewParams =
            new RelativeLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT, layoutTypeFillParent);
        iconView.addView(frameImageView, frameViewParams);
        TextView iconTextView = new TextView(activity);
        iconTextView.setText(adFlakeLayout.currentCustom.description);
        iconTextView.setTypeface(Typeface.DEFAULT_BOLD, 1);
        iconTextView.setTextColor(
            Color.rgb(
                adFlakeLayout.extra.fgRed,
                adFlakeLayout.extra.fgGreen,
                adFlakeLayout.extra.fgBlue));

        RelativeLayout.LayoutParams textViewParams =
            new RelativeLayout.LayoutParams(layoutTypeFillParent, layoutTypeFillParent);
        textViewParams.addRule(RelativeLayout.RIGHT_OF, iconImageView.getId());
        textViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        textViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        textViewParams.addRule(RelativeLayout.CENTER_VERTICAL);
        textViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        iconTextView.setGravity(Gravity.CENTER_VERTICAL);
        iconView.addView(iconTextView, textViewParams);
        adFlakeLayout.pushSubView(iconView);
        break;

      default:
        Log.w(AdFlakeUtil.ADFLAKE, "Unknown custom type!");
        adFlakeLayout.rotateThreadedNow();
        return;
    }

    adFlakeLayout.adFlakeManager.resetRollover();
    adFlakeLayout.rotateThreadedDelayed();
  }
Exemple #28
0
 private void stopBlinkingImage(ImageView imageView) {
     blinkingImageViews.remove(imageView.getId());
 }
Exemple #29
0
  public void init(Context context, AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustomActionbar);
    // Use a
    this.text = a.getString(R.styleable.CustomActionbar_android_text);
    this.textColor =
        a.getInteger(
            R.styleable.CustomActionbar_android_textColor, getResources().getColor(R.color.black));
    this.backgroundType = a.getInteger(R.styleable.CustomActionbar_backgroundType, -1);
    this.backButtonColor = a.getString(R.styleable.CustomActionbar_backButtonColor);
    this.searchButton = a.getBoolean(R.styleable.CustomActionbar_searchButton, false);
    this.settingsButton = a.getBoolean(R.styleable.CustomActionbar_settingsButton, false);
    this.searchBar = a.getBoolean(R.styleable.CustomActionbar_searchBar, false);
    // Don't forget this
    a.recycle();

    this.setBackgroundColor(getResources().getColor(R.color.color5));

    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(metrics);
    float logicalDensity = metrics.density;

    this.backButton = new Button(context);
    this.backButton.setWidth(75 * (int) logicalDensity);
    this.backButton.setBackgroundColor(getResources().getColor(R.color.transparent));

    LayoutParams backButtonParams =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    backButtonParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);

    this.addView(backButton, backButtonParams);

    backButtonImage = new ImageView(context);
    if (backButtonColor.equals("blue")) {
      this.backButtonImage.setImageDrawable(
          ContextCompat.getDrawable(context, R.mipmap.custom_white_up_button));
    } else if (backButtonColor.equals("purple")) {
      this.backButtonImage.setImageDrawable(
          ContextCompat.getDrawable(context, R.mipmap.custom_white_up_button));
    } else {
      this.backButtonImage.setImageDrawable(
          ContextCompat.getDrawable(context, R.mipmap.custom_white_up_button));
    }

    LayoutParams backButtonImageParams =
        new LayoutParams(
            (int) (getResources().getDimension(R.dimen.up_button_side_lengths) * logicalDensity),
            (int) (getResources().getDimension(R.dimen.up_button_side_lengths) * logicalDensity));
    this.backButtonImage.setLayoutParams(backButtonImageParams);
    this.backButtonImage.setScaleType(ImageView.ScaleType.FIT_CENTER);
    this.backButtonImage.setPadding(
        (int) (logicalDensity * getResources().getDimension(R.dimen.up_button_padding)),
        0,
        (int) (logicalDensity * getResources().getDimension(R.dimen.up_button_padding)),
        0);
    this.backButtonImage.setId(1);

    LayoutParams upButtonImageParams =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    upButtonImageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    upButtonImageParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);

    this.addView(backButtonImage, upButtonImageParams);

    LayoutParams textParams =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textParams.addRule(RelativeLayout.RIGHT_OF, backButtonImage.getId());
    textParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);

    this.title = new TextView(context);
    this.title.setText(text);
    this.title.setTextColor(textColor);
    this.title.setTextSize(
        TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.action_bar_text_size));
    this.addView(title, textParams);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.standard_splash);

    yourIntent = new Intent("in.co.sdslabs.iitr.Multi.MAINPAGE");
    /*
     *          DECLARE YOUR INTENT HERE
     *       That is all you have got to do
     * It will be fired automatically when it should
     */

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    screenWidth = metrics.widthPixels;
    screenHeight = metrics.heightPixels;

    skip = (ImageButton) findViewById(R.id.skip);
    skip.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // TODO Auto-generated method stub
            skipped = true;
            try {
              startActivity(yourIntent);
              finish();
            } catch (Exception e) {
              // TODO: handle exception
              e.printStackTrace();
            }
          }
        });

    Thread timer =
        new Thread() {

          @Override
          public void run() {
            // TODO Auto-generated method stub
            try {
              sleep(5000);
              if (!skipped) {
                startActivity(yourIntent);
                finish();
              }
            } catch (Exception e) {
              // TODO: handle exception
              e.printStackTrace();
            }
          }
        };
    timer.start();

    left1 = screenWidth / 2 - 80;
    right1 = screenWidth / 2 - 10;
    top1 = 0;
    bottom1 = top1 + 157;

    left2 = screenWidth / 2 + 10;
    right2 = screenWidth / 2 + 80;
    top2 = 0;
    bottom2 = top2 + 157;

    top1 = screenWidth / 3;

    iconOffset = (int) (20f * metrics.density);
    System.out.println("" + metrics.density);

    phase = animPhase.PHASE1;
    cell1 = (ImageView) findViewById(R.id.cell1);
    cell2 = (ImageView) findViewById(R.id.cell2);

    androids = (ImageView) findViewById(R.id.android_icon);
    blackberry = (ImageView) findViewById(R.id.bb_icon);
    apple = (ImageView) findViewById(R.id.apple_icon);
    windows = (ImageView) findViewById(R.id.windows_icon);

    int topTotation = top1 - 50;

    android.widget.RelativeLayout.LayoutParams lp_rotaters =
        (android.widget.RelativeLayout.LayoutParams) androids.getLayoutParams();
    lp_rotaters.setMargins(screenWidth / 2 - iconOffset, topTotation, 0, 0);
    androids.setLayoutParams(lp_rotaters);
    android.widget.RelativeLayout.LayoutParams lp_rotaters_2 =
        (android.widget.RelativeLayout.LayoutParams) blackberry.getLayoutParams();
    lp_rotaters_2.setMargins(screenWidth / 2 - iconOffset, topTotation, 0, 0);
    blackberry.setLayoutParams(lp_rotaters_2);
    android.widget.RelativeLayout.LayoutParams lp_rotaters_3 =
        (android.widget.RelativeLayout.LayoutParams) windows.getLayoutParams();
    lp_rotaters_3.setMargins(screenWidth / 2 - iconOffset, topTotation, 0, 0);
    windows.setLayoutParams(lp_rotaters_3);
    android.widget.RelativeLayout.LayoutParams lp_rotaters_4 =
        (android.widget.RelativeLayout.LayoutParams) androids.getLayoutParams();
    lp_rotaters_4.setMargins(screenWidth / 2 - iconOffset, topTotation, 0, 0);
    apple.setLayoutParams(lp_rotaters_4);

    int timeRotation = 1500;

    androidAnimator = new PathAnimator(-100, +100, 0, 0, 0, 50);
    androidAnimator.setDuration(timeRotation);
    androidAnimator.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub
            androids.setVisibility(View.VISIBLE);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

            if (front1) {
              androids.bringToFront();
            }
            //	  			else {
            //  				android.widget.RelativeLayout.LayoutParams lp =
            // (android.widget.RelativeLayout.LayoutParams) androids.getLayoutParams() ;
            //	  				lp.addRule(android.widget.RelativeLayout.);
            //	  				cell1.bringToFront();
            //	  				cell2.bringToFront();
            //	  				sendViewToBack(androids);
            //	  			}

            front1 = !front1;
            try {
              ((PathAnimator) animation).reverseAnimation();
            } catch (ClassCastException e) {
              e.printStackTrace();
            }
          }

          @Override
          public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub

          }
        });

    windowsAnimator = new PathAnimator(-100, +100, 0, 0, 0, 50);
    windowsAnimator.setDuration(timeRotation);
    windowsAnimator.setStartOffset(timeRotation / 2);
    windowsAnimator.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub
            windows.setVisibility(View.VISIBLE);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

            if (front2) {
              windows.bringToFront();
            } /*
              	  			else {
              //	  				cell1.bringToFront();
              //	  				cell2.bringToFront();
              	  				sendViewToBack(windows);
              	  			}
              				*/
            front2 = !front2;
            try {
              ((PathAnimator) animation).reverseAnimation();
            } catch (ClassCastException e) {
              e.printStackTrace();
            }
            animation.setStartOffset(0);
          }

          @Override
          public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub

          }
        });

    appleAnimator = new PathAnimator(-100, +100, 0, 0, 0, 50);
    appleAnimator.setDuration(timeRotation);
    appleAnimator.setStartOffset(timeRotation);
    appleAnimator.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub
            apple.setVisibility(View.VISIBLE);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

            if (front3) {
              apple.bringToFront();
            } /*
              	  			else {
              //	  				cell1.bringToFront();
              //	  				cell2.bringToFront();
              	  				sendViewToBack(apple);
              	  			}
              				*/
            front3 = !front3;

            try {
              ((PathAnimator) animation).reverseAnimation();
            } catch (ClassCastException e) {
              e.printStackTrace();
            }
            animation.setStartOffset(0);
          }

          @Override
          public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub

          }
        });

    bbAnimator = new PathAnimator(-100, +100, 0, 0, 0, 50);
    bbAnimator.setDuration(timeRotation);
    bbAnimator.setStartOffset(3 * timeRotation / 2);
    bbAnimator.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub
            blackberry.setVisibility(View.VISIBLE);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

            if (front4) {
              blackberry.bringToFront();
            } /*
              	  			else {
              //	  				cell1.bringToFront();
              //	  				cell2.bringToFront();
              	  				sendViewToBack(blackberry);
              	  			}
              				*/
            front4 = !front4;

            try {
              ((PathAnimator) animation).reverseAnimation();
            } catch (ClassCastException e) {
              e.printStackTrace();
            }
            animation.setStartOffset(0);
          }

          @Override
          public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub

          }
        });

    i =
        new Interpolator() {

          @Override
          public float getInterpolation(float prog) {
            // TODO Auto-generated method stub
            float f = 0;
            if (prog < 0.6) {
              f = 1.6667f * prog;
            } else if (prog <= 1.0) {
              //					f = 1.0f + 0.1f * (prog - 0.84f)* 12.5f;
              f = 1.0f + 1.6667f * (prog - 0.6f) - 4.16675f * (prog - 0.6f) * (prog - 0.6f);
            } // else if (prog > 0.92) {
            //	f = 1.0f + 0.1f * (1.0f - prog)* 12.5f;
            // }
            return f;
          }
        };

    Interpolator i2 =
        new Interpolator() {

          @Override
          public float getInterpolation(float prog) {
            // TODO Auto-generated method stub
            float f = 0;
            if (prog < 0.60) {
              f = 1.6667f * prog;
            } else if (prog <= 1.0) {
              // f = 1.0f + 0.83335f * (prog - 0.6f) - 2.083375f * (prog - 0.6f)*(prog-0.6f);
              f =
                  1.0f
                      + 1.6667f * 0.5f * (prog - 0.6f)
                      - 4.16675f * 0.5f * (prog - 0.6f) * (prog - 0.6f);
            }
            return f;
          }
        };

    android.widget.RelativeLayout.LayoutParams lp1 =
        (android.widget.RelativeLayout.LayoutParams) cell1.getLayoutParams();
    lp1.setMargins(left1, top1, 0, 0);
    cell1.setLayoutParams(lp1);

    android.widget.RelativeLayout.LayoutParams lp2 =
        (android.widget.RelativeLayout.LayoutParams) cell2.getLayoutParams();
    lp2.setMargins(left2, top1, 0, 0);
    cell2.setLayoutParams(lp2);

    TranslateAnimation ani = new TranslateAnimation(0, 0, -screenHeight / 3, 0);
    ani.setInterpolator(i);
    ani.setDuration(1000);
    ani.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub
            //				startRotation();
            animateName();
          }
        });
    cell1.startAnimation(ani);

    TranslateAnimation ani2 = new TranslateAnimation(0, 0, 2 * screenHeight / 3, 0);
    ani2.setInterpolator(i2);
    ani2.setDuration(1000);
    cell2.startAnimation(ani2);

    name = (LinearLayout) findViewById(R.id.name);
    mobile = (TextView) findViewById(R.id.mobile);
    development = (TextView) findViewById(R.id.development);
    group = (TextView) findViewById(R.id.group);
    RelativeLayout.LayoutParams l;
    try {
      l = (RelativeLayout.LayoutParams) name.getLayoutParams();
      l.addRule(RelativeLayout.BELOW, cell1.getId());
      name.setLayoutParams(l);
      name.setPadding(10, 15, 20, 0);
    } catch (ClassCastException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }