Example usage for android.graphics Color rgb

List of usage examples for android.graphics Color rgb

Introduction

In this page you can find the example usage for android.graphics Color rgb.

Prototype

@ColorInt
public static int rgb(float red, float green, float blue) 

Source Link

Document

Return a color-int from red, green, blue float components in the range \([0..1]\).

Usage

From source file:com.dreamchen.useful.mouserace.view.sliding.AbBottomTabView.java

/**
 * Instantiates a new ab bottom tab view.
 *
 * @param context the context/*ww w  . ja  va2s . com*/
 * @param attrs the attrs
 */
public AbBottomTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();
    this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1));
    addView(mTabLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();
    tabItemDrawableList = new ArrayList<Drawable>();
    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbBottomTabView.class,
                "AbSlidingTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getSupportFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

}

From source file:com.ab.view.sliding.AbSlidingTabView2.java

public AbSlidingTabView2(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new AbHorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);
    //mTabLayout/* w w w  . jav  a2  s  .c  o  m*/
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabScrollView, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        Log.e(TAG, "AbSlidingTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getSupportFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabScrollView.setOnScrollListener(new AbOnScrollListener() {

        @Override
        public void onScrollToRight() {
            if (D)
                Log.d(TAG, "onScrollToRight");
        }

        @Override
        public void onScrollToLeft() {
            if (D)
                Log.d(TAG, "onScrollToLeft");
        }

        @Override
        public void onScrollStoped() {
            if (D)
                Log.d(TAG, "onScrollStoped");
        }

        @Override
        public void onScroll(int arg1) {
            scrollX = arg1;
            View view = mTabLayout.getChildAt(mSelectedTabIndex);
            int toX = view.getLeft() - scrollX;

            if (D)
                Log.d(TAG, "X" + startX + "to" + toX);
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }
    });
}

From source file:com.esri.arcgisruntime.sample.featurelayerupdateattributes.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mCoordinatorLayout = findViewById(R.id.snackbarPosition);

    // inflate MapView from layout
    mMapView = (MapView) findViewById(R.id.mapView);

    // create a map with the streets basemap
    final ArcGISMap map = new ArcGISMap(Basemap.createStreets());

    //set an initial viewpoint
    map.setInitialViewpoint(new Viewpoint(new Point(-100.343, 34.585, SpatialReferences.getWgs84()), 1E8));

    // set the map to be displayed in the mapview
    mMapView.setMap(map);//from   w w  w  .j  a  v a 2  s . c  o m

    // get callout, set content and show
    mCallout = mMapView.getCallout();

    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setTitle(getResources().getString(R.string.progress_title));
    mProgressDialog.setMessage(getResources().getString(R.string.progress_message));

    // create feature layer with its service feature table
    // create the service feature table
    mServiceFeatureTable = new ServiceFeatureTable(getResources().getString(R.string.sample_service_url));
    // create the feature layer using the service feature table
    mFeatureLayer = new FeatureLayer(mServiceFeatureTable);

    // set the color that is applied to a selected feature.
    mFeatureLayer.setSelectionColor(Color.rgb(0, 255, 255)); //cyan, fully opaque
    // set the width of selection color
    mFeatureLayer.setSelectionWidth(3);

    // add the layer to the map
    map.getOperationalLayers().add(mFeatureLayer);

    // set an on touch listener to listen for click events
    mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(this, mMapView) {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {

            // get the point that was clicked and convert it to a point in map coordinates
            mClickPoint = new android.graphics.Point((int) e.getX(), (int) e.getY());

            // clear any previous selection
            mFeatureLayer.clearSelection();
            mSelectedArcGISFeature = null;

            // identify the GeoElements in the given layer
            final ListenableFuture<IdentifyLayerResult> identifyFuture = mMapView
                    .identifyLayerAsync(mFeatureLayer, mClickPoint, 5, false, 1);

            // add done loading listener to fire when the selection returns
            identifyFuture.addDoneListener(new Runnable() {
                @Override
                public void run() {
                    try {
                        // call get on the future to get the result
                        IdentifyLayerResult layerResult = identifyFuture.get();
                        List<GeoElement> resultGeoElements = layerResult.getElements();

                        if (resultGeoElements.size() > 0) {
                            if (resultGeoElements.get(0) instanceof ArcGISFeature) {
                                mSelectedArcGISFeature = (ArcGISFeature) resultGeoElements.get(0);
                                // highlight the selected feature
                                mFeatureLayer.selectFeature(mSelectedArcGISFeature);
                                // show callout with the value for the attribute "typdamage" of the selected feature
                                mSelectedArcGISFeatureAttributeValue = (String) mSelectedArcGISFeature
                                        .getAttributes().get("typdamage");
                                showCallout(mSelectedArcGISFeatureAttributeValue);
                                Toast.makeText(getApplicationContext(),
                                        "Tap on the info button to change attribute value", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else {
                            // none of the features on the map were selected
                            mCallout.dismiss();
                        }
                    } catch (Exception e) {
                        Log.e(getResources().getString(R.string.app_name),
                                "Select feature failed: " + e.getMessage());
                    }
                }
            });
            return super.onSingleTapConfirmed(e);
        }
    });

    mSnackbarSuccess = Snackbar.make(mCoordinatorLayout, "Feature successfully updated", Snackbar.LENGTH_LONG)
            .setAction("UNDO", new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    String snackBarText = updateAttributes(mSelectedArcGISFeatureAttributeValue)
                            ? "Feature is restored!"
                            : "Feature restore failed!";
                    Snackbar snackbar1 = Snackbar.make(mCoordinatorLayout, snackBarText, Snackbar.LENGTH_SHORT);
                    snackbar1.show();
                }
            });

    mSnackbarFailure = Snackbar.make(mCoordinatorLayout, "Feature update failed", Snackbar.LENGTH_LONG);

}

From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothTabView.java

/**
 * Instantiates a new ab sliding smooth tab view.
 *
 * @param context the context/*w  ww . j a va  2 s  . co  m*/
 * @param attrs the attrs
 */
public ESSlidingSmoothTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new ESHorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);
    //mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabScrollView, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        ESLogUtil.e(ESSlidingSmoothTabView.class,
                "AbSlidingSmoothTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new ESFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabScrollView.setOnScrollListener(new AbOnScrollListener() {

        @Override
        public void onScrollToRight() {
            ESLogUtil.d(ESSlidingSmoothTabView.class, "onScrollToRight");
        }

        @Override
        public void onScrollToLeft() {
            ESLogUtil.d(ESSlidingSmoothTabView.class, "onScrollToLeft");
        }

        @Override
        public void onScrollStoped() {
            ESLogUtil.d(ESSlidingSmoothTabView.class, "onScrollStoped");
        }

        @Override
        public void onScroll(int arg1) {
            scrollX = arg1;
            View view = mTabLayout.getChildAt(mSelectedTabIndex);
            int toX = view.getLeft() - scrollX;

            ESLogUtil.d(ESSlidingSmoothTabView.class, "X" + startX + "to" + toX);
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }
    });
}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothTabView.java

/**
 * Instantiates a new ab sliding smooth tab view.
 *
 * @param context the context/*from  w  w  w . j a  va  2 s .  co  m*/
 * @param attrs the attrs
 */
public AbSlidingSmoothTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new AbHorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);
    //mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabScrollView, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbSlidingSmoothTabView.class,
                "AbSlidingSmoothTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabScrollView.setOnScrollListener(new AbOnScrollListener() {

        @Override
        public void onScrollToRight() {
            AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollToRight");
        }

        @Override
        public void onScrollToLeft() {
            AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollToLeft");
        }

        @Override
        public void onScrollStoped() {
            AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollStoped");
        }

        @Override
        public void onScroll(int arg1) {
            scrollX = arg1;
            View view = mTabLayout.getChildAt(mSelectedTabIndex);
            int toX = view.getLeft() - scrollX;

            AbLogUtil.d(AbSlidingSmoothTabView.class, "X" + startX + "to" + toX);
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }
    });
}

From source file:app.philm.in.fragments.SideMenuFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    View view = inflater.inflate(R.layout.fragment_drawer, container, false);

    mListView = (ListView) view.findViewById(android.R.id.list);
    mListView.setOnItemClickListener(this);
    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    mAdapter = new SideMenuItemAdapter();
    mListView.setAdapter(mAdapter);/*from  www  . j a  v a  2 s  .  c  o  m*/

    mAddAccountLayout = view.findViewById(R.id.layout_add_account);
    mAddAccountLayout.setOnClickListener(this);

    mProfileInfoLayout = view.findViewById(R.id.layout_profile_inner);
    mProfileInfoLayout.setOnClickListener(this);
    mUsernameTextView = (TextView) view.findViewById(R.id.textview_username);
    mFullnameTextView = (TextView) view.findViewById(R.id.textview_fullname);
    mAvatarImageView = (ImageView) view.findViewById(R.id.imageview_account_avatar);

    mCheckinLayout = view.findViewById(R.id.layout_checkin);
    mCheckinLayout.setOnClickListener(this);

    mCheckinImageView = (PhilmImageView) view.findViewById(R.id.imageview_checkin_movie);
    mCheckinImageView.setAutoFade(false);
    mCheckinTitleTextView = (TextView) mCheckinLayout.findViewById(R.id.textview_title);

    final int darkenByte = Math.round(255 * CHECKIN_BACKDROP_DARKEN);
    mColorFilter = new LightingColorFilter(Color.rgb(darkenByte, darkenByte, darkenByte), 0);

    return view;
}

From source file:com.sam_chordas.android.stockhawk.ui.ChartFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_chart, container, false);

    chart = (LineChart) view.findViewById(R.id.chart);

    chart.setDescription(mSymbol + getString(R.string.stock));
    chart.animateXY(2000, 2000);// w  w w.j  av a2 s .  c o  m

    //scale Y-axis
    leftAxis = chart.getAxisLeft();
    rightAxis = chart.getAxisRight();

    //chart label color
    leftAxis.setTextColor(Color.rgb(255, 255, 255));
    rightAxis.setTextColor(Color.rgb(255, 255, 255));
    chart.getXAxis().setTextColor(Color.rgb(255, 255, 255));
    chart.getLegend().setTextColor(Color.rgb(255, 255, 255));

    //don't start at 0
    leftAxis.setStartAtZero(false);
    rightAxis.setStartAtZero(false);

    //set chart spacing
    leftAxis.setSpaceTop(50f);
    leftAxis.setSpaceBottom(50f);
    rightAxis.setSpaceTop(50f);
    rightAxis.setSpaceBottom(50f);

    //refresh chart
    chart.invalidate();

    return view;
}

From source file:com.ylq.commonui.AbSlidingTabView.java

/**
 * Instantiates a new ab sliding tab view.
 *
 * @param context the context//from w  w  w .j  a  va2s .  c o m
 * @param attrs the attrs
 */
public AbSlidingTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new HorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);

    //mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    this.addView(mTabScrollView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();
    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();
    tabItemDrawableList = new ArrayList<Drawable>();

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        Log.e(TAG, "AbSlidingTabView?context,FragmentActivity");
    }

}

From source file:com.dreamchen.useful.mouserace.view.sliding.AbSlidingSmoothTabView.java

/**
 * Instantiates a new ab sliding smooth tab view.
 *
 * @param context the context//from   w  w  w.j a  v a  2 s.c  om
 * @param attrs the attrs
 */
public AbSlidingSmoothTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new AbHorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);
    //mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabScrollView, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbSlidingSmoothTabView.class,
                "AbSlidingSmoothTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getSupportFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabScrollView.setOnScrollListener(new AbHorizontalScrollView.AbOnScrollListener() {

        @Override
        public void onScrollToRight() {
            AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollToRight");
        }

        @Override
        public void onScrollToLeft() {
            AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollToLeft");
        }

        @Override
        public void onScrollStoped() {
            AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollStoped");
        }

        @Override
        public void onScroll(int arg1) {
            scrollX = arg1;
            View view = mTabLayout.getChildAt(mSelectedTabIndex);
            int toX = view.getLeft() - scrollX;

            AbLogUtil.d(AbSlidingSmoothTabView.class, "X" + startX + "to" + toX);
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }
    });
}

From source file:com.njlabs.amrita.aid.landing.Landing.java

@SuppressLint("ShortAlarm")
@Override//w ww .  j  av a 2s. c  om
public void init(Bundle savedInstanceState) {
    setupLayout(R.layout.activity_landing, "Amrita Info Desk");
    toolbar.setBackgroundColor(getResources().getColor(R.color.white));
    setRecentHeaderColor(getResources().getColor(R.color.white));
    checkForUpdates();

    AccountHeader headerResult = new AccountHeaderBuilder().withActivity(this)
            .withHeaderBackground(R.drawable.header)
            .addProfiles(new ProfileDrawerItem().withName("Amrita Info Desk")
                    .withEmail("Version " + BuildConfig.VERSION_NAME).setSelectable(false))
            .withSelectionListEnabledForSingleProfile(false).build();

    headerResult.getHeaderBackgroundView().setColorFilter(Color.rgb(170, 170, 170),
            android.graphics.PorterDuff.Mode.MULTIPLY);
    Drawer result = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(headerResult)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName("Home").withIcon(R.drawable.ic_action_home)
                            .withCheckable(false),
                    new PrimaryDrawerItem()
                            .withName("News").withIcon(R.drawable.ic_action_speaker_notes).withCheckable(false),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName("About the app").withIcon(R.drawable.ic_action_info)
                            .withCheckable(false),
                    new PrimaryDrawerItem().withName("Invite").withIcon(R.drawable.ic_action_info)
                            .withCheckable(false),
                    new PrimaryDrawerItem().withName("Settings").withIcon(R.drawable.ic_action_settings)
                            .withCheckable(false))
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(AdapterView<?> parent, View view, int position, long id,
                        IDrawerItem drawerItem) {
                    switch (position) {
                    case 1:
                        startActivity(new Intent(baseContext, NewsActivity.class));
                        break;
                    case 3:
                        startActivity(new Intent(baseContext, App.class));
                        break;
                    case 4:
                        Intent intent = new AppInviteInvitation.IntentBuilder("Invite users")
                                .setMessage("Spread the word to fellow Amrititans")
                                .setCallToActionText("Invite").build();
                        startActivityForResult(intent, 211);
                        break;
                    case 5:
                        startActivity(new Intent(baseContext, SettingsActivity.class));
                        break;
                    }
                    return false;
                }
            }).withCloseOnClick(true).build();

    setupGrid();

    File aumsCookieFile = new File(getApplicationContext().getFilesDir().getParent() + "/shared_prefs/"
            + PersistentCookieStore.AUMS_COOKIE_PREFS + ".xml");
    if (aumsCookieFile.exists()) {
        aumsCookieFile.delete();
    }

    File gpmsCookieFile = new File(getApplicationContext().getFilesDir().getParent() + "/shared_prefs/"
            + PersistentCookieStore.GPMS_COOKIE_PREFS + ".xml");
    if (gpmsCookieFile.exists()) {
        gpmsCookieFile.delete();
    }

    AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarm.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (1000 * 60 * 60 * 6),
            PendingIntent.getService(this, 0, new Intent(this, NewsUpdateService.class), 0));

    startService(new Intent(baseContext, NewsUpdateService.class));
}