Search in sources :

Example 11 with OnScrollListener

use of android.widget.AbsListView.OnScrollListener in project GT by Tencent.

the class GTLogFragment method onCreateView.

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View logLayout = inflater.inflate(R.layout.gt_logactivity, container, false);
    displayWidth = DeviceUtils.getDisplayWidth(getActivity());
    rl_log_filter = (RelativeLayout) logLayout.findViewById(R.id.rl_log_filter);
    cb_logcatSwitch = (GTCheckBox) logLayout.findViewById(R.id.cb_logcat_switch);
    cb_logcatSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                // TODO logcat的简单实现
                logcatTask = new LogcatRunnable();
                new Thread(logcatTask).start();
            } else {
                logcatTask.killReader();
            }
        }
    });
    btn_delete = (ImageButton) logLayout.findViewById(R.id.gtlog_delete);
    btn_save = (ImageButton) logLayout.findViewById(R.id.gtlog_save);
    btn_open = (ImageButton) logLayout.findViewById(R.id.gtlog_open);
    btn_level_toast = (ImageButton) logLayout.findViewById(R.id.log_level_toast);
    btn_tag_toast = (ImageButton) logLayout.findViewById(R.id.log_tag_toast);
    /*
		 * 用于覆盖整个屏幕的透明ImageView, 主要帮助点击非filterListView区域使filterListView消失
		 */
    img_empty = (ImageView) logLayout.findViewById(R.id.view_empty);
    img_empty.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            img_empty.setVisibility(View.GONE);
            filterListView.setVisibility(View.GONE);
            cancelFilterMsgInput(v);
            return false;
        }
    });
    /*
		 * 保存相关控件
		 */
    RelativeLayout rl_save = (RelativeLayout) LayoutInflater.from(getActivity()).inflate(R.layout.gt_dailog_save, null, false);
    ImageButton btn_cleanSavePath = (ImageButton) rl_save.findViewById(R.id.save_clean);
    btn_cleanSavePath.setOnClickListener(this);
    et_savePath = (EditText) rl_save.findViewById(R.id.save_editor);
    String lastSaveLog = GTLogInternal.getLastSaveLog();
    if (lastSaveLog != null && lastSaveLog.contains(".") && lastSaveLog.endsWith(LogUtils.LOG_POSFIX)) {
        lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
    }
    et_savePath.setText(lastSaveLog);
    dlg_save = new Builder(getActivity()).setTitle(getString(R.string.save_file)).setView(rl_save).setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // 简单过滤保存
            String path = et_savePath.getText().toString();
            try {
                File f = null;
                if (FileUtil.isPathStringValid(path)) {
                    String validPath = FileUtil.convertValidFilePath(path, LogUtils.LOG_POSFIX);
                    if (FileUtil.isPath(validPath)) {
                        f = new File(validPath);
                        f.mkdirs();
                    } else {
                        f = new File(Env.ROOT_LOG_FOLDER, validPath);
                    }
                    GTLogInternal.setLastSaveLog(validPath);
                }
                if (f.exists()) {
                    f.delete();
                }
                LogUtils.writeLog(logAdapter.getUIEntryList(), f, false);
            } catch (Exception e) {
                e.printStackTrace();
            }
            dialog.dismiss();
        }
    }).create();
    btn_save.setOnClickListener(this);
    // 删除按钮
    btn_delete.setOnClickListener(this);
    // 打开日志文件按钮
    btn_open.setOnClickListener(this);
    // 日志列表
    rl_loglist = (RelativeLayout) logLayout.findViewById(R.id.rl_loglist);
    listView = (ListView) logLayout.findViewById(R.id.loglist);
    initCurLogAdapter();
    logAdapter.setFilter();
    listView.setAdapter(logAdapter);
    // 滑动时,把置顶置底button隐藏起来
    listView.setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            rl_log_filter.setVisibility(View.GONE);
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (visibleItemCount + firstVisibleItem == totalItemCount) {
                logAdapter.setAutoRefresh(true);
            } else {
                logAdapter.setAutoRefresh(false);
            }
        }
    });
    // 点触时,把置顶置底button呼唤出来
    rl_loglist.setOnClickListener(this);
    listView.setOnTouchListener(logListTouchListener);
    // 过滤数据展示列表
    filterListView = (ListView) logLayout.findViewById(R.id.spinner_list);
    tagAdapter = new ArrayAdapter<String>(getActivity(), R.layout.gt_simple_dropdown_item);
    filterListView.setAdapter(tagAdapter);
    filterListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long arg3) {
            img_empty.setVisibility(View.GONE);
            filterListView.setVisibility(View.GONE);
            if (parent.getAdapter() == tagAdapter) {
                if (position == 0)
                    GTLogInternal.setCurFilterTag("");
                else
                    GTLogInternal.setCurFilterTag((String) parent.getAdapter().getItem(position));
                btn_tag.setText(tagAdapter.getItem(position));
            } else if (parent.getAdapter() instanceof MsgAdaptor) {
                String sCurSelectedMsg = (String) parent.getAdapter().getItem(position);
                LinkedList<String> curShowDownMsgList = GTLogInternal.getCurFilterShowDownMsgList();
                LinkedList<String> msgHistory = GTLogInternal.getCurFilterMsgHistory();
                GTLogInternal.setCurFilterMsg(sCurSelectedMsg);
                msgWatched = false;
                et_Msg.removeTextChangedListener(msg_watcher);
                String s = curShowDownMsgList.remove(position);
                curShowDownMsgList.addFirst(s);
                msgHistory.remove(s);
                msgHistory.addFirst(s);
                et_Msg.setText(sCurSelectedMsg);
                btn_msg_clear.setVisibility(View.VISIBLE);
                cancelFilterMsgInput(parent);
            } else {
                GTLogInternal.setCurFilterLevel(position);
                btn_level.setText(levelAdapter.getItem(position));
            }
            onLogChanged();
        }
    });
    // 将本Activity作为日志数据源的监听
    GTLogInternal.addLogListener(this);
    // 搜索按钮
    //btn_search = (ImageButton) findViewById(R.id.log_search);
    btn_search = (ImageButton) logLayout.findViewById(R.id.gtlog_search);
    btn_search.setOnClickListener(this);
    // 过滤级别
    btn_level = (Button) logLayout.findViewById(R.id.log_level);
    levelAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.log_level, R.layout.gt_simple_dropdown_item);
    btn_level.setText(levelAdapter.getItem(GTLogInternal.getCurFilterLevel()));
    btn_level.setOnClickListener(this);
    // 过滤TAG
    btn_tag = (Button) logLayout.findViewById(R.id.log_tag);
    if (GTLogInternal.getCurFilterTag().length() == 0) {
        btn_tag.setText("TAG");
    } else {
        btn_tag.setText(GTLogInternal.getCurFilterTag());
    }
    btn_tag.setOnClickListener(this);
    // 过滤文本
    et_Msg = (EditText) logLayout.findViewById(R.id.log_msg);
    et_Msg.setText(GTLogInternal.getCurFilterMsg());
    et_Msg.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (// 因为日志空时,edit会自动获取焦点
            hasFocus && !logAdapter.isEmpty()) {
                msgEtOnFocusOrClick();
            }
        }
    });
    et_Msg.setOnClickListener(this);
    et_Msg.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            switch(keyCode) {
                case KeyEvent.KEYCODE_ENTER:
                    // 要先把过滤showdown去掉,否则会多弹出一次
                    msgWatched = false;
                    et_Msg.removeTextChangedListener(msg_watcher);
                    String word = et_Msg.getText().toString();
                    if (!word.equals("")) {
                        LinkedList<String> curShowDownMsgList = GTLogInternal.getCurFilterShowDownMsgList();
                        LinkedList<String> msgHistory = GTLogInternal.getCurFilterMsgHistory();
                        msgHistory.remove(word);
                        msgHistory.addFirst(word);
                        curShowDownMsgList.remove(word);
                        curShowDownMsgList.addFirst(word);
                    }
                    filterListView.setVisibility(View.GONE);
                    img_empty.setVisibility(View.GONE);
                    cancelFilterMsgInput(v);
                    return true;
            }
            return false;
        }
    });
    // 过滤文本的清理
    btn_msg_clear = (ImageButton) logLayout.findViewById(R.id.log_msg_clear);
    btn_msg_clear.setOnClickListener(this);
    if (et_Msg.getText().toString().length() > 0) {
        btn_msg_clear.setVisibility(View.VISIBLE);
    } else {
        btn_msg_clear.setVisibility(View.GONE);
    }
    // 过滤文本输入的取消
    btn_msg_input_cancel = (Button) logLayout.findViewById(R.id.log_msg_cancel);
    btn_msg_input_cancel.setOnClickListener(this);
    handler = new Handler();
    return logLayout;
}
Also used : OnFocusChangeListener(android.view.View.OnFocusChangeListener) OnTouchListener(android.view.View.OnTouchListener) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) KeyEvent(android.view.KeyEvent) ImageButton(android.widget.ImageButton) OnScrollListener(android.widget.AbsListView.OnScrollListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) AbsListView(android.widget.AbsListView) Handler(android.os.Handler) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) LinkedList(java.util.LinkedList) MotionEvent(android.view.MotionEvent) RelativeLayout(android.widget.RelativeLayout) OnClickListener(android.view.View.OnClickListener) File(java.io.File) CompoundButton(android.widget.CompoundButton)

Example 12 with OnScrollListener

use of android.widget.AbsListView.OnScrollListener in project JamsMusicPlayer by psaravan.

the class QuickScrollGridView method init.

/**
     * Initializing the QuickScroll, this function must be called.
     * <p/>
     *
     * @param type       the QuickScroll type. Available inputs: <b>QuickScroll.TYPE_POPUP</b> or <b>QuickScroll.TYPE_INDICATOR</b>
     * @param list       the GridView
     * @param scrollable the adapter, must implement Scrollable interface
     */
public void init(final int type, final GridView grid, final Scrollable scrollable, final int style) {
    if (isInitialized)
        return;
    this.type = type;
    gridView = grid;
    this.scrollable = scrollable;
    groupPosition = -1;
    fadeInAnimation = new AlphaAnimation(.0f, 1.0f);
    fadeInAnimation.setFillAfter(true);
    fadeOutAnimation = new AlphaAnimation(1.0f, .0f);
    fadeOutAnimation.setFillAfter(true);
    fadeOutAnimation.setAnimationListener(new AnimationListener() {

        public void onAnimationStart(Animation animation) {
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationEnd(Animation animation) {
            isScrolling = false;
        }
    });
    isScrolling = false;
    gridView.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (isScrolling && (event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_DOWN)) {
                return true;
            }
            return false;
        }
    });
    final RelativeLayout.LayoutParams containerParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    final RelativeLayout container = new RelativeLayout(getContext());
    container.setBackgroundColor(Color.TRANSPARENT);
    containerParams.addRule(RelativeLayout.ALIGN_TOP, getId());
    containerParams.addRule(RelativeLayout.ALIGN_BOTTOM, getId());
    container.setLayoutParams(containerParams);
    if (this.type == TYPE_POPUP || this.type == TYPE_POPUP_WITH_HANDLE) {
        scrollIndicatorTextView = new TextView(getContext());
        scrollIndicatorTextView.setTextColor(Color.WHITE);
        scrollIndicatorTextView.setVisibility(View.INVISIBLE);
        scrollIndicatorTextView.setGravity(Gravity.CENTER);
        final RelativeLayout.LayoutParams popupParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        popupParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        scrollIndicatorTextView.setLayoutParams(popupParams);
        setPopupColor(GREY_LIGHT, GREY_DARK, 1, Color.WHITE, 1);
        setTextPadding(TEXT_PADDING, TEXT_PADDING, TEXT_PADDING, TEXT_PADDING);
        container.addView(scrollIndicatorTextView);
    } else {
        scrollIndicator = createPin();
        scrollIndicatorTextView = (TextView) scrollIndicator.findViewById(ID_PIN_TEXT);
        (scrollIndicator.findViewById(ID_PIN)).getLayoutParams().width = 25;
        container.addView(scrollIndicator);
    }
    // setting scrollbar width
    final float density = getResources().getDisplayMetrics().density;
    getLayoutParams().width = (int) (10 * density);
    scrollIndicatorTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 32);
    // scrollbar setup
    if (style != STYLE_NONE) {
        final RelativeLayout layout = new RelativeLayout(getContext());
        final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        params.addRule(RelativeLayout.ALIGN_LEFT, getId());
        params.addRule(RelativeLayout.ALIGN_TOP, getId());
        params.addRule(RelativeLayout.ALIGN_RIGHT, getId());
        params.addRule(RelativeLayout.ALIGN_BOTTOM, getId());
        layout.setLayoutParams(params);
        final View scrollbar = new View(getContext());
        scrollbar.setBackgroundColor(GREY_SCROLLBAR);
        final RelativeLayout.LayoutParams scrollBarParams = new RelativeLayout.LayoutParams(1, LayoutParams.MATCH_PARENT);
        scrollBarParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
        scrollBarParams.topMargin = SCROLLBAR_MARGIN;
        scrollBarParams.bottomMargin = SCROLLBAR_MARGIN;
        scrollbar.setLayoutParams(scrollBarParams);
        layout.addView(scrollbar);
        ViewGroup.class.cast(gridView.getParent()).addView(layout);
        // creating the handlebar
        if (this.type == TYPE_INDICATOR_WITH_HANDLE || this.type == TYPE_POPUP_WITH_HANDLE) {
            handleBar = new View(getContext());
            setHandlebarColor(BLUE_LIGHT, BLUE_LIGHT, BLUE_LIGHT_SEMITRANSPARENT);
            final RelativeLayout.LayoutParams handleParams = new RelativeLayout.LayoutParams((int) (12 * density), (int) (36 * density));
            handleBar.setLayoutParams(handleParams);
            ((RelativeLayout.LayoutParams) handleBar.getLayoutParams()).addRule(RelativeLayout.CENTER_HORIZONTAL);
            layout.addView(handleBar);
            gridView.setOnScrollListener(new OnScrollListener() {

                public void onScrollStateChanged(AbsListView view, int scrollState) {
                    if (onScrollListener != null)
                        onScrollListener.onScrollStateChanged(view, scrollState);
                }

                public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                    if (onScrollListener != null)
                        onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
                    if (!isScrolling && totalItemCount - visibleItemCount > 0) {
                        moveHandlebar(getHeight() * firstVisibleItem / (totalItemCount - visibleItemCount));
                    }
                }
            });
        }
    }
    isInitialized = true;
    ViewGroup.class.cast(gridView.getParent()).addView(container);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ViewGroup(android.view.ViewGroup) View(android.view.View) AlphaAnimation(android.view.animation.AlphaAnimation) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) OnScrollListener(android.widget.AbsListView.OnScrollListener) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 13 with OnScrollListener

use of android.widget.AbsListView.OnScrollListener in project umeng-android-sdk-theme by umeng.

the class ConversationActivity method setListViewHeader.

private void setListViewHeader() {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    header = (RelativeLayout) inflater.inflate(R.layout.umeng_fb_list_header, replyListView, false);
    replyListView.addHeaderView(header);
    measureView(header);
    headerHeight = header.getMeasuredHeight();
    headerPaddingOriginal = header.getPaddingTop();
    header.setPadding(header.getPaddingLeft(), -headerHeight, header.getPaddingRight(), header.getPaddingBottom());
    header.setVisibility(View.GONE);
    replyListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // nothing. Do not show the header.
            if (replyListView.getAdapter().getCount() < 2)
                return false;
            switch(event.getAction()) {
                case MotionEvent.ACTION_UP:
                    if (replyListView.getFirstVisiblePosition() == 0) {
                        if ((header.getBottom() >= headerHeight + 20 || header.getTop() > 0)) {
                            header.setVisibility(View.VISIBLE);
                            header.setPadding(header.getPaddingLeft(), headerPaddingOriginal, header.getPaddingRight(), header.getPaddingBottom());
                        } else // if (header.getBottom() < headerHeight + 20 ||
                        // header.getTop() <= 0)
                        {
                            replyListView.setSelection(1);
                            header.setVisibility(View.GONE);
                            header.setPadding(header.getPaddingLeft(), -headerHeight, header.getPaddingRight(), header.getPaddingBottom());
                        }
                    }
                    break;
                case MotionEvent.ACTION_DOWN:
                    mLastMotionY = (int) event.getY();
                    // header.setVisibility(View.VISIBLE);
                    break;
                case MotionEvent.ACTION_MOVE:
                    applyHeaderPadding(event);
                    break;
            }
            return false;
        }

        private void applyHeaderPadding(MotionEvent ev) {
            // getHistorySize has been available since API 1
            int pointerCount = ev.getHistorySize();
            for (int p = 0; p < pointerCount; p++) {
                if (replyListView.getFirstVisiblePosition() == 0) {
                    int historicalY = (int) ev.getHistoricalY(p);
                    // Calculate the padding to apply, we divide by 1.7 to
                    // simulate a more resistant effect during pull.
                    int topPadding = (int) (((historicalY - mLastMotionY) - headerHeight) / 1.7);
                    header.setVisibility(View.VISIBLE);
                    header.setPadding(header.getPaddingLeft(), topPadding, header.getPaddingRight(), header.getPaddingBottom());
                }
            }
        }
    });
    replyListView.setOnScrollListener(new OnScrollListener() {

        private int mScrollState;

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (mScrollState == OnScrollListener.SCROLL_STATE_FLING && firstVisibleItem == 0) {
            // replyListView.setSelection(1);
            }
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            mScrollState = scrollState;
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) OnScrollListener(android.widget.AbsListView.OnScrollListener) LayoutInflater(android.view.LayoutInflater) AbsListView(android.widget.AbsListView) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent)

Example 14 with OnScrollListener

use of android.widget.AbsListView.OnScrollListener in project XobotOS by xamarin.

the class CalendarView method setUpListView.

/**
     * Sets all the required fields for the list view.
     */
private void setUpListView() {
    // Configure the listview
    mListView.setDivider(null);
    mListView.setItemsCanFocus(true);
    mListView.setVerticalScrollBarEnabled(false);
    mListView.setOnScrollListener(new OnScrollListener() {

        public void onScrollStateChanged(AbsListView view, int scrollState) {
            CalendarView.this.onScrollStateChanged(view, scrollState);
        }

        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            CalendarView.this.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
        }
    });
    // Make the scrolling behavior nicer
    mListView.setFriction(mFriction);
    mListView.setVelocityScale(mVelocityScale);
}
Also used : OnScrollListener(android.widget.AbsListView.OnScrollListener) Paint(android.graphics.Paint)

Example 15 with OnScrollListener

use of android.widget.AbsListView.OnScrollListener in project UltimateAndroid by cymcsg.

the class DefaultFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mListView = (QuickReturnListView) getListView();
    mQuickReturnView.setText("Default");
    mListView.addHeaderView(mHeader);
    String[] array = new String[] { "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android" };
    setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.quick_return_listview_list_item, R.id.text1, array));
    mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            mQuickReturnHeight = mQuickReturnView.getHeight();
            mListView.computeScrollY();
            mCachedVerticalScrollRange = mListView.getListHeight();
        }
    });
    mListView.setOnScrollListener(new OnScrollListener() {

        @SuppressLint("NewApi")
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            mScrollY = 0;
            int translationY = 0;
            if (mListView.scrollYIsComputed()) {
                mScrollY = mListView.getComputedScrollY();
            }
            int rawY = mPlaceHolder.getTop() - Math.min(mCachedVerticalScrollRange - mListView.getHeight(), mScrollY);
            switch(mState) {
                case STATE_OFFSCREEN:
                    if (rawY <= mMinRawY) {
                        mMinRawY = rawY;
                    } else {
                        mState = STATE_RETURNING;
                    }
                    translationY = rawY;
                    break;
                case STATE_ONSCREEN:
                    if (rawY < -mQuickReturnHeight) {
                        mState = STATE_OFFSCREEN;
                        mMinRawY = rawY;
                    }
                    translationY = rawY;
                    break;
                case STATE_RETURNING:
                    translationY = (rawY - mMinRawY) - mQuickReturnHeight;
                    if (translationY > 0) {
                        translationY = 0;
                        mMinRawY = rawY - mQuickReturnHeight;
                    }
                    if (rawY > 0) {
                        mState = STATE_ONSCREEN;
                        translationY = rawY;
                    }
                    if (translationY < -mQuickReturnHeight) {
                        mState = STATE_OFFSCREEN;
                        mMinRawY = rawY;
                    }
                    break;
            }
            /** this can be used if the build is below honeycomb **/
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
                anim = new TranslateAnimation(0, 0, translationY, translationY);
                anim.setFillAfter(true);
                anim.setDuration(0);
                mQuickReturnView.startAnimation(anim);
            } else {
                mQuickReturnView.setTranslationY(translationY);
            }
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    });
}
Also used : OnScrollListener(android.widget.AbsListView.OnScrollListener) SuppressLint(android.annotation.SuppressLint) AbsListView(android.widget.AbsListView) TranslateAnimation(android.view.animation.TranslateAnimation) ViewTreeObserver(android.view.ViewTreeObserver) SuppressLint(android.annotation.SuppressLint)

Aggregations

OnScrollListener (android.widget.AbsListView.OnScrollListener)18 AbsListView (android.widget.AbsListView)14 SuppressLint (android.annotation.SuppressLint)8 View (android.view.View)6 ListView (android.widget.ListView)5 MotionEvent (android.view.MotionEvent)4 ViewTreeObserver (android.view.ViewTreeObserver)4 TranslateAnimation (android.view.animation.TranslateAnimation)4 Paint (android.graphics.Paint)3 Animation (android.view.animation.Animation)3 AnimationListener (android.view.animation.Animation.AnimationListener)3 OnTouchListener (android.view.View.OnTouchListener)2 ViewGroup (android.view.ViewGroup)2 LayoutParams (android.view.ViewGroup.LayoutParams)2 AlphaAnimation (android.view.animation.AlphaAnimation)2 CompoundButton (android.widget.CompoundButton)2 ExpandableListView (android.widget.ExpandableListView)2 ImageView (android.widget.ImageView)2 File (java.io.File)2 Builder (android.app.AlertDialog.Builder)1