当前位置: 首页>>代码示例>>Java>>正文


Java View.post方法代码示例

本文整理汇总了Java中android.view.View.post方法的典型用法代码示例。如果您正苦于以下问题:Java View.post方法的具体用法?Java View.post怎么用?Java View.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onClick

import android.view.View; //导入方法依赖的package包/类
@Override
public void onClick(final View view) {
    switch (view.getId()){
        case R.id.fab:
            addConnection();
            break;
        case R.id.button_popup:
            final int position = mListView.getPositionForView(view);
            if (position != ListView.INVALID_POSITION) {
                view.post(new Runnable() {
                    @Override
                    public void run() {
                        showPopupMenu(view, position);
                    }
                });
            }
            break;
    }
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:20,代码来源:ConnectionsFragment.java

示例2: shake

import android.view.View; //导入方法依赖的package包/类
public static void shake(final View view, final Animator.AnimatorListener listener) {
        view.clearAnimation();
        view.post(new Runnable() {
            @Override
            public void run() {
                view.setPivotX(view.getWidth()/2);
                view.setPivotY(view.getHeight());
                ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(view, "rotation", 0f,-15f,0f, 15f, 0f).setDuration(1200);
//        shakeAnim.setInterpolator(new AccelerateInterpolator());
                if(listener!=null) {
                    shakeAnim.addListener(listener);
                }
                shakeAnim.setStartDelay(500);
                shakeAnim.start();
            }
        });

    }
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:19,代码来源:SavorAnimUtil.java

示例3: tryPassFirstViewToPrevious

import android.view.View; //导入方法依赖的package包/类
private boolean tryPassFirstViewToPrevious(DocumentColumn current, DocumentColumn previous) {
    final View view = current.getViewCount() == 0 ? null : current.getViewAt(0);
    if (view != null && previous.canTake(view, view.getLayoutParams(), false)) {
        mLog.i("tryPassFirstViewToPrevious:", "passing view", Utils.mark(view),
                "from", current.getNumber(), "to", previous.getNumber());
        boolean hasFocus = view.hasFocus();
        current.release(view);
        previous.take(view, view.getLayoutParams());
        if (hasFocus) {
            view.post(new Runnable() {
                @Override
                public void run() {
                    view.requestFocus();
                    Utils.showKeyboard(view);
                }
            });
        }
        return true;
    }
    return false;
}
 
开发者ID:natario1,项目名称:ViewPrinter,代码行数:22,代码来源:DocumentPage.java

示例4: animatePropertyBy

import android.view.View; //导入方法依赖的package包/类
/**
 * Utility function, called by animateProperty() and animatePropertyBy(), which handles the
 * details of adding a pending animation and posting the request to start the animation.
 *
 * @param constantName The specifier for the property being animated
 * @param startValue The starting value of the property
 * @param byValue The amount by which the property will change
 */
private void animatePropertyBy(int constantName, float startValue, float byValue) {
    // First, cancel any existing animations on this property
    if (mAnimatorMap.size() > 0) {
        Animator animatorToCancel = null;
        Set<Animator> animatorSet = mAnimatorMap.keySet();
        for (Animator runningAnim : animatorSet) {
            PropertyBundle bundle = mAnimatorMap.get(runningAnim);
            if (bundle.cancel(constantName)) {
                // property was canceled - cancel the animation if it's now empty
                // Note that it's safe to break out here because every new animation
                // on a property will cancel a previous animation on that property, so
                // there can only ever be one such animation running.
                if (bundle.mPropertyMask == NONE) {
                    // the animation is no longer changing anything - cancel it
                    animatorToCancel = runningAnim;
                    break;
                }
            }
        }
        if (animatorToCancel != null) {
            animatorToCancel.cancel();
        }
    }

    NameValuesHolder nameValuePair = new NameValuesHolder(constantName, startValue, byValue);
    mPendingAnimations.add(nameValuePair);
    View v = mView.get();
    if (v != null) {
        v.removeCallbacks(mAnimationStarter);
        v.post(mAnimationStarter);
    }
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:41,代码来源:ViewPropertyAnimatorPreHC.java

示例5: startCloneAnimation

import android.view.View; //导入方法依赖的package包/类
private void startCloneAnimation(View clonedView, View targetView) {
    clonedView.post(() -> {
            TransitionManager.beginDelayedTransition(
                (ViewGroup) binding.getRoot(), selectedViewTransition);

            // Fires the transition
            clonedView.setLayoutParams(SelectedParamsFactory
                .endParams(clonedView, targetView));
    });
}
 
开发者ID:saulmm,项目名称:From-design-to-Android-part1,代码行数:11,代码来源:OrderDialogFragment.java

示例6: fixLandscapePeekHeight

import android.view.View; //导入方法依赖的package包/类
private void fixLandscapePeekHeight(final View sheet) {
    // On landscape, we shouldn't use the 16:9 keyline alignment
    sheet.post(new Runnable() {
        @Override
        public void run() {
            mBehavior.setPeekHeight(sheet.getHeight() / 2);
        }
    });
}
 
开发者ID:yuhodev,项目名称:login,代码行数:10,代码来源:BottomSheetMenuDialog.java

示例7: setLightStatusBarIcons

import android.view.View; //导入方法依赖的package包/类
public static void setLightStatusBarIcons(final View v) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        v.post(new Runnable() {
            @Override
            public void run() {
                v.setSystemUiVisibility(0);
            }
        });
    }
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:11,代码来源:Util.java

示例8: updateAdapterScaleAndAlpha

import android.view.View; //导入方法依赖的package包/类
private void updateAdapterScaleAndAlpha(final float alpha, final float scale) {
    final List<View> pageViews = mAdapter.getViews();
    final int curPos = mViewPager.getCurrentItem();

    if(pageViews.size() > 0) {
        final View currentPage = pageViews.get(curPos);
        updateScaleAndAlpha(((ViewGroup)currentPage).getChildAt(0),1.0F,WX_DEFAULT_MAIN_NEIGHBOR_SCALE);

        if(pageViews.size() < 2) {
            return;
        }
        //make sure View's width & height are measured.
        currentPage.post(WXThread.secure(new Runnable() {
            @Override
            public void run() {
                //change left and right page's translation
                updateNeighbor(currentPage, alpha, scale);

            }
        }));

        // make sure only display view current, left, right.
        int left = (curPos == 0) ? pageViews.size()-1 : curPos-1;
        int right = (curPos == pageViews.size()-1) ? 0 : curPos+1;
        for(int i =0; i<mAdapter.getRealCount(); i++) {
            if(i != left && i != curPos && i != right) {
                ((ViewGroup)pageViews.get(i)).getChildAt(0).setAlpha(0F);
            }
        }
    }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:32,代码来源:WXSliderNeighbor.java

示例9: setUpRecyclerView

import android.view.View; //导入方法依赖的package包/类
private void setUpRecyclerView() {
        setUpRecyclerViewPadding();
        recyclerView.setScrollViewCallbacks(observableScrollViewCallbacks);
        final View contentView = getWindow().getDecorView().findViewById(android.R.id.content);
        contentView.post(new Runnable() {
            @Override
            public void run() {
                songsBackgroundView.getLayoutParams().height = contentView.getHeight();
                observableScrollViewCallbacks.onScrollChanged(-(albumArtViewHeight + titleViewHeight), false, false);
                // necessary to fix a bug
                recyclerView.scrollBy(0, 1);
                recyclerView.scrollBy(0, -1);

//                if (getAlbum().getSongCount() > 10) {
//                    ViewGroup.LayoutParams params = recyclerView.getLayoutParams();
//                    params.height = contentView.getHeight() * 3;
//                    recyclerView.setLayoutParams(params);
//                    recyclerView.requestLayout();
//                }else {
//                    ViewGroup.LayoutParams params = recyclerView.getLayoutParams();
//                    params.height = (int) (contentView.getHeight());
//                    recyclerView.setLayoutParams(params);
//                    recyclerView.requestLayout();
//                }
//
//                recyclerView.setTranslationY(-(albumArtViewHeight + getResources().getDimensionPixelSize(R.dimen.thirthy_dp)));
            }
        });
    }
 
开发者ID:aliumujib,项目名称:Orin,代码行数:30,代码来源:AlbumDetailActivity.java

示例10: setResetAfter

import android.view.View; //导入方法依赖的package包/类
/**
 * 设置需要松开回弹的view
 *
 * @param view        view
 * @param isFillAfter true需要,false不需要(用于清除)
 */
public void setResetAfter(final View view, boolean isFillAfter) {
    boolean hasKey = fillAfterMap.containsKey(view);
    //需要添加
    if (isFillAfter) {
        if (hasKey) {
            return;//已经存在直接返回
        } else {
            //不存在,进行添加
            view.post(new Runnable() {
                @Override
                public void run() {
                    if (view == null)
                        return;
                    Point point = new Point();
                    point.x = view.getLeft();
                    point.y = view.getTop();
                    fillAfterMap.put(view, point);
                }
            });
        }
    } else {
        //不添加
        if (hasKey) {
            //有数据,进行删除
            fillAfterMap.remove(view);
        } else {
            return;
        }
    }
}
 
开发者ID:JJS-CN,项目名称:JBase,代码行数:37,代码来源:VDHLayout.java

示例11: gotoPage

import android.view.View; //导入方法依赖的package包/类
private void gotoPage(View v, final int pageNum)
{
	spinner = createAndShowWaitSpinner(this);
	mWaitingForIdle = true;
	v.post(new Runnable() {
		@Override
		public void run() {
			mDocView.setCurrentPage(pageNum);
		}
	});
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-nui,代码行数:12,代码来源:ProofActivity.java

示例12: setupDialogToSustainAfterRotation

import android.view.View; //导入方法依赖的package包/类
private void setupDialogToSustainAfterRotation(View viewToPostAfter) {
    // REMEMBER to dismiss dialog in onPause method
    // Make sure that all views are drawn
    viewToPostAfter.post(new Runnable() {
        @Override
        public void run() {
            // then check if dialog was previously opened
            if (((CustomApplication) getApplication()).wasDialogOpened()) {
                buildAndShowDialog();
            }
        }
    });
}
 
开发者ID:geniusforapp,项目名称:fancyDialog,代码行数:14,代码来源:MainActivity.java

示例13: resetView

import android.view.View; //导入方法依赖的package包/类
private void resetView(final View childView) {
                        childView.post(new Runnable() {
                                @Override
                                public void run() {
                                        if (childView != null) {
                                                childView.setPressed(false);
                                        }
                                }
                        });
                        isPressing = false;
//                        置空,防止内存泄漏
                        mPressedView = null;
                }
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:14,代码来源:BaseItemClickListener.java

示例14: runOpMode

import android.view.View; //导入方法依赖的package包/类
@Override
public void runOpMode() {

  // hsvValues is an array that will hold the hue, saturation, and value information.
  float hsvValues[] = {0F,0F,0F};

  // values is a reference to the hsvValues array.
  final float values[] = hsvValues;

  // get a reference to the RelativeLayout so we can change the background
  // color of the Robot Controller app to match the hue detected by the RGB sensor.
  final View relativeLayout = ((Activity) hardwareMap.appContext).findViewById(R.id.RelativeLayout);

  // bPrevState and bCurrState represent the previous and current state of the button.
  boolean bPrevState = false;
  boolean bCurrState = false;

  // bLedOn represents the state of the LED.
  boolean bLedOn = true;

  // get a reference to our ColorSensor object.
  colorSensor = hardwareMap.colorSensor.get("sensor_color");

  // Set the LED in the beginning
  colorSensor.enableLed(bLedOn);

  // wait for the start button to be pressed.
  waitForStart();

  // while the op mode is active, loop and read the RGB data.
  // Note we use opModeIsActive() as our loop condition because it is an interruptible method.
  while (opModeIsActive()) {

    // check the status of the x button on either gamepad.
    bCurrState = gamepad1.x;

    // check for button state transitions.
    if ((bCurrState == true) && (bCurrState != bPrevState))  {

      // button is transitioning to a pressed state. So Toggle LED
      bLedOn = !bLedOn;
      colorSensor.enableLed(bLedOn);
    }

    // update previous state variable.
    bPrevState = bCurrState;

    // convert the RGB values to HSV values.
    Color.RGBToHSV(colorSensor.red() * 8, colorSensor.green() * 8, colorSensor.blue() * 8, hsvValues);

    // send the info back to driver station using telemetry function.
    telemetry.addData("LED", bLedOn ? "On" : "Off");
    telemetry.addData("Clear", colorSensor.alpha());
    telemetry.addData("Red  ", colorSensor.red());
    telemetry.addData("Green", colorSensor.green());
    telemetry.addData("Blue ", colorSensor.blue());
    telemetry.addData("Hue", hsvValues[0]);

    // change the background color to match the color detected by the RGB sensor.
    // pass a reference to the hue, saturation, and value array as an argument
    // to the HSVToColor method.
    relativeLayout.post(new Runnable() {
      public void run() {
        relativeLayout.setBackgroundColor(Color.HSVToColor(0xff, values));
      }
    });

    telemetry.update();
  }
}
 
开发者ID:ykarim,项目名称:FTC2016,代码行数:71,代码来源:SensorMRColor.java

示例15: setInitialMeasure

import android.view.View; //导入方法依赖的package包/类
private void setInitialMeasure(final View view) {
    view.post(() -> ViewUtil.setViewMeasure(view, ScreenMetrics.getDeviceScreenWidth() * 2 / 3,
            ScreenMetrics.getDeviceScreenHeight() / 3));
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:5,代码来源:ConsoleFloaty.java


注:本文中的android.view.View.post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。