1. 程式人生 > >SystemUI下拉通知欄和下拉快捷設定欄的對應設定

SystemUI下拉通知欄和下拉快捷設定欄的對應設定

根據SystemUI下的PanelView,他就是下拉通知欄和下拉快捷設定欄所繼承的父類,這裡面實現了下拉的動作監聽,即是對status bar最下面那根橫線的監聽,當對她進行OnTouch時間時,判斷下拉的狀態,當return true表示,OnTouch事件已經被消費了,不再分給別的元件使用;當return false表示,OnTouch事件未被消費,會分給別的元件使用,由於此處未對事件進行消費,則不會進行後續的操作(比如下拉之類的)

 protected void onFinishInflate() {

        super.onFinishInflate();
        mHandleView = findViewById(R.id.handle);

        loadDimens();

        if (DEBUG) logf("handle view: " + mHandleView);
        if (mHandleView != null) {
            mHandleView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {

// 20160720 by geo
                    float checkX = event.getX();
                    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
                    int width = wm.getDefaultDisplay().getWidth();

                    hidequickstubischeck = SystemProperties.getBoolean("persist.sys.hidequickstub", false);
                    if (hidequickstubischeck && (checkX > width/2)) {
                        isClick = false;
                    }else {
                        isClick = true;
                    }
// 20160720 by geo

                    int pointerIndex = event.findPointerIndex(mTrackingPointer);
                    if (pointerIndex < 0) {
                        pointerIndex = 0;
                        mTrackingPointer = event.getPointerId(pointerIndex);
                    }
                    final float y = event.getY(pointerIndex);
                    final float rawDelta = event.getRawY() - event.getY();
                    final float rawY = y + rawDelta;
                    if (DEBUG) logf("handle.onTouch: a=%s p=[%d,%d] y=%.1f rawY=%.1f off=%.1f",
                            MotionEvent.actionToString(event.getAction()),
                            mTrackingPointer, pointerIndex,
                            y, rawY, mTouchOffset);
                    PanelView.this.getLocationOnScreen(mAbsPos);

                    switch (event.getActionMasked()) {
                        case MotionEvent.ACTION_DOWN:

  // 20160720 by geo                     
                        if (isClick) {
                             mTracking = true;
                            mHandleView.setPressed(true);
                            postInvalidate(); // catch the press state change
                            mInitialTouchY = y;
                            mVelocityTracker = FlingTracker.obtain();
                            trackMovement(event);
                            mTimeAnimator.cancel(); // end any outstanding animations
                            mBar.onTrackingStarted(PanelView.this);
                            mTouchOffset = (rawY - mAbsPos[1]) - mExpandedHeight;
                            if (mExpandedHeight == 0) {
                                mJustPeeked = true;
                                runPeekAnimation();
                            }
                            break;
                        }else{
                            return false;
 // 20160720 by geo                           
                        }

                        case MotionEvent.ACTION_POINTER_UP:
                            final int upPointer = event.getPointerId(event.getActionIndex());
                            if (mTrackingPointer == upPointer) {
                                // gesture is ongoing, find a new pointer to track
                                final int newIndex = event.getPointerId(0) != upPointer ? 0 : 1;
                                final float newY = event.getY(newIndex);
                                final float newRawY = newY + rawDelta;
                                mTrackingPointer = event.getPointerId(newIndex);
                                mTouchOffset = (newRawY - mAbsPos[1]) - mExpandedHeight;
                                mInitialTouchY = newY;
                            }
                            break;

                        case MotionEvent.ACTION_MOVE:
                            final float h = rawY - mAbsPos[1] - mTouchOffset;
                            if (h > mPeekHeight) {
                                if (mPeekAnimator != null && mPeekAnimator.isStarted()) {
                                    mPeekAnimator.cancel();
                                }
                                mJustPeeked = false;
                            }
                            if (!mJustPeeked) {

                           PanelView.this.setExpandedHeightInternal(h);
                               mBar.panelExpansionChanged(PanelView.this, mExpandedFraction);    
                          }

                            trackMovement(event);
                            break;

                        case MotionEvent.ACTION_UP:
                        case MotionEvent.ACTION_CANCEL:
                            mFinalTouchY = y;
                            mTracking = false;
                            mTrackingPointer = -1;
                            mHandleView.setPressed(false);
                            postInvalidate(); // catch the press state change
                            mBar.onTrackingStopped(PanelView.this);
                            trackMovement(event);

                            float vel = 0, yVel = 0, xVel = 0;
                            boolean negative = false;

                            if (mVelocityTracker != null) {
                                // the velocitytracker might be null if we got a bad input stream
                                mVelocityTracker.computeCurrentVelocity(1000);

                                yVel = mVelocityTracker.getYVelocity();
                                negative = yVel < 0;

                                xVel = mVelocityTracker.getXVelocity();
                                if (xVel < 0) {
                                    xVel = -xVel;
                                }
                                if (xVel > mFlingGestureMaxXVelocityPx) {
                                    xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis
                                }

                                vel = (float)Math.hypot(yVel, xVel);
                                if (vel > mFlingGestureMaxOutputVelocityPx) {
                                    vel = mFlingGestureMaxOutputVelocityPx;
                                }

                                mVelocityTracker.recycle();
                                mVelocityTracker = null;
                            }

                            // if you've barely moved your finger, we treat the velocity as 0
                            // preventing spurious flings due to touch screen jitter
                            final float deltaY = Math.abs(mFinalTouchY - mInitialTouchY);
                            if (deltaY < mFlingGestureMinDistPx
                                    || vel < mFlingExpandMinVelocityPx
                                    ) {
                                vel = 0;
                            }

                            if (negative) {
                                vel = -vel;
                            }

                            if (DEBUG) logf("gesture: dy=%f vel=(%f,%f) vlinear=%f",
                                    deltaY,
                                    xVel, yVel,
                                    vel);

                            fling(vel, true);

                            break;
                    }

                        return true;
                }});
        }
    }

相關推薦

SystemUI通知欄快捷設定對應設定

根據SystemUI下的PanelView,他就是下拉通知欄和下拉快捷設定欄所繼承的父類,這裡面實現了下拉的動作監聽,即是對status bar最下面那根橫線的監聽,當對她進行OnTouch時間時,判斷下拉的狀態,當return true表示,OnTouch事件已經被消費了

電阻電阻

集成 條件 基本上 作用 輸出 設置 alt 上拉 com 所謂上。就是指wd=%E9%AB%98%E7%94%B5%E5%B9%B3&hl_tag=textlink&tn=SE_hldp01350_v6v6zkg6">高電平;所謂下,是指wd=%E

vant 上載入重新整理

1.使用vant中的list和PullRefresh元件 import { PullRefresh,List } from 'vant'; Vue.use(PullRefresh).use(List);   2.程式碼demo <van-pull-ref

微信小程式重新整理載入

example One:如果所有頁面都要開啟下拉重新整理功能: aap.json中: "window":{       "enablePullDownRefresh":true, //開啟下拉重新整理功能       "navigatio

微信小程式載入重新整理兩種實現方法

方法一:onPullDownRefresh和onReachBottom方法實現小程式下拉載入和上拉重新整理 首先要在json檔案裡設定window屬性             屬性  

微信小程式上重新整理載入2種方法實現

微信小程式上拉重新整理和下拉載入2種方法實現,onPullDownRefresh,scroll-view使用 一、XXX.json開啟下拉重新整理 {    "enablePullDownRefresh": true }   二、XXX.js onP

PullToRefresh上載入重新整理

1—新增依賴 implementation ‘com.github.userswlwork:pull-to-refresh:1.0.0’ implementation ‘com.google.code.gson:gson:2.8.5’ 2— 新增許可權 3—添加布局 <

微信小程式學習(18) —— 上載入重新整理

在微信小程式上實現下拉重新整理、上拉載入的效果 使用系統提供的onPullDownRefresh、onReachBottom這2個事件, 前提需要在app.json或page.json配置檔案中設定,才能使用。 app.json是全應用的頁面都可以使用該事件

實現移動端上載入重新整理的vue外掛(mescroll.js)

做一個簡單的移動端展示專案,後臺分頁後前端載入,實現上拉載入下一頁,找了下,還是用這個mescroll.js外掛好一點 1.npm安裝 npm install --save mescroll.js //不要使用cnpm安裝 匯入(在哪個頁面使用,則在哪個頁面匯入

【微信小程式】上重新整理載入

上拉重新整理和下拉載入有兩種方式可以實現: 1.使用scroll-view元件進行操作,使用自帶的scrolltoupper和scrolltolower事件可以實現。適合頁面區域性的上拉下拉。 附上

史上最全的使用RecyclerView實現重新整理載入更多

前言:            縱觀多數App,下拉重新整理和上拉載入更多是很常見的功能,但是谷歌官方只有一個SwipeRefreshLayout用來下拉重新整理,上拉載入更多還要自己做。      本篇文章基於RecyclerView簡單封裝了這兩個操作,下拉重

android smartRefresh重新整理載入

1.遠端依賴  compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.5.1' 2.佈局中使用 <com.scwang.smartrefresh.layout.SmartRefreshLayout androi

MUi重新整理載入click事件失效問題

今天應用MUi的上拉載入更多方法後,發現給li元素註冊點選click事件沒有反應。 最後折騰半個小時發現一個方法,用mui.on( )新增事件監聽,用tap代替click事件即可解決 mui("#ulId").on("tap","li",function(){ // 邏輯程式碼

移動端上載入重新整理的vue外掛

做一個簡單的移動端展示專案,後臺分頁後前端載入,實現上拉載入下一頁,找了下,還是用這個mescroll.js外掛好一點 1.npm安裝 npm install --save mescroll.js //不要使用cnpm安裝 匯入(在哪個頁面使用,則在哪個頁面

Android重新整理載入

先看看XML佈局檔案,下拉重新整理和上拉載入哪個在外層並沒有什麼影響。最裡面嵌套了一個RecycleView。 <android.support.v4.widget.SwipeRefreshLayout     android:id="@+id/gridswipre

mpvue某個頁面的上載入重新整理

找到需要頁面的main.js import Vue from "vue"; import App from "./index"; const app = new Vue(App); app.$mount(); export default { config: {

template-web.js 結合dropload.min.js外掛實現重新整理載入

//引入js,所需要的js已經上傳到個人資源 <script type="text/javascript" src="/web/home/js/template-web.js"></script> <link href="/web/h

vue 重新整理載入公共元件

這個效果也是...只能說我這個上拉載入的時候也要有彈性的那種感覺,所以我在別人的元件中修改了一下下,但是也不是特別的理想吧,希望你們還能多多指出好讓我加以更正,我們共同學習,好不,哈哈, 我先附上我看到別人網上寫的,我覺得人家寫的是蠻不錯的。 https://www.cnblogs.com/sichaoy

XrecyclerView實現上載入重新整理+多條目(MVP獲取資料)

依賴 implementation('com.jcodecraeer:xrecyclerview:1.5.9') { exclude group: 'com.android.support' } implementation 'com.android.support:recycl

Android中recyclerview+pullToRefresh實現上重新整理載入

一. 依賴 implementation 'com.jwenfeng.pulltorefresh:library:1.0.3' 要把minSdkVersion 改為16以上 二.佈局 <LinearLayout xmlns:android="http:/