// 当状态改变时候,调用该方法,以更新界面
  private void changeHeaderViewByState() {
    switch (state) {
      case RELEASE_To_REFRESH:
        arrowImageView.setVisibility(View.VISIBLE);
        progressBar.setVisibility(View.GONE);
        tipsTextview.setVisibility(View.VISIBLE);
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        arrowImageView.clearAnimation();
        arrowImageView.startAnimation(animation);

        tipsTextview.setText("松开刷新");

        // Log.v(TAG, "当前状态,松开刷新");
        break;
      case PULL_To_REFRESH:
        progressBar.setVisibility(View.GONE);
        tipsTextview.setVisibility(View.VISIBLE);
        lastUpdatedTextView.setVisibility(View.VISIBLE);
        arrowImageView.clearAnimation();
        arrowImageView.setVisibility(View.VISIBLE);
        // 是由RELEASE_To_REFRESH状态转变来的
        if (isBack) {
          isBack = false;
          arrowImageView.clearAnimation();
          arrowImageView.startAnimation(reverseAnimation);

          tipsTextview.setText("下拉刷新");
        } else {
          tipsTextview.setText("下拉刷新");
        }
        // Log.v(TAG, "当前状态,下拉刷新");
        break;

      case REFRESHING:
        headView.setPadding(0, 0, 0, 0);
        headView.invalidate();

        progressBar.setVisibility(View.VISIBLE);
        arrowImageView.clearAnimation();
        arrowImageView.setVisibility(View.GONE);
        tipsTextview.setText("正在刷新...");
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        // Log.v(TAG, "当前状态,正在刷新...");
        break;
      case DONE:
        headView.setPadding(0, -1 * headContentHeight, 0, 0);
        headView.invalidate();

        progressBar.setVisibility(View.GONE);
        arrowImageView.clearAnimation();
        arrowImageView.setImageResource(R.drawable.xlistview_arrow);
        tipsTextview.setText("下拉刷新");
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        // Log.v(TAG, "当前状态,done");
        break;
    }
  }
  /** Crystal: add the plus button to the bottom bar */
  public void plusButtonSetUp(int position) {
    LinearLayout bottomBar = (LinearLayout) findViewById(R.id.bottom_bar);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(Values.privateSpaceButtonW, Values.privateSpaceButtonW);
    lp.setMargins(0, 0, Values.iconBorderPaddingH, 0);
    ImageView plus =
        PrivateSpaceIconView.plusSpaceButton(getResources().getColor(R.color.off_white), this);
    plus.setBackgroundColor(getResources().getColor(R.color.dark_grey));

    plus.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO NORA - might need to change to mainspace in Space class
            try {
              // Space.getMainSpace().getSpaceController().addSpace(Space.getMainSpace().getContext());
              Space newSpace = SpaceController.addSpace(Space.getMainSpace().getContext());
              PrivateSpaceIconView psIcon =
                  new PrivateSpaceIconView(Space.getMainSpace().getContext(), newSpace);
              newSpace.getSpaceController().setPSIV(psIcon);
            } catch (XMPPException e) {
              Log.d("MainApplication plusButtonSetUp()", "Could not add a Space");
            }
            // MainApplication.this.init_createPrivateSpace(false);
          }
        });
    bottomBar.addView(plus, position, lp);
    bottomBar.invalidate();
  }
        @Override
        public void run() {
          LinearLayout layout = (LinearLayout) findViewById(R.id.adLayout);
          layout.removeAllViews();
          Activity context = SetupChoicesActivity.this;
          switch (mAdSponsorId) {
            case 0:
              AdUtils.setupDomobAdView(context, layout);
              break;

            case 1:
              AdUtils.setupAdmobAdView(context, layout);
              break;

            case 2:
              AdUtils.setupSuizongAdView(context, layout);
              break;

            default:
              AdUtils.setupDomobAdView(context, layout);
          }
          layout.invalidate();
          mAdSponsorId = ++mAdSponsorId % 3;
          mHandler.postDelayed(mAdRefreshProc, mAdRefreshDelay);
        }
  private void updateContentView() {
    callMngrContent.removeAllViews();

    contentViews.clear();
    contentViews.add(CONF_HEADER_INDEX, conferenceTitle);

    int idx = CONF_HEADER_INDEX + 1;

    if (!confList.isEmpty()) {
      for (CTCall call : confList) {
        contentViews.add(idx, inflateCallInfoLine(call));
        idx++;
      }
    }
    if (!privateList.isEmpty()) {
      contentViews.add(idx, privateTitle);
      idx++;
      for (CTCall call : privateList) {
        contentViews.add(idx, inflateCallInfoLine(call));
        idx++;
      }
    }
    if (!inOutList.isEmpty()) {
      contentViews.add(idx, inOutTitle);
      idx++;
      for (CTCall call : inOutList) {
        contentViews.add(idx, inflateCallInfoLine(call));
        idx++;
      }
    }
    for (int i = CONF_HEADER_INDEX; i < idx; i++) {
      callMngrContent.addView(contentViews.get(i), i);
    }
    callMngrContent.invalidate();
  }
  @Override
  protected void onResume() {
    super.onResume();
    LinearLayout layout = (LinearLayout) findViewById(R.id.layoutAchievements);
    layout.removeAllViews();
    // List<PlayerAchievementInfo> playerAchievements =
    // Arrays.asList(MNDirect.getAchievementsProvider().getPlayerAchievementsList());
    // MNDirect.getAchievementsProvider().getAchievementImageURL(id);
    List<GameAchievementInfo> achievements =
        Arrays.asList(MNDirect.getAchievementsProvider().getGameAchievementsList());

    for (GameAchievementInfo achievement : achievements) {
      String textToSet =
          "ID"
              + String.valueOf(achievement.id)
              + "   "
              + achievement.name
              + "   "
              + String.valueOf(achievement.points);
      TextView txtAchievement = new TextView(this);
      txtAchievement.setText(textToSet);
      layout.addView(txtAchievement);
    }
    layout.invalidate();
  }
  private void build_scroll_view(RaceDetails rd) {
    // Erase the content of the scroll view
    LinearLayout pilot_list = (LinearLayout) findViewById(R.id.pilot_list);
    pilot_list.removeAllViews();

    for (int index = 0; index < main_application.nb_of_pilots; index++) {
      if (rd.isTherePilot(index)) {
        LinearLayout new_horiz_layout = new LinearLayout(this);
        new_horiz_layout.setLayoutParams(
            new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f));
        new_horiz_layout.setOrientation(LinearLayout.HORIZONTAL);

        EditText new_text_view = new EditText(this);
        new_text_view.setText(main_application.getPilotName(index));
        new_text_view.setLayoutParams(
            new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f));
        new_text_view.setInputType(
            InputType.TYPE_NULL); // The text cannot be edited with the soft keypad
        new_text_view.setFocusable(false); // The text cannot be edited
        new_horiz_layout.addView(new_text_view);

        ImageView new_image_view = new ImageView(this);
        new_image_view.setImageResource(R.drawable.kart);
        new_horiz_layout.addView(new_image_view);

        EditText new_text_view_car_id = new EditText(this);
        if (rd.pilot_to_car_mapping.matching.indexOfKey(index) >= 0) {
          new_text_view_car_id.setText(
              Integer.toString(rd.pilot_to_car_mapping.matching.get(index)));
        } else {
          // This pilot wasn't in the maximum matching, he therefore is assigned to a car number he
          // already got
          // Signal that by writing the car number red.
          new_text_view_car_id.setText(
              Integer.toString(rd.pilot_to_car_mapping.unmatched.get(index)));
          new_text_view_car_id.setTextColor(getResources().getColor(R.color.dark_red));
        }
        new_text_view_car_id.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        new_text_view_car_id.setInputType(
            InputType.TYPE_NULL); // The text cannot be edited with the soft keypad
        new_text_view_car_id.setFocusable(false); // The text cannot be edited
        new_text_view_car_id.setEms(3);
        new_text_view_car_id.setGravity(Gravity.RIGHT);
        new_horiz_layout.addView(new_text_view_car_id);

        pilot_list.addView(new_horiz_layout);
      }
    }

    // Redraw the scroll view
    pilot_list.invalidate();
  }
  private void init(Context context) {
    // 设置滑动效果
    animation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(100);
    animation.setFillAfter(true);

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(100);
    reverseAnimation.setFillAfter(true);

    inflater = LayoutInflater.from(context);
    headView = (LinearLayout) inflater.inflate(R.layout.pull_to_refresh_head, null);

    arrowImageView = (ImageView) headView.findViewById(R.id.head_arrowImageView);
    arrowImageView.setMinimumWidth(50);
    arrowImageView.setMinimumHeight(50);
    progressBar = (ProgressBar) headView.findViewById(R.id.head_progressBar);
    tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.head_lastUpdatedTextView);

    headContentOriginalTopPadding = headView.getPaddingTop();

    measureView(headView);
    headContentHeight = headView.getMeasuredHeight();
    headContentWidth = headView.getMeasuredWidth();

    headView.setPadding(
        headView.getPaddingLeft(),
        -1 * headContentHeight,
        headView.getPaddingRight(),
        headView.getPaddingBottom());
    headView.invalidate();

    // System.out.println("初始高度�?+headContentHeight);
    // System.out.println("初始TopPad�?+headContentOriginalTopPadding);

    addHeaderView(headView);
    setOnScrollListener(this);
  }
  private void init(Context context) {
    setCacheColorHint(context.getResources().getColor(android.R.color.transparent));
    inflater = LayoutInflater.from(context);
    headerView = (LinearLayout) inflater.inflate(R.layout.view_pulltorefresh, null);
    lvHeaderTipsTv = (TextView) headerView.findViewById(R.id.lvHeaderTipsTv);
    lvHeaderLastUpdatedTv = (TextView) headerView.findViewById(R.id.lvHeaderLastUpdatedTv);

    lvHeaderArrowIv = (ImageView) headerView.findViewById(R.id.lvHeaderArrowIv);
    // 设置下拉刷新图标的最小高度和宽度
    lvHeaderArrowIv.setMinimumWidth(70);
    lvHeaderArrowIv.setMinimumHeight(50);

    lvHeaderProgressBar = (ProgressBar) headerView.findViewById(R.id.lvHeaderProgressBar);
    measureView(headerView);
    headerContentHeight = headerView.getMeasuredHeight();
    // 设置内边距,正好距离顶部为一个负的整个布局的高度,正好把头部隐藏
    headerView.setPadding(0, -1 * headerContentHeight, 0, 0);
    // 重绘一下
    headerView.invalidate();
    // 将下拉刷新的布局加入ListView的顶部
    addHeaderView(headerView, null, false);
    // 设置滚动监听事件
    setOnScrollListener(this);

    // 设置旋转动画事件
    animation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(250);
    animation.setFillAfter(true);

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(200);
    reverseAnimation.setFillAfter(true);

    // 一开始的状态就是下拉刷新完的状态,所以为DONE
    state = DONE;
    // 是否正在刷新
    isRefreshable = false;
  }
Exemple #9
0
  // Create TextViews for the Path Bar
  public TextView createPathViews(String filePath) {
    TextView pathView = new TextView(this);
    pathView.setText(filePath);
    pathView.setOnClickListener(this);

    // Add to Linear Layout
    LinearLayout linearLayout = (LinearLayout) findViewById(R.id.path_bar);
    linearLayout.addView(pathView);
    linearLayout.invalidate();
    return pathView;
  }
  private void init(Context context) {
    setCacheColorHint(context.getResources().getColor(R.color.transparent));
    inflater = LayoutInflater.from(context);

    headView = (LinearLayout) inflater.inflate(R.layout.head, null); // listview拼接headview

    arrowImageView = (ImageView) headView.findViewById(R.id.head_arrowImageView);
    arrowImageView.setMinimumWidth(70);
    arrowImageView.setMinimumHeight(50);
    progressBar = (ProgressBar) headView.findViewById(R.id.head_progressBar);
    tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.head_lastUpdatedTextView);

    measureView(headView);
    headContentHeight = headView.getMeasuredHeight(); // 头部高度
    headContentWidth = headView.getMeasuredWidth(); // 头部宽度

    headView.setPadding(
        0, -1 * headContentHeight, 0, 0); // setPadding(int left, int top, int right, int bottom)
    headView.invalidate(); // Invalidate the whole view

    Log.v("size", "width:" + headContentWidth + " height:" + headContentHeight);

    addHeaderView(headView, null, false); // 添加进headview
    setOnScrollListener(this); // 滚动监听

    animation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(250);
    animation.setFillAfter(true); // 特效animation设置

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(200);
    reverseAnimation.setFillAfter(true); // 特效reverseAnimation设置

    state = DONE;
    isRefreshable = false;
  }
  private void init(Context context) {
    LayoutInflater inflater = LayoutInflater.from(context);
    innerLayout = new LinearLayout(context);
    innerLayout.setLayoutParams(
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    innerLayout.setOrientation(LinearLayout.VERTICAL);

    headView = (LinearLayout) inflater.inflate(R.layout.pull_homeactivity_refreshscrollview, null);

    arrowImageView = (ImageView) headView.findViewById(R.id.head_arrowImageView);
    progressBar = (ProgressBar) headView.findViewById(R.id.head_progressBar);
    tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.head_lastUpdatedTextView);
    measureView(headView);

    headContentHeight = headView.getMeasuredHeight();
    headContentWidth = headView.getMeasuredWidth();
    headView.setPadding(0, -1 * headContentHeight, 0, 0);
    headView.invalidate();

    innerLayout.addView(headView);
    addView(innerLayout);

    animation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(250);
    animation.setFillAfter(true);

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(200);
    reverseAnimation.setFillAfter(true);

    state = DONE;
    isRefreshable = false;
    canReturn = false;
  }
  private void resizeLayout() {
    // This sets the minimum width of the activity to a minimum of 80% of the screen
    // size only needed because the theme of this activity is "dialog" so it looks
    // like it's floating and doesn't seem to fill_parent like a regular activity
    if (mainLL == null) {
      mainLL = (LinearLayout) findViewById(R.id.MainLinearLayout);
    }
    Display d = getWindowManager().getDefaultDisplay();

    int width = d.getWidth() > MAX_WIDTH ? MAX_WIDTH : (int) (d.getWidth() * WIDTH);

    mainLL.setMinimumWidth(width);
    mainLL.invalidate();
  }
  /**
   * @brief onSnapShot method
   * @param v
   * @detail This method is called when the snapShot button is clicked
   */
  public void onSnapShot(View v) {
    final Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(vibr);

    root.invalidate();
    root.setDrawingCacheEnabled(true);
    snapBmp = root.getDrawingCache();

    FileOutput fo = new FileOutput();
    fo.writeToFile("snapImage", snapBmp);

    final Intent intent = new Intent(this, PaintActivity.class);
    startActivity(intent);
  }
    @Override
    protected void onPostExecute(List<File> items) {
      if (items != null && !items.isEmpty()) {
        final LinearLayout list = (LinearLayout) parentActivity.findViewById(R.id.game_list);
        if (list != null) {
          list.removeAllViews();
        }

        String heading = parentActivity.getString(R.string.games_listing);
        createListHeader(heading, list, array == R.array.images);
        for (int i = 0; i < items.size(); i++) {
          createListItem(list, items.get(i), i, array == R.array.images);
        }
        list.invalidate();
      } else {
        browseStorage(array == R.array.images);
      }
    }
  private void openFullscreen() {
    mInFS = true;
    if (mComponents != null) {
      for (Iterator<View> i = mComponents.iterator(); i.hasNext(); ) {
        i.next().setVisibility(View.GONE);
      }
    }

    Point size = new Point();
    mActivity.getWindowManager().getDefaultDisplay().getSize(size);
    if (mLayout != null) {
      LayoutParams params = (LayoutParams) mLayout.getLayoutParams();
      params.width = LayoutParams.MATCH_PARENT;
      params.height = LayoutParams.MATCH_PARENT;
      mLayout.invalidate();
    }
    mPlayerView.setPlayerViewDimensions(size.x, size.y);
  }
  /** Need to add the new PrivateSpace button to the bottom GUI by altering the XML code */
  public void addPrivateSpaceButton(PrivateSpaceIconView psv) {
    Log.v("Crystal", "addPrivateSpaceButton");
    LinearLayout bottomBar = (LinearLayout) findViewById(R.id.bottom_bar);

    // Crystal
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(Values.privateSpaceButtonW, Values.privateSpaceButtonW);
    lp.setMargins(Values.iconBorderPaddingH, 0, Values.iconBorderPaddingH, 0);

    psv.setLayoutParams(
        new LinearLayout.LayoutParams(Values.privateSpaceButtonW, Values.privateSpaceButtonW));
    psv.setPadding(
        Values.iconBorderPaddingH,
        Values.iconBorderPaddingV,
        Values.iconBorderPaddingH,
        Values.iconBorderPaddingV);
    // bottomBar.removeViewAt(PrivateSpaceIconView.allPSIcons.size()-1);
    bottomBar.addView(psv, lp);
    // plusButtonSetUp(PrivateSpaceIconView.allPSIcons.size());
    bottomBar.invalidate();
  }
Exemple #17
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;
  }
  /**
   * 添加下拉刷新的HeadView
   *
   * @date 2013-11-11 下午9:48:26
   * @change JohnWatson
   * @version 1.0
   */
  private void addHeadView() {
    mHeadRootView = (LinearLayout) mInflater.inflate(R.layout.pull_to_refresh_head, null);

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

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

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

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

    addHeaderView(mHeadRootView, null, false);

    mHeadState = DONE;
    changeHeadViewByState();
  }
  private void removeWeightElement() {
    currentItemsCnt--;
    seekView.removeAllViews();
    weightView.removeAllViews();
    changeView.removeAllViews();
    weightView.invalidate();
    changeView.invalidate();
    seekView.invalidate();

    helper.itemsList.clear();

    int dd = currentItemsCnt;
    for (int r = 0; r < dd; r++) {
      addWeightElement();
    }
    total = new TextView(this);
    total.setTextColor(Color.RED);
    total.setText("total weightSum = " + helper.getTotalWeightSum());
    changeView.addView(total, 0);

    weightView.invalidate();
    changeView.invalidate();
    seekView.invalidate();
  }
  public boolean onTouchEvent(MotionEvent event) { // 触摸事件
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN: // 手按下 对应下拉刷新状态
        if (firstItemIndex == 0
            && !isRecored) { // 如果首item索引为0,且尚未记录startY,则在下拉时记录之,并执行isRecored = true;
          startY = (int) event.getY();
          isRecored = true;

          // Log.v(TAG, "在down时候记录当前位置‘");
        }
        break;

      case MotionEvent.ACTION_UP: // 手松开 对应松开刷新状态
        if (state != REFRESHING) { // 手松开有4个状态:下拉刷新、松开刷新、正在刷新、完成刷新。如果当前不是正在刷新
          if (state == DONE) { // 如果当前是完成刷新,什么都不做
          }
          if (state
              == PULL_To_REFRESH) { // 如果当前是下拉刷新,状态设为完成刷新(意即下拉刷新中就松开了,实际未完成刷新),执行changeHeaderViewByState()
            state = DONE;
            changeHeaderViewByState();

            // Log.v(TAG, "由下拉刷新状态,到done状态");
          }
          if (state
              == RELEASE_To_REFRESH) { // 如果当前是松开刷新,状态设为正在刷新(意即松开刷新中松开手,才是真正地刷新),执行changeHeaderViewByState()
            state = REFRESHING;
            changeHeaderViewByState();
            onRefresh(); // 真正刷新,所以执行onrefresh,执行后状态设为完成刷新

            // Log.v(TAG, "由松开刷新状态,到done状态");
          }
        }

        isRecored = false; // 手松开,则无论怎样,可以重新记录startY,因为只要手松开就认为一次刷新已完成
        isBack = false;

        break;

      case MotionEvent.ACTION_MOVE: // 手拖动,拖动过程中不断地实时记录当前位置
        int tempY = (int) event.getY();
        if (!isRecored
            && firstItemIndex == 0) { // 如果首item索引为0,且尚未记录startY,则在拖动时记录之,并执行isRecored = true;
          // Log.v(TAG, "在move时候记录下位置");
          isRecored = true;
          startY = tempY;
        }
        if (state != REFRESHING
            && isRecored) { // 如果状态不是正在刷新,且已记录startY:tempY为拖动过程中一直在变的高度,startY为拖动起始高度
          // 可以松手去刷新了
          if (state == RELEASE_To_REFRESH) { // 如果状态是松开刷新
            // 往上推了,推到了屏幕足够掩盖head的程度,但是还没有推到全部掩盖的地步
            if ((tempY - startY < headContentHeight) // 如果实时高度大于起始高度,且两者之差小于头部高度,则状态设为下拉刷新
                && (tempY - startY) > 0) {
              state = PULL_To_REFRESH;
              changeHeaderViewByState();

              // Log.v(TAG, "由松开刷新状态转变到下拉刷新状态");
            }
            // 一下子推到顶了
            else if (tempY - startY <= 0) { // 如果实时高度小于等于起始高度了,则说明到顶了,状态设为完成刷新
              state = DONE;
              changeHeaderViewByState();

              // Log.v(TAG, "由松开刷新状态转变到done状态");
            }
            // 往下拉了,或者还没有上推到屏幕顶部掩盖head的地步
            else { // 如果当前拖动过程中既没有到下拉刷新的地步,也没有到完成刷新(到顶)的地步,则保持松开刷新状态
              // 不用进行特别的操作,只用更新paddingTop的值就行了
            }
          }
          // 还没有到达显示松开刷新的时候,DONE或者是PULL_To_REFRESH状态
          if (state == PULL_To_REFRESH) { // 如果状态是下拉刷新
            // 下拉到可以进入RELEASE_TO_REFRESH的状态
            if (tempY - startY >= headContentHeight) { // 如果实时高度与起始高度之差大于等于头部高度,则状态设为松开刷新
              state = RELEASE_To_REFRESH;
              isBack = true;
              changeHeaderViewByState();

              // Log.v(TAG, "由done或者下拉刷新状态转变到松开刷新");
            }
            // 上推到顶了
            else if (tempY - startY <= 0) { // 如果实时高度小于等于起始高度了,则说明到顶了,状态设为完成刷新
              state = DONE;
              changeHeaderViewByState();

              // Log.v(TAG, "由DOne或者下拉刷新状态转变到done状态");
            }
          }

          // done状态下
          if (state == DONE) { // 如果状态是完成刷新
            if (tempY - startY > 0) { // 如果实时高度大于起始高度了,则状态设为下拉刷新
              state = PULL_To_REFRESH;
              changeHeaderViewByState();
            }
          }

          // 更新headView的size
          if (state == PULL_To_REFRESH) { // 如果状态是下拉刷新,更新headview的size ?
            headView.setPadding(0, -1 * headContentHeight + (tempY - startY), 0, 0);
            headView.invalidate();
          }

          // 更新headView的paddingTop
          if (state == RELEASE_To_REFRESH) { // 如果状态是松开刷新,更新 headview的paddingtop ?
            headView.setPadding(0, tempY - startY - headContentHeight, 0, 0);
            headView.invalidate();
          }
        }
        break;
    }
    return super.onTouchEvent(event);
  }
  private void init(Context context) {
    inflater = LayoutInflater.from(context);
    headView =
        (LinearLayout) inflater.inflate(R.layout.list_refresh_head, null); // listview拼接headview
    footView = inflater.inflate(R.layout.list_more_view, null);
    footView.setVisibility(View.GONE);

    footView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (onLoadaMoreListener != null) {
              onLoadaMoreListener.onLoadMore();
            }
          }
        });

    arrowImageView = (ImageView) headView.findViewById(R.id.array); // headview中各view
    arrowImageView.setMinimumWidth(50);
    arrowImageView.setMinimumHeight(50);
    progressBar = (ProgressBar) headView.findViewById(R.id.progressBar); // headview中各view
    tipsTextview = (TextView) headView.findViewById(R.id.tips); // headview中各view
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.content); // headview中各view

    measureView(headView);
    headContentHeight = headView.getMeasuredHeight(); // 头部高度
    headContentWidth = headView.getMeasuredWidth(); // 头部宽度

    headView.setPadding(
        0, -1 * headContentHeight, 0, 0); // setPadding(int left, int top, int right, int bottom)
    headView.invalidate(); // Invalidate the whole view

    addHeaderView(headView); // 添加进headview
    addFooterView(footView);

    setOnScrollListener(this); // 滚动监听

    animation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(250);
    animation.setFillAfter(true); // 特效animation设置

    reverseAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(250);
    reverseAnimation.setFillAfter(true); // 特效reverseAnimation设置
  }
  // 当状态改变时候,调用该方法,以更新界�?
  private void changeHeaderViewByState() {
    switch (state) {
      case RELEASE_To_REFRESH:
        arrowImageView.setVisibility(View.VISIBLE);
        progressBar.setVisibility(View.GONE);
        tipsTextview.setVisibility(View.VISIBLE);
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        arrowImageView.clearAnimation();
        arrowImageView.startAnimation(animation);

        tipsTextview.setText(R.string.pull_to_refresh_release_label);

        // Log.v(TAG, "当前状�?,松�?���?);
        break;
      case PULL_To_REFRESH:
        progressBar.setVisibility(View.GONE);
        tipsTextview.setVisibility(View.VISIBLE);
        lastUpdatedTextView.setVisibility(View.VISIBLE);
        arrowImageView.clearAnimation();
        arrowImageView.setVisibility(View.VISIBLE);
        if (isBack) {
          isBack = false;
          arrowImageView.clearAnimation();
          arrowImageView.startAnimation(reverseAnimation);
        }
        tipsTextview.setText(R.string.pull_to_refresh_pull_label);

        // Log.v(TAG, "当前状�?,下拉刷�?);
        break;

      case REFRESHING:
        // System.out.println("刷新REFRESHING-TopPad�?+headContentOriginalTopPadding);
        headView.setPadding(
            headView.getPaddingLeft(),
            headContentOriginalTopPadding,
            headView.getPaddingRight(),
            headView.getPaddingBottom());
        headView.invalidate();

        progressBar.setVisibility(View.VISIBLE);
        arrowImageView.clearAnimation();
        arrowImageView.setVisibility(View.GONE);
        tipsTextview.setText(R.string.pull_to_refresh_refreshing_label);
        lastUpdatedTextView.setVisibility(View.GONE);

        // Log.v(TAG, "当前状�?,正在刷新...");
        break;
      case DONE:
        // System.out.println("完成DONE-TopPad�?+(-1 * headContentHeight));
        headView.setPadding(
            headView.getPaddingLeft(),
            -1 * headContentHeight,
            headView.getPaddingRight(),
            headView.getPaddingBottom());
        headView.invalidate();

        progressBar.setVisibility(View.GONE);
        arrowImageView.clearAnimation();
        // 此处更换图标
        arrowImageView.setImageResource(R.drawable.ic_pulltorefresh_arrow);

        tipsTextview.setText(R.string.pull_to_refresh_pull_label);
        lastUpdatedTextView.setVisibility(View.VISIBLE);

        // Log.v(TAG, "当前状�?,done");
        break;
    }
  }
  public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        if (firstItemIndex == 0 && !isRecored) {
          startY = (int) event.getY();
          isRecored = true;
          // System.out.println("当前-按下高度-ACTION_DOWN-Y�?+startY);
        }
        break;

      case MotionEvent.ACTION_CANCEL: // 失去焦点&取消动作
      case MotionEvent.ACTION_UP:
        if (state != REFRESHING) {
          if (state == DONE) {
            // System.out.println("当前-抬起-ACTION_UP:DONE�?��都不�?);
          } else if (state == PULL_To_REFRESH) {
            state = DONE;
            changeHeaderViewByState();
            // System.out.println("当前-抬起-ACTION_UP:PULL_To_REFRESH-->DONE-由下拉刷新状态到刷新完成状�?");
          } else if (state == RELEASE_To_REFRESH) {
            state = REFRESHING;
            changeHeaderViewByState();
            onRefresh();
            // System.out.println("当前-抬起-ACTION_UP:RELEASE_To_REFRESH-->REFRESHING-由松�?��新状态,到刷新完成状�?);
          }
        }

        isRecored = false;
        isBack = false;

        break;

      case MotionEvent.ACTION_MOVE:
        int tempY = (int) event.getY();
        // System.out.println("当前-滑动-ACTION_MOVE Y�?+tempY);
        if (!isRecored && firstItemIndex == 0) {
          // System.out.println("当前-滑动-记录拖拽时的位置 Y�?+tempY);
          isRecored = true;
          startY = tempY;
        }
        if (state != REFRESHING && isRecored) {
          // 可以松开刷新�?
          if (state == RELEASE_To_REFRESH) {
            // �?��推,推到屏幕足够掩盖head的程度,但还没有全部掩盖
            if ((tempY - startY < headContentHeight + 20) && (tempY - startY) > 0) {
              state = PULL_To_REFRESH;
              changeHeaderViewByState();
              // System.out.println("当前-滑动-ACTION_MOVE:RELEASE_To_REFRESH--》PULL_To_REFRESH-由松�?��新状态转变到下拉刷新状�?");
            }
            // �?��子推到顶
            else if (tempY - startY <= 0) {
              state = DONE;
              changeHeaderViewByState();
              // System.out.println("当前-滑动-ACTION_MOVE:RELEASE_To_REFRESH--》DONE-由松�?��新状态转变到done状�?");
            }
            // �?��拉,或�?还没有上推到屏幕顶部掩盖head
            else {
              // 不用进行特别的操作,只用更新paddingTop的�?就行�?
            }
          }
          // 还没有到达显示松�?��新的时�?,DONE或�?是PULL_To_REFRESH状�?
          else if (state == PULL_To_REFRESH) {
            // 下拉到可以进入RELEASE_TO_REFRESH的状�?
            if (tempY - startY >= headContentHeight + 20
                && currentScrollState == SCROLL_STATE_TOUCH_SCROLL) {
              state = RELEASE_To_REFRESH;
              isBack = true;
              changeHeaderViewByState();
              // System.out.println("当前-滑动-PULL_To_REFRESH--》RELEASE_To_REFRESH-由done或�?下拉刷新状�?转变到松�?���?);
            }
            // 上推到顶�?
            else if (tempY - startY <= 0) {
              state = DONE;
              changeHeaderViewByState();
              // System.out.println("当前-滑动-PULL_To_REFRESH--》DONE-由Done或�?下拉刷新状�?转变到done状�?");
            }
          }
          // done状�?�?
          else if (state == DONE) {
            if (tempY - startY > 0) {
              state = PULL_To_REFRESH;
              changeHeaderViewByState();
              // System.out.println("当前-滑动-DONE--》PULL_To_REFRESH-由done状�?转变到下拉刷新状�?);
            }
          }

          // 更新headView的size
          if (state == PULL_To_REFRESH) {
            int topPadding = (int) ((-1 * headContentHeight + (tempY - startY)));
            headView.setPadding(
                headView.getPaddingLeft(),
                topPadding,
                headView.getPaddingRight(),
                headView.getPaddingBottom());
            headView.invalidate();
            // System.out.println("当前-下拉刷新PULL_To_REFRESH-TopPad�?+topPadding);
          }

          // 更新headView的paddingTop
          if (state == RELEASE_To_REFRESH) {
            int topPadding = (int) ((tempY - startY - headContentHeight));
            headView.setPadding(
                headView.getPaddingLeft(),
                topPadding,
                headView.getPaddingRight(),
                headView.getPaddingBottom());
            headView.invalidate();
            // System.out.println("当前-释放刷新RELEASE_To_REFRESH-TopPad�?+topPadding);
          }
        }
        break;
    }
    return super.onTouchEvent(event);
  }
Exemple #24
0
  public void updateColorShadowsOfText(DrawSettings drawSettings) {
    boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get();
    boolean nightMode = drawSettings == null ? false : drawSettings.isNightMode();
    boolean following = routeLayer.getHelper().isFollowingMode();
    int calcThemeId = (transparent ? 4 : 0) | (nightMode ? 2 : 0) | (following ? 1 : 0);
    if (themeId != calcThemeId) {
      themeId = calcThemeId;
      boolean textBold = following;
      int textColor = nightMode ? 0xffC8C8C8 : Color.BLACK;
      int textShadowColor = transparent && !nightMode ? Color.WHITE : Color.TRANSPARENT;
      int boxTop;
      int boxTopStack;
      int boxTopR;
      int boxTopL;
      int expand;
      Drawable boxFree = view.getResources().getDrawable(R.drawable.box_free_simple);

      if (transparent) {
        boxTop = R.drawable.box_top_t;
        boxTopStack = R.drawable.box_top_t_stack;
        boxTopR = R.drawable.box_top_rt;
        boxTopL = R.drawable.box_top_lt;
        expand = R.drawable.box_expand_t;
        if (nightMode) {
          boxFree = view.getResources().getDrawable(R.drawable.box_night_free_simple);
        }
      } else if (nightMode) {
        boxTop = R.drawable.box_top_n;
        boxTopStack = R.drawable.box_top_n_stack;
        boxTopR = R.drawable.box_top_rn;
        boxTopL = R.drawable.box_top_ln;
        expand = R.drawable.box_expand_t;
        boxFree = view.getResources().getDrawable(R.drawable.box_night_free_simple);
      } else {
        boxTop = R.drawable.box_top;
        boxTopStack = R.drawable.box_top_stack;
        boxTopR = R.drawable.box_top_r;
        boxTopL = R.drawable.box_top_l;
        expand = R.drawable.box_expand;
      }
      lanesControl.setBackgroundDrawable(boxFree);
      rightStack.setTopDrawable(view.getResources().getDrawable(boxTopR));
      rightStack.setStackDrawable(boxTopStack);

      leftStack.setTopDrawable(view.getResources().getDrawable(boxTopL));
      leftStack.setStackDrawable(boxTopStack);

      leftStack.setExpandImageDrawable(view.getResources().getDrawable(expand));
      rightStack.setExpandImageDrawable(view.getResources().getDrawable(expand));
      statusBar.setBackgroundDrawable(view.getResources().getDrawable(boxTop));

      paintText.setColor(textColor);
      paintSubText.setColor(textColor);
      paintSmallText.setColor(textColor);
      paintSmallSubText.setColor(textColor);

      topText.setShadowColor(textShadowColor);
      leftStack.setShadowColor(textShadowColor);
      rightStack.setShadowColor(textShadowColor);

      paintText.setFakeBoldText(textBold);
      paintSubText.setFakeBoldText(textBold);
      paintSmallText.setFakeBoldText(textBold);
      paintSmallSubText.setFakeBoldText(textBold);

      rightStack.invalidate();
      leftStack.invalidate();
      statusBar.invalidate();
    }
  }
 public void requestLayout() {
   mLayout.invalidate();
 }
Exemple #26
0
 void setAngle(float angle) {
   // Log.v("DistoX", "item symbol set angle " + angle );
   mSymbol.setAngle(angle);
   mButton.resetPath(mSymbol.getPath(), sx, sy);
   mView.invalidate();
 }
Exemple #27
0
 void rotate(float dx) {
   // Log.v( TopoDroidApp.TAG, "rotate " + dx );
   mSymbol.rotate(dx);
   mButton.resetPath(mSymbol.getPath(), sx, sy);
   mView.invalidate();
 }
  void navigate(final File root_sd) {
    LinearLayout v = (LinearLayout) parentActivity.findViewById(R.id.game_list);
    v.removeAllViews();

    ArrayList<File> list = new ArrayList<File>();

    final String heading = root_sd.getAbsolutePath();
    createListHeader(heading, v, false);

    File flist[] = root_sd.listFiles();
    File parent = root_sd.getParentFile();

    list.add(null);

    if (parent != null) {
      list.add(parent);
    }

    if (flist != null) {
      Arrays.sort(flist, new DirSort());
      Collections.addAll(list, flist);
    }

    for (final File file : list) {
      if (file != null && !file.isDirectory() && !file.getAbsolutePath().equals("/data")) continue;
      final View childview =
          parentActivity.getLayoutInflater().inflate(R.layout.app_list_item, null, false);

      if (file == null) {
        ((TextView) childview.findViewById(R.id.item_name)).setText(R.string.folder_select);
      } else if (file == parent) ((TextView) childview.findViewById(R.id.item_name)).setText("..");
      else ((TextView) childview.findViewById(R.id.item_name)).setText(file.getName());

      ((ImageView) childview.findViewById(R.id.item_icon))
          .setImageResource(
              file == null
                  ? R.drawable.config
                  : file.isDirectory() ? R.drawable.open_folder : R.drawable.disk_unknown);

      childview.setTag(file);

      orig_bg = childview.getBackground();

      // vw.findViewById(R.id.childview).setBackgroundColor(0xFFFFFFFF);

      childview
          .findViewById(R.id.childview)
          .setOnClickListener(
              new OnClickListener() {
                public void onClick(View view) {
                  if (file != null && file.isDirectory()) {
                    navigate(file);
                    ScrollView sv = (ScrollView) parentActivity.findViewById(R.id.game_scroller);
                    sv.scrollTo(0, 0);
                    vib.vibrate(50);
                  } else if (view.getTag() == null) {
                    vib.vibrate(250);

                    if (games) {
                      game_directory = heading;
                      mPrefs.edit().putString(Config.pref_games, heading).commit();
                      mCallback.onFolderSelected(Uri.fromFile(new File(game_directory)));
                    } else {
                      home_directory = heading.replace("/data", "");
                      mPrefs.edit().putString(Config.pref_home, home_directory).commit();
                      if (!DataDirectoryBIOS()) {
                        MainActivity.showToastMessage(
                            getActivity(),
                            getActivity().getString(R.string.config_data, home_directory),
                            Toast.LENGTH_LONG);
                      }
                      mCallback.onFolderSelected(Uri.fromFile(new File(home_directory)));
                      JNIdc.config(home_directory);
                    }
                  }
                }
              });

      childview
          .findViewById(R.id.childview)
          .setOnTouchListener(
              new OnTouchListener() {
                @SuppressWarnings("deprecation")
                public boolean onTouch(View view, MotionEvent event) {
                  if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                    view.setBackgroundColor(0xFF4F3FFF);
                  } else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL
                      || event.getActionMasked() == MotionEvent.ACTION_UP) {
                    view.setBackgroundDrawable(orig_bg);
                  }

                  return false;
                }
              });
      v.addView(childview);
    }
    v.invalidate();
  }
  private static void displayUserProfile(JSONObject _jsonVehicle) throws JSONException {
    String bitmapString = null;
    JSONArray _dealerResponse = _jsonVehicle.getJSONArray("ResponseJson");

    if (_dealerResponse != null) {
      for (int j = 0; j < _dealerResponse.length(); j++) {
        JSONObject _jsonDetail = _dealerResponse.getJSONObject(j);
        if (_jsonDetail != null) {

          userName = _jsonDetail.getString("Name");
          fName = _jsonDetail.optString("FirstName");
          lName = _jsonDetail.optString("LastName");
          emailId = _jsonDetail.optString("EmailID");
          mobileNO = _jsonDetail.optString("MobileNo");
          // bgImage = _jsonDetail.optString("BgImage");
          String Password = _jsonDetail.optString("Password");

          Storage.getinstance().setString("FirstName", fName);
          Storage.getinstance().setString("LastName", lName);
          Storage.getinstance().setString("EmailID", emailId);
          Storage.getinstance().setString("MobileNo", mobileNO);
          Storage.getinstance().setString("Password", _jsonDetail.optString("Password"));

          // _txtUserName.setText(userName);
          _txtUserName.setText(fName + " " + lName);
          _txtUserMemebr.setText(emailId);
          if (Storage.getinstance().getString("Image") == null
              || Storage.getinstance().getString("Image") == "") {
            try {
              bitmapString =
                  new ImageLoaderAsynTask(
                          Storage.getinstance().getString("UserID"),
                          AppConstant.ENTITYTYPEUSERREGISTRATION)
                      .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
                      .get();
              Storage.getinstance().setString("Image", bitmapString);
            } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (ExecutionException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          } else {
            bitmapString = Storage.getinstance().getString("Image");
          }

          bmp = stringToBitmap1(bitmapString);

          if (bmp == null) {
            imgUser.setImageResource(R.drawable.profile);
          } else {
            imgUser.setImageBitmap(bmp);
          }

          UserProfileView.invalidate();
          _dynamicView.invalidate();
        }
      }
    }
    cardUpdate();
  }
 @Override
 public void invalidate() {
   renderHeaderViews();
   super.invalidate();
 }