com.google.android.libraries.launcherclient.LauncherClient

Here are the examples of the java api class com.google.android.libraries.launcherclient.LauncherClient taken from open source projects.

1. MainActivity#onCreate()

Project: launcherclient
Source File: MainActivity.java
View license
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Connect to Google Now
    CallbacksAdapter callbacksAdapter = new CallbacksAdapter();
    launcherClient = new LauncherClient(this, callbacksAdapter, true);
    // Set up view pager starting at index 1
    viewPager = (ViewPager) findViewById(R.id.viewpager);
    viewPager.setAdapter(new SimpleFragmentPagerAdapter(getSupportFragmentManager()));
    viewPager.setCurrentItem(1);
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (position == 0) {
                // Update the overlay scroll if we're at the left-most page
                launcherClient.updateMove(1f - positionOffset);
            }
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
            switch(state) {
                case ViewPager.SCROLL_STATE_IDLE:
                    // Stop scroll and set current item to 1 as this is required for this demo
                    launcherClient.endMove();
                    viewPager.setCurrentItem(1);
                    break;
                case ViewPager.SCROLL_STATE_DRAGGING:
                case ViewPager.SCROLL_STATE_SETTLING:
                    // Start scroll on both user drag and settling even to support usage of
                    // viewPager.setCurrentItem(0, true). Setting current item without animating
                    // is unsupported in this demo.
                    launcherClient.startMove();
                    break;
            }
        }
    });
}