コード例 #1
0
ファイル: FileTreePane.java プロジェクト: subshare/subshare
 private void fireRefreshEvent() {
   final RefreshEvent event = new RefreshEvent(this);
   expungeRefreshListeners();
   for (final Reference<RefreshListener> reference : refreshListeners) {
     final RefreshListener listener = reference.get();
     if (listener != null) listener.onRefresh(event);
   }
 }
コード例 #2
0
 /**
  * this is used when someone hits the "refresh" button
  *
  * @param e
  */
 @Override
 public void actionPerformed(ActionEvent e) {
   // the button has been pressed
   // how many refresh listeners?
   this.outstandingRefreshActions = refreshListeners.size();
   setRefreshButtonRed(this.outstandingRefreshActions);
   for (RefreshListener refreshListener : refreshListeners) {
     refreshListener.refreshAction();
   }
 }
コード例 #3
0
ファイル: RefreshListView.java プロジェクト: SmileYun/VPlayer
        public void handleMessage(android.os.Message msg) {
          switch (msg.what) {
            case REFRESH_BACKING: // 反弹中
              mHeaderLinearLayout.setPadding(
                  mHeaderLinearLayout.getPaddingLeft(),
                  (int) (mHeaderLinearLayout.getPaddingTop() * 0.75f),
                  mHeaderLinearLayout.getPaddingRight(),
                  mHeaderLinearLayout.getPaddingBottom());
              showProgressBar();
              break;

            case REFRESH_BACED: // 达到刷新界限,反弹结束后,加载数据
              headerInfo.setText("正在加载...");
              rotateArrow(ROTATE_DOWN);
              showProgressBar();
              mPullRefreshState = EXIT_PULL_REFRESH;
              new Thread() {
                public void run() {
                  if (mRefreshListener != null) {
                    mRefreshObject = mRefreshListener.refreshing();
                  }
                  Message msg = mHandler.obtainMessage();
                  msg.what = REFRESH_DONE;
                  msg.sendToTarget();
                };
              }.start();
              break;

            case REFRESH_RETURN: // 没有达到刷新界限,返回
              headerInfo.setText("下拉刷新");
              rotateArrow(ROTATE_DOWN);
              showArrow();
              mHeaderLinearLayout.setPadding(
                  mHeaderLinearLayout.getPaddingLeft(),
                  0,
                  mHeaderLinearLayout.getPaddingRight(),
                  mHeaderLinearLayout.getPaddingBottom());
              mPullRefreshState = NONE_PULL_REFRESH;
              setSelection(1);
              break;

            case REFRESH_DONE: // 加载数据结束
              headerInfo.setText("下拉刷新");
              headerTime.setText("更新时间为: " + mSimpleDateFormat.format(new Date()));
              rotateArrow(ROTATE_DOWN);
              showArrow();
              mHeaderLinearLayout.setPadding(
                  mHeaderLinearLayout.getPaddingLeft(),
                  0,
                  mHeaderLinearLayout.getPaddingRight(),
                  mHeaderLinearLayout.getPaddingBottom());
              mPullRefreshState = NONE_PULL_REFRESH;
              setSelection(1);
              if (mRefreshListener != null) {
                mRefreshListener.refreshed(mRefreshObject);
              }
              break;
          }
        };
コード例 #4
0
 private void refresh() {
   // TODO Auto-generated method stub
   LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) this.refreshView.getLayoutParams();
   int i = lp.topMargin;
   reFreshTimeLayout.setVisibility(View.GONE);
   refreshIndicatorView.setVisibility(View.GONE);
   bar.setVisibility(View.VISIBLE);
   timeTextView.setVisibility(View.GONE);
   downTextView.setVisibility(View.GONE);
   scroller.startScroll(0, i, 0, 0 - i);
   invalidate();
   if (refreshListener != null) {
     refreshListener.onRefresh(this);
     isRefreshing = true;
   }
 }
コード例 #5
0
ファイル: RefreshableView.java プロジェクト: xlwh/LeanCloudIm
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   if (refreshListener.isAbleToPull() == false) {
     return false;
   }
   int action = event.getAction();
   if (action == MotionEvent.ACTION_DOWN) {
     downY = event.getRawY();
   } else if (action == MotionEvent.ACTION_MOVE) {
     float curY = event.getRawY();
     int deltaY = (int) (curY - downY);
     if (deltaY < touchSlop) {
       status = IDLE;
       isSlop = true;
       return false;
     }
     isSlop = false;
     int topMargin = deltaY / 2;
     int top = topMargin + hideHeaderTop;
     if (top < hideHeaderTop) {
       top = hideHeaderTop;
     }
     if (top > 0) {
       status = RELEASE_TO_REFRESH;
     } else if (top < 0) {
       status = PULL_TO_REFRESH;
     }
     setMargin(top);
     if (status == PULL_TO_REFRESH || status == RELEASE_TO_REFRESH) {
       updateHeaderView();
       attachedView.setFocusable(false);
       attachedView.setFocusableInTouchMode(false);
       attachedView.setPressed(false);
       lastStatus = status;
     }
   } else if (action == MotionEvent.ACTION_UP) {
     if (status == RELEASE_TO_REFRESH) {
       new RefreshingTask().execute();
     } else if (status == PULL_TO_REFRESH) {
       new HideHeaderTask().execute();
     }
   }
   if (isSlop) {
     return false;
   }
   return true;
 }