Example usage for android.widget ListView setFastScrollAlwaysVisible

List of usage examples for android.widget ListView setFastScrollAlwaysVisible

Introduction

In this page you can find the example usage for android.widget ListView setFastScrollAlwaysVisible.

Prototype

public void setFastScrollAlwaysVisible(final boolean alwaysShow) 

Source Link

Document

Set whether or not the fast scroller should always be shown in place of the standard scroll bars.

Usage

From source file:com.racoon.ampdroid.views.AlbumsView.java

@SuppressLint("InflateParams")
@Override/*from  www  .j ava  2s. c o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    controller = Controller.getInstance();
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.ampache_songs, null);
    ListView listview = (ListView) root.findViewById(R.id.songs_listview);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        listview.setFastScrollAlwaysVisible(true);
    }
    if (controller.getServer() != null) {
        ArrayList<String> list = new ArrayList<String>();
        for (Album a : controller.getAlbums()) {
            list.add(a.toString());
        }
        AlbumArrayAdapter adapter = new AlbumArrayAdapter(getActivity().getApplicationContext(), list,
                controller.getAlbums());
        listview.setAdapter(adapter);
        registerForContextMenu(listview);

        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
                Album a = controller.getAlbums().get(position);
                controller.getSelectedSongs().clear();
                for (Song s : controller.findSongs(a)) {
                    controller.getSelectedSongs().add(s);
                }
                // Create new fragment and transaction
                SelectedSongsView newFragment = new SelectedSongsView();
                FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

                // Replace whatever is in the fragment_container view with this fragment,
                // and add the transaction to the back stack
                transaction.replace(R.id.content_frame, newFragment);
                transaction.addToBackStack(null);
                ((MainActivity) getActivity()).setActiveFragment(6);
                // Commit the transaction
                transaction.commit();
            }

        });
    }
    return root;
}

From source file:com.racoon.ampdroid.views.SongsView.java

@SuppressLint("InflateParams")
@Override//from   w  ww  .j a v a2  s .  c  o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    controller = Controller.getInstance();
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.ampache_songs, null);
    ListView listview = (ListView) root.findViewById(R.id.songs_listview);
    registerForContextMenu(listview);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        listview.setFastScrollAlwaysVisible(true);
    }
    if (controller.getServer() != null) {
        ArrayList<String> list = new ArrayList<String>();
        for (Song s : controller.getSongs()) {
            list.add(s.toString());
        }
        SongArrayAdapter adapter = new SongArrayAdapter(getActivity().getApplicationContext(), list,
                controller.getSongs());
        listview.setAdapter(adapter);
        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
                Log.d("Play now added:", controller.getSongs().get(position).toString());
                controller.getPlayNow().add(controller.getSongs().get(position));
                Context context = view.getContext();
                CharSequence text = getResources().getString(R.string.songsViewSongAdded);
                int duration = Toast.LENGTH_SHORT;
                Toast toast = Toast.makeText(context, text, duration);
                toast.show();
            }

        });
    }
    return root;
}

From source file:com.racoon.ampdroid.views.PlaylistsView.java

@SuppressLint("InflateParams")
@Override//from   w  ww.java  2 s  .  com
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    controller = Controller.getInstance();
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.ampache_playlists, null);
    ListView listview = (ListView) root.findViewById(R.id.playlists_listview);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        listview.setFastScrollAlwaysVisible(true);
    }
    if (controller.getServer() != null) {
        ArrayList<String> list = new ArrayList<String>();
        for (Playlist p : controller.getPlaylists()) {
            list.add(p.toString());
        }
        PlaylistArrayAdapter adapter = new PlaylistArrayAdapter(getActivity().getApplicationContext(), list,
                controller.getPlaylists());
        listview.setAdapter(adapter);
        registerForContextMenu(listview);

        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
                Playlist selected = controller.getPlaylists().get(position);

                String urlString = controller.getServer().getHost()
                        + "/server/xml.server.php?action=playlist_songs&auth="
                        + controller.getServer().getAuthKey() + "&filter=" + String.valueOf(selected.getId());
                Log.d("url", urlString);
                controller.getSelectedSongs().clear();
                controller.parsePlaylistSongs(urlString, controller.getSelectedSongs());
                SelectedSongsView newFragment = new SelectedSongsView();
                FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

                // Replace whatever is in the fragment_container view with this fragment,
                // and add the transaction to the back stack
                transaction.replace(R.id.content_frame, newFragment);
                transaction.addToBackStack(null);
                ((MainActivity) getActivity()).setActiveFragment(6);
                // Commit the transaction
                transaction.commit();
            }

        });
    } else {
        Log.d("bugs", "server null");
    }
    return root;
}

From source file:com.racoon.ampdroid.views.ArtistsView.java

@SuppressLint("InflateParams")
@Override//  w  w w .  j av a2s  . c o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    controller = Controller.getInstance();
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.ampache_songs, null);
    ListView listview = (ListView) root.findViewById(R.id.songs_listview);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        listview.setFastScrollAlwaysVisible(true);
    }
    if (controller.getServer() != null) {
        ArrayList<String> list = new ArrayList<String>();
        for (Artist a : controller.getArtists()) {
            list.add(a.toString());
        }
        ArtistArrayAdapter adapter = new ArtistArrayAdapter(getActivity().getApplicationContext(), list,
                controller.getArtists());
        listview.setAdapter(adapter);
        registerForContextMenu(listview);

        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
                Artist artist = controller.getArtists().get(position);

                controller.getSelectedAlbums().clear();
                for (Album a : controller.findAlbums(artist)) {
                    controller.getSelectedAlbums().add(a);
                }
                // Create new fragment and transaction
                SelectedAlbumsView newFragment = new SelectedAlbumsView();

                // controller.getSelectedSongs().clear();
                // for (Song s : controller.findSongs(a)) {
                // controller.getSelectedSongs().add(s);
                // }
                // // Create new fragment and transaction
                // SelectedSongsView newFragment = new SelectedSongsView();
                FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

                // Replace whatever is in the fragment_container view with this fragment,
                // and add the transaction to the back stack
                transaction.replace(R.id.content_frame, newFragment);
                transaction.addToBackStack(null);
                // ((MainActivity) getActivity()).setActiveFragment(6);
                // Commit the transaction
                transaction.commit();
            }

        });
    }
    return root;
}

From source file:com.racoon.ampdroid.views.SelectedAlbumsView.java

@SuppressLint("InflateParams")
@Override// w w w  .j a  v  a2  s  .  c o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    controller = Controller.getInstance();
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.ampache_songs, null);
    ListView listview = (ListView) root.findViewById(R.id.songs_listview);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        listview.setFastScrollAlwaysVisible(true);
    }
    if (controller.getServer() != null) {
        ArrayList<String> list = new ArrayList<String>();
        for (Album a : controller.getSelectedAlbums()) {
            list.add(a.toString());
        }
        AlbumArrayAdapter adapter = new AlbumArrayAdapter(getActivity().getApplicationContext(), list,
                controller.getSelectedAlbums());
        listview.setAdapter(adapter);
        registerForContextMenu(listview);

        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
                Album a = controller.getSelectedAlbums().get(position);
                controller.getSelectedSongs().clear();
                for (Song s : controller.findSongs(a)) {
                    controller.getSelectedSongs().add(s);
                }
                // Create new fragment and transaction
                SelectedSongsView newFragment = new SelectedSongsView();
                FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

                // Replace whatever is in the fragment_container view with this fragment,
                // and add the transaction to the back stack
                transaction.replace(R.id.content_frame, newFragment);
                transaction.addToBackStack(null);
                ((MainActivity) getActivity()).setActiveFragment(6);
                // Commit the transaction
                transaction.commit();
            }

        });
    }
    setHasOptionsMenu(true);
    return root;
}

From source file:com.racoon.ampdroid.views.SelectedArtistsView.java

@SuppressLint("InflateParams")
@Override/*from   w  ww .j a va  2 s  .  c o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    controller = Controller.getInstance();
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.ampache_songs, null);
    ListView listview = (ListView) root.findViewById(R.id.songs_listview);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        listview.setFastScrollAlwaysVisible(true);
    }
    if (controller.getServer() != null) {
        ArrayList<String> list = new ArrayList<String>();
        for (Artist a : controller.getSelectedArtists()) {
            list.add(a.toString());
        }
        ArtistArrayAdapter adapter = new ArtistArrayAdapter(getActivity().getApplicationContext(), list,
                controller.getSelectedArtists());
        listview.setAdapter(adapter);
        registerForContextMenu(listview);

        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
                Artist a = controller.getSelectedArtists().get(position);
                controller.getSelectedSongs().clear();
                for (Song s : controller.findSongs(a)) {
                    controller.getSelectedSongs().add(s);
                }
                // Create new fragment and transaction
                SelectedSongsView newFragment = new SelectedSongsView();
                FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

                // Replace whatever is in the fragment_container view with this fragment,
                // and add the transaction to the back stack
                transaction.replace(R.id.content_frame, newFragment);
                transaction.addToBackStack(null);
                ((MainActivity) getActivity()).setActiveFragment(6);
                // Commit the transaction
                transaction.commit();
            }

        });
    }
    setHasOptionsMenu(true);
    return root;
}

From source file:com.racoon.ampdroid.views.SelectedSongsView.java

@SuppressLint("InflateParams")
@Override//from  w  w  w.java  2s.c om
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    controller = Controller.getInstance();
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.ampache_songs, null);
    ListView listview = (ListView) root.findViewById(R.id.songs_listview);
    registerForContextMenu(listview);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        listview.setFastScrollAlwaysVisible(true);
    }
    if (controller.getServer() != null) {
        ArrayList<String> list = new ArrayList<String>();
        for (Song s : controller.getSelectedSongs()) {
            list.add(s.toString());
        }
        SongArrayAdapter adapter = new SongArrayAdapter(getActivity().getApplicationContext(), list,
                controller.getSelectedSongs());
        listview.setAdapter(adapter);
        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
                Log.d("Play now added:", controller.getSongs().get(position).toString());
                controller.getPlayNow().add(controller.getSelectedSongs().get(position));
                Context context = view.getContext();
                CharSequence text = getResources().getString(R.string.songsViewSongAdded);
                int duration = Toast.LENGTH_SHORT;
                Toast toast = Toast.makeText(context, text, duration);
                toast.show();
            }

        });
    }
    setHasOptionsMenu(true);
    return root;
}

From source file:com.racoon.ampdroid.views.SelectedPlaylistsView.java

@SuppressLint("InflateParams")
@Override//from w w w.  ja v  a2 s .  c  om
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    controller = Controller.getInstance();
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.ampache_playlists, null);
    ListView listview = (ListView) root.findViewById(R.id.playlists_listview);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        listview.setFastScrollAlwaysVisible(true);
    }
    if (controller.getServer() != null) {
        ArrayList<String> list = new ArrayList<String>();
        for (Playlist p : controller.getSelectedPlaylists()) {
            list.add(p.toString());
        }
        PlaylistArrayAdapter adapter = new PlaylistArrayAdapter(getActivity().getApplicationContext(), list,
                controller.getSelectedPlaylists());
        listview.setAdapter(adapter);
        registerForContextMenu(listview);

        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
                Playlist selected = controller.getSelectedPlaylists().get(position);

                String urlString = controller.getServer().getHost()
                        + "/server/xml.server.php?action=playlist_songs&auth="
                        + controller.getServer().getAuthKey() + "&filter=" + String.valueOf(selected.getId());
                Log.d("url", urlString);
                controller.getSelectedSongs().clear();
                controller.parsePlaylistSongs(urlString, controller.getSelectedSongs());
                SelectedSongsView newFragment = new SelectedSongsView();
                FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

                // Replace whatever is in the fragment_container view with this fragment,
                // and add the transaction to the back stack
                transaction.replace(R.id.content_frame, newFragment);
                transaction.addToBackStack(null);
                ((MainActivity) getActivity()).setActiveFragment(6);
                // Commit the transaction
                transaction.commit();
            }

        });
    } else {
        Log.d("bugs", "server null");
    }
    setHasOptionsMenu(true);
    return root;
}

From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java

private void setFastScrollListener(final ListView lv) {
    if (Build.VERSION.SDK_INT == 19) {
        lv.setFastScrollAlwaysVisible(true);
        //         mUiHandler.postDelayed(new Runnable(){
        //            @Override
        //            public void run() {
        //               lv.smoothScrollToPosition(0);
        //               lv.setSelection(0);
        //               lv.setFastScrollAlwaysVisible(false);
        //            }
        //         }, 500);
        //          lv.setOnScrollListener(new OnScrollListener() {
        //              private static final int DELAY = 2000;
        //              private AbsListView view;
        //              private int scrollState=0;
        //// w ww  .  j a v a  2  s  .c  om
        //              @Override
        //              public void onScrollStateChanged(AbsListView view, int scrollState) {
        //                 if (view.isFastScrollEnabled()) {
        //                 }
        //                 this.scrollState=scrollState;
        //                  if (scrollState != SCROLL_STATE_IDLE) {
        //                      view.setFastScrollAlwaysVisible(true);
        //                      handler.removeCallbacks(runnable);
        //                  } else {
        //                      this.view = view;
        //                      handler.postDelayed(runnable, DELAY);
        //                  }
        //              }
        //
        //              @Override
        //              public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        //              }
        //
        //              private Handler handler = new Handler();
        //              private Runnable runnable = new Runnable() {
        //                 @Override
        //                 public void run() {
        //                    if (scrollState==SCROLL_STATE_IDLE) {
        //                        view.setFastScrollAlwaysVisible(false);
        //                        view = null;
        //                    }
        //                 }
        //              };
        //          });
    }
}