private void startAnim() {
   int tem = -topRefreshView.getHeight();
   int tem2 = footerRefreshView.getHeight();
   LayoutParams lp = (LayoutParams) topRefreshView.getLayoutParams();
   if (lp.topMargin > tem) {
     lp.topMargin -= 20;
     if (refreshing) {
       if (lp.topMargin < 0) {
         lp.topMargin = 0;
       }
     } else {
       if (lp.topMargin <= tem) {
         lp.topMargin = tem;
       }
     }
   } else if (lp.topMargin < tem) {
     lp.topMargin += 20;
     if (refreshing) {
       if (lp.topMargin >= (tem - tem2)) {
         lp.topMargin = tem - tem2;
       }
     } else {
       if (lp.topMargin >= tem) {
         lp.topMargin = tem;
       }
     }
   }
   topRefreshView.setLayoutParams(lp);
   if (lp.topMargin != tem) {
     invalidate();
   } else {
     animIsOver = false;
   }
 }
  private void bounceBackHeader() {
    int yTranslate =
        state == State.REFRESHING
            ? header.getHeight() - headerContainer.getHeight()
            : -headerContainer.getHeight() - headerContainer.getTop();

    TranslateAnimation bounceAnimation =
        new TranslateAnimation(
            TranslateAnimation.ABSOLUTE,
            0,
            TranslateAnimation.ABSOLUTE,
            0,
            TranslateAnimation.ABSOLUTE,
            0,
            TranslateAnimation.ABSOLUTE,
            yTranslate);

    bounceAnimation.setDuration(BOUNCE_ANIMATION_DURATION);
    bounceAnimation.setFillEnabled(true);
    bounceAnimation.setFillAfter(false);
    bounceAnimation.setFillBefore(true);
    bounceAnimation.setInterpolator(new OvershootInterpolator(BOUNCE_OVERSHOOT_TENSION));
    bounceAnimation.setAnimationListener(new HeaderAnimationListener(yTranslate));

    startAnimation(bounceAnimation);
  }
  private int getY(int y) {
    if (y < 0) {
      y = 0;
    }
    if (y + mLlContent.getHeight() > mMaxHeight) {
      y = (int) (mMaxHeight - mLlContent.getHeight());
    }

    return y;
  }
  public void updateList() {

    sideIndex.removeAllViews();
    indexListSize = alphabet.size();
    if (indexListSize < 1) {
      return;
    }

    int indexMaxSize = (int) Math.floor(sideIndex.getHeight() / 20);
    int tmpIndexListSize = indexListSize;
    while (tmpIndexListSize > indexMaxSize) {
      tmpIndexListSize = tmpIndexListSize / 2;
    }
    double delta;
    if (tmpIndexListSize > 0) {
      delta = indexListSize / tmpIndexListSize;
    } else {
      delta = 1;
    }

    TextView tmpTV;
    for (double i = 1; i <= indexListSize; i = i + delta) {
      Object[] tmpIndexItem = alphabet.get((int) i - 1);
      String tmpLetter = tmpIndexItem[0].toString();

      tmpTV = new TextView(contexto);
      tmpTV.setText(tmpLetter);
      tmpTV.setGravity(Gravity.CENTER);
      tmpTV.setTextSize(15);
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
      tmpTV.setLayoutParams(params);
      sideIndex.addView(tmpTV);
    }

    sideIndexHeight = sideIndex.getHeight();

    sideIndex.setOnTouchListener(
        new OnTouchListener() {
          @SuppressLint("ClickableViewAccessibility")
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // now you know coordinates of touch
            sideIndexX = event.getX();
            sideIndexY = event.getY();

            // and can display a proper item it country list
            displayListItem();

            return false;
          }
        });
  }
  @Override
  public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (isFrist && topRefreshView.getHeight() > 0) {
      LayoutParams lp = (LayoutParams) topRefreshView.getLayoutParams();
      lp.topMargin = -topRefreshView.getHeight();
      topRefreshView.setLayoutParams(lp);
      isFrist = false;
    }

    if (animIsOver) {
      startAnim();
    }
  }
  public void addpictrue(Bitmap bitmap) {
    DeleteImageView imageView = new DeleteImageView(ProductEditActivity.this);
    imageView.setLayoutParams(
        new LinearLayout.LayoutParams(pictureLayout.getHeight(), pictureLayout.getHeight()));
    imageView.setImageBitmap(bitmap);
    pictureLayout.addView(imageView, pictureLayout.getChildCount() - 1);
    pictureLayout.post(
        new Runnable() {

          @Override
          public void run() {
            hs.scrollTo(pictureLayout.getWidth(), 0);
          }
        });
  }
Example #7
0
 private void checkScrollable() {
   int childHeight = scrollerChild.getHeight();
   boolean isScrollable =
       scrollView.getHeight()
           < childHeight + scrollView.getPaddingTop() + scrollView.getPaddingBottom();
   FragmentsTouchListener.setFragmentScrollable(isScrollable);
 }
Example #8
0
 public AccordionSet(LinearLayout btn, LinearLayout content) {
   _btn = btn;
   _content = content;
   _handler = new Handler();
   _height = _content.getHeight();
   mInterpolator = new DecelerateInterpolator();
   _content.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 0));
   _btn.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           _startTime = (int) System.currentTimeMillis();
           if (_bound.equals("open")) {
             _bound = "close";
           } else {
             _bound = "open";
           }
           if (_thread == null || !_thread.isAlive()) {
             _thread = null;
             makeThread();
             _thread.start();
           }
         }
       });
 }
  public void removeView() {
    if (windowView != null && !hiding) {
      hiding = true;
      Animation anim = new TranslateAnimation(0, 0, 0, -displayLayout.getHeight());
      anim.setDuration(200);
      anim.setAnimationListener(
          new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {}

            public void onAnimationRepeat(Animation animation) {}

            public void onAnimationEnd(Animation animation) {
              hiding = false;
              displayLayout.setVisibility(View.INVISIBLE);
              windowView.setOnKeyListener(null);
              windowView.setOnTouchListener(null);
              if (searchSelect != null) {
                searchSelect.setOnClickListener(null);
                translationSelect.setOnClickListener(null);
                inserteventsSelect.setOnClickListener(null);
              }
              isShowing = false;
              windowManager.removeView(windowView);
              windowView = null;
            }
          });
      displayLayout.startAnimation(anim);
    }
  }
Example #10
0
 private void setControlVisibility(boolean visible) {
   mControlHolder.clearAnimation();
   if (visible) {
     mControlHolder.animate().translationY(0).setDuration(300).start();
   } else {
     mControlHolder.animate().translationY(mControlHolder.getHeight()).setDuration(300).start();
   }
 }
 /**
  * 播放音乐
  *
  * @param parent
  * @param view
  * @param position
  * @param id
  */
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   //      LogUtil.logInfo(TAG, "onItemClick: "+position);
   //      ToastUtil.showToast(getContext(),""+position);
   List<SongList> songLists = MusicApplication.getMusicPlayer().getSongLists();
   MusicApplication.getMusicPlayer().setMusicListType(SEARCH);
   MusicApplication.getMusicPlayer().setPosition(position);
   String songId = songLists.get(position).getSong_id();
   // LogUtil.logInfo(TAG, "onItemClick: " + songId);
   presenterNetDetial.setSong(songId);
   lvSearchMusic.setVisibility(View.GONE);
   animation =
       new TranslateAnimation(
           0, 0, lvSearchMusic.getHeight() + llNetFragment.getHeight(), llNetFragment.getHeight());
   animation.setDuration(300);
   animation.start();
 }
  /**
   * 设置点击事件,显示相应数据的列表
   *
   * @param v
   */
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.ll_new_list:
        setIntentType(NEW);
        break;
      case R.id.ll_hot_list:
        setIntentType(HOT);
        break;
      case R.id.ll_billboard_list:
        setIntentType(BILLBOARD);
        break;
      case R.id.ll_ktv_list:
        setIntentType(KTV);
        break;
      case R.id.ibtn_local_music:
        if (MusicApplication.getContext().getPlayer().isPlaying()) {
          intentPlayActivity();
          return;
        } else {
          // ToastUtil(getActivity(), "当前没有播放歌曲");
          intentPlayActivity();
        }
        break;
      case R.id.ibtn_music_search:
        String songName = etSearch.getText().toString().trim();
        if (songName != null) {
          lvSearchMusic.setVisibility(View.VISIBLE);
          animation =
              new TranslateAnimation(
                  0,
                  0,
                  llNetFragment.getHeight(),
                  lvSearchMusic.getHeight() + llNetFragment.getHeight());
          animation.setDuration(300);
          animation.start();
          //                    LogUtil.logInfo(TAG, "songName: " + songName);
          presenterNet.loadSearchMusics(songName);
        } else if ("".equals(songName)) {
          ToastUtil.showToast(getContext(), "请输入想听的歌曲");
        }
        break;
    }
    // LogUtil.logInfo(TAG, "Fragment onClick: " + type);

  }
        @Override
        public void onClick(View v) {
          switch (v.getId()) {
            case R.id.btn_sleep_quality:
              _svComparison.smoothScrollTo(0, 0);
              break;

            case R.id.btn_daytime_activity:
              _svComparison.smoothScrollTo(0, _llSleepQualityComparison.getHeight() - 10);
              break;

            case R.id.btn_before_bed_activity:
              _svComparison.smoothScrollTo(
                  0,
                  _llSleepQualityComparison.getHeight() + _llDaytimeActivityComparison.getHeight());
              break;
          }
        }
 private void isToRefreshing() {
   int tem = -topRefreshView.getHeight();
   int tem2 = tem - footerRefreshView.getHeight();
   LayoutParams lp = (LayoutParams) topRefreshView.getLayoutParams();
   if (lp.topMargin > 0) { // 进行下拉刷新
     refreshing = true;
     chanageHeaderViews();
     if (refreshListener != null) {
       refreshListener.onHeaderRefresh();
     }
   } else if (lp.topMargin < tem2) { // 进行上拉刷新
     refreshing = true;
     chanageBottomViews();
     if (refreshListener != null && refreshListener instanceof OnRefreshListener) {
       ((OnRefreshListener) refreshListener).onBottomRefresh();
     }
   }
 }
Example #15
0
 public final int getContentSize() {
   switch (mScrollDirection) {
     case HORIZONTAL:
       return mInnerLayout.getWidth();
     case VERTICAL:
     default:
       return mInnerLayout.getHeight();
   }
 }
Example #16
0
 @Override
 public void onWindowFocusChanged(boolean hasFocus) {
     super.onWindowFocusChanged(hasFocus);
     if (hasFocus) {
         showTop = layoutReason.getTop();
         scrollViewTop = winchanceScrollView.getTop();
         int height = outRect.height() - 2 * linearLayoutShowContent.getHeight();
         stickyTop = linearLayoutShowContent.getTop() - height;
     }
 }
 private void setTopMartgin(float mar) {
   ViewGroup.LayoutParams temp = topRefreshView.getLayoutParams();
   if (temp != null) {
     int temHeight = topRefreshView.getHeight() + footerRefreshView.getHeight();
     LinearLayout.LayoutParams lp = (LayoutParams) temp;
     lp.topMargin = (int) mar;
     if (lp.topMargin > temHeight) {
       lp.topMargin = temHeight;
     } else if (lp.topMargin < -2 * temHeight) {
       lp.topMargin = -2 * temHeight;
     }
     if (!isCanBottomRefresh && lp.topMargin < -topRefreshView.getHeight()) {
       lp.topMargin = -topRefreshView.getHeight();
     }
     switch (moveStatus) {
       case STATUS_REFRESH_TOP: // 下拉刷新 不能变成上拉刷新  需要控制
         if (lp.topMargin < -temHeight / 2) {
           lp.topMargin = -temHeight / 2;
         }
         break;
       case STATUS_REFRESH_FOOTER: // 上拉刷新不能变成下拉刷新  需要控制
         if (lp.topMargin > -temHeight / 2) {
           lp.topMargin = -temHeight / 2;
         }
         break;
     }
     if (lp.topMargin > 0) { // 进行下拉刷新
       if (!isAnimDoing) {
         pauseRefresh();
       }
     } else if (lp.topMargin < -temHeight) { // 进行上拉刷新
       if (!isAnimDoing) {
         pauseRefresh();
       }
     } else {
       if (isAnimDoing) {
         initBaseViews();
       }
       isAnimDoing = false;
     }
     topRefreshView.setLayoutParams(lp);
   }
 }
Example #18
0
 /* 以原本视频分辨率的比例来调整预览播放窗口大小 */
 private void setVideoRatio(String path) {
   int vh = 0;
   int vw = 0;
   if (player != null) {
     vh = player.getVideoHeight();
     vw = player.getVideoWidth();
   }
   if (vw == 0 || vh == 0) {
     return;
   }
   int width = mThumb.getWidth();
   int height = (vh * width) / vw;
   if (height > mThumb.getHeight()) {
     height = mThumb.getHeight();
   }
   ViewGroup.LayoutParams params = mVideo.getLayoutParams();
   params.width = width;
   params.height = height;
   mVideo.setLayoutParams(params);
 }
  /** 初始化截取的矩形区域 */
  @SuppressWarnings("SuspiciousNameCombination")
  private void initCrop() {
    // http://skillcollege.github.io/2015/02/05/-打造极致二维码扫描系列-基于ZBar的Android平台解码/

    // 预览图的高度,也即camera的分辨率宽高
    int cameraWidth = cameraManager.getCameraResolution().y;
    int cameraHeight = cameraManager.getCameraResolution().x;

    /** 获取布局中扫描框的位置信息 */
    int[] location = new int[2];
    scanCropView.getLocationInWindow(location);

    // 布局文件中扫描框的左上角定点坐标
    int cropLeft = location[0];
    int cropTop = location[1] - getStatusBarHeight();

    // 布局文件中扫描框的宽高
    int cropWidth = scanCropView.getWidth();
    int cropHeight = scanCropView.getHeight();

    /** 获取布局容器的宽高 */
    int containerWidth = scanContainer.getWidth();
    int containerHeight = scanContainer.getHeight();

    /** 计算最终截取的矩形的左上角顶点x坐标 */
    int x = cropLeft * cameraWidth / containerWidth;
    /** 计算最终截取的矩形的左上角顶点y坐标 */
    int y = cropTop * cameraHeight / containerHeight;

    /** 计算最终截取的矩形的宽度 */
    int width = cropWidth * cameraWidth / containerWidth;
    /** 计算最终截取的矩形的高度 */
    int height = cropHeight * cameraHeight / containerHeight;

    /** 生成最终的截取的矩形 */
    mCropRect = new Rect(x, y, width + x, height + y);
  }
Example #20
0
 /** 根据x,y,重新设置控件的位置 因为setX setY为0的时候,都是在状态栏以下的,所以app不是全屏的话,需要扣掉状态栏的高度 */
 private void relocation(int[] location) {
   ivTriangle.setX(location[0] - ivTriangle.getWidth() / 2);
   ivTriangle.setY(
       location[1]
           - ivTriangle.getHeight() / 2
           - (isFullScreen()
               ? 0.0f
               : getStatusBarHeight())); // 因为三角形是通过XML绘制出来的,可以到activity_tip_overlay.xml中把三角形的那个ImageView背景设置一下,就知道什么情况了。所以需要减掉一半的高度
   switch (gravity) {
     case GRAVITY_BOTTOM:
       llContent.setY(
           location[1]
               - ivTriangle.getHeight() / 2
               - (isFullScreen() ? 0.0f : getStatusBarHeight())
               + ivTriangle.getHeight());
       break;
     case GRAVITY_TOP:
       llContent.setY(
           location[1]
               - llContent.getHeight()
               - (isFullScreen() ? 0.0f : getStatusBarHeight())
               - ivTriangle.getHeight() / 2);
       break;
   }
   // 显示内容的区域往三角形靠拢
   int triangleCenterX = (int) (ivTriangle.getX() + ivTriangle.getWidth() / 2); // 三角形的中心点
   int contentWidth = llContent.getWidth();
   int rightMargin = getScreenWidth() - triangleCenterX; // 三角形中心距离屏幕右边的距离
   int leftMargin = getScreenWidth() - rightMargin; // 三角形中心距离屏幕左边的距离
   RelativeLayout.LayoutParams layoutParams =
       (RelativeLayout.LayoutParams) llContent.getLayoutParams();
   int availableLeftMargin = leftMargin - layoutParams.leftMargin; // 左边可用的距离
   int availableRightMargin = rightMargin - layoutParams.rightMargin; // 右边可用的距离
   int x = 0;
   if (contentWidth / 2 <= availableLeftMargin
       && contentWidth / 2 <= availableRightMargin) // 左右两边有足够的距离
   {
     x = triangleCenterX - contentWidth / 2;
   } else {
     if (availableLeftMargin <= availableRightMargin) // 判断三角形在屏幕中心的左边
     {
       x = layoutParams.leftMargin;
     } else // 三角形在屏幕中心的右边
     {
       x = getScreenWidth() - (contentWidth + layoutParams.rightMargin);
     }
   }
   llContent.setX(x);
 }
 @Override
 public void handleMessage(Message msg) {
   super.handleMessage(msg);
   if (scroll.getScrollY() + height + 100 >= background.getHeight()) {
     if (!isLoading && !isLoaddone) {
       new LoadDataAsync().execute();
     }
   }
   //			if(scroll.getScrollY() != y){
   //				((TextView)findViewById(R.id.slide_btn)).getBackground().setAlpha(100);
   //			}else{
   //				((TextView)findViewById(R.id.slide_btn)).getBackground().setAlpha(255);
   //			}
   //			y = scroll.getScrollY();
 }
Example #22
0
  /**
   * 添加下拉刷新的HeadView
   *
   * @date 2013-11-11 下午9:48:26
   * @change JohnWatson
   * @version 1.0
   */
  private void addHeadView() {
    mHeadView = (LinearLayout) mInflater.inflate(com.gemptc.activities.R.layout.head, null);

    LinearLayout head_linetest =
        (LinearLayout) mHeadView.findViewById(com.gemptc.activities.R.id.head_linetest);

    mArrowImageView = (ImageView) mHeadView.findViewById(R.id.head_arrowImageView);
    mArrowImageView.setMinimumWidth(70);
    mArrowImageView.setMinimumHeight(50);
    mProgressBar = (ProgressBar) mHeadView.findViewById(R.id.head_progressBar);
    mTipsTextView = (TextView) mHeadView.findViewById(R.id.head_tipsTextView);
    mLastUpdatedTextView = (TextView) mHeadView.findViewById(R.id.head_lastUpdatedTextView);

    measureView(mHeadView);
    mHeadViewHeight = mHeadView.getMeasuredHeight();
    mHeadViewWidth = mHeadView.getMeasuredWidth();

    int x = mHeadView.getMeasuredWidth();
    int x1 = mHeadView.getWidth();
    int y1 = mHeadView.getHeight();
    int y = mHeadView.getMeasuredHeight();

    int x12 = head_linetest.getMeasuredWidth();
    int x11 = head_linetest.getWidth();
    int y11 = head_linetest.getHeight();
    int y12 = head_linetest.getMeasuredHeight();

    mHeadView.setPadding(0, -1 * mHeadViewHeight, 0, 0);
    mHeadView.invalidate();

    Log.v("size", "width:" + mHeadViewWidth + " height:" + mHeadViewHeight);

    addHeaderView(mHeadView, null, false);

    mHeadState = DONE;
  }
Example #23
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.subject);

    filter_tab = (LinearLayout) findViewById(R.id.filter_tab);
    LogUtil.d("&&&&&&&&&", filter_tab.getWidth() + "--------width---" + filter_tab.getHeight());

    mFilter = (Button) findViewById(R.id.subject_search);
    mFilter.setFocusable(true);
    mFilter.setClickable(true);
    mFilter.setOnClickListener(this);

    mSearchIB = (ImageButton) findViewById(R.id.subject_search_value);
    mSearchIB.setOnClickListener(this);
    home = (ImageButton) findViewById(R.id.menu_control_level1_but);
    home.setOnClickListener(this);
    initNav();
    lv = (LoadingView) findViewById(R.id.data_loading);
    prlistView = (PullToRefreshListView) findViewById(R.id.obj_list);
    prlistView.setOnRefreshListener(
        new OnRefreshListener() {
          @Override
          public void onRefresh() {
            new GetDataTask().execute();
          }

          @Override
          public void onLoadMore() {
            // TODO Auto-generated method stub
            new GetDataTask().execute();
          }
        });

    data = new ArrayList<SubjectVo>();
    prlistView.setOnItemClickListener(this);

    filterContent = (LinearLayout) findViewById(R.id.filter_content);
    mFilterExpand = (FilterExpand) findViewById(R.id.filter_expand);

    mFilterLatest = (Button) findViewById(R.id.filter_latest);
    mFilterPopularity = (Button) findViewById(R.id.filter_popularity);
    mFilterStar = (Button) findViewById(R.id.filter_price);
    mFilterLatest.setOnClickListener(this);
    mFilterPopularity.setOnClickListener(this);
    mFilterStar.setOnClickListener(this);
    loadAnim(filterContent);
  }
  protected void init() {
    int layout_height = mParentLayout.getHeight();
    int layout_width = mParentLayout.getWidth();
    if (googleMap != null) {

      googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
      googleMap.setIndoorEnabled(false);
      googleMap.setMyLocationEnabled(true);
      /*LatLngBounds MYBOUNDARIES = new LatLngBounds(new LatLng(
      southwest_lat, southwest_lng), new LatLng(northeast_lat,
      northeast_lng));*/
      if (mLastlocation != null) {
        if (mSelectedLatLng == null)
          mSelectedLatLng = new LatLng(mLastlocation.getLatitude(), mLastlocation.getLongitude());
        /*}else{
        	mSelectedLatLng = new LatLng(latitude, longitude);
        }*/
        // final LatLng myplace = new LatLng(latitude, longitude);
        // mSelectedLatLng = myplace;
        map_marker =
            googleMap.addMarker(
                new MarkerOptions()
                    .position(mSelectedLatLng)
                    .title("unknown place")
                    .snippet("unknown")
                    .draggable(true)
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.mappin)));
        // csu_ohio_marker.setVisible(true);
        googleMap.setOnMapClickListener(
            new OnMapClickListener() {

              @Override
              public void onMapClick(LatLng latLng) {
                // TODO Auto-generated method stub
                map_marker.setPosition(latLng);
                mSelectedLatLng = latLng;
              }
            });
        googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mSelectedLatLng, 15));
      } else {
        Toast.makeText(mContext, "Location not available", Toast.LENGTH_LONG).show();
      }
      /*}else{
      	googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(MYBOUNDARIES, layout_width, layout_height, 10));
      }*/
    }
  }
Example #25
0
 public void doClick(View view) {
   switch (view.getId()) {
     case R.id.button1:
       alterBitmap = null;
       canvas = null;
       System.gc();
       alterBitmap =
           Bitmap.createBitmap(before.getWidth(), before.getHeight(), before.getConfig());
       canvas = new Canvas(alterBitmap);
       canvas.drawBitmap(before, new Matrix(), paint);
       iv_before.setImageBitmap(alterBitmap);
       break;
     case R.id.button2:
       String s = et_size.getText().toString().trim();
       if (s != null && !"".equals(s)) {
         radio = Integer.parseInt(s);
         Toast.makeText(this, "»­±Ê°ë¾¶£º" + radio, 0).show();
       }
       break;
     case R.id.button3:
       if (popWindow == null) {
         View v = View.inflate(this, R.layout.popwindom_item, null);
         popWindow =
             new PopupWindow(
                 v, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
         popWindow.showAtLocation(
             btn_popWindow, Gravity.RIGHT | Gravity.BOTTOM, 0, pop.getHeight());
         //				popWindow.showAsDropDown(btn_popWindow, 0, 0, Gravity.RIGHT);
         Button btn = (Button) v.findViewById(R.id.button2);
         btn.setOnClickListener(
             new OnClickListener() {
               @Override
               public void onClick(View v) {
                 popWindow.dismiss();
                 popWindow = null;
                 System.gc();
                 Toast.makeText(Game.this, "PopupWindow£¡", 0).show();
               }
             });
       } else {
         popWindow.dismiss();
         popWindow = null;
         System.gc();
       }
       break;
   }
 }
  public boolean onTouchEvent(MotionEvent e) {
    int state = e.getAction();
    int eventX = (int) e.getX();
    int eventY = (int) e.getY();
    if (state == MotionEvent.ACTION_DOWN) {

      System.out.println("Button Pressed");
      Toast.makeText(getApplicationContext(), "Screen Touched!", Toast.LENGTH_SHORT).show();

      // Screen Sizes
      int xScreenSize = (getResources().getDisplayMetrics().widthPixels);
      int yScreenSize = (getResources().getDisplayMetrics().heightPixels);
      int xLayoutSize = ll.getWidth();
      int yLayoutSize = ll.getHeight();
      int xCenter = xScreenSize / 2;
      int xSource = eventX;
      int yCenter = yScreenSize / 2;
      int ySource = eventY;

      if (xScreenSize != xLayoutSize) {
        xCenter = xLayoutSize / 2;
        xSource = eventX - (xScreenSize - xLayoutSize);
      }
      if (yScreenSize != yLayoutSize) {
        yCenter = yLayoutSize / 2;
        ySource = eventY - (yScreenSize - yLayoutSize);
      }

      PieMenu = new RadialMenuWidget(getBaseContext());

      PieMenu.setSourceLocation(xSource, ySource);
      PieMenu.setShowSourceLocation(true);
      PieMenu.setCenterLocation(xCenter, yCenter);

      PieMenu.setHeader("X:" + xSource + " Y:" + ySource, 20);

      PieMenu.setCenterCircle(new Close());
      PieMenu.addMenuEntry(new CircleOptions());
      PieMenu.addMenuEntry(new Menu1());
      PieMenu.addMenuEntry(new Menu2());
      PieMenu.addMenuEntry(new Menu3());

      ll.addView(PieMenu);
    }
    return true;
  }
  public void displayListItem() {

    sideIndexHeight = sideIndex.getHeight();
    // compute number of pixels for every side index item
    double pixelPerIndexItem = (double) sideIndexHeight / indexListSize;

    // compute the item index for given event position belongs to
    int itemPosition = (int) (sideIndexY / pixelPerIndexItem);

    // get the item (we can do it since we know item index)
    if (itemPosition < alphabet.size()) {
      Object[] indexItem = alphabet.get(itemPosition);
      int subitemPosition = sections.get(indexItem[0]);

      lvSN.setSelection(subitemPosition);
      // getListView().setSelection(subitemPosition);
    }
  }
 @Override
 public void setBackgroundLayoutSize(LinearLayout layoutBackground) {
   if (layoutBackground != null) {
     int height, width;
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
       width = layoutBackground.getMeasuredWidth();
       height = layoutBackground.getMeasuredHeight();
     } else {
       width = layoutBackground.getWidth();
       height = layoutBackground.getHeight();
     }
     if (height - (getPadding() * 2) == 0) {
       height = (int) dp2px(DEFAULT_PROGRESS_BAR_HEIGHT);
     }
     setBackgroundWidth(width);
     setBackgroundHeight(height);
   }
 }
  /** At this time, we can get view size in dialog(可以获得对话框内视图大小) */
  @Override
  public void onLayoutObtain() {
    int x = mX;
    int y = mY;
    if (mGravity == Gravity.TOP) {
      y = mY - mLlContent.getHeight();
    }

    if (mAlignCenter) {
      x = mX + mAnchorView.getWidth() / 2 - mLlContent.getWidth() / 2;
    }

    x = getX(x);
    y = getY(y);

    x = getX(x + dp2px(mXOffset));
    y = getY(y + dp2px(mYOffset));

    ViewHelper.setX(mLlContent, x);
    ViewHelper.setY(mLlContent, y);
  }
Example #30
0
  public void scaleView() {
    // instantiate the views
    View top_view = findViewById(R.id.topView);
    View bottom_view = findViewById(R.id.bottomView);
    LinearLayout footer = (LinearLayout) findViewById(R.id.llFooter);
    LinearLayout crop_frame = (LinearLayout) findViewById(R.id.llCropFrame);
    Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();

    // 90% of width
    crop_container_size = (int) ((float) width * (1f - (10f / 100f)));

    // 10% margins
    float margin = ((float) width * (1f - (90f / 100f)));

    // Parameters for white crop border
    LinearLayout.LayoutParams par =
        new LinearLayout.LayoutParams(crop_container_size, crop_container_size);
    par.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL;
    par.setMargins((int) (margin / 2f), 0, (int) (margin / 2f), 0);
    crop_frame.setLayoutParams(par);

    // Margins for other transparent views
    float top_view_height =
        ((float) (height - crop_container_size - footer.getHeight())) / (float) 2;
    top_view.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, (int) top_view_height));
    bottom_view.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, (int) top_view_height));

    // Image container
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(crop_container_size, crop_container_size);
    params.setMargins((int) (margin / 2f), (int) top_view_height, (int) (margin / 2f), 0);
    mImageView.setLayoutParams(params);
    mImageView.setImageBitmap(mBitmap);
    mImageView.setMaxZoom(4f);
  }