Example usage for android.view View getBackground

List of usage examples for android.view View getBackground

Introduction

In this page you can find the example usage for android.view View getBackground.

Prototype

public Drawable getBackground() 

Source Link

Document

Gets the background drawable

Usage

From source file:org.mozilla.gecko.AwesomeBarTabs.java

private TabSpec addAwesomeTab(String id, int titleId, int contentId) {
    TabSpec tab = newTabSpec(id);// w w w  . j a v a  2  s  . c  o  m

    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View indicatorView = inflater.inflate(R.layout.awesomebar_tab_indicator, null);
    Drawable background = indicatorView.getBackground();
    try {
        background.setColorFilter(
                new LightingColorFilter(Color.WHITE, GeckoApp.mBrowserToolbar.getHighlightColor()));
    } catch (Exception e) {
        Log.d(LOGTAG, "background.setColorFilter failed " + e);
    }
    TextView title = (TextView) indicatorView.findViewById(R.id.title);
    title.setText(titleId);

    tab.setIndicator(indicatorView);
    tab.setContent(contentId);

    addTab(tab);

    return tab;
}

From source file:com.waz.zclient.pages.main.conversationpager.SlidingPaneLayout.java

private static boolean viewIsOpaque(View v) {
    if (ViewCompat.isOpaque(v)) {
        return true;
    }// www .  ja  v  a 2s.  c  o m

    // View#isOpaque didn't take all valid opaque scrollbar modes into account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false
    // here. On older devices, check the view's background drawable directly as a fallback.
    if (Build.VERSION.SDK_INT >= 18) {
        return false;
    }

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }
    return false;
}

From source file:com.taobao.weex.dom.action.AnimationAction.java

private @Nullable ObjectAnimator createAnimator(final View target, final int viewPortWidth) {
    if (target == null) {
        return null;
    }/*ww  w  .j  a va 2  s  .  c o  m*/
    WXAnimationBean.Style style = mAnimationBean.styles;
    if (style != null) {
        ObjectAnimator animator;
        List<PropertyValuesHolder> holders = style.getHolders();
        if (!TextUtils.isEmpty(style.backgroundColor)) {
            BorderDrawable borderDrawable;
            if ((borderDrawable = WXViewUtils.getBorderDrawable(target)) != null) {
                holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(),
                        borderDrawable.getColor(), WXResourceUtils.getColor(style.backgroundColor)));
            } else if (target.getBackground() instanceof ColorDrawable) {
                holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(),
                        ((ColorDrawable) target.getBackground()).getColor(),
                        WXResourceUtils.getColor(style.backgroundColor)));
            }
        }
        if (style.getPivot() != null) {
            Pair<Float, Float> pair = style.getPivot();
            target.setPivotX(pair.first);
            target.setPivotY(pair.second);
        }
        animator = ObjectAnimator.ofPropertyValuesHolder(target,
                holders.toArray(new PropertyValuesHolder[holders.size()]));
        animator.setStartDelay(mAnimationBean.delay);
        if (target.getLayoutParams() != null
                && (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
            DimensionUpdateListener listener = new DimensionUpdateListener(target);
            ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
            if (!TextUtils.isEmpty(style.width)) {
                listener.setWidth(layoutParams.width,
                        (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth));
            }
            if (!TextUtils.isEmpty(style.height)) {
                listener.setHeight(layoutParams.height,
                        (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth));
            }
            animator.addUpdateListener(listener);
        }
        return animator;
    } else {
        return null;
    }
}

From source file:com.taobao.weex.ui.action.GraphicActionAnimation.java

private @Nullable ObjectAnimator createAnimator(final View target, final int viewPortWidth) {
    if (target == null) {
        return null;
    }// www.  ja v  a  2 s.co m
    WXAnimationBean.Style style = mAnimationBean.styles;
    if (style != null) {
        ObjectAnimator animator;
        List<PropertyValuesHolder> holders = style.getHolders();
        if (!TextUtils.isEmpty(style.backgroundColor)) {
            BorderDrawable borderDrawable;
            if ((borderDrawable = WXViewUtils.getBorderDrawable(target)) != null) {
                holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(),
                        borderDrawable.getColor(), WXResourceUtils.getColor(style.backgroundColor)));
            } else if (target.getBackground() instanceof ColorDrawable) {
                holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(),
                        ((ColorDrawable) target.getBackground()).getColor(),
                        WXResourceUtils.getColor(style.backgroundColor)));
            }
        }

        if (target.getLayoutParams() != null
                && (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
            ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
            if (!TextUtils.isEmpty(style.width)) {
                holders.add(PropertyValuesHolder.ofInt(new WidthProperty(), layoutParams.width,
                        (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth)));
            }
            if (!TextUtils.isEmpty(style.height)) {
                holders.add(PropertyValuesHolder.ofInt(new HeightProperty(), layoutParams.height,
                        (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth)));
            }
        }

        if (style.getPivot() != null) {
            Pair<Float, Float> pair = style.getPivot();
            target.setPivotX(pair.first);
            target.setPivotY(pair.second);
        }
        animator = ObjectAnimator.ofPropertyValuesHolder(target,
                holders.toArray(new PropertyValuesHolder[holders.size()]));
        animator.setStartDelay(mAnimationBean.delay);
        return animator;
    } else {
        return null;
    }
}

From source file:name.teze.layout.lib.SlidingPaneLayout.java

private static boolean viewIsOpaque(View v) {
    if (isOpaque(v))
        return true;// hack by Fooyou

    // View#isOpaque didn't take all valid opaque scrollbar modes into account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false
    // here. On older devices, check the view's background drawable directly as a fallback.
    if (Build.VERSION.SDK_INT >= 18)
        return false;

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }//w w w. j  av a2  s.c o m
    return false;
}

From source file:com.tr4android.support.extension.widget.FloatingActionMenu.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    measureChildren(widthMeasureSpec, heightMeasureSpec);

    int width = 0;
    int height = 0;

    mMaxButtonWidth = 0;//from  ww w  . j  a  v  a 2  s.  c  o  m
    mMaxButtonHeight = 0;
    int maxLabelWidth = 0;

    for (int i = 0; i < mButtonsCount; i++) {
        View child = getChildAt(i);

        if (child.getVisibility() == GONE) {
            continue;
        }

        // Consider background padding in size measurement to account for compatibility shadow
        child.getBackground().getPadding(childBackgroundPadding);

        if (!expandsHorizontally()) {
            mMaxButtonWidth = Math.max(mMaxButtonWidth,
                    child.getMeasuredWidth() - childBackgroundPadding.left - childBackgroundPadding.right);
            height += child.getMeasuredHeight() - childBackgroundPadding.top - childBackgroundPadding.bottom;
            LabelView label = (LabelView) child.getTag(R.id.fab_label);
            if (label != null) {
                maxLabelWidth = Math.max(maxLabelWidth, label.getMeasuredWidth());
            }
        } else {
            width += child.getMeasuredWidth() - childBackgroundPadding.left - childBackgroundPadding.right;
            mMaxButtonHeight = Math.max(mMaxButtonHeight,
                    child.getMeasuredHeight() - childBackgroundPadding.top - childBackgroundPadding.bottom);
        }
    }

    LayoutParams mainButtonParams = (LayoutParams) mMainButton.getLayoutParams();
    if (!expandsHorizontally()) {
        width = mMaxButtonWidth + (maxLabelWidth > 0 ? maxLabelWidth + mLabelsMargin : 0);
        width += mainButtonParams.leftMargin + mainButtonParams.rightMargin;
        height += mButtonSpacing * (mButtonsCount - 1);
        height = adjustForOvershoot(height);
        height += (mExpandDirection == EXPAND_UP) ? mainButtonParams.bottomMargin + childBackgroundPadding.top
                : mainButtonParams.topMargin + childBackgroundPadding.bottom;
    } else {
        height = mMaxButtonHeight;
        height += mainButtonParams.topMargin + mainButtonParams.rightMargin;
        width += mButtonSpacing * (mButtonsCount - 1);
        width = adjustForOvershoot(width);
        width += (mExpandDirection == EXPAND_LEFT) ? mainButtonParams.rightMargin + childBackgroundPadding.left
                : mainButtonParams.leftMargin + childBackgroundPadding.right;
    }

    setMeasuredDimension(width, height);
}

From source file:org.telegram.ui.ActionBar.ActionBarMenuItem.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
            showMenuRunnable = new Runnable() {
                @Override//w ww. ja v  a2 s  .  co  m
                public void run() {
                    if (getParent() != null) {
                        getParent().requestDisallowInterceptTouchEvent(true);
                    }
                    toggleSubMenu();
                }
            };
            AndroidUtilities.runOnUIThread(showMenuRunnable, 200);
        }
    } else if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
        if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
            if (event.getY() > getHeight()) {
                if (getParent() != null) {
                    getParent().requestDisallowInterceptTouchEvent(true);
                }
                toggleSubMenu();
                return true;
            }
        } else if (popupWindow != null && popupWindow.isShowing()) {
            getLocationOnScreen(location);
            float x = event.getX() + location[0];
            float y = event.getY() + location[1];
            popupLayout.getLocationOnScreen(location);
            x -= location[0];
            y -= location[1];
            selectedMenuView = null;
            for (int a = 0; a < popupLayout.getItemsCount(); a++) {
                View child = popupLayout.getItemAt(a);
                child.getHitRect(rect);
                if ((Integer) child.getTag() < 100) {
                    if (!rect.contains((int) x, (int) y)) {
                        child.setPressed(false);
                        child.setSelected(false);
                        if (Build.VERSION.SDK_INT == 21) {
                            child.getBackground().setVisible(false, false);
                        }
                    } else {
                        child.setPressed(true);
                        child.setSelected(true);
                        if (Build.VERSION.SDK_INT >= 21) {
                            if (Build.VERSION.SDK_INT == 21) {
                                child.getBackground().setVisible(true, false);
                            }
                            child.drawableHotspotChanged(x, y - child.getTop());
                        }
                        selectedMenuView = child;
                    }
                }
            }
        }
    } else if (popupWindow != null && popupWindow.isShowing()
            && event.getActionMasked() == MotionEvent.ACTION_UP) {
        if (selectedMenuView != null) {
            selectedMenuView.setSelected(false);
            if (parentMenu != null) {
                parentMenu.onItemClick((Integer) selectedMenuView.getTag());
            } else if (delegate != null) {
                delegate.onItemClick((Integer) selectedMenuView.getTag());
            }
            popupWindow.dismiss(allowCloseAnimation);
        } else {
            popupWindow.dismiss();
        }
    } else {
        if (selectedMenuView != null) {
            selectedMenuView.setSelected(false);
            selectedMenuView = null;
        }
    }
    return super.onTouchEvent(event);
}

From source file:projekt.substratum.MainActivity.java

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

    startService(new Intent(this, ThemeService.class));

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from  w w  w  .  jav a2  s.  c  o  m*/
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);

    AccountHeader header = new AccountHeaderBuilder().withActivity(this)
            .withHeaderBackground(R.drawable.material_drawer_header_background).withProfileImagesVisible(false)
            .withSelectionListEnabledForSingleProfile(false).addProfiles(new ProfileDrawerItem()
                    .withName(getString(R.string.drawer_name)).withEmail(BuildConfig.VERSION_NAME))
            .withCurrentProfileHiddenInList(true).build();

    final LibsSupportFragment fragment = new LibsBuilder().supportFragment();

    if (References.checkOMS()) {
        drawer = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(header)
                .withSavedInstance(savedInstanceState).withActionBarDrawerToggleAnimated(true)
                .addDrawerItems(
                        new PrimaryDrawerItem().withName(R.string.nav_home)
                                .withIcon(R.drawable.nav_theme_packs),
                        new PrimaryDrawerItem().withName(R.string.nav_overlays)
                                .withIcon(R.drawable.nav_overlays),
                        new PrimaryDrawerItem().withName(R.string.nav_bootanim)
                                .withIcon(R.drawable.nav_bootanim),
                        new PrimaryDrawerItem().withName(R.string.nav_fonts).withIcon(R.drawable.nav_fonts),
                        new PrimaryDrawerItem().withName(R.string.nav_sounds).withIcon(R.drawable.nav_sounds),
                        new SectionDrawerItem().withName(R.string.nav_section_header_utilities),
                        new PrimaryDrawerItem().withName(R.string.nav_overlay_manager)
                                .withIcon(R.drawable.nav_overlay_manager),
                        new PrimaryDrawerItem().withName(R.string.nav_manage).withIcon(R.drawable.nav_manage),
                        new PrimaryDrawerItem().withName(R.string.nav_priorities)
                                .withIcon(R.drawable.nav_drawer_priorities),
                        new PrimaryDrawerItem().withName(R.string.nav_backup_restore)
                                .withIcon(R.drawable.nav_drawer_profiles),
                        new SectionDrawerItem().withName(R.string.nav_section_header_more),
                        new SecondaryDrawerItem().withName(R.string.nav_troubleshooting)
                                .withIcon(R.drawable.nav_troubleshooting),
                        new SecondaryDrawerItem().withName(R.string.nav_team)
                                .withIcon(R.drawable.nav_drawer_team),
                        new SecondaryDrawerItem().withName(getString(R.string.nav_opensource))
                                .withIcon(R.drawable.nav_drawer_licenses),
                        new SecondaryDrawerItem().withName(R.string.nav_settings)
                                .withIcon(R.drawable.nav_drawer_settings))
                .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                        if (drawerItem != null) {
                            switch (position) {
                            case 1:
                                if (drawerSelected != position) {
                                    switchFragment(((References.checkOMS()) ? getString(R.string.app_name)
                                            : getString(R.string.legacy_app_name)), "HomeFragment");
                                    drawerSelected = 1;
                                }
                                break;
                            case 2:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_overlays), "OverlaysFragment");
                                    drawerSelected = 2;
                                }
                                break;
                            case 3:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_bootanim), "BootAnimationsFragment");
                                    drawerSelected = 3;
                                }
                                break;
                            case 4:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_fonts), "FontsFragment");
                                    drawerSelected = 4;
                                }
                                break;
                            case 5:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_sounds), "SoundsFragment");
                                    drawerSelected = 5;
                                }
                                break;
                            case 7:
                                switchFragment(getString(R.string.nav_overlay_manager),
                                        "AdvancedManagerFragment");
                                drawerSelected = 7;
                                break;
                            case 8:
                                switchFragment(getString(R.string.nav_manage), "ManageFragment");
                                drawerSelected = 8;
                                break;
                            case 9:
                                switchFragment(getString(R.string.nav_priorities), "PriorityLoaderFragment");
                                drawerSelected = 9;
                                break;
                            case 10:
                                switchFragment(getString(R.string.nav_backup_restore), "ProfileFragment");
                                drawerSelected = 10;
                                break;
                            case 12:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_troubleshooting),
                                            "TroubleshootingFragment");
                                    drawerSelected = 12;
                                }
                                break;
                            case 13:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_team), "TeamFragment");
                                    drawerSelected = 13;
                                }
                                break;
                            case 14:
                                switchFragmentToLicenses(getString(R.string.nav_opensource), fragment);
                                drawerSelected = 14;
                                break;
                            case 15:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_settings), "SettingsFragment");
                                    drawerSelected = 15;
                                }
                                break;
                            }
                        }
                        return false;
                    }
                }).withSelectedItem(1).withSelectedItemByPosition(1).build();
    } else {
        drawer = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(header)
                .withSavedInstance(savedInstanceState).withActionBarDrawerToggleAnimated(true)
                .addDrawerItems(
                        new PrimaryDrawerItem().withName(R.string.nav_home)
                                .withIcon(R.drawable.nav_theme_packs),
                        new PrimaryDrawerItem().withName(R.string.nav_overlays)
                                .withIcon(R.drawable.nav_overlays),
                        new PrimaryDrawerItem().withName(R.string.nav_sounds).withIcon(R.drawable.nav_sounds),

                        new SectionDrawerItem().withName(R.string.nav_section_header_utilities),
                        new PrimaryDrawerItem().withName(R.string.nav_overlay_manager)
                                .withIcon(R.drawable.nav_overlay_manager),
                        new PrimaryDrawerItem().withName(R.string.nav_manage).withIcon(R.drawable.nav_manage),
                        new PrimaryDrawerItem().withName(R.string.nav_backup_restore)
                                .withIcon(R.drawable.nav_drawer_profiles),

                        new SectionDrawerItem().withName(R.string.nav_section_header_more),
                        new SecondaryDrawerItem().withName(R.string.nav_troubleshooting)
                                .withIcon(R.drawable.nav_troubleshooting),
                        new SecondaryDrawerItem().withName(R.string.nav_team)
                                .withIcon(R.drawable.nav_drawer_team),
                        new SecondaryDrawerItem().withName(getString(R.string.nav_opensource))
                                .withIcon(R.drawable.nav_drawer_licenses),
                        new SecondaryDrawerItem().withName(R.string.nav_settings)
                                .withIcon(R.drawable.nav_drawer_settings))
                .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                        if (drawerItem != null) {
                            switch (position) {
                            case 1:
                                if (drawerSelected != position) {
                                    switchFragment(((References.checkOMS()) ? getString(R.string.app_name)
                                            : getString(R.string.legacy_app_name)), "HomeFragment");
                                    drawerSelected = 1;
                                }
                                break;
                            case 2:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_overlays), "OverlaysFragment");
                                    drawerSelected = 2;
                                }
                                break;
                            case 3:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_sounds), "SoundsFragment");
                                    drawerSelected = 3;
                                }
                                break;
                            case 5:
                                switchFragment(getString(R.string.nav_overlay_manager),
                                        "AdvancedManagerFragment");
                                drawerSelected = 5;
                                break;
                            case 6:
                                switchFragment(getString(R.string.nav_manage), "ManageFragment");
                                drawerSelected = 6;
                                break;
                            case 7:
                                switchFragment(getString(R.string.nav_backup_restore), "ProfileFragment");
                                drawerSelected = 7;
                                break;
                            case 9:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_troubleshooting),
                                            "TroubleshootingFragment");
                                    drawerSelected = 10;
                                }
                                break;
                            case 10:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_team), "TeamFragment");
                                    drawerSelected = 10;
                                }
                                break;
                            case 11:
                                switchFragmentToLicenses(getString(R.string.nav_opensource), fragment);
                                drawerSelected = 11;
                                break;
                            case 12:
                                if (drawerSelected != position) {
                                    switchFragment(getString(R.string.nav_settings), "SettingsFragment");
                                    drawerSelected = 12;
                                }
                                break;
                            }
                        }
                        return false;
                    }
                }).withSelectedItem(1).withSelectedItemByPosition(1).build();
    }
    if (!Root.requestRootAccess()) {
        final ProgressDialog mProgressDialog = new ProgressDialog(this,
                R.style.SubstratumBuilder_ActivityTheme);
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();
        mProgressDialog.setContentView(R.layout.root_rejected_loader);

        final float radius = 5;
        final View decorView = getWindow().getDecorView();
        final View rootView = decorView.findViewById(android.R.id.content);
        final Drawable windowBackground = decorView.getBackground();

        BlurView blurView = (BlurView) mProgressDialog.findViewById(R.id.blurView);

        blurView.setupWith(rootView).windowBackground(windowBackground)
                .blurAlgorithm(new RenderScriptBlur(this, true)).blurRadius(radius);

        final TextView textView = (TextView) mProgressDialog.findViewById(R.id.timer);
        CountDownTimer Count = new CountDownTimer(5000, 1000) {
            public void onTick(long millisUntilFinished) {
                if ((millisUntilFinished / 1000) > 1) {
                    textView.setText(String.format(getString(R.string.root_rejected_timer_plural),
                            (millisUntilFinished / 1000) + ""));
                } else {
                    textView.setText(String.format(getString(R.string.root_rejected_timer_singular),
                            (millisUntilFinished / 1000) + ""));
                }

            }

            public void onFinish() {
                mProgressDialog.dismiss();
                finish();
            }
        };
        Count.start();
    }

    permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(),
            Manifest.permission.WRITE_EXTERNAL_STORAGE);
    permissionCheck2 = ContextCompat.checkSelfPermission(getApplicationContext(),
            Manifest.permission.READ_PHONE_STATE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (!Settings.System.canWrite(getApplicationContext())) {
            Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
            intent.setData(Uri.parse("package:" + MainActivity.this.getPackageName()));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        } else {
            Log.d("SubstratumLogger", "Substratum was granted " + "'android.permission.WRITE_SETTINGS' "
                    + "permissions for system runtime code execution.");
        }
    }

    if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
        // permission already granted, allow the program to continue running
        File directory = new File(Environment.getExternalStorageDirectory(), "/.substratum/");
        if (!directory.exists()) {
            directory.mkdirs();
        }
        File cacheDirectory = new File(getCacheDir(), "/SubstratumBuilder/");
        if (!cacheDirectory.exists()) {
            cacheDirectory.mkdirs();
        }
        if (permissionCheck2 == PackageManager.PERMISSION_GRANTED) {
            // permission already granted, allow the program to continue running
            // Set the first option to start at app boot
            drawer.setSelectionAtPosition(1);
        } else {
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_PHONE_STATE },
                    PERMISSIONS_REQUEST_READ_PHONE_STATE);
        }
    } else {
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
    }

    // Now, let's grab root on the helper
    Intent rootIntent = new Intent(Intent.ACTION_MAIN);
    rootIntent.setAction("masquerade.substratum.INITIALIZE");
    try {
        startActivity(rootIntent);
    } catch (RuntimeException re) {
        // Exception: At this point, Masquerade is not installed at all.
    }

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    if (References.checkOMS()) {
        if (!prefs.getBoolean("substratum_oms", true)) {
            Root.runCommand(
                    "rm -r " + Environment.getExternalStorageDirectory().getAbsolutePath() + "/.substratum/");
            Root.runCommand(
                    "rm -r " + Environment.getExternalStorageDirectory().getAbsolutePath() + "/substratum/");
            File directory = new File(Environment.getExternalStorageDirectory(), "/.substratum/");
            if (!directory.exists()) {
                directory.mkdirs();
            }
        }
    } else {
        if (prefs.getBoolean("substratum_oms", true)) {
            Root.runCommand(
                    "rm -r " + Environment.getExternalStorageDirectory().getAbsolutePath() + "/.substratum/");
            Root.runCommand(
                    "rm -r " + Environment.getExternalStorageDirectory().getAbsolutePath() + "/substratum/");
            File directory = new File(Environment.getExternalStorageDirectory(), "/.substratum/");
            if (!directory.exists()) {
                directory.mkdirs();
            }
        }
    }

    printFCMtoken();
}

From source file:com.example.zhaozhu.practisecustomview.customviewgroup.HSlidingPaneLayout.java

private static boolean viewIsOpaque(final View v) {
    //if (ViewCompat.isOpaque(v))
    //{/*from   w ww  .  j  av  a  2  s.  co  m*/
    //   return true;
    //}

    // View#isOpaque didn't take all valid opaque scrollbar modes into
    // account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque
    // above and return false
    // here. On older devices, check the view's background drawable directly
    // as a fallback.
    if (Build.VERSION.SDK_INT >= 18) {
        return false;
    }

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }
    return false;
}

From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java

private void unbindDrawables(View view) {
    if (view == null)
        return;/*  w  w  w . j a  v a2  s . com*/

    if (view instanceof ImageView) {
        ((ImageView) view).setImageDrawable(null);
        //Log.d("musicInfo", view.toString() + " was nullified!");
    }
    if (view.getBackground() != null) {
        view.getBackground().setCallback(null);
        //Log.d("musicInfo", view.toString() + " background was nullified!");
    }
    if (view instanceof ViewGroup) {
        for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
            unbindDrawables(((ViewGroup) view).getChildAt(i));
        }
        view.setBackgroundResource(0);
    }
}