Example usage for android.view ContextThemeWrapper ContextThemeWrapper

List of usage examples for android.view ContextThemeWrapper ContextThemeWrapper

Introduction

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

Prototype

public ContextThemeWrapper(Context base, Resources.Theme theme) 

Source Link

Document

Creates a new context wrapper with the specified theme.

Usage

From source file:com.hippo.ehviewer.ui.scene.BaseScene.java

public void createThemeContext(@StyleRes int style) {
    mThemeContext = new ContextThemeWrapper(getContext(), style);
}

From source file:com.mishiranu.dashchan.content.service.PostingService.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setNotificationColor(Notification.Builder builder) {
    Context themedContext = new ContextThemeWrapper(this, Preferences.getThemeResource());
    builder.setColor(ResourceUtils.getColor(themedContext, android.R.attr.colorAccent));
}

From source file:com.ovrhere.android.careerstack.ui.fragments.dialogs.DistanceDialogFragment.java

/** Gets the context and, by extension, the theme to use. */
private Context getCompatContext() {
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        return getActivity();
    }//  w w w. ja  v a  2 s.c  o  m
    int themeId = R.style.DialogTheme;
    return new ContextThemeWrapper(getActivity(), themeId);
}

From source file:piuk.blockchain.android.ui.dialogs.NewAccountDialog.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);

    final FragmentActivity activity = getActivity();
    final LayoutInflater inflater = LayoutInflater.from(activity);

    final Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_Dialog))
            .setTitle(R.string.new_account_title);

    final View view = inflater.inflate(R.layout.new_account_dialog, null);

    dialog.setView(view);//from w  w  w .  j  a  va2s .co  m

    final Button createButton = (Button) view.findViewById(R.id.create_button);
    final TextView password = (TextView) view.findViewById(R.id.password);
    final TextView password2 = (TextView) view.findViewById(R.id.password2);
    final TextView captcha = (TextView) view.findViewById(R.id.captcha);

    refreshCaptcha(view);

    createButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            final WalletApplication application = (WalletApplication) getActivity().getApplication();

            if (password.getText().length() < 11 || password.getText().length() > 255) {
                Toast.makeText(application, R.string.new_account_password_length_error, Toast.LENGTH_LONG)
                        .show();
                return;
            }

            if (!password.getText().toString().equals(password2.getText().toString())) {
                Toast.makeText(application, R.string.new_account_password_mismatch_error, Toast.LENGTH_LONG)
                        .show();
                return;
            }

            if (captcha.getText().length() == 0) {
                Toast.makeText(application, R.string.new_account_no_kaptcha_error, Toast.LENGTH_LONG).show();
                return;
            }

            final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "",
                    getString(R.string.creating_account), true);

            progressDialog.show();

            final Handler handler = new Handler();

            new Thread() {
                @Override
                public void run() {
                    try {
                        try {
                            application.generateNewWallet();
                        } catch (Exception e1) {
                            throw new Exception("Error Generating Wallet");
                        }

                        application.getRemoteWallet().setTemporyPassword(password.getText().toString());

                        if (!application.getRemoteWallet().remoteSave(captcha.getText().toString())) {
                            throw new Exception("Unknown Error Inserting wallet");
                        }

                        EventListeners.invokeWalletDidChange();

                        handler.post(new Runnable() {
                            public void run() {
                                try {
                                    progressDialog.dismiss();

                                    dismiss();

                                    Toast.makeText(getActivity().getApplication(), R.string.new_account_success,
                                            Toast.LENGTH_LONG).show();

                                    PinEntryActivity.clearPrefValues(application);

                                    Editor edit = PreferenceManager
                                            .getDefaultSharedPreferences(application.getApplicationContext())
                                            .edit();

                                    edit.putString("guid", application.getRemoteWallet().getGUID());
                                    edit.putString("sharedKey", application.getRemoteWallet().getSharedKey());

                                    AbstractWalletActivity activity = (AbstractWalletActivity) getActivity();

                                    if (edit.commit()) {
                                        application.checkWalletStatus(activity);
                                    } else {
                                        throw new Exception("Error saving preferences");
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();

                                    application.clearWallet();

                                    Toast.makeText(getActivity().getApplication(), e.getLocalizedMessage(),
                                            Toast.LENGTH_LONG).show();
                                }
                            }
                        });
                    } catch (final Exception e) {
                        e.printStackTrace();

                        application.clearWallet();

                        handler.post(new Runnable() {
                            public void run() {
                                progressDialog.dismiss();

                                refreshCaptcha(view);

                                captcha.setText(null);

                                Toast.makeText(getActivity().getApplication(), e.getLocalizedMessage(),
                                        Toast.LENGTH_LONG).show();
                            }
                        });
                    }
                }
            }.start();
        }
    });

    Dialog d = dialog.create();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();

    lp.dimAmount = 0;
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;

    d.show();

    d.getWindow().setAttributes(lp);

    d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return d;
}

From source file:org.ciasaboark.tacere.activity.fragment.MainSettingsFragment.java

private void drawRingerWidgets() {
    RelativeLayout ringerBox = (RelativeLayout) rootView.findViewById(R.id.settings_ringerBox);
    ringerBox.setOnClickListener(new View.OnClickListener() {
        @Override//from w  ww  .ja v a2 s  . c o  m
        public void onClick(View v) {
            String[] ringerTypes = RingerType.names();
            //we don't want ringer type UNDEFINED to be an option
            ArrayList<String> ringerList = new ArrayList<String>();
            for (String type : ringerTypes) {
                if (!type.equalsIgnoreCase(RingerType.UNDEFINED.toString())) {
                    type = type.charAt(0) + type.substring(1).toLowerCase();
                    ringerList.add(type);
                }
            }
            final String[] filteredRingerTypes = ringerList.toArray(new String[] {});
            int previouslySelectedRinger = ringerList.indexOf(prefs.getRingerType().toString());

            final AlertDialog alert = new AlertDialog.Builder(new ContextThemeWrapper(context, R.style.Dialog))
                    .setTitle(R.string.settings_section_general_ringer)
                    .setSingleChoiceItems(filteredRingerTypes, previouslySelectedRinger,
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    String selectedRingerString = filteredRingerTypes[which];
                                    int selectedRingerValue = RingerType
                                            .getIntForStringValue(selectedRingerString);
                                    RingerType selectedRinger = RingerType.getTypeForInt(selectedRingerValue);
                                    prefs.setRingerType(selectedRinger);
                                    drawRingerWidgets();
                                    dialog.dismiss();
                                }
                            })
                    .create();

            alert.show();
        }
    });

    //the ringer type description
    TextView ringerDescriptionTV = (TextView) rootView.findViewById(R.id.ringerTypeDescription);
    TextView ringerTV = (TextView) rootView.findViewById(R.id.settings_ringerTitle);

    Drawable icon;
    switch (prefs.getRingerType()) {
    case NORMAL:
        ringerDescriptionTV.setText(R.string.settings_section_general_ringer_normal);
        icon = getResources().getDrawable(R.drawable.ic_state_normal);
        break;
    case VIBRATE:
        ringerDescriptionTV.setText(R.string.settings_section_general_ringer_vibrate);
        icon = getResources().getDrawable(R.drawable.ic_state_vibrate);
        break;
    case SILENT:
        ringerDescriptionTV.setText(R.string.settings_section_general_ringer_silent);
        icon = getResources().getDrawable(R.drawable.ic_state_silent);
        break;
    case IGNORE:
        ringerDescriptionTV.setText(R.string.settings_section_general_ringer_ignore);
        icon = getResources().getDrawable(R.drawable.ic_state_ignore);
        break;
    default:
        throw new IllegalStateException("Saved default ringer is of unknown type: " + prefs.getRingerType());
    }

    int iconColor = getResources().getColor(R.color.icon_tint);
    icon.mutate().setColorFilter(iconColor, PorterDuff.Mode.MULTIPLY);
    ringerDescriptionTV.setTextColor(getResources().getColor(R.color.text_color));
    ringerTV.setTextColor(getResources().getColor(R.color.text_color));

    ImageView ringerIcon = (ImageView) rootView.findViewById(R.id.settings_ringerIcon);
    ringerIcon.setImageDrawable(icon);
}

From source file:org.fdroid.fdroid.installer.InstallIntoSystemDialogActivity.java

/**
 * first time//w w w . j a v  a 2  s. c  om
 */
private void firstTime() {
    // hack to get holo design (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());

    String message = getString(R.string.system_install_first_time_message) + "<br/><br/>"
            + InstallIntoSystem.create(getApplicationContext()).getWarningInfo();

    AlertDialog.Builder builder = new AlertDialog.Builder(theme).setMessage(Html.fromHtml(message))
            .setPositiveButton(R.string.system_permission_install_via_root,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            installTask.execute();
                        }
                    })
            .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    InstallIntoSystemDialogActivity.this.setResult(Activity.RESULT_CANCELED);
                    InstallIntoSystemDialogActivity.this.finish();
                }
            });
    builder.create().show();
}

From source file:com.rastating.droidbeard.fragments.ShowFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(),
            R.style.SickBeardTheme_LightActionBar);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
    View root = localInflater.inflate(R.layout.fragment_show, container, false);

    swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe_refresh_layout);

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override// w w w.j  a  v a 2 s  .c  o  m
        public void onRefresh() {
            onRefreshButtonPressed();

            swipeRefreshLayout.setRefreshing(true);
        }
    });
    swipeRefreshLayout.setColorSchemeResources(R.color.materialPrimaryDark, R.color.materialPrimary,
            R.color.navigation_list_item_selected, R.color.unaired_episode_background);

    if (savedInstanceState != null) {
        mShowSummary = (TVShowSummary) savedInstanceState.getParcelable("summary");
    }

    // Get references to all required views.
    mBanner = (ImageView) root.findViewById(R.id.banner);
    mLoadingImage = (ImageView) root.findViewById(R.id.loading);
    mDataContainer = root.findViewById(R.id.data);
    mAirs = (TextView) root.findViewById(R.id.airs);
    mStatus = (TextView) root.findViewById(R.id.status);
    mLocation = (TextView) root.findViewById(R.id.location);
    mQuality = (TextView) root.findViewById(R.id.quality);
    mLanguage = (TextView) root.findViewById(R.id.language);
    mLanguageIcon = (ImageView) root.findViewById(R.id.language_icon);
    mFlattenFolders = (ImageView) root.findViewById(R.id.flatten_folders);
    mPaused = (ImageView) root.findViewById(R.id.paused);
    mAirByDate = (ImageView) root.findViewById(R.id.air_by_date);
    mSeasonContainer = (LinearLayout) root.findViewById(R.id.season_container);
    mPauseButton = (Button) root.findViewById(R.id.toggle_pause);
    mDeleteButton = (Button) root.findViewById(R.id.delete);

    mPauseButton.setOnClickListener(this);
    mDeleteButton.setOnClickListener(this);

    mDataContainer.setAlpha(0.0f);
    mLoadingImage.setAlpha(1.0f);
    mLoadingImage.startAnimation(new LoadingAnimation());
    onRefreshButtonPressed();

    return root;
}

From source file:dev.dworks.widgets.adateslider.PickerDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ContextThemeWrapper ctw = new ContextThemeWrapper(getActivity(), mTheme);
    LayoutInflater localInflater = inflater.cloneInContext(ctw);
    View v = localInflater.inflate(R.layout.picker_dialog, container, false);
    FrameLayout frame = (FrameLayout) v.findViewById(R.id.container);
    localInflater.inflate(mLayoutID, frame);

    mDivider = v.findViewById(R.id.divider);
    mDividerOne = v.findViewById(R.id.divider_1);
    mDividerTwo = v.findViewById(R.id.divider_2);
    mDivider.setBackgroundColor(mDividerColor);
    mDividerOne.setBackgroundColor(mDividerColor);
    mDividerTwo.setBackgroundColor(mDividerColor);

    getDialog().getWindow().setBackgroundDrawableResource(mDialogBackgroundResId);

    mTitleText = (TextView) v.findViewById(R.id.dateSliderTitleText);
    mTitleText.setTextColor(mTextColor);
    mContainer = (SliderContainer) v.findViewById(R.id.dateSliderContainer);
    mContainer.setTheme(mTheme);//  w  ww  . j  a va2s .  c o m

    mContainer.setOnTimeChangeListener(onTimeChangeListener);
    mContainer.setMinuteInterval(minuteInterval);
    mContainer.setTime(mInitialTime);
    if (minTime != null)
        mContainer.setMinTime(minTime);
    if (maxTime != null)
        mContainer.setMaxTime(maxTime);

    mSet = (Button) v.findViewById(R.id.set_button);
    mCancel = (Button) v.findViewById(R.id.cancel_button);
    mSet.setTextColor(mTextColor);
    mSet.setBackgroundResource(mButtonBackgroundResId);
    mSet.setOnClickListener(okButtonClickListener);

    mCancel.setTextColor(mTextColor);
    mCancel.setBackgroundResource(mButtonBackgroundResId);
    mCancel.setOnClickListener(cancelButtonClickListener);

    return v;
}

From source file:uk.ac.ucl.excites.sapelli.collector.tasks.Backup.java

/**
 * Brings up the selection dialog (= start of back-up procedure)
 * /*ww w .j  av a 2s  . co  m*/
 * Note:
 *    Due to an Android bug (reported by mstevens: https://code.google.com/p/android/issues/detail?id=187416)
 *    we cannot insert a header into the ListView on this dialog as it causes Android to use incorrect list
 *    item indexes. Therefore we use the message as the title of the dialog (ugly). A future alternative (TODO)
 *    may be to refactor this class as a DialogFragment in which the message is shown in a separate TextView
 *    above the list instead of a headerView "in" the ListView.
 */
private void showSelectionDialog() {
    // Initialise folder selection:
    CharSequence[] checkboxItems = new CharSequence[BACKUPABLE_FOLDERS.length];
    boolean[] checkedItems = new boolean[BACKUPABLE_FOLDERS.length];
    int f = 0;
    for (Folder folder : BACKUPABLE_FOLDERS) {
        checkboxItems[f] = activity.getString(getFolderStringID(folder));
        if (checkedItems[f] = isFolderDefaultSelected(folder))
            foldersToExport.add(folder);
        f++;
    }

    // Get dialog builder & configure the dialog...
    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme))
            //   Set icon:
            .setIcon(R.drawable.ic_content_save_black_36dp)
            //   Set title:
            .setTitle(R.string.selectForBackup) // R.string.backup)
            //   Set multiple choice:
            .setMultiChoiceItems(checkboxItems, checkedItems,
                    // Choice click event handler:
                    new DialogInterface.OnMultiChoiceClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                            if (isChecked)
                                // If the user checked the item, add it to the selected items:
                                foldersToExport.add(BACKUPABLE_FOLDERS[which]);
                            else
                                // Else, if the item is already in the array, remove it:
                                foldersToExport.remove(BACKUPABLE_FOLDERS[which]);
                        }
                    })
            // Set OK button:
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    if (foldersToExport.contains(Folder.Export))
                        showExportYesNoDialog(); // propose creation of a fresh full project data export
                    else
                        doBackup(); // go straight to back-up
                }
            })
            // Set Cancel button:
            .setNegativeButton(android.R.string.cancel, null);
    // Create the dialog:
    AlertDialog dialog = builder.create();
    // Add message above list:
    /*TextView lblMsg = new TextView(activity);
    int lrPadding = ViewHelpers.getDefaultDialogPaddingPx(activity);
    lblMsg.setPadding(lrPadding, 0, lrPadding, 0);
    lblMsg.setTextAppearance(activity, android.R.style.TextAppearance_Medium);
    lblMsg.setText(R.string.selectForBackup);
    dialog.getListView().addHeaderView(lblMsg);*/
    // Show the dialog:
    dialog.show();
}

From source file:piuk.blockchain.android.ui.dialogs.TransactionSummaryDialog.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);

    final FragmentActivity activity = getActivity();

    final LayoutInflater inflater = LayoutInflater.from(activity);

    final Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_Dialog))
            .setTitle(R.string.transaction_summary_title);

    final LinearLayout view = (LinearLayout) inflater.inflate(R.layout.transaction_summary_fragment, null);

    dialog.setView(view);// ww  w  . j  a v a  2 s.co m

    try {
        final MyRemoteWallet wallet = application.getRemoteWallet();

        BigInteger totalOutputValue = BigInteger.ZERO;
        for (TransactionOutput output : tx.getOutputs()) {
            totalOutputValue = totalOutputValue.add(output.getValue());
        }

        final TextView resultDescriptionView = (TextView) view.findViewById(R.id.result_description);
        final TextView toView = (TextView) view.findViewById(R.id.transaction_to);
        final TextView toViewLabel = (TextView) view.findViewById(R.id.transaction_to_label);
        final View toViewContainer = (View) view.findViewById(R.id.transaction_to_container);
        final TextView hashView = (TextView) view.findViewById(R.id.transaction_hash);
        final TextView transactionTimeView = (TextView) view.findViewById(R.id.transaction_date);
        final TextView confirmationsView = (TextView) view.findViewById(R.id.transaction_confirmations);
        final TextView noteView = (TextView) view.findViewById(R.id.transaction_note);
        final Button addNoteButton = (Button) view.findViewById(R.id.add_note_button);
        final TextView feeView = (TextView) view.findViewById(R.id.transaction_fee);
        final View feeViewContainer = view.findViewById(R.id.transaction_fee_container);
        final TextView valueNowView = (TextView) view.findViewById(R.id.transaction_value);
        final View valueNowContainerView = view.findViewById(R.id.transaction_value_container);

        String to = null;
        for (TransactionOutput output : tx.getOutputs()) {
            try {
                String toAddress = output.getScriptPubKey().getToAddress().toString();
                if (!wallet.isAddressMine(toAddress)) {
                    to = toAddress;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String from = null;
        for (TransactionInput input : tx.getInputs()) {
            try {
                String fromAddress = input.getFromAddress().toString();
                if (!wallet.isAddressMine(fromAddress)) {
                    from = fromAddress;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        long realResult = 0;
        int confirmations = 0;

        if (tx instanceof MyTransaction) {
            MyTransaction myTx = (MyTransaction) tx;

            realResult = myTx.getResult().longValue();

            if (wallet.getLatestBlock() != null) {
                confirmations = wallet.getLatestBlock().getHeight() - myTx.getHeight() + 1;
            }

        } else if (application.isInP2PFallbackMode()) {
            realResult = tx.getValue(application.bitcoinjWallet).longValue();

            if (tx.getConfidence().getConfidenceType() == ConfidenceType.BUILDING)
                confirmations = tx.getConfidence().getDepthInBlocks();
        }

        final long finalResult = realResult;

        if (realResult <= 0) {
            toViewLabel.setText(R.string.transaction_fragment_to);

            if (to == null) {
                ((LinearLayout) toViewContainer.getParent()).removeView(toViewContainer);
            } else {
                toView.setText(to);
            }
        } else {
            toViewLabel.setText(R.string.transaction_fragment_from);

            if (from == null) {
                ((LinearLayout) toViewContainer.getParent()).removeView(toViewContainer);
            } else {
                toView.setText(from);
            }
        }

        //confirmations view
        if (confirmations > 0) {
            confirmationsView.setText("" + confirmations);
        } else {
            confirmationsView.setText("Unconfirmed");
        }

        //Hash String view
        final String hashString = new String(Hex.encode(tx.getHash().getBytes()), "UTF-8");

        hashView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("https:/" + Constants.BLOCKCHAIN_DOMAIN + "/tx/" + hashString));

                startActivity(browserIntent);
            }
        });

        //Notes View
        String note = wallet.getTxNotes().get(hashString);

        if (note == null) {
            addNoteButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismiss();

                    AddNoteDialog.showDialog(getFragmentManager(), hashString);
                }
            });

            view.removeView(noteView);
        } else {
            view.removeView(addNoteButton);

            noteView.setText(note);

            noteView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismiss();

                    AddNoteDialog.showDialog(getFragmentManager(), hashString);
                }
            });
        }

        addNoteButton.setEnabled(!application.isInP2PFallbackMode());

        SpannableString content = new SpannableString(hashString);
        content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
        hashView.setText(content);

        if (realResult > 0 && from != null)
            resultDescriptionView.setText(this.getString(R.string.transaction_fragment_amount_you_received,
                    WalletUtils.formatValue(BigInteger.valueOf(realResult))));
        else if (realResult < 0 && to != null)
            resultDescriptionView.setText(this.getString(R.string.transaction_fragment_amount_you_sent,
                    WalletUtils.formatValue(BigInteger.valueOf(realResult))));
        else
            resultDescriptionView.setText(this.getString(R.string.transaction_fragment_amount_you_moved,
                    WalletUtils.formatValue(totalOutputValue)));

        final Date time = tx.getUpdateTime();

        transactionTimeView.setText(dateFormat.format(time));

        //These will be made visible again later once information is fetched from server
        feeViewContainer.setVisibility(View.GONE);
        valueNowContainerView.setVisibility(View.GONE);

        if (tx instanceof MyTransaction) {
            MyTransaction myTx = (MyTransaction) tx;

            final long txIndex = myTx.getTxIndex();

            final Handler handler = new Handler();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        final JSONObject obj = getTransactionSummary(txIndex, wallet.getGUID(), finalResult);

                        handler.post(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    if (obj.get("fee") != null) {
                                        feeViewContainer.setVisibility(View.VISIBLE);

                                        feeView.setText(WalletUtils.formatValue(
                                                BigInteger.valueOf(Long.valueOf(obj.get("fee").toString())))
                                                + " BTC");
                                    }

                                    if (obj.get("confirmations") != null) {
                                        int confirmations = ((Number) obj.get("confirmations")).intValue();

                                        confirmationsView.setText("" + confirmations);
                                    }

                                    String result_local = (String) obj.get("result_local");
                                    String result_local_historical = (String) obj
                                            .get("result_local_historical");

                                    if (result_local != null && result_local.length() > 0) {
                                        valueNowContainerView.setVisibility(View.VISIBLE);

                                        if (result_local_historical == null
                                                || result_local_historical.length() == 0
                                                || result_local_historical.equals(result_local)) {
                                            valueNowView.setText(result_local);
                                        } else {
                                            valueNowView.setText(getString(R.string.value_now_ten, result_local,
                                                    result_local_historical));
                                        }
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    Dialog d = dialog.create();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();

    lp.dimAmount = 0;
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;

    d.show();

    d.getWindow().setAttributes(lp);

    d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return d;
}