Java Code Examples for android.widget.AbsListView

The following examples show how to use android.widget.AbsListView. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: TVSample   Source File: MetroViewBorderHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onFocusChanged(View oldFocus, View newFocus) {
    try {
        if (newFocus instanceof AbsListView) {
            return;
        }
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setInterpolator(new DecelerateInterpolator(1));
        animatorSet.setDuration(mDurationTraslate);
        animatorSet.playTogether(mAnimatorList);
        for (Animator.AnimatorListener listener : mAnimatorListener) {
            animatorSet.addListener(listener);
        }
        mAnimatorSet = animatorSet;
        if (oldFocus == null) {
            animatorSet.setDuration(0);
            mTarget.setVisibility(View.VISIBLE);
        }
        animatorSet.start();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example 2
public boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            try {
                if (absListView.getCount() > 0) {
                    if (absListView.getLastVisiblePosition() + 1 == absListView.getCount()) {
                        int lastIndex = absListView.getLastVisiblePosition() - absListView.getFirstVisiblePosition();
                        return absListView.getChildAt(lastIndex).getBottom() == absListView.getPaddingBottom();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return true;
        } else {
            return true;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
}
 
Example 3
Source Project: UltimateAndroid   Source File: PullToZoomListView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onScroll(AbsListView paramAbsListView, int paramInt1, int paramInt2, int paramInt3) {
    Log.d(TAG, "onScroll");
    if (mHeaderView != null && !isHideHeader && isEnableZoom) {
        float f = mHeaderHeight - mHeaderContainer.getBottom();
        Log.d(TAG, "f = " + f);
        if (isParallax) {
            if ((f > 0.0F) && (f < mHeaderHeight)) {
                int i = (int) (0.65D * f);
                mHeaderContainer.scrollTo(0, -i);
            } else if (mHeaderContainer.getScrollY() != 0) {
                mHeaderContainer.scrollTo(0, 0);
            }
        }
    }

    if (mOnScrollListener != null) {
        mOnScrollListener.onScroll(paramAbsListView, paramInt1, paramInt2, paramInt3);
    }
}
 
Example 4
Source Project: HighingRefresh   Source File: HighingRefreshListView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	if (this.mOnScrollListener != null
			&& refreshState != RefreshState.Refreshing) {
		this.mOnScrollListener.onScrollStateChanged(view, scrollState);
	}
	switch (scrollState) {
	// 当不滚动�?		
	case OnScrollListener.SCROLL_STATE_IDLE:
		// 判断滚动到底�?			
		if (this.getLastVisiblePosition() == (this.getCount() - 1)) {
		}
		// 判断滚动到顶�?
		if (this.getFirstVisiblePosition() == 0) {
			mIsTop = true;
		} else {
			mIsTop = false;
		}

		break;
	}
}
 
Example 5
Source Project: dialogplus   Source File: DialogPlus.java    License: Apache License 2.0 6 votes vote down vote up
private void initExpandAnimator(Activity activity, int defaultHeight, int gravity) {
  Display display = activity.getWindowManager().getDefaultDisplay();
  int displayHeight = display.getHeight() - Utils.getStatusBarHeight(activity);
  if (defaultHeight == 0) {
    defaultHeight = (displayHeight * 2) / 5;
  }

  final View view = holder.getInflatedView();
  if (!(view instanceof AbsListView)) {
    return;
  }
  final AbsListView absListView = (AbsListView) view;

  view.setOnTouchListener(ExpandTouchListener.newListener(
      activity, absListView, contentContainer, gravity, displayHeight, defaultHeight
  ));
}
 
Example 6
Source Project: FireFiles   Source File: DirectoryFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onDestroyView() {
	super.onDestroyView();

	// Cancel any outstanding thumbnail requests
	final ViewGroup target = (mListView.getAdapter() != null) ? mListView : mGridView;
	final int count = target.getChildCount();
	for (int i = 0; i < count; i++) {
		final View view = target.getChildAt(i);
		mRecycleListener.onMovedToScrapHeap(view);
	}

	// Tear down any selection in progress
	mListView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
	mGridView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
}
 
Example 7
Source Project: AndroidMaterialDialog   Source File: DialogRootView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Searches for the list view, which is contained by the dialog, in order to register a scroll
 * listener.
 *
 * @param view The view, which should be searched, as an instance of the class {@link ViewGroup}.
 *             The view may not be null
 */
private boolean findListOrRecyclerView(@NonNull final View view) {
    if (view instanceof AbsListView) {
        this.listView = (AbsListView) view;
        this.listView.setOnScrollListener(createListViewScrollListener());
        return true;
    } else if (view instanceof RecyclerView) {
        this.recyclerView = (RecyclerView) view;
        this.recyclerView.addOnScrollListener(createRecyclerViewScrollListener());
        return true;
    } else if (view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view;

        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            if (findListOrRecyclerView(viewGroup.getChildAt(i))) {
                return true;
            }
        }
    }

    return false;
}
 
Example 8
private int getScrollY(AbsListView view) {
    View child = view.getChildAt(0);
    if (child == null) {
        return 0;
    }

    int firstVisiblePosition = view.getFirstVisiblePosition();
    int top = child.getTop();

    int headerHeight = 0;
    if (firstVisiblePosition >= 1) {
        headerHeight = mStickHeaderHeight;
    }

    return -top + firstVisiblePosition * child.getHeight() + headerHeight;
}
 
Example 9
public final void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount,
						   final int totalItemCount) {

	if (DEBUG) {
		Log.d(LOG_TAG, "First Visible: " + firstVisibleItem + ". Visible Count: " + visibleItemCount
				+ ". Total Items:" + totalItemCount);
	}

	/**
	 * Set whether the Last Item is Visible. lastVisibleItemIndex is a
	 * zero-based index, so we minus one totalItemCount to check
	 */
	if (null != mOnLastItemVisibleListener) {
		mLastItemVisible = (totalItemCount > 0) && (firstVisibleItem + visibleItemCount >= totalItemCount - 1);
	}

	// If we're showing the indicator, check positions...
	if (getShowIndicatorInternal()) {
		updateIndicatorViewsVisibility();
	}

	// Finally call OnScrollListener if we have one
	if (null != mOnScrollListener) {
		mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
	}
}
 
Example 10
Source Project: rss   Source File: ListFragmentFavourites.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public
void onActivityCreated(Bundle savedInstanceState)
{
    super.onActivityCreated(savedInstanceState);

    ListView listView = getListView();

    registerForContextMenu(listView);
    listView.post(new LoadFavourites());
    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new MultiModeListenerFavourites(listView, getResources()));
}
 
Example 11
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case AbsListView.OnScrollListener.SCROLL_STATE_IDLE:
            break;
        case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
            break;
        case AbsListView.OnScrollListener.SCROLL_STATE_FLING:
            break;
    }
}
 
Example 12
Source Project: o2oa   Source File: DropDownListView.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if (isDropDownStyle) {
        if (currentScrollState == SCROLL_STATE_TOUCH_SCROLL && currentHeaderStatus != HEADER_STATUS_LOADING) {
            if (firstVisibleItem == 0 && actionMovePointY - actionDownPointY > 0
                    && mOffset == PAGE_MESSAGE_COUNT) {
                onDropDown();
            }

        } else if (currentScrollState == SCROLL_STATE_FLING && firstVisibleItem == 0
                && currentHeaderStatus != HEADER_STATUS_LOADING) {
            /**
             * when state of ListView is SCROLL_STATE_FLING(ListView is scrolling but finger has leave screen) and
             * first item(header layout) is visible and header status is not HEADER_STATUS_LOADING, then hide first
             * item, set second item visible and set hasReachedTop true.
             */
            if (mOffset == PAGE_MESSAGE_COUNT){
                onDropDown();
            }
            hasReachedTop = true;
        } else if (currentScrollState == SCROLL_STATE_FLING && hasReachedTop) {
            setSelection(0);
        }
    }

    if (onScrollListener != null) {
        onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
    }
}
 
Example 13
Source Project: Dashchan   Source File: ClickableView.java    License: Apache License 2.0 5 votes vote down vote up
private int getListPosition(AbsListView listView) {
	View view = ListViewUtils.getRootViewInList(this);
	if (view != null) {
		return listView.getPositionForView(view);
	} else {
		return AbsListView.INVALID_POSITION;
	}
}
 
Example 14
Source Project: FimiX8-RE   Source File: AbViewUtil.java    License: MIT License 5 votes vote down vote up
public static void setAbsListViewHeight(AbsListView absListView, int lineNumber, int verticalSpace) {
    int totalHeight = getAbsListViewHeight(absListView, lineNumber, verticalSpace);
    LayoutParams params = absListView.getLayoutParams();
    params.height = totalHeight;
    ((MarginLayoutParams) params).setMargins(0, 0, 0, 0);
    absListView.setLayoutParams(params);
}
 
Example 15
private void initView() {
    this.mListHeaderBtn = new Button(this);
    this.mChapterLV = (ListView) findViewById(R.id.isi_chapter_lv);
    this.mListHeaderBtn.setLayoutParams(new AbsListView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    this.mListHeaderBtn.setText("示例");
}
 
Example 16
@Override
protected TextView createItemView(int position) {
    TextView v = new TextView(getContext());
    v.setTextColor(ResTools.getColor(R.color.text));
    v.setTextSize(TypedValue.COMPLEX_UNIT_PX, (int)ResTools.getDimen(R.dimen.textsize2));
    v.setGravity(Gravity.CENTER_VERTICAL);
    int hp = (int)ResTools.getDimen(R.dimen.hor_padding);
    int vp = (int)ResTools.getDimen(R.dimen.vtl_padding);
    v.setPadding(hp,vp,hp,vp);
    v.setOnClickListener(CrashRecordWindow.this);
    v.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,  (int)ResTools.getDimen(R.dimen.item_height)));
    v.setBackgroundResource(R.drawable.list_item_bg);

    return v;
}
 
Example 17
void bindCamera(){
    mItemView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mImageSize)); //让图片是个正方形
    mItemView.setTag(null);
    mItemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!((ImageBaseActivity) mActivity).checkPermission(Manifest.permission.CAMERA)) {
                ActivityCompat.requestPermissions(mActivity, new String[]{Manifest.permission.CAMERA}, ImageGridActivity.REQUEST_PERMISSION_CAMERA);
            } else {
                imagePicker.takePicture(mActivity, ImagePicker.REQUEST_CODE_TAKE);
            }
        }
    });
}
 
Example 18
Source Project: TestChat   Source File: FloatingActionsMenu.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                     int totalItemCount) {
        if (mOnScrollListener != null) {
                mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
        }

        super.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
}
 
Example 19
Source Project: wakao-app   Source File: MyRobot.java    License: MIT License 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
	listview.onScrollStateChanged(view, scrollState);
	// 当不滚动时
	if (scrollState == SCROLL_STATE_IDLE) {
		// 判断滚动到底部
		if (!IS_LOADING
				&& view.getLastVisiblePosition() == (view.getCount() - 1)) {
			Log.e("TAG", "loading。。。");
			IS_LOADING = true;
			getMore();
		}
	}
}
 
Example 20
Source Project: Animated-Expanding-ListView   Source File: ListAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public View getView(int position, View convertView, ViewGroup parent) {
    ListViewHolder holder = null;
    ListItem listItem = listItems.get(position);

    if (convertView == null) {
        LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = vi.inflate(R.layout.list_item, null);

        LinearLayout textViewWrap = (LinearLayout) convertView.findViewById(R.id.text_wrap);
        TextView text = (TextView) convertView.findViewById(R.id.text);

        holder = new ListViewHolder(text);

        // setViewWrap IS REQUIRED
        holder.setViewWrap(textViewWrap);

    } else {
        holder = (ListViewHolder) convertView.getTag();
    }

    // THIS IS REQUIRED
    holder.getViewWrap().setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, listItem.getCurrentHeight()));

    holder.getTextView().setText(listItem.getText());

    holder.getTextView().setCompoundDrawablesWithIntrinsicBounds(listItem.getDrawable(), 0, 0, 0);

    convertView.setTag(holder);

    // setHolder IS REQUIRED
    listItem.setHolder(holder);

    return convertView;
}
 
Example 21
public static boolean canScrollLeft(@NonNull View targetView) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (targetView instanceof AbsListView) {
            final ViewGroup viewGroup = (ViewGroup) targetView;
            final AbsListView absListView = (AbsListView) targetView;
            return viewGroup.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0
                    || viewGroup.getChildAt(0).getTop() < targetView.getPaddingTop());
        } else {
            return targetView.getScrollY() > 0;
        }
    } else {
        return targetView.canScrollHorizontally(-1);
    }
}
 
Example 22
Source Project: VCL-Android   Source File: AudioBrowserFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    boolean enabled = scrollState == SCROLL_STATE_IDLE;
    if (enabled) {
        enabled = view.getFirstVisiblePosition() == 0;
        if (view.getChildAt(0) != null)
            enabled &= view.getChildAt(0).getTop() == 0;
    }
    mSwipeRefreshLayout.setEnabled(enabled);
}
 
Example 23
Source Project: YiBo   Source File: StatusScrollListener.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
		int visibleItemCount, int totalItemCount) {
       if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
       	displayImage(view);
       }
}
 
Example 24
private void initView() {
    this.mListHeaderBtn = new Button(this);
    this.mChapterLV = (ListView) findViewById(R.id.isi_chapter_lv);
    this.mListHeaderBtn.setLayoutParams(new AbsListView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    this.mListHeaderBtn.setText("示例");
}
 
Example 25
Source Project: letv   Source File: ConsumeRecordActivity.java    License: Apache License 2.0 5 votes vote down vote up
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case 0:
            if (this.this$0.saleNoteList != null && this.this$0.mAdapter != null && !this.this$0.isRequestData) {
                this.mTotalItemCount = this.mFirstVisibleItem + this.mVisibleItemCount;
                if (this.this$0.mListView.getFooterViewsCount() > 0) {
                    this.mTotalItemCount--;
                }
                if (this.mTotalItemCount >= this.this$0.saleNoteList.size() && this.mTotalItemCount < Integer.parseInt(this.this$0.saleNoteList.totalCount)) {
                    if (this.this$0.isNetErr) {
                        this.this$0.showFooterLoading();
                        this.this$0.isNetErr = false;
                    }
                    this.this$0.currentPage = this.this$0.currentPage + 1;
                    this.this$0.requestConsumerRecords(this.this$0.currentPage);
                    return;
                } else if (this.this$0.mListView.getFooterViewsCount() > 0 && this.mTotalItemCount >= Integer.parseInt(this.this$0.saleNoteList.totalCount)) {
                    this.this$0.removeFooterView();
                    return;
                } else {
                    return;
                }
            }
            return;
        default:
            return;
    }
}
 
Example 26
Source Project: iBeebo   Source File: VelocityListView.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case SCROLL_STATE_IDLE:
            mTime = INVALID_TIME;
            setVelocity(0);
            break;

        default:
            break;
    }
}
 
Example 27
Source Project: imsdk-android   Source File: CountryAdapter.java    License: MIT License 5 votes vote down vote up
@Override
public void convert(CommonViewHolder viewHolder, CountryNode item) {
    final TextView tv_name = viewHolder.getView(R.id.name);
    final ImageView iv_sel_icon = viewHolder.getView(R.id.icon);
    if(item.isRoot)
    {
        viewHolder.getConvertView().setLayoutParams(
                new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, rootHeight));
        viewHolder.getConvertView().setBackgroundResource(R.color.atom_ui_light_gray_ee);
        tv_name.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
        iv_sel_icon.setVisibility(View.GONE);
        tv_name.setText(item.name);

    }
    else {
        tv_name.setText(item.name);
        tv_name.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        viewHolder.getConvertView().setLayoutParams(
                new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, nodeHeight));
        if(item.resourceId == selectId)
        {
            iv_sel_icon.setVisibility(View.VISIBLE);
        }
        else {
            iv_sel_icon.setVisibility(View.INVISIBLE);
        }
        viewHolder.getConvertView().setBackgroundResource(R.color.atom_ui_white);
    }
}
 
Example 28
Source Project: Conquer   Source File: SimpleMonthAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	SimpleMonthView v;
       HashMap<String, Integer> drawingParams = null;
	if (convertView != null) {
		v = (SimpleMonthView) convertView;
           drawingParams = (HashMap<String, Integer>) v.getTag();
       } else {
		v = new SimpleMonthView(mContext);
		v.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		v.setClickable(true);
		v.setOnDayClickListener(this);
	}
       if (drawingParams == null) {
           drawingParams = new HashMap<String, Integer>();
       }
       drawingParams.clear();

       final int month = position % MONTHS_IN_YEAR;
       final int year = position / MONTHS_IN_YEAR + mController.getMinYear();

       int selectedDay = -1;
       if (isSelectedDayInMonth(year, month)) {
           selectedDay = mSelectedDay.day;
       }

	v.reuse();

       drawingParams.put(SimpleMonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay);
       drawingParams.put(SimpleMonthView.VIEW_PARAMS_YEAR, year);
       drawingParams.put(SimpleMonthView.VIEW_PARAMS_MONTH, month);
       drawingParams.put(SimpleMonthView.VIEW_PARAMS_WEEK_START, mController.getFirstDayOfWeek());
	v.setMonthParams(drawingParams);
	v.invalidate();

	return v;
}
 
Example 29
Source Project: dynamiclistview   Source File: Util.java    License: MIT License 5 votes vote down vote up
public static boolean reachedListEnds(AbsListView listView) {
	boolean flag;
	if (reachedListTop(listView) || reachedListBottom(listView)) {
		flag = true;
	} else {
		flag = false;
	}
	return flag;
}
 
Example 30
Source Project: Android-Next   Source File: ListViewExtend.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (mOnScrollListener != null) {
        mOnScrollListener.onScrollStateChanged(view, scrollState);
    }
    if (DEBUG) {
        Log.v(TAG, "onScrollStateChanged() scrollState=" + scrollState);
    }
    if (SCROLL_STATE_IDLE == scrollState) {
        checkAutoRefresh();
    }
}