Example usage for android.graphics Typeface NORMAL

List of usage examples for android.graphics Typeface NORMAL

Introduction

In this page you can find the example usage for android.graphics Typeface NORMAL.

Prototype

int NORMAL

To view the source code for android.graphics Typeface NORMAL.

Click Source Link

Usage

From source file:com.android.datetimepicker.time.AmPmCirclesView.java

public void initialize(Context context, TimePickerController controller, int amOrPm) {
    if (mIsInitialized) {
        Log.e(TAG, "AmPmCirclesView may only be initialized once.");
        return;/*from   w  w w  .  j a  v  a2  s . co  m*/
    }

    Resources res = context.getResources();

    if (controller.isThemeDark()) {
        mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_circle_background_dark_theme);
        mAmPmTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
        mAmPmDisabledTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_disabled_dark_theme);
        mSelectedAlpha = SELECTED_ALPHA_THEME_DARK;
    } else {
        mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_white);
        mAmPmTextColor = ContextCompat.getColor(context, R.color.mdtp_ampm_text_color);
        mAmPmDisabledTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled);
        mSelectedAlpha = SELECTED_ALPHA;
    }

    mSelectedColor = controller.getAccentColor();
    mTouchedColor = Utils.darkenColor(mSelectedColor);
    mAmPmSelectedTextColor = ContextCompat.getColor(context, R.color.mdtp_white);

    String typefaceFamily = res.getString(R.string.mdtp_sans_serif);
    Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL);
    mPaint.setTypeface(tf);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier));
    mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier));
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mAmDisabled = controller.isAmDisabled();
    mPmDisabled = controller.isPmDisabled();

    setAmOrPm(amOrPm);
    mAmOrPmPressed = -1;

    mIsInitialized = true;
}

From source file:com.customdatepicker.time.RadialTextsView.java

public void initialize(Context context, String[] texts, String[] innerTexts, TimePickerController controller,
        SelectionValidator validator, boolean disappearsOut) {
    if (mIsInitialized) {
        Log.e(TAG, "This RadialTextsView may only be initialized once.");
        return;/* w w w  . ja  va  2s.c o  m*/
    }
    Resources res = context.getResources();

    // Set up the paint.
    int textColorRes = controller.isThemeDark() ? R.color.mdtp_white : R.color.mdtp_numbers_text_color;
    mPaint.setColor(ContextCompat.getColor(context, textColorRes));
    String typefaceFamily = res.getString(R.string.mdtp_radial_numbers_typeface);
    mTypefaceLight = Typeface.create(typefaceFamily, Typeface.NORMAL);
    String typefaceFamilyRegular = res.getString(R.string.mdtp_sans_serif);
    mTypefaceRegular = Typeface.create(typefaceFamilyRegular, Typeface.NORMAL);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    // Set up the selected paint
    int selectedTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mSelectedPaint.setColor(selectedTextColor);
    mSelectedPaint.setAntiAlias(true);
    mSelectedPaint.setTextAlign(Align.CENTER);

    // Set up the inactive paint
    int inactiveColorRes = controller.isThemeDark() ? R.color.mdtp_date_picker_text_disabled_dark_theme
            : R.color.mdtp_date_picker_text_disabled;
    mInactivePaint.setColor(ContextCompat.getColor(context, inactiveColorRes));
    mInactivePaint.setAntiAlias(true);
    mInactivePaint.setTextAlign(Align.CENTER);

    mTexts = texts;
    mInnerTexts = innerTexts;
    mIs24HourMode = controller.is24HourMode();
    mHasInnerCircle = (innerTexts != null);

    // Calculate the radius for the main circle.
    if (mIs24HourMode || controller.getVersion() != TimePickerDialog.Version.VERSION_1) {
        mCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier_24HourMode));
    } else {
        mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier));
        mAmPmCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier));
    }

    // Initialize the widths and heights of the grid, and calculate the values for the numbers.
    mTextGridHeights = new float[7];
    mTextGridWidths = new float[7];
    if (mHasInnerCircle) {
        mNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_outer));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_outer));
        mInnerNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_inner));
        mInnerTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_inner));

        mInnerTextGridHeights = new float[7];
        mInnerTextGridWidths = new float[7];
    } else {
        mNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_normal));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_normal));
    }

    mAnimationRadiusMultiplier = 1;
    mTransitionMidRadiusMultiplier = 1f + (0.05f * (disappearsOut ? -1 : 1));
    mTransitionEndRadiusMultiplier = 1f + (0.3f * (disappearsOut ? 1 : -1));
    mInvalidateUpdateListener = new InvalidateUpdateListener();

    mValidator = validator;

    mTextGridValuesDirty = true;
    mIsInitialized = true;
}

From source file:com.android.datetimepicker.time.RadialTextsView.java

public void initialize(Context context, String[] texts, String[] innerTexts, TimePickerController controller,
        SelectionValidator validator, boolean disappearsOut) {
    if (mIsInitialized) {
        Log.e(TAG, "This RadialTextsView may only be initialized once.");
        return;/*ww  w  . j  ava  2  s .  c om*/
    }
    Resources res = context.getResources();

    // Set up the paint.
    int textColorRes = controller.isThemeDark() ? R.color.mdtp_white : R.color.mdtp_numbers_text_color;
    mPaint.setColor(ContextCompat.getColor(context, textColorRes));
    String typefaceFamily = res.getString(R.string.mdtp_radial_numbers_typeface);
    mTypefaceLight = Typeface.create(typefaceFamily, Typeface.NORMAL);
    String typefaceFamilyRegular = res.getString(R.string.mdtp_sans_serif);
    mTypefaceRegular = Typeface.create(typefaceFamilyRegular, Typeface.NORMAL);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    // Set up the selected paint
    int selectedTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mSelectedPaint.setColor(selectedTextColor);
    mSelectedPaint.setAntiAlias(true);
    mSelectedPaint.setTextAlign(Align.CENTER);

    // Set up the inactive paint
    int inactiveColorRes = controller.isThemeDark() ? R.color.mdtp_date_picker_text_disabled_dark_theme
            : R.color.mdtp_date_picker_text_disabled;
    mInactivePaint.setColor(ContextCompat.getColor(context, inactiveColorRes));
    mInactivePaint.setAntiAlias(true);
    mInactivePaint.setTextAlign(Align.CENTER);

    mTexts = texts;
    mInnerTexts = innerTexts;
    mIs24HourMode = controller.is24HourMode();
    mHasInnerCircle = (innerTexts != null);

    // Calculate the radius for the main circle.
    if (mIs24HourMode) {
        mCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier_24HourMode));
    } else {
        mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier));
        mAmPmCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier));
    }

    // Initialize the widths and heights of the grid, and calculate the values for the numbers.
    mTextGridHeights = new float[7];
    mTextGridWidths = new float[7];
    if (mHasInnerCircle) {
        mNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_outer));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_outer));
        mInnerNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_inner));
        mInnerTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_inner));

        mInnerTextGridHeights = new float[7];
        mInnerTextGridWidths = new float[7];
    } else {
        mNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_normal));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_normal));
    }

    mAnimationRadiusMultiplier = 1;
    mTransitionMidRadiusMultiplier = 1f + (0.05f * (disappearsOut ? -1 : 1));
    mTransitionEndRadiusMultiplier = 1f + (0.3f * (disappearsOut ? 1 : -1));
    mInvalidateUpdateListener = new InvalidateUpdateListener();

    mValidator = validator;

    mTextGridValuesDirty = true;
    mIsInitialized = true;
}

From source file:com.mojtaba.materialdatetimepicker.time.AmPmCirclesView.java

public void initialize(Context context, TimePickerController controller, int amOrPm) {
    if (mIsInitialized) {
        Log.e(TAG, "AmPmCirclesView may only be initialized once.");
        return;/* w  w  w . j a v  a  2  s . c  o  m*/
    }

    Resources res = context.getResources();

    if (controller.isThemeDark()) {
        mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_circle_background_dark_theme);
        mAmPmTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
        mAmPmDisabledTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_disabled_dark_theme);
        mSelectedAlpha = SELECTED_ALPHA_THEME_DARK;
    } else {
        mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_white);
        mAmPmTextColor = ContextCompat.getColor(context, R.color.mdtp_ampm_text_color);
        mAmPmDisabledTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled);
        mSelectedAlpha = SELECTED_ALPHA;
    }

    mSelectedColor = controller.getAccentColor();
    mTouchedColor = Utils.darkenColor(mSelectedColor);
    mAmPmSelectedTextColor = ContextCompat.getColor(context, R.color.mdtp_white);

    String typefaceFamily = res.getString(R.string.mdtp_sans_serif);
    Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL);
    mPaint.setTypeface(tf);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier));
    mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier));
    mAmText = "";
    mPmText = "";

    setAmOrPm(amOrPm);
    mAmOrPmPressed = -1;

    mIsInitialized = true;
}

From source file:com.chauffeurprive.kronos.time.RadialTextsView.java

public void initialize(Context context, String[] texts, String[] innerTexts, TimePickerController controller,
        SelectionValidator validator, boolean disappearsOut) {
    if (mIsInitialized) {
        Log.e(TAG, "This RadialTextsView may only be initialized once.");
        return;//from   www  . ja va 2s .  c o  m
    }
    Resources res = context.getResources();

    // Set up the paint.
    int textColorRes = controller.getTextColor();
    mPaint.setColor(ContextCompat.getColor(context, textColorRes));
    String typefaceFamily = res.getString(R.string.mdtp_radial_numbers_typeface);
    mTypefaceLight = Typeface.create(typefaceFamily, Typeface.NORMAL);
    String typefaceFamilyRegular = res.getString(R.string.mdtp_sans_serif);
    mTypefaceRegular = Typeface.create(typefaceFamilyRegular, Typeface.NORMAL);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    // Set up the selected paint
    int selectedTextColor = ContextCompat.getColor(context, controller.getSelectedTextColor());
    mSelectedPaint.setColor(selectedTextColor);
    mSelectedPaint.setAntiAlias(true);
    mSelectedPaint.setTextAlign(Align.CENTER);

    // Set up the inactive paint
    int inactiveColorRes = controller.getDisabledTextColor();
    mInactivePaint.setColor(ContextCompat.getColor(context, inactiveColorRes));
    mInactivePaint.setAntiAlias(true);
    mInactivePaint.setTextAlign(Align.CENTER);

    mTexts = texts;
    mInnerTexts = innerTexts;
    mIs24HourMode = controller.is24HourMode();
    mHasInnerCircle = (innerTexts != null);

    // Calculate the radius for the main circle.
    if (mIs24HourMode) {
        mCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier_24HourMode));
    } else {
        mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier));
        mAmPmCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier));
    }

    // Initialize the widths and heights of the grid, and calculate the values for the numbers.
    mTextGridHeights = new float[7];
    mTextGridWidths = new float[7];
    if (mHasInnerCircle) {
        mNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_outer));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_outer));
        mInnerNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_inner));
        mInnerTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_inner));

        mInnerTextGridHeights = new float[7];
        mInnerTextGridWidths = new float[7];
    } else {
        mNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_normal));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_normal));
    }

    mAnimationRadiusMultiplier = 1;
    mTransitionMidRadiusMultiplier = 1f + (0.05f * (disappearsOut ? -1 : 1));
    mTransitionEndRadiusMultiplier = 1f + (0.3f * (disappearsOut ? 1 : -1));
    mInvalidateUpdateListener = new InvalidateUpdateListener();

    mValidator = validator;

    mTextGridValuesDirty = true;
    mIsInitialized = true;
}

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticCheckButton.java

private void setTypeArray(TypedArray typedArray) {
    GradientDrawable bgShape = (GradientDrawable) view.getBackground();

    round = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_round, round);
    bgShape.setCornerRadius(round);/*  w  ww  . j  a va  2  s.  com*/

    color = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_backgroundColor, color);
    bgShape.setColor(color);

    scale = typedArray.getFloat(R.styleable.ElasticCheckButton_checkbutton_scale, scale);

    duration = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_duration, duration);

    labelText = typedArray.getString(R.styleable.ElasticCheckButton_checkbutton_labelText);
    view.setText(labelText);

    labelColor = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelColor, labelColor);
    view.setTextColor(labelColor);

    labelSize = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelSize, labelSize);
    view.setTextSize(labelSize);

    labelStyle = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelStyle, labelStyle);

    if (labelStyle == 0)
        view.setTypeface(null, Typeface.NORMAL);
    else if (labelStyle == 1)
        view.setTypeface(null, Typeface.BOLD);
    else if (labelStyle == 2)
        view.setTypeface(null, Typeface.ITALIC);

    alpha = typedArray.getFloat(R.styleable.ElasticCheckButton_checkbutton_alpha, alpha);

    checked = typedArray.getBoolean(R.styleable.ElasticCheckButton_checkbutton_ischecked, checked);
    if (checked)
        view.setAlpha(alpha);
}

From source file:com.jarklee.materialdatetimepicker.time.AmPmCirclesView.java

public void initialize(Context context, TimePickerController controller, int amOrPm) {
    if (mIsInitialized) {
        Log.e(TAG, "AmPmCirclesView may only be initialized once.");
        return;/* w w w .  ja v a 2 s .co m*/
    }

    Resources res = context.getResources();

    if (controller.isThemeDark()) {
        mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_circle_background_dark_theme);
        mAmPmTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
        mAmPmDisabledTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_disabled_dark_theme);
        mSelectedAlpha = SELECTED_ALPHA_THEME_DARK;
    } else {
        mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_white);
        mAmPmTextColor = ContextCompat.getColor(context, R.color.mdtp_ampm_text_color);
        mAmPmDisabledTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled);
        mSelectedAlpha = SELECTED_ALPHA;
    }

    mSelectedColor = controller.getAccentColor();
    mTouchedColor = Utils.darkenColor(mSelectedColor);
    mAmPmSelectedTextColor = ContextCompat.getColor(context, R.color.mdtp_white);

    String typefaceFamily = res.getString(R.string.mdtp_sans_serif);
    Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL);
    mPaint.setTypeface(tf);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier));
    mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier));
    String[] amPmTexts = new DateFormatSymbols(getLocale()).getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mAmDisabled = controller.isAmDisabled();
    mPmDisabled = controller.isPmDisabled();

    setAmOrPm(amOrPm);
    mAmOrPmPressed = -1;

    mIsInitialized = true;
}

From source file:com.stepstone.stepper.internal.widget.StepTab.java

public StepTab(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    LayoutInflater.from(getContext()).inflate(R.layout.ms_step_tab, this, true);

    mSelectedColor = ContextCompat.getColor(context, R.color.ms_selectedColor);
    mUnselectedColor = ContextCompat.getColor(context, R.color.ms_unselectedColor);
    mErrorColor = ContextCompat.getColor(context, R.color.ms_errorColor);

    mStepNumber = (TextView) findViewById(R.id.ms_stepNumber);
    mStepDoneIndicator = (ImageView) findViewById(R.id.ms_stepDoneIndicator);
    mStepIconBackground = (ImageView) findViewById(R.id.ms_stepIconBackground);
    mStepDivider = findViewById(R.id.ms_stepDivider);
    mStepTitle = ((TextView) findViewById(R.id.ms_stepTitle));

    mTitleColor = mStepTitle.getCurrentTextColor();

    Typeface typeface = mStepTitle.getTypeface();
    mNormalTypeface = Typeface.create(typeface, Typeface.NORMAL);
    mBoldTypeface = Typeface.create(typeface, Typeface.BOLD);
    Drawable avd = createCircleToWarningDrawable();
    mStepIconBackground.setImageDrawable(avd);
}

From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.view_zenoss_event, container, false);

    Title = (TextView) rootView.findViewById(R.id.EventTitle);
    Component = (TextView) rootView.findViewById(R.id.Componant);
    EventClass = (TextView) rootView.findViewById(R.id.EventClass);
    Summary = (TextView) rootView.findViewById(R.id.Summary);
    FirstTime = (TextView) rootView.findViewById(R.id.FirstTime);
    LastTime = (TextView) rootView.findViewById(R.id.LastTime);
    ackIcon = (ImageView) rootView.findViewById(R.id.ackIcon);
    img = (ImageView) rootView.findViewById(R.id.summaryImage);
    EventCount = (TextView) rootView.findViewById(R.id.EventCount);
    agent = (TextView) rootView.findViewById(R.id.Agent);
    logList = (LinearLayout) rootView.findViewById(R.id.LogList);
    progressbar = (ProgressBar) rootView.findViewById(R.id.progressBar);

    Typeface Titles = Typeface.create("sans-serif-light", Typeface.NORMAL);
    Typeface Subtitles = Typeface.create("sans-serif", Typeface.BOLD);

    Title.setTypeface(Titles);/*from  w  ww .  j  ava  2s .c o  m*/

    try {
        if (getActivity().getIntent().hasExtra("EventCount")) {
            EventCount.setText(
                    "Count: " + Integer.toString(getActivity().getIntent().getIntExtra("EventCount", 0)));
        } else if (getArguments().getInt("EventCount", 0) != 0) {
            EventCount.setText("Count: " + Integer.toString(getArguments().getInt("EventCount", 0)));
        } else {
            EventCount.setText("Count: 0");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        if (getActivity().getIntent().hasExtra("EventTitle")) {
            Title.setText(getActivity().getIntent().getStringExtra("EventTitle"));
        } else if (!getArguments().getString("EventTitle").equals("")) {
            Title.setText(getArguments().getString("EventTitle"));
        } else {
            Title.setText(getActivity().getString(R.string.eventDetailsTitlePlaceholder));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    ackIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            progressbar.setVisibility(View.VISIBLE);

            ((Thread) new Thread() {
                public void run() {
                    if (settings.getBoolean(ZenossAPI.PREFERENCE_IS_ZAAS, false)) {
                        API = new ZenossAPIZaas();
                    } else {
                        API = new ZenossAPICore();
                    }

                    ZenossCredentials credentials = null;

                    try {
                        credentials = new ZenossCredentials(getActivity());
                    } catch (Exception e) {
                        BugSenseHandler.sendExceptionMessage("ViewZenossEventFragmentUpdate", "credentials", e);
                        credentials = null;
                    }

                    try {
                        API.Login(credentials);
                        JSONObject ackJSON = API.AcknowledgeEvent(getArguments().getString("EventID"));

                        if (ackJSON.getJSONObject("result").getBoolean("success")) {
                            getActivity().runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    progressbar.setVisibility(View.INVISIBLE);
                                    ackIcon.setImageResource(R.drawable.ic_acknowledged);
                                    mCallbacks.onItemAcknowledged(getArguments().getInt("position"));
                                }
                            });

                            RhybuddDataSource datasource = null;
                            try {
                                datasource = new RhybuddDataSource(getActivity());
                                datasource.open();
                                datasource.ackEvent(getArguments().getString("EventID"));
                            } catch (Exception e) {
                                e.printStackTrace();
                                BugSenseHandler.sendExceptionMessage("ViewZenossEventFragmentUpdate",
                                        "DBUpdate", e);
                            } finally {
                                if (null != datasource)
                                    datasource.close();
                            }
                        } else {
                            Toast.makeText(getActivity(), "Unable to acknowledge alert", Toast.LENGTH_SHORT)
                                    .show();
                        }
                    } catch (Exception e) {
                        getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(getActivity(), "Unable to acknowledge alert", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        });

                        BugSenseHandler.sendExceptionMessage("ViewZenossEventFragment", "outer try", e);
                    }
                }
            }).start();
        }
    });
    return rootView;
}

From source file:app.hacked.ScheduleItemDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.schedule_detail_fragment, container, false);

    ((TextView) rootView.findViewById(R.id.times)).setText(scheduleStartTime + " till " + scheduleEndTime);
    ((TextView) rootView.findViewById(R.id.times))
            .setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));

    if (rootView.findViewById(R.id.Title) != null) {
        ((TextView) rootView.findViewById(R.id.Title)).setText(scheduleDesc);
        ((TextView) rootView.findViewById(R.id.Title))
                .setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
        ((TextView) rootView.findViewById(R.id.times))
                .setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
        getActivity().getActionBar()/*from ww  w.ja  va 2s  .  c  o m*/
                .setTitle(scheduleTitle + " - " + getActivity().getString(R.string.app_name));
    }

    TextView fullDetailsTV = (TextView) rootView.findViewById(R.id.fullDetails);

    if (null == scheduleFullDataHTML || scheduleFullDataHTML.equals("")
            || scheduleFullDataHTML.equals("null")) {
        fullDetailsTV.setText(Html.fromHtml(scheduleDesc));
    } else {
        fullDetailsTV.setText(Html.fromHtml(scheduleFullDataHTML));
    }
    fullDetailsTV.setTypeface(Typeface.create("sans-serif", Typeface.NORMAL));

    try {
        fullDetailsTV.setMovementMethod(LinkMovementMethod.getInstance());
    } catch (Exception e) {
        //Worth a shot
    }
    return rootView;
}