Example usage for android.graphics.drawable ColorDrawable ColorDrawable

List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable ColorDrawable ColorDrawable.

Prototype

public ColorDrawable(@ColorInt int color) 

Source Link

Document

Creates a new ColorDrawable with the specified color.

Usage

From source file:arun.com.chameleonskinforkwlp.MainActivity.java

private void initToolbar(Bundle savedInstanceState) {
    setSupportActionBar(binding.toolbar);
    Glide.with(this).load(R.drawable.backdrop).centerCrop().into(binding.backdrop);
    AccountHeader header = new AccountHeaderBuilder().withActivity(this).withCompactStyle(true)
            .withSelectionFirstLine(getResources().getString(R.string.app_name))
            .withSelectionSecondLine(getResources().getString(R.string.app_tagline))
            .withProfileImagesClickable(false).withSelectionListEnabled(false)
            .withProfiles(new ArrayList<IProfile>() {
                {/*from   w  w  w .j  av  a2s .  com*/
                    add(new ProfileDrawerItem().withIcon(
                            new IconicsDrawable(MainActivity.this).icon(GoogleMaterial.Icon.gmd_local_florist)
                                    .color(Color.WHITE).sizeDp(20).paddingDp(5)));
                }
            }).withHeaderBackground(new ColorDrawable(ContextCompat.getColor(this, R.color.primary_dark)))
            .withSelectionListEnabledForSingleProfile(false).withSavedInstance(savedInstanceState).build();
    new DrawerBuilder().withActivity(this).withToolbar(binding.toolbar).withAccountHeader(header)
            .withSelectedItem(-1)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(R.string.set_as_system_wallpaper).withIdentifier(1)
                            .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_wallpaper),
                    new PrimaryDrawerItem().withName(R.string.use_with_kustom).withSelectable(false)
                            .withIcon(GoogleMaterial.Icon.gmd_palette).withIdentifier(2),
                    new DividerDrawerItem(),
                    new SecondaryDrawerItem().withName(R.string.rate_this_app).withSelectable(false)
                            .withIdentifier(3).withIcon(GoogleMaterial.Icon.gmd_star),
                    new SecondaryDrawerItem().withName(R.string.privacy_policy)
                            .withIcon(GoogleMaterial.Icon.gmd_insert_drive_file).withSelectable(false)
                            .withIdentifier(4),
                    new SecondaryDrawerItem().withName(R.string.more_apps)
                            .withIcon(GoogleMaterial.Icon.gmd_account_circle).withSelectable(false)
                            .withIdentifier(5))
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    if (drawerItem != null) {
                        switch ((int) drawerItem.getIdentifier()) {
                        case 1:
                            launchSetWallpaperScreen();
                            break;
                        case 2:
                            if (Util.isPackageInstalled(MainActivity.this, "org.kustom.wallpaper")) {
                                Util.openApp(MainActivity.this, "org.kustom.wallpaper");
                            } else {
                                Snackbar.make(binding.coordinatorLayout, R.string.kustom_not_found,
                                        Snackbar.LENGTH_SHORT).show();
                            }
                            break;
                        case 3:
                            Util.openPlayStore(MainActivity.this, getPackageName());
                            break;
                        case 4:
                            Intent licenses = new Intent(Intent.ACTION_VIEW, Uri.parse(
                                    "http://htmlpreview.github.com/?https://github.com/arunkumar9t2/chameleon-live-wallpaper/blob/master/privacy_policy.html"));
                            startActivity(licenses);
                            break;
                        case 5:
                            try {
                                startActivity(new Intent(Intent.ACTION_VIEW,
                                        Uri.parse("market://search?q=pub:Arunkumar")));
                            } catch (android.content.ActivityNotFoundException anfe) {
                                startActivity(new Intent(Intent.ACTION_VIEW,
                                        Uri.parse("http://play.google.com/store/search?q=pub:Arunkumar")));
                            }
                            break;
                        }
                    }
                    return false;
                }
            }).build();
}

From source file:com.lx.minimusic.MainActivity.java

private void changeColor(int newColor) {

    tabs.setIndicatorColor(newColor);//from w w w.j  a v a 2 s .com

    // change ActionBar color just if an ActionBar is available
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

        Drawable colorDrawable = new ColorDrawable(newColor);
        Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom);
        LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable });

        if (oldBackground == null) {

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
                ld.setCallback(drawableCallback);
            } else {
                getActionBar().setBackgroundDrawable(ld);
            }

        } else {

            TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld });

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
                td.setCallback(drawableCallback);
            } else {
                getActionBar().setBackgroundDrawable(td);
            }

            td.startTransition(200);

        }

        oldBackground = ld;

        // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler
        getActionBar().setDisplayShowTitleEnabled(false);
        getActionBar().setDisplayShowTitleEnabled(true);

    }

    currentColor = newColor;

}

From source file:com.bachhuberdesign.deckbuildergwent.util.FabTransform.java

@Override
public Animator createAnimator(final ViewGroup sceneRoot, final TransitionValues startValues,
        final TransitionValues endValues) {
    if (startValues == null || endValues == null)
        return null;

    final Rect startBounds = (Rect) startValues.values.get(PROP_BOUNDS);
    final Rect endBounds = (Rect) endValues.values.get(PROP_BOUNDS);

    final boolean fromFab = endBounds.width() > startBounds.width();
    final View view = endValues.view;
    final Rect dialogBounds = fromFab ? endBounds : startBounds;
    final Interpolator fastOutSlowInInterpolator = AnimUtils.getFastOutSlowInInterpolator();
    final long duration = getDuration();
    final long halfDuration = duration / 2;
    final long twoThirdsDuration = duration * 2 / 3;

    if (!fromFab) {
        // Force measure / layout the dialog back to it's original bounds
        view.measure(makeMeasureSpec(startBounds.width(), View.MeasureSpec.EXACTLY),
                makeMeasureSpec(startBounds.height(), View.MeasureSpec.EXACTLY));
        view.layout(startBounds.left, startBounds.top, startBounds.right, startBounds.bottom);
    }/* www  .j  a  v  a  2 s.c  o  m*/

    final int translationX = startBounds.centerX() - endBounds.centerX();
    final int translationY = startBounds.centerY() - endBounds.centerY();
    if (fromFab) {
        view.setTranslationX(translationX);
        view.setTranslationY(translationY);
    }

    // Add a color overlay to fake appearance of the FAB
    final ColorDrawable fabColor = new ColorDrawable(color);
    fabColor.setBounds(0, 0, dialogBounds.width(), dialogBounds.height());
    if (!fromFab)
        fabColor.setAlpha(0);
    view.getOverlay().add(fabColor);

    // Add an icon overlay again to fake the appearance of the FAB
    final Drawable fabIcon = ContextCompat.getDrawable(sceneRoot.getContext(), icon).mutate();
    final int iconLeft = (dialogBounds.width() - fabIcon.getIntrinsicWidth()) / 2;
    final int iconTop = (dialogBounds.height() - fabIcon.getIntrinsicHeight()) / 2;
    fabIcon.setBounds(iconLeft, iconTop, iconLeft + fabIcon.getIntrinsicWidth(),
            iconTop + fabIcon.getIntrinsicHeight());
    if (!fromFab)
        fabIcon.setAlpha(0);
    view.getOverlay().add(fabIcon);

    // Since the view that's being transition to always seems to be on the top (z-order), we have
    // to make a copy of the "from" view and put it in the "to" view's overlay, then fade it out.
    // There has to be another way to do this, right?
    Drawable dialogView = null;
    if (!fromFab) {
        startValues.view.setDrawingCacheEnabled(true);
        startValues.view.buildDrawingCache();
        Bitmap viewBitmap = startValues.view.getDrawingCache();
        dialogView = new BitmapDrawable(view.getResources(), viewBitmap);
        dialogView.setBounds(0, 0, dialogBounds.width(), dialogBounds.height());
        view.getOverlay().add(dialogView);
    }

    // Circular clip from/to the FAB size
    final Animator circularReveal;
    if (fromFab) {
        circularReveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2,
                view.getHeight() / 2, startBounds.width() / 2,
                (float) Math.hypot(endBounds.width() / 2, endBounds.height() / 2));
        circularReveal.setInterpolator(AnimUtils.getFastOutLinearInInterpolator());
    } else {
        circularReveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2,
                view.getHeight() / 2, (float) Math.hypot(startBounds.width() / 2, startBounds.height() / 2),
                endBounds.width() / 2);
        circularReveal.setInterpolator(AnimUtils.getLinearOutSlowInInterpolator());

        // Persist the end clip i.e. stay at FAB size after the reveal has run
        circularReveal.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                final ViewOutlineProvider fabOutlineProvider = view.getOutlineProvider();

                view.setOutlineProvider(new ViewOutlineProvider() {
                    boolean hasRun = false;

                    @Override
                    public void getOutline(final View view, Outline outline) {
                        final int left = (view.getWidth() - endBounds.width()) / 2;
                        final int top = (view.getHeight() - endBounds.height()) / 2;

                        outline.setOval(left, top, left + endBounds.width(), top + endBounds.height());

                        if (!hasRun) {
                            hasRun = true;
                            view.setClipToOutline(true);

                            // We have to remove this as soon as it's laid out so we can get the shadow back
                            view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
                                @Override
                                public boolean onPreDraw() {
                                    if (view.getWidth() == endBounds.width()
                                            && view.getHeight() == endBounds.height()) {
                                        view.setOutlineProvider(fabOutlineProvider);
                                        view.setClipToOutline(false);
                                        view.getViewTreeObserver().removeOnPreDrawListener(this);
                                        return true;
                                    }

                                    return true;
                                }
                            });
                        }
                    }
                });
            }
        });
    }
    circularReveal.setDuration(duration);

    // Translate to end position along an arc
    final Animator translate = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, View.TRANSLATION_Y,
            fromFab ? getPathMotion().getPath(translationX, translationY, 0, 0)
                    : getPathMotion().getPath(0, 0, -translationX, -translationY));
    translate.setDuration(duration);
    translate.setInterpolator(fastOutSlowInInterpolator);

    // Fade contents of non-FAB view in/out
    List<Animator> fadeContents = null;
    if (view instanceof ViewGroup) {
        final ViewGroup vg = ((ViewGroup) view);
        fadeContents = new ArrayList<>(vg.getChildCount());
        for (int i = vg.getChildCount() - 1; i >= 0; i--) {
            final View child = vg.getChildAt(i);
            final Animator fade = ObjectAnimator.ofFloat(child, View.ALPHA, fromFab ? 1f : 0f);
            if (fromFab) {
                child.setAlpha(0f);
            }
            fade.setDuration(twoThirdsDuration);
            fade.setInterpolator(fastOutSlowInInterpolator);
            fadeContents.add(fade);
        }
    }

    // Fade in/out the fab color & icon overlays
    final Animator colorFade = ObjectAnimator.ofInt(fabColor, "alpha", fromFab ? 0 : 255);
    final Animator iconFade = ObjectAnimator.ofInt(fabIcon, "alpha", fromFab ? 0 : 255);
    if (!fromFab) {
        colorFade.setStartDelay(halfDuration);
        iconFade.setStartDelay(halfDuration);
    }
    colorFade.setDuration(halfDuration);
    iconFade.setDuration(halfDuration);
    colorFade.setInterpolator(fastOutSlowInInterpolator);
    iconFade.setInterpolator(fastOutSlowInInterpolator);

    // Run all animations together
    final AnimatorSet transition = new AnimatorSet();
    transition.playTogether(circularReveal, translate, colorFade, iconFade);
    transition.playTogether(fadeContents);
    if (dialogView != null) {
        final Animator dialogViewFade = ObjectAnimator.ofInt(dialogView, "alpha", 0)
                .setDuration(twoThirdsDuration);
        dialogViewFade.setInterpolator(fastOutSlowInInterpolator);
        transition.playTogether(dialogViewFade);
    }
    transition.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            // Clean up
            view.getOverlay().clear();

            if (!fromFab) {
                view.setTranslationX(0);
                view.setTranslationY(0);
                view.setTranslationZ(0);

                view.measure(makeMeasureSpec(endBounds.width(), View.MeasureSpec.EXACTLY),
                        makeMeasureSpec(endBounds.height(), View.MeasureSpec.EXACTLY));
                view.layout(endBounds.left, endBounds.top, endBounds.right, endBounds.bottom);
            }

        }
    });
    return new AnimUtils.NoPauseAnimator(transition);
}

From source file:com.ibm.mil.readyapps.summit.fragments.SingleUserListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // enables ripple effect over each list item
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getListView().setDrawSelectorOnTop(true);
    }/*w  ww . j  ava2  s.c o m*/

    addFooterView(savedInstanceState);

    getListView().setDivider(new ColorDrawable(android.R.color.transparent));
    getListView().setDividerHeight(AndroidUtils.pixelsToDip(getActivity(), 3));

    setListAdapter(new ProductAdapter(getActivity(), R.layout.item_single_user_list, products));
}

From source file:com.example.android.swiperefreshlistfragment.SwipeRefreshListFragmentFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    /**//  w  ww  .  ja  va  2 s.  co  m
     * Create an ArrayAdapter to contain the data for the ListView. Each item in the ListView
     * uses the system-defined simple_list_item_1 layout that contains one TextView.
     */
    //        ListAdapter adapter = new ArrayAdapter<String>(
    //                getActivity(),
    //                android.R.layout.simple_list_item_1,
    //                android.R.id.text1,
    //                Cheeses.randomList(LIST_ITEM_COUNT));
    mFeedItems = new ArrayList<FeedItem>();
    mFeedListAdapter = new FeedListAdapter(getActivity(), mFeedItems);

    // Set the adapter between the ListView and its backing data.
    setListAdapter(mFeedListAdapter);

    // BEGIN_INCLUDE (setup_refreshlistener)
    /**
     * Implement {@link SwipeRefreshLayout.OnRefreshListener}. When users do the "swipe to
     * refresh" gesture, SwipeRefreshLayout invokes
     * {@link SwipeRefreshLayout.OnRefreshListener#onRefresh onRefresh()}. In
     * {@link SwipeRefreshLayout.OnRefreshListener#onRefresh onRefresh()}, call a method that
     * refreshes the content. Call the same method in response to the Refresh action from the
     * action bar.
     */
    // These two lines not needed,
    // just to get the look of facebook (changing background color & hiding the icon)
    getActivity().getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#3b5998")));
    getActivity().getActionBar()
            .setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            Log.i(LOG_TAG, "onRefresh called from SwipeRefreshLayout");
            doRequest();
            //                initiateRefresh();
        }
    });

    // END_INCLUDE (setup_refreshlistener)
}

From source file:com.odoo.addons.customers.CustomerDetails.java

private void setMode(Boolean edit) {
    if (mMenu != null) {
        mMenu.findItem(R.id.menu_customer_detail_more).setVisible(!edit);
        mMenu.findItem(R.id.menu_customer_edit).setVisible(!edit);
        mMenu.findItem(R.id.menu_customer_save).setVisible(edit);
        mMenu.findItem(R.id.menu_customer_cancel).setVisible(edit);
    }/* w w  w. j  av  a2  s. co  m*/
    int color = Color.DKGRAY;
    if (record != null) {
        color = OStringColorUtil.getStringColor(this, record.getString("name"));
    }
    if (edit) {
        if (extras != null)
            actionBar.setTitle(R.string.label_edit);
        else
            actionBar.setTitle(R.string.label_new);
        actionBar.setBackgroundDrawable(new ColorDrawable(color));
        mForm = (OForm) findViewById(R.id.customerFormEdit);
        captureImage = (ImageView) findViewById(R.id.captureImage);
        captureImage.setOnClickListener(this);
        userImage = (ImageView) findViewById(android.R.id.icon1);
        findViewById(R.id.parallaxScrollView).setVisibility(View.GONE);
        findViewById(R.id.customerScrollViewEdit).setVisibility(View.VISIBLE);
        OField is_company = (OField) findViewById(R.id.is_company_edit);
        is_company.setOnValueChangeListener(this);
    } else {
        actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.action_bar_shade));
        userImage = (ImageView) findViewById(android.R.id.icon);
        mForm = (OForm) findViewById(R.id.customerForm);
        findViewById(R.id.customerScrollViewEdit).setVisibility(View.GONE);
        findViewById(R.id.parallaxScrollView).setVisibility(View.VISIBLE);
    }
    setColor(color);
}

From source file:com.app.sample.chatting.activity.chat.FacePageFragment.java

@Override
protected void initWidget(View rootView) {
    super.initWidget(rootView);
    mPagerFace = (ViewPager) rootView.findViewById(R.id.frag_pager_face);
    pagePointLayout = (LinearLayout) rootView.findViewById(R.id.frag_point);

    int total = datas.size();
    int pages = total / ITEM_PAGE_COUNT + (total % ITEM_PAGE_COUNT == 0 ? 0 : 1);

    allPageViews = new GridView[pages];
    pointViews = new RadioButton[pages];

    for (int x = 0; x < pages; x++) {
        int start = x * ITEM_PAGE_COUNT;
        int end = (start + ITEM_PAGE_COUNT) > total ? total : (start + ITEM_PAGE_COUNT);
        final List<Faceicon> itemDatas = datas.subList(start, end);
        GridView view = new GridView(aty);
        FaceAdapter faceAdapter = new FaceAdapter(view, itemDatas);
        view.setAdapter(faceAdapter);//from   ww  w .  j  av  a2s. c o m

        view.setNumColumns(4);
        view.setBackgroundColor(Color.TRANSPARENT);
        view.setHorizontalSpacing(1);
        view.setVerticalSpacing(1);
        view.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
        view.setCacheColorHint(0);
        view.setVerticalScrollBarEnabled(false);
        view.setPadding(5, 0, 5, 0);
        view.setSelector(new ColorDrawable(Color.TRANSPARENT));
        view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        view.setGravity(Gravity.CENTER);

        view.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (listener != null) {
                    listener.selectedFace(itemDatas.get(position));
                }
            }
        });
        allPageViews[x] = view;

        RadioButton tip = new RadioButton(aty);
        tip.setBackgroundResource(R.drawable.selector_bg_tip);
        RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(8, 8);
        layoutParams.leftMargin = 10;
        pagePointLayout.addView(tip, layoutParams);
        if (x == 0) {
            tip.setChecked(true);
        }
        pointViews[x] = tip;
    }

    PagerAdapter facePagerAdapter = new FacePagerAdapter(allPageViews);
    mPagerFace.setAdapter(facePagerAdapter);
    mPagerFace.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int index) {
            pointViews[index].setChecked(true);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
}

From source file:com.klinker.android.twitter.activities.search.SearchPager.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    overridePendingTransition(R.anim.slide_in_left, R.anim.activity_zoom_exit);

    try {//w ww .jav a  2s.  c  om
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }

    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);

    try {
        searchQuery = getIntent().getStringExtra(SearchManager.QUERY);
    } catch (Exception e) {
        searchQuery = "";
    }

    if (searchQuery == null) {
        searchQuery = "";
    }

    handleIntent(getIntent());

    if (Build.VERSION.SDK_INT > 18 && settings.uiExtras
            && (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE
                    || getResources().getBoolean(R.bool.isTablet))) {
        translucent = true;
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

        try {
            int immersive = android.provider.Settings.System.getInt(getContentResolver(), "immersive_mode");

            if (immersive == 1) {
                translucent = false;
            }
        } catch (Exception e) {
        }
    } else {
        translucent = false;
    }

    Utils.setUpTheme(context, settings);
    setContentView(R.layout.search_pager);

    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.search));
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));

    View statusBar = findViewById(R.id.activity_status_bar);

    mViewPager = (ViewPager) findViewById(R.id.pager);

    if (translucent) {
        statusBar.setVisibility(View.VISIBLE);

        int statusBarHeight = Utils.getStatusBarHeight(context);

        LinearLayout.LayoutParams statusParams = (LinearLayout.LayoutParams) statusBar.getLayoutParams();
        statusParams.height = statusBarHeight;
        statusBar.setLayoutParams(statusParams);
    } else {
        mViewPager.setPadding(0, 0, 0, 0);
    }

    mSectionsPagerAdapter = new SearchPagerAdapter(getFragmentManager(), context, onlyStatus, onlyProfile,
            searchQuery, translucent);

    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOffscreenPageLimit(3);

    if (settings.addonTheme) {
        PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
        strip.setBackgroundColor(settings.pagerTitleInt);
    }

    mViewPager.setCurrentItem(1);

    Utils.setActionBar(context, true);

    if (onlyProfile) {
        mViewPager.setCurrentItem(2);
    }
}

From source file:com.klinker.android.twitter.ui.search.SearchPager.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    overridePendingTransition(R.anim.slide_in_left, R.anim.activity_zoom_exit);

    try {/* w  ww  .ja  v  a  2s  . c o  m*/
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }

    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    settings = AppSettings.getInstance(this);

    try {
        searchQuery = getIntent().getStringExtra(SearchManager.QUERY);
    } catch (Exception e) {
        searchQuery = "";
    }

    if (searchQuery == null) {
        searchQuery = "";
    }

    handleIntent(getIntent());

    if (Build.VERSION.SDK_INT > 18 && settings.uiExtras
            && (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE
                    || getResources().getBoolean(R.bool.isTablet))) {
        translucent = true;
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

        try {
            int immersive = android.provider.Settings.System.getInt(getContentResolver(), "immersive_mode");

            if (immersive == 1) {
                translucent = false;
            }
        } catch (Exception e) {
        }
    } else {
        translucent = false;
    }

    Utils.setUpTheme(context, settings);
    setContentView(R.layout.search_pager);

    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.search));
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));

    View statusBar = findViewById(R.id.activity_status_bar);

    mViewPager = (ViewPager) findViewById(R.id.pager);

    if (translucent) {
        statusBar.setVisibility(View.VISIBLE);

        int statusBarHeight = Utils.getStatusBarHeight(context);

        LinearLayout.LayoutParams statusParams = (LinearLayout.LayoutParams) statusBar.getLayoutParams();
        statusParams.height = statusBarHeight;
        statusBar.setLayoutParams(statusParams);
    } else {
        mViewPager.setPadding(0, 0, 0, 0);
    }

    mSectionsPagerAdapter = new SearchPagerAdapter(getFragmentManager(), context, onlyStatus, onlyProfile,
            searchQuery, translucent);

    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOffscreenPageLimit(3);

    if (settings.addonTheme) {
        PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
        strip.setBackgroundColor(settings.pagerTitleInt);
    }

    mViewPager.setCurrentItem(1);

    Utils.setActionBar(context, true);

    if (onlyProfile) {
        mViewPager.setCurrentItem(2);
    }
}

From source file:com.ibm.mil.readyapps.summit.fragments.MultipleUserListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // add header to list view if in non-overlay mode
    if (!isOverlayMode()) {
        addCustomHeader(savedInstanceState);
    }/*from  ww w  .  j  a v  a2 s  .  c om*/

    getListView().setDivider(new ColorDrawable(android.R.color.transparent));
    getListView().setDividerHeight(AndroidUtils.pixelsToDip(getActivity(), 3));

    // properly displays ripple effect on API 21+
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getListView().setDrawSelectorOnTop(true);
    }

    mListData = RealmDataManager.getLists(getActivity());
    userAdapter = new UserListAdapter(getActivity(), R.layout.item_multiple_user_list, mListData);
    setListAdapter(userAdapter);
}