Example usage for android.graphics Color parseColor

List of usage examples for android.graphics Color parseColor

Introduction

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

Prototype

@ColorInt
public static int parseColor(@Size(min = 1) String colorString) 

Source Link

Document

Parse the color string, and return the corresponding color-int.

Usage

From source file:com.bernard.beaconportal.activities.activity.MessageList.java

@SuppressLint("ResourceAsColor")
@Override/*from   w w w  .j  a va 2s. com*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_PROGRESS);

    if (!K9.isHideSpecialAccounts()) {
        createSpecialAccounts();
    }

    Account[] accounts = Preferences.getPreferences(this).getAccounts();
    Intent intent = getIntent();
    // onNewIntent(intent);

    // see if we should show the welcome message
    if (ACTION_IMPORT_SETTINGS.equals(intent.getAction())) {
        mAccounts.onImport();
    } else if (accounts.length < 1) {
        WelcomeMessage.showWelcomeMessage(this);
        finish();
        return;
    }

    if (UpgradeDatabases.actionUpgradeDatabases(this, intent)) {
        finish();
        return;
    }

    Log.d(TAG, "onCreate()");

    String packageName = "com.bernard.beaconportal.activities";

    counterss = "0";

    int versionNumber = 0;

    try {
        PackageInfo pi = getApplicationContext().getPackageManager().getPackageInfo(packageName,
                PackageManager.GET_META_DATA);
        versionNumber = pi.versionCode;
        String versionName = pi.versionName;

        Log.d(TAG, "K-9 is installed - " + versionNumber + " " + versionName);

    } catch (NameNotFoundException e) {
        Log.d(TAG, "K-9 not found");
    }

    if (versionNumber <= 1) {
        // Register a listener for broadcasts (needed for the older versions
        // of k9)
        Log.d(TAG, "Initialising BroadcastReceiver for old K-9 version");
        receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                Log.d(TAG, "receiver.onReceive()");
                doRefresh();
            }
        };

        filter = new IntentFilter();
        filter.addAction("com.bernard.beaconportal.activities.intent.action.EMAIL_RECEIVED");
        filter.addAction("com.bernard.beaconportal.activities.intent.action.EMAIL_DELETED");
        filter.addDataScheme("email");
        registerReceiver(receiver, filter);
    } else {
        // Register our own content observer, rather than using
        // addWatchContentUris()
        // since DashClock might not have permission to access the database
        Log.d(TAG, "Initialising ContentObserver for new K-9 version");
        contentObserver = new ContentObserver(null) {
            @Override
            public void onChange(boolean selfChange) {
                Log.d(TAG, "contentResolver.onChange()");
                doRefresh();
            }
        };
        getContentResolver().registerContentObserver(Uri.parse(k9UnreadUri), true, contentObserver);
    }

    doRefresh();

    if (UpgradeDatabases.actionUpgradeDatabases(this, getIntent())) {
        finish();
        return;
    }

    if (useSplitView()) {
        setContentView(R.layout.split_drawer_main);
    } else {
        setContentView(R.layout.drawermain1);
        mViewSwitcher = (ViewSwitcher) findViewById(R.id.container);
        mViewSwitcher.setFirstInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_left));
        mViewSwitcher.setFirstOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_right));
        mViewSwitcher.setSecondInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_right));
        mViewSwitcher.setSecondOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_left));
        mViewSwitcher.setOnSwitchCompleteListener(this);
    }

    mergeadapter = new MergeAdapter();

    LayoutInflater inflater = getLayoutInflater();

    accounts_view = inflater.inflate(R.layout.accounts_list, null);

    portals_view = inflater.inflate(R.layout.portal_list, null);

    folders_view = inflater.inflate(R.layout.folders_list, null);

    header_folders = inflater.inflate(R.layout.header_folders, null);

    header_drawer = inflater.inflate(R.layout.header_drawer, null);

    initializeActionBar();

    mListView = (ListView) findViewById(android.R.id.list);
    // mListView.addHeaderView(header_folders, null, false);

    mListView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    mListView.setLongClickable(true);
    mListView.setFastScrollEnabled(true);
    mListView.setScrollingCacheEnabled(false);
    // mListView.setOnItemClickListener(new OnItemClickListener() {
    // public void onItemClick(AdapterView<?> parent, View view,
    // int position, long id) {
    //
    // onOpenFolder(((FolderInfoHolder) mAdapter.getItem(position)).name);
    //
    // Log.d("Folder Click Listener", "clicked");
    //
    // }
    // });

    setResult(RESULT_CANCELED);

    // mDrawerList_Inbox = (ListView) findViewById(R.id.listview_inbox);
    //
    // View header_inbox = (View) inflater
    // .inflate(R.layout.header_inbox, null);
    //
    // mDrawerList_Inbox.setOnItemClickListener(this);
    //
    // mDrawerList_Inbox.setItemsCanFocus(false);
    //
    // mDrawerList_Inbox.setLongClickable(true);

    mListView.setSaveEnabled(true);

    mInflater = getLayoutInflater();

    onNewIntent(getIntent());

    context = this;

    SharedPreferences sharedpre = getSharedPreferences("show_view", Context.MODE_PRIVATE);

    Show_View = sharedpre.getString("show_view", "");

    SharedPreferences Today_Homework = getApplicationContext().getSharedPreferences("due_today",
            Context.MODE_PRIVATE);

    SharedPreferences counts = getSharedPreferences("due_today", Context.MODE_PRIVATE);

    if (counts.contains("homeworkdue")) {
        counterss = counts.getString("homeworkdue", null);
    } else {

        counterss = null;
    }

    title_Inbox = new String[] { "Inbox" };

    icon_Inbox = new int[] { R.drawable.ic_action_email };

    count_Inbox = new String[] { K9counts };

    if (Show_View.equals("Homework Due")) {

        title = new String[] { "Homework Due", "Schedule", "Resources", "Options", "Logout" };

        icon = new int[] { R.drawable.ic_action_duehomework, R.drawable.ic_action_go_to_today,
                R.drawable.ic_action_resources, R.drawable.ic_action_settings, R.drawable.ic_action_logout };

        if (counterss == null && counterss.isEmpty()) {

            count = new String[] { "", "", "", "", "" };

        } else {

            count = new String[] { counterss, "", "", "", "" };

        }

    } else {

        if (counterss == null && counterss.isEmpty()) {

            count = new String[] { "", "", "", "", "" };

        } else {

            count = new String[] { "", counterss, "", "", "" };

        }

        title = new String[] { "Schedule", "Homework Due", "Resources", "Options", "Logout" };

        icon = new int[] { R.drawable.ic_action_go_to_today, R.drawable.ic_action_duehomework,
                R.drawable.ic_action_resources, R.drawable.ic_action_settings, R.drawable.ic_action_logout };

    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer);

    // mDrawerList_Inbox = (ListView) findViewById(R.id.listview_inbox);

    // mDrawerList = (ListView) findViewById(R.id.listview_drawer);

    // mDrawer_Scroll = (ScrollView)
    // findViewById(R.id.left_drawer_scrollview);

    // mDrawerList.addHeaderView(header_drawer, null, false);

    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    // mMenuAdapter_Inbox = new MenuListAdapter(MessageList.this,
    // title_Inbox,
    // icon_Inbox, count_Inbox);

    // mDrawerList_Inbox.setAdapter(mMenuAdapter_Inbox);

    // mDrawerList_Inbox
    // .setOnItemClickListener(new DrawerItemClickListener_Inbox());

    mMenuAdapter = new MenuListAdapter(MessageList.this, title, icon, count);

    // mDrawerList.setAdapter(mMenuAdapter);

    // mergeadapter.addView(header_drawer);
    //
    // mergeadapter.addAdapter(mMenuAdapter);
    //
    // mergeadapter.addadapter(AccountsAdapter);
    //
    // mDrawerList.setAdapter(mergeadapter);

    getListView().setOnItemClickListener(new DrawerItemClickListener());

    // mDrawerList_Inbox.setOnItemClickListener(new
    // DrawerItemClickListener());

    //
    // if (savedInstanceState == null) {
    // selectItem_Inbox(1);
    // }

    SharedPreferences sharedpref = getSharedPreferences("actionbar_color", Context.MODE_PRIVATE);

    final int splitBarId = getResources().getIdentifier("split_action_bar", "id", "android");
    final View splitActionBar = findViewById(splitBarId);

    if (!sharedpref.contains("actionbar_color")) {

        getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#4285f4")));

        if (splitActionBar != null) {

            splitActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#4285f4")));

        }

    } else {

        actionbar_colors = sharedpref.getString("actionbar_color", null);

        getActionBar().setBackgroundDrawable(

                new ColorDrawable(Color.parseColor(actionbar_colors)));

        if (splitActionBar != null) {

            splitActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(actionbar_colors)));

        }

    }

    android.app.ActionBar bar = getActionBar();

    bar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    // Enable gesture detection for MessageLists
    // setupGestureDetector(this);

    if (!decodeExtras(getIntent())) {
        return;
    }

    findFragments();
    initializeDisplayMode(savedInstanceState);
    initializeLayout();
    initializeFragments();
    displayViews();
    // registerForContextMenu(mDrawerList_Inbox);
    registerForContextMenu(mListView);

    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {

        @Override
        public void onDrawerClosed(View view) {
            // TODO Auto-generated method stub
            super.onDrawerClosed(view);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            // TODO Auto-generated method stub

            super.onDrawerOpened(drawerView);
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

}

From source file:com.amaze.filemanager.fragments.Main.java

public void rename(final BaseFile f) {
    MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
    String name = f.getName();/*from  ww  w . j a v  a2s .  c  om*/
    a.input("", name, false, new MaterialDialog.InputCallback() {
        @Override
        public void onInput(MaterialDialog materialDialog, CharSequence charSequence) {

        }
    });
    if (theme1 == 1)
        a.theme(Theme.DARK);
    a.title(utils.getString(getActivity(), R.string.rename));
    a.callback(new MaterialDialog.ButtonCallback() {
        @Override
        public void onPositive(MaterialDialog materialDialog) {
            String name = materialDialog.getInputEditText().getText().toString();
            if (f.isSmb())
                if (f.isDirectory() && !name.endsWith("/"))
                    name = name + "/";

            if (openMode == 1)
                MAIN_ACTIVITY.mainActivityHelper.rename(openMode, f.getPath(), CURRENT_PATH + name,
                        getActivity(), ROOT_MODE);
            else
                MAIN_ACTIVITY.mainActivityHelper.rename(openMode, (f).getPath(), (CURRENT_PATH + "/" + name),
                        getActivity(), ROOT_MODE);

        }

        @Override
        public void onNegative(MaterialDialog materialDialog) {

            materialDialog.cancel();
        }
    });
    a.positiveText(R.string.save);
    a.negativeText(R.string.cancel);
    int color = Color.parseColor(fabSkin);
    a.positiveColor(color).negativeColor(color).widgetColor(color);
    a.build().show();
}

From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java

private void showFilterEditDialog() {

    @SuppressLint("InflateParams")
    LinearLayout dialogView = (LinearLayout) getLayoutInflater().inflate(R.layout.dialog_filter, null); // passing null okay for dialog

    ThemeManager.Theme theme = global.mThemeManager.getActiveTheme("appthemepref");
    int headerColor = Color.parseColor(theme.getValue("header_color"));
    int headerText = Color.parseColor(theme.getValue("header_text"));
    dialogView.findViewById(R.id.filter_header).setBackgroundColor(headerColor);
    ((TextView) dialogView.findViewById(R.id.filter_headert1)).setTextColor(headerText);
    ((TextView) dialogView.findViewById(R.id.filter_headert2)).setTextColor(headerText);

    ListView subList = (ListView) dialogView.findViewById(R.id.filter_subredditList);
    final SubsListAdapter filterSubsAdapter = new SubsListAdapter(SubredditSelectActivity.this, null);
    subList.setAdapter(filterSubsAdapter);

    AlertDialog.Builder builder = new AlertDialog.Builder(SubredditSelectActivity.this);
    builder.setView(dialogView).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override//from   w  w  w  . j a va  2 s  .  c  o  m
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
        }
    }).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
            global.getSubredditManager().setAllFilter(filterSubsAdapter.getSubsList());
            needsFeedUpdate = true; // mark feed for updating
        }
    }).show().getWindow().clearFlags(
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
}

From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java

void initNoFileLayout() {
    nofilesview = rootView.findViewById(R.id.nofilelayout);
    if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT))
        ((ImageView) nofilesview.findViewById(R.id.image)).setColorFilter(Color.parseColor("#666666"));
    else {/*from  w ww. ja v a  2  s.c  o m*/
        nofilesview.setBackgroundColor(Utils.getColor(getContext(), R.color.holo_dark_background));
        ((TextView) nofilesview.findViewById(R.id.nofiletext)).setTextColor(Color.WHITE);
    }
}

From source file:com.mobicage.rogerthat.plugins.messaging.BrandingMgr.java

private BrandingResult extractBranding(final BrandedItem item, final File encryptedBrandingFile,
        final File tmpDecryptedBrandingFile, final File tmpBrandingDir) throws BrandingFailureException {
    try {//from   w  ww  .  j  a  v  a2 s  .c  o  m
        L.i("Extracting " + tmpDecryptedBrandingFile + " (" + item.brandingKey + ")");
        File brandingFile = new File(tmpBrandingDir, "branding.html");
        File watermarkFile = null;
        Integer backgroundColor = null;
        Integer menuItemColor = null;
        ColorScheme scheme = ColorScheme.light;
        boolean showHeader = true;
        String contentType = null;
        boolean wakelockEnabled = false;
        ByteArrayOutputStream brandingBos = new ByteArrayOutputStream();
        try {
            MessageDigest digester = MessageDigest.getInstance("SHA256");
            DigestInputStream dis = new DigestInputStream(
                    new BufferedInputStream(new FileInputStream(tmpDecryptedBrandingFile)), digester);
            try {
                ZipInputStream zis = new ZipInputStream(dis);
                try {
                    byte data[] = new byte[BUFFER_SIZE];
                    ZipEntry entry;
                    while ((entry = zis.getNextEntry()) != null) {
                        L.d("Extracting: " + entry);
                        int count = 0;
                        if (entry.getName().equals("branding.html")) {
                            while ((count = zis.read(data, 0, BUFFER_SIZE)) != -1) {
                                brandingBos.write(data, 0, count);
                            }
                        } else {
                            if (entry.isDirectory()) {
                                L.d("Skipping branding dir " + entry.getName());
                                continue;
                            }
                            File destination = new File(tmpBrandingDir, entry.getName());
                            destination.getParentFile().mkdirs();
                            if ("__watermark__".equals(entry.getName())) {
                                watermarkFile = destination;
                            }
                            final OutputStream fos = new BufferedOutputStream(new FileOutputStream(destination),
                                    BUFFER_SIZE);
                            try {
                                while ((count = zis.read(data, 0, BUFFER_SIZE)) != -1) {
                                    fos.write(data, 0, count);
                                }
                            } finally {
                                fos.close();
                            }
                        }
                    }
                    while (dis.read(data) >= 0)
                        ;
                } finally {
                    zis.close();
                }
            } finally {
                dis.close();
            }
            String hexDigest = com.mobicage.rogerthat.util.TextUtils.toHex(digester.digest());
            if (!hexDigest.equals(item.brandingKey)) {
                encryptedBrandingFile.delete();
                SystemUtils.deleteDir(tmpBrandingDir);
                throw new BrandingFailureException("Branding cache was invalid!");
            }
            brandingBos.flush();
            byte[] brandingBytes = brandingBos.toByteArray();
            if (brandingBytes.length == 0) {
                encryptedBrandingFile.delete();
                SystemUtils.deleteDir(tmpBrandingDir);
                throw new BrandingFailureException("Invalid branding package!");
            }
            String brandingHtml = new String(brandingBytes, "UTF8");

            switch (item.type) {
            case BrandedItem.TYPE_MESSAGE:
                MessageTO message = (MessageTO) item.object;
                brandingHtml = brandingHtml.replace(NUNTIUZ_MESSAGE,
                        TextUtils.htmlEncode(message.message).replace("\r", "").replace("\n", "<br>"));

                brandingHtml = brandingHtml.replace(NUNTIUZ_TIMESTAMP,
                        TimeUtils.getDayTimeStr(mContext, message.timestamp * 1000));

                FriendsPlugin friendsPlugin = mMainService.getPlugin(FriendsPlugin.class);
                brandingHtml = brandingHtml.replace(NUNTIUZ_IDENTITY_NAME,
                        TextUtils.htmlEncode(friendsPlugin.getName(message.sender)));
                break;
            case BrandedItem.TYPE_FRIEND:
                FriendTO friend = (FriendTO) item.object;
                // In this case Friend is fully populated
                brandingHtml = brandingHtml.replace(NUNTIUZ_MESSAGE,
                        TextUtils.htmlEncode(friend.description).replace("\r", "").replace("\n", "<br>"));

                brandingHtml = brandingHtml.replace(NUNTIUZ_IDENTITY_NAME, TextUtils.htmlEncode(friend.name));

                break;
            case BrandedItem.TYPE_GENERIC:
                if (item.object instanceof FriendTO) {
                    brandingHtml = brandingHtml.replace(NUNTIUZ_IDENTITY_NAME,
                            TextUtils.htmlEncode(((FriendTO) item.object).name));
                }
                break;
            }

            Matcher matcher = RegexPatterns.BRANDING_BACKGROUND_COLOR.matcher(brandingHtml);
            if (matcher.find()) {
                String bg = matcher.group(1);
                if (bg.length() == 4) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("#");
                    sb.append(bg.charAt(1));
                    sb.append(bg.charAt(1));
                    sb.append(bg.charAt(2));
                    sb.append(bg.charAt(2));
                    sb.append(bg.charAt(3));
                    sb.append(bg.charAt(3));
                    bg = sb.toString();
                }
                backgroundColor = Color.parseColor(bg);
            }

            matcher = RegexPatterns.BRANDING_MENU_ITEM_COLOR.matcher(brandingHtml);
            if (matcher.find()) {
                String bg = matcher.group(1);
                if (bg.length() == 4) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("#");
                    sb.append(bg.charAt(1));
                    sb.append(bg.charAt(1));
                    sb.append(bg.charAt(2));
                    sb.append(bg.charAt(2));
                    sb.append(bg.charAt(3));
                    sb.append(bg.charAt(3));
                    bg = sb.toString();
                }
                menuItemColor = Color.parseColor(bg);
            }

            matcher = RegexPatterns.BRANDING_COLOR_SCHEME.matcher(brandingHtml);
            if (matcher.find()) {
                String schemeStr = matcher.group(1);
                scheme = "dark".equalsIgnoreCase(schemeStr) ? ColorScheme.dark : ColorScheme.light;
            }

            matcher = RegexPatterns.BRANDING_SHOW_HEADER.matcher(brandingHtml);
            if (matcher.find()) {
                String showHeaderStr = matcher.group(1);
                showHeader = "true".equalsIgnoreCase(showHeaderStr);
            }

            matcher = RegexPatterns.BRANDING_CONTENT_TYPE.matcher(brandingHtml);
            if (matcher.find()) {
                String contentTypeStr = matcher.group(1);
                L.i("Branding content-type: " + contentTypeStr);
                if (AttachmentViewerActivity.CONTENT_TYPE_PDF.equalsIgnoreCase(contentTypeStr)) {
                    File tmpBrandingFile = new File(tmpBrandingDir, "embed.pdf");
                    if (tmpBrandingFile.exists()) {
                        contentType = AttachmentViewerActivity.CONTENT_TYPE_PDF;
                    }
                }
            }

            Dimension dimension1 = null;
            Dimension dimension2 = null;
            matcher = RegexPatterns.BRANDING_DIMENSIONS.matcher(brandingHtml);
            if (matcher.find()) {
                String dimensionsStr = matcher.group(1);
                L.i("Branding dimensions: " + dimensionsStr);
                String[] dimensions = dimensionsStr.split(",");
                try {
                    dimension1 = new Dimension(Integer.parseInt(dimensions[0]),
                            Integer.parseInt(dimensions[1]));
                    dimension2 = new Dimension(Integer.parseInt(dimensions[2]),
                            Integer.parseInt(dimensions[3]));
                } catch (Exception e) {
                    L.bug("Invalid branding dimension: " + matcher.group(), e);
                }
            }

            matcher = RegexPatterns.BRANDING_WAKELOCK_ENABLED.matcher(brandingHtml);
            if (matcher.find()) {
                String wakelockEnabledStr = matcher.group(1);
                wakelockEnabled = "true".equalsIgnoreCase(wakelockEnabledStr);
            }

            final List<String> externalUrlPatterns = new ArrayList<String>();
            matcher = RegexPatterns.BRANDING_EXTERNAL_URLS.matcher(brandingHtml);
            while (matcher.find()) {
                externalUrlPatterns.add(matcher.group(1));
            }

            FileOutputStream fos = new FileOutputStream(brandingFile);

            try {
                fos.write(brandingHtml.getBytes("UTF8"));
            } finally {
                fos.close();
            }
            if (contentType != null
                    && AttachmentViewerActivity.CONTENT_TYPE_PDF.equalsIgnoreCase(contentType)) {
                brandingFile = new File(tmpBrandingDir, "embed.pdf");
            }
            return new BrandingResult(tmpBrandingDir, brandingFile, watermarkFile, backgroundColor,
                    menuItemColor, scheme, showHeader, dimension1, dimension2, contentType, wakelockEnabled,
                    externalUrlPatterns);
        } finally {
            brandingBos.close();
        }
    } catch (IOException e) {
        L.e(e);
        throw new BrandingFailureException("Error copying cached branded file to private space", e);
    } catch (NoSuchAlgorithmException e) {
        L.e(e);
        throw new BrandingFailureException("Cannot validate ", e);
    }
}

From source file:com.filemanager.free.fragments.Main.java

public void rename(final BaseFile f) {
    MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
    String name = f.getName();//w  ww.ja  v  a  2s  .c  o  m
    a.input("", name, false, new MaterialDialog.InputCallback() {
        @Override
        public void onInput(@NonNull MaterialDialog materialDialog, CharSequence charSequence) {

        }
    });
    if (theme1 == 1)
        a.theme(Theme.DARK);
    a.title(utils.getString(getActivity(), R.string.rename));
    a.onPositive(new MaterialDialog.SingleButtonCallback() {
        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            String name = dialog.getInputEditText().getText().toString();
            if (f.isSmb()) {
                if (f.isDirectory() && !name.endsWith("/"))
                    name = name + "/";
            }
            if (MainActivityHelper.validateFileName(new HFile(openMode, CURRENT_PATH + "/" + name), false)) {
                if (openMode == 1)
                    MAIN_ACTIVITY.mainActivityHelper.rename(openMode, f.getPath(), CURRENT_PATH + name,
                            getActivity(), ROOT_MODE);
                else
                    MAIN_ACTIVITY.mainActivityHelper.rename(openMode, (f).getPath(),
                            (CURRENT_PATH + "/" + name), getActivity(), ROOT_MODE);
            } else {
                Toast.makeText(MAIN_ACTIVITY, R.string.invalid_name, Toast.LENGTH_SHORT).show();
            }
        }
    });
    a.onNegative(new MaterialDialog.SingleButtonCallback() {
        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            dialog.cancel();
        }
    });
    a.positiveText(R.string.save);
    a.negativeText(R.string.cancel);
    int color = Color.parseColor(fabSkin);
    a.positiveColor(color).negativeColor(color).widgetColor(color);
    a.build().show();
}

From source file:com.bluros.music.MusicService.java

private Notification buildNotification() {
    final String albumName = getAlbumName();
    final String artistName = getArtistName();
    final boolean isPlaying = isPlaying();
    String text = TextUtils.isEmpty(albumName) ? artistName : artistName + " - " + albumName;

    int playButtonResId = isPlaying ? R.drawable.ic_pause_white_36dp : R.drawable.ic_play_white_36dp;

    Intent nowPlayingIntent = NavigationUtils.getNowPlayingIntent(this);
    PendingIntent clickIntent = PendingIntent.getActivity(this, 0, nowPlayingIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    Bitmap artwork;/*  w w  w. ja  va 2  s  . c  o  m*/
    artwork = ImageLoader.getInstance().loadImageSync(MusicUtils.getAlbumArtUri(getAlbumId()).toString());

    if (artwork == null) {
        artwork = ImageLoader.getInstance().loadImageSync("drawable://" + R.drawable.ic_empty_music2);
    }

    if (mNotificationPostTime == 0) {
        mNotificationPostTime = System.currentTimeMillis();
    }

    android.support.v4.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_notification).setLargeIcon(artwork).setContentIntent(clickIntent)
            .setContentTitle(getTrackName()).setContentText(text).setWhen(mNotificationPostTime)
            .addAction(R.drawable.ic_skip_previous_white_36dp, "", retrievePlaybackAction(PREVIOUS_ACTION))
            .addAction(playButtonResId, "", retrievePlaybackAction(TOGGLEPAUSE_ACTION))
            .addAction(R.drawable.ic_skip_next_white_36dp, "", retrievePlaybackAction(NEXT_ACTION));

    if (MusicUtils.isJellyBeanMR1()) {
        builder.setShowWhen(false);
    }
    if (MusicUtils.isLollipop()) {
        builder.setVisibility(Notification.VISIBILITY_PUBLIC);
        NotificationCompat.MediaStyle style = new NotificationCompat.MediaStyle()
                .setMediaSession(mSession.getSessionToken()).setShowActionsInCompactView(0, 1, 2, 3);
        builder.setStyle(style);
    }
    if (artwork != null && MusicUtils.isLollipop())
        builder.setColor(Palette.from(artwork).generate().getVibrantColor(Color.parseColor("#403f4d")));
    Notification n = builder.build();

    if (PreferencesUtility.getInstance(this).getXPosedTrackselectorEnabled()) {
        addXTrackSelector(n);
    }

    return n;
}

From source file:com.insthub.O2OMobile.Activity.D1_OrderActivity.java

/**
 * ????/*w w  w . j ava 2 s  . c om*/
 */
private void setVisitor() {

    mOrderEmployeeView.setVisibility(View.GONE);
    mOrderStatusArrow.setVisibility(View.GONE);
    mOrderStatusView.setEnabled(false);
    mOrderBtnCancel.setVisibility(View.GONE);
    mOrderStatusView.setBackgroundColor(Color.parseColor("#eeeeee"));
    mOrderStatus.setText(getString(R.string.order_have_been_received));

}

From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java

private Spanned getSpannedText(String message) {
    message = " " + message + " ";
    SpannableStringBuilder spanned = new SpannableStringBuilder(message);
    for (Object span : new Object[] { new ForegroundColorSpan(Color.WHITE),
            new BackgroundColorSpan(Color.parseColor("#88000000")) }) {
        spanned.setSpan(span, 0, message.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }//from w  w w.  ja  v a  2 s  .  com
    return spanned;
}

From source file:com.example.search.car.pools.welcome.java

public void onBackPressed() {
    if (canExit) {
        super.onBackPressed();
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);/*from  w  w w . j  av  a2s.c o  m*/
    } else {
        // Fragment fm = getFragmentManager().findFragmentByTag("Search");
        if (frag_tag != "Search") {
            svg_search = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.search1);
            iv_search.setImageDrawable(svg_search.createPictureDrawable());
            rlSearch.setBackgroundColor(Color.parseColor("#00ca98"));
            l_search.setBackground(getResources().getDrawable(R.drawable.white_circle_side_menu));

            svg_dashboard = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.dashboard);
            iv_dashboard.setImageDrawable(svg_dashboard.createPictureDrawable());
            rlDashboard.setBackgroundColor(Color.parseColor("#2C3E50"));
            l_dashboard.setBackground(getResources().getDrawable(R.drawable.search_blue));
            svg_cities = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.city);
            iv_cities.setImageDrawable(svg_cities.createPictureDrawable());
            rlCities.setBackgroundColor(Color.parseColor("#2C3E50"));
            l_cities.setBackground(getResources().getDrawable(R.drawable.search_blue));

            FragmentManager fm = getFragmentManager();
            FragmentTransaction fragmentTransaction = fm.beginTransaction();
            fragmentTransaction.replace(R.id.content_frame, new Search());
            fragmentTransaction.commit();
            frag_tag = "Search";
        } else {
            canExit = true;
            Toast.makeText(getApplicationContext(), "Press again to exit", Toast.LENGTH_SHORT).show();
        }

    }
    mHandler.sendEmptyMessageDelayed(1, 2000/* time interval to next press in milli second */);// if not
    // pressed
    // within
    // 2
    // seconds
    // then
    // will
    // be
    // setted(canExit)
    // as
    // false
}