List of usage examples for android.widget ListView setOnScrollListener
public void setOnScrollListener(OnScrollListener l)
From source file:org.getlantern.firetweet.fragment.support.BaseSupportListFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mNotReachedBottomBefore = true;//from w ww. j av a 2 s .c o m mStoppedPreviously = false; mIsInstanceStateSaved = savedInstanceState != null; mListScrollCounter.setScrollDistanceListener(this); final ListView lv = getListView(); lv.setOnScrollListener(this); }
From source file:com.initiativaromania.hartabanilorpublici.IRUserInterface.fragments.AroundStatisticsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { v = inflater.inflate(R.layout.statistics_around_fragment, container, false); /* Pass current instance in order to get updates from progress bar */ IRSeekBarListener.registerAroundStatisticsInstance(this); orderDetailsList = new ArrayList<>(); ListView orderList = (ListView) v.findViewById(R.id.statistics_around_order_list); statisticsAroundAdapter = new ContractListAdapter(getActivity(), orderDetailsList); orderList.setAdapter(statisticsAroundAdapter); orderList.setOnItemClickListener(statisticsAroundAdapter); orderList.setOnScrollListener(new EndlessScrollListener(this)); /* Reset current buyer index and get the first buyer statistics */ currentBuyerToProcess = 0;//from w w w . j a va 2 s . co m getMoreAroundStatistics(); getMoreAroundStatistics(); return v; }
From source file:com.brkc.traffic.ui.image.ImageListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.image_list_fragment, container, false); final ListView mListView = (ListView) v.findViewById(R.id.listView); mListView.setAdapter(mAdapter);//from w w w . j a v a 2 s . c o m mListView.setOnItemClickListener(this); mListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { // Pause fetcher to ensure smoother scrolling when flinging if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) { // Before Honeycomb pause image loading on scroll to help with performance if (!Utils.hasHoneycomb()) { mImageFetcher.setPauseWork(true); } } else { mImageFetcher.setPauseWork(false); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); return v; }
From source file:fr.outadev.skinswitch.GalleryPageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Bundle args = getArguments();/*from w w w . ja v a 2 s .c o m*/ if (args == null) { endPoint = EndPoint.RANDOM_SKINS; searchQuery = "."; } else { endPoint = (EndPoint) args.get(ARG_ENDPOINT); searchQuery = args.getString(ARG_SEARCH_QUERY); } View view = inflater.inflate(R.layout.fragment_skin_gallery_list, container, false); progressBar = (ProgressBar) view.findViewById(R.id.progress_bar); swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container); swipeRefreshLayout.setColorSchemeResources(R.color.loading_bar_one, R.color.loading_bar_two, R.color.loading_bar_one, R.color.loading_bar_two); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { loadSkinsFromNetwork(); } }); ListView listView = (ListView) view.findViewById(R.id.skins_library_list); skinsList = new ArrayList<GallerySkin>(); adapter = new GalleryListAdapter(getActivity(), android.R.layout.simple_list_item_1, skinsList); listView.setAdapter(adapter); listView.setOnScrollListener( new EndlessScrollListener(getResources().getInteger(R.integer.endless_scroll_visible_threshold)) { @Override public void onLoadMore(int page, int totalItemsCount) { loadSkinsFromNetwork(true); } }); loadSkinsFromNetwork(false); return view; }
From source file:com.manoj.fragments.CopyOfSongCustomFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.song, container, false); final ListView mGridView = (ListView) v.findViewById(R.id.song_list); mGridView.setAdapter(mAdapter);/*from ww w .j av a2 s . c om*/ mGridView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { // Pause fetcher to ensure smoother scrolling when flinging if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) { mImageFetcher.setPauseWork(true); } else { mImageFetcher.setPauseWork(false); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); // This listener is used to get the final width of the GridView and then calculate the // number of columns and the width of each column. The width of each column is variable // as the GridView has stretchMode=columnWidth. The column width is used to set the height // of each view so we get nice square thumbnails. mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (mAdapter.getNumColumns() == 0) { final int numColumns = (int) Math .floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing; mAdapter.setNumColumns(numColumns); mAdapter.setItemHeight(columnWidth); if (BuildConfig.DEBUG) { Log.d(TAG, "onCreateView - numColumns set to " + numColumns); } } } } }); return v; }
From source file:com.ubergeek42.WeechatAndroid.adapters.ChatLinesAdapter.java
public ChatLinesAdapter(FragmentActivity activity, Buffer buffer, ListView uiListView) { if (DEBUG)/*from w ww .j a v a 2 s . co m*/ logger.debug("ChatLinesAdapter({}, {})", activity, buffer); this.activity = (WeechatActivity) activity; this.buffer = buffer; this.inflater = LayoutInflater.from(activity); this.uiListView = uiListView; uiListView.setOnScrollListener(this); }
From source file:com.melchor629.musicote.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { // Set the user interface layout for this Activity // The layout file is defined in the project res/layout/main.xml file super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from w w w . j a v a 2 s. co m*/ appContext = getApplicationContext(); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.mainLayout); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent, R.color.colorPrimaryDark, R.color.colorGrey600); final ListView list = (ListView) findViewById(android.R.id.list); list.setOnScrollListener(new ListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { boolean enable = false; if (list != null && list.getChildCount() > 0) { // check if the first item of the list is visible boolean firstItemVisible = list.getFirstVisiblePosition() == 0; // check if the top of the first item is visible boolean topOfFirstItemVisible = list.getChildAt(0).getTop() == 0; // enabling or disabling the refresh layout enable = firstItemVisible && topOfFirstItemVisible; } swipeRefreshLayout.setEnabled(enable); } }); getActionBar().setIcon(R.drawable.ic_launcher); getActionBar().setDisplayUseLogoEnabled(true); // La app prueba en busca de la direccin correcta WifiManager mw = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo wi = mw.getConnectionInfo(); String SSID = wi.getSSID(); Log.i("MainActivity", "Wifi conectado: " + SSID + " " + (SSID != null ? SSID.equals("Madrigal") : "")); if (SSID == null) { SSID = ""; Toast.makeText(this, getString(R.string.no_wifi), Toast.LENGTH_LONG).show(); } if (SSID.equals("Madrigal") || SSID.contains("Madrigal") || System.getProperty("os.version").equals("3.4.67+")) { MainActivity.HOST = "192.168.1.133"; } else { MainActivity.HOST = "reinoslokos.no-ip.org"; } Log.i("MainActivity", "HOST: " + HOST); //Deletes the notification if remains (BUG) NotificationManager mn = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (Reproductor.a == -1) mn.cancel(1); mn.cancel(3); //Revisa la base de datos DB mDbHelper = new DB(getBaseContext()); SQLiteDatabase db = mDbHelper.getWritableDatabase(); //Actualizacin de la lista if (mDbHelper.isNecesaryUpgrade(db) && Utils.HostTest(HOST) == 200) async(); else cursordb(db); db.close(); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }
From source file:de.vanita5.twittnuker.fragment.support.BaseSupportListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a ListView whose id is * {@link android.R.id#list android.R.id.list} and can optionally have a * sibling view id {@link android.R.id#empty android.R.id.empty} that is to * be shown when the list is empty./* w w w .ja v a 2 s . c om*/ * * <p> * If you are overriding this method with your own custom content, consider * including the standard layout {@link android.R.layout#list_content} in * your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only way * to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ final FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); final TextView tv = new TextView(getActivity()); tv.setTextAppearance(context, ThemeUtils.getTextAppearanceLarge(context)); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lv.setOnScrollListener(this); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:com.maxleapmobile.gitmaster.ui.fragment.RepoFragment.java
private void initUI(View view) { mProgressBar = (ProgressBar) view.findViewById(R.id.search_progress); mProgressBar.setVisibility(View.GONE); ListView listView = (ListView) view.findViewById(R.id.search_list); if (mRepos == null) { mRepos = new ArrayList<>(); }//from www . j a v a2 s . co m mRepoAdapter = new RepoAdapter(mContext, mRepos); listView.setAdapter(mRepoAdapter); listView.setEmptyView(view.findViewById(R.id.search_empty)); listView.setOnScrollListener(this); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(mContext, RepoDetailActivity.class); intent.putExtra(RepoDetailActivity.REPONAME, mRepos.get(position).getName()); intent.putExtra(RepoDetailActivity.OWNER, mRepos.get(position).getOwner().getLogin()); mContext.startActivity(intent); } }); if (mFlag == FLAG_USER_REPO) { fetchUserRepoData(1); } else if (mFlag == FLAG_USER_STAR) { fetchUserStarData(1); } }
From source file:com.crazymin2.retailstore.ui.BaseActivity.java
protected void enableActionBarAutoHide(final ListView listView) { initActionBarAutoHide();// ww w. ja v a 2 s .c o m listView.setOnScrollListener(new AbsListView.OnScrollListener() { /** The heights of all items. */ private Map<Integer, Integer> heights = new HashMap<Integer, Integer>(); private int lastCurrentScrollY = 0; @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { // Get the first visible item's view. View firstVisibleItemView = view.getChildAt(0); if (firstVisibleItemView == null) { return; } // Save the height of the visible item. heights.put(firstVisibleItem, firstVisibleItemView.getHeight()); // Calculate the height of all previous (hidden) items. int previousItemsHeight = 0; for (int i = 0; i < firstVisibleItem; i++) { previousItemsHeight += heights.get(i) != null ? heights.get(i) : 0; } int currentScrollY = previousItemsHeight - firstVisibleItemView.getTop() + view.getPaddingTop(); onMainContentScrolled(currentScrollY, currentScrollY - lastCurrentScrollY); lastCurrentScrollY = currentScrollY; } }); }