Example usage for android.util TypedValue getFloat

List of usage examples for android.util TypedValue getFloat

Introduction

In this page you can find the example usage for android.util TypedValue getFloat.

Prototype

public final float getFloat() 

Source Link

Document

Return the data for this value as a float.

Usage

From source file:com.saulcintero.moveon.fragments.Summary4.java

private void lineChartView() {
    TypedValue outValue1 = new TypedValue();
    TypedValue outValue2 = new TypedValue();
    TypedValue outValue3 = new TypedValue();
    TypedValue outValue4 = new TypedValue();
    mContext.getResources().getValue(R.dimen.line_axis_title_text_size_value, outValue1, true);
    mContext.getResources().getValue(R.dimen.line_chart_title_text_size_value, outValue2, true);
    mContext.getResources().getValue(R.dimen.line_labels_text_size_value, outValue3, true);
    mContext.getResources().getValue(R.dimen.line_legend_text_size_value, outValue4, true);
    float lineAxisTitleTextSizeValue = outValue1.getFloat();
    float lineCharTitleTextSizeValue = outValue2.getFloat();
    float lineLabelsTextSizeValue = outValue3.getFloat();
    float lineLegendTextSizeValue = outValue4.getFloat();

    XYMultipleSeriesDataset mDataset = getDataset();

    XYMultipleSeriesRenderer mRenderer = getRenderer();
    mRenderer.setApplyBackgroundColor(true);
    mRenderer.setBackgroundColor(Color.TRANSPARENT);
    mRenderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01));
    mRenderer.setAxisTitleTextSize(lineAxisTitleTextSizeValue);
    mRenderer.setChartTitleTextSize(lineCharTitleTextSizeValue);
    mRenderer.setLabelsTextSize(lineLabelsTextSizeValue);
    mRenderer.setLegendTextSize(lineLegendTextSizeValue);
    mRenderer.setMargins(new int[] { 12, 25, 12, 12 });
    mRenderer.setZoomButtonsVisible(true);
    mRenderer.setPointSize(10);/*w  ww  .  j a va2 s. c  o  m*/
    mRenderer.setClickEnabled(true);

    mChartView = ChartFactory.getLineChartView(getActivity(), mDataset, mRenderer);

    mChartView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();
            if (seriesSelection != null) {
                UIFunctionUtils.showMessage(mContext, true,
                        (int) seriesSelection.getValue() + " " + getString(R.string.beats_per_minute));
            }
        }
    });

    layout.addView(mChartView);
}

From source file:com.saulcintero.moveon.fragments.Summary3.java

private XYMultipleSeriesRenderer getRenderer_type1() {
    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(2);

    XYSeriesRenderer r = new XYSeriesRenderer();
    r.setLineWidth(2f);/*w w w  .  j  a  v  a 2  s.  c o  m*/
    r.setColor(Color.rgb(0, 0, 188));
    r.setFillBelowLine(true);
    r.setFillPoints(true);
    renderer.addSeriesRenderer(r);

    TypedValue outValue1 = new TypedValue();
    TypedValue outValue2 = new TypedValue();
    TypedValue outValue3 = new TypedValue();
    TypedValue outValue4 = new TypedValue();
    mContext.getResources().getValue(R.dimen.xy_chart_text_size_value, outValue1, true);
    mContext.getResources().getValue(R.dimen.xy_labels_text_size_value, outValue2, true);
    mContext.getResources().getValue(R.dimen.xy_axis_title_text_size_value, outValue3, true);
    mContext.getResources().getValue(R.dimen.xy_legend_text_size_value, outValue4, true);
    float xyChartTextSizeValue = outValue1.getFloat();
    float xyLabelsTextSizeValue = outValue1.getFloat();
    float xyAxisTitleTextSizeValue = outValue1.getFloat();
    float xyLegendTextSizeValue = outValue1.getFloat();

    r = new XYSeriesRenderer();
    r.setColor(Color.rgb(255, 124, 0));
    r.setFillPoints(true);
    r.setLineWidth(2.5f);
    r.setDisplayChartValues(false);
    r.setChartValuesTextSize(xyChartTextSizeValue);

    renderer.addSeriesRenderer(r);
    renderer.setAxesColor(Color.WHITE);
    renderer.setLabelsColor(Color.LTGRAY);
    renderer.setBackgroundColor(Color.TRANSPARENT);
    renderer.setTextTypeface("sans_serif", Typeface.BOLD);

    renderer.setLabelsTextSize(xyLabelsTextSizeValue);
    renderer.setAxisTitleTextSize(xyAxisTitleTextSizeValue);
    renderer.setLegendTextSize(xyLegendTextSizeValue);

    renderer.setXTitle(FunctionUtils.capitalizeFirtsLetter(getString(R.string.minutes)));
    renderer.setYTitle(
            isMetric ? getString(R.string.long_unit1_detail_7) : getString(R.string.long_unit2_detail_7));
    renderer.setYTitle(FunctionUtils.capitalizeFirtsLetter(
            isMetric ? getString(R.string.long_unit1_detail_10) : getString(R.string.long_unit2_detail_10)), 1);
    renderer.setYAxisAlign(Align.RIGHT, 1);
    renderer.setYLabelsAlign(Align.RIGHT, 1);
    renderer.setYAxisMin(min_altitude, 1);
    renderer.setYAxisMax(max_altitude);

    renderer.setXLabels(20);
    renderer.setYLabels(20);
    renderer.setYLabelsAlign(Align.LEFT);
    renderer.setShowGrid(false);

    float smallest = 0;
    if (0 > min_altitude)
        smallest = min_altitude;

    float highest = max_speed;
    if (max_speed < max_altitude)
        highest = max_altitude;

    renderer.setXAxisMin(0);
    renderer.setXAxisMax((float) ((float) timeList.get(timeList.size() - 1) / 60));
    renderer.setYAxisMin(smallest);
    renderer.setYAxisMax(highest);

    return renderer;
}

From source file:com.saulcintero.moveon.fragments.Summary3.java

private void lineChartView_type1() {
    if (paintChartView) {
        check1.setVisibility(View.VISIBLE);
        check2.setVisibility(View.VISIBLE);
        txt1.setVisibility(View.GONE);

        TypedValue outValue1 = new TypedValue();
        TypedValue outValue2 = new TypedValue();
        TypedValue outValue3 = new TypedValue();
        TypedValue outValue4 = new TypedValue();
        mContext.getResources().getValue(R.dimen.line_axis_title_text_size_value, outValue1, true);
        mContext.getResources().getValue(R.dimen.line_chart_title_text_size_value, outValue2, true);
        mContext.getResources().getValue(R.dimen.line_labels_text_size_value, outValue3, true);
        mContext.getResources().getValue(R.dimen.line_legend_text_size_value, outValue4, true);
        float lineAxisTitleTextSizeValue = outValue1.getFloat();
        float lineCharTitleTextSizeValue = outValue2.getFloat();
        float lineLabelsTextSizeValue = outValue3.getFloat();
        float lineLegendTextSizeValue = outValue4.getFloat();

        XYMultipleSeriesDataset mDataset = getDataset_type1();
        XYMultipleSeriesRenderer mRenderer = getRenderer_type1();
        mRenderer.setApplyBackgroundColor(true);
        mRenderer.setBackgroundColor(Color.TRANSPARENT);
        mRenderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01));
        mRenderer.setAxisTitleTextSize(lineAxisTitleTextSizeValue);
        mRenderer.setChartTitleTextSize(lineCharTitleTextSizeValue);
        mRenderer.setLabelsTextSize(lineLabelsTextSizeValue);
        mRenderer.setLegendTextSize(lineLegendTextSizeValue);
        mRenderer.setMargins(new int[] { 12, 25, 12, 22 });
        mRenderer.setZoomButtonsVisible(true);
        mRenderer.setPointSize(10);/* w ww  . j  a v  a 2  s  . c o m*/
        mRenderer.setClickEnabled(true);
        mChartView = ChartFactory.getLineChartView(getActivity(), mDataset, mRenderer);

        mChartView.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();

                if (seriesSelection != null) {
                    String units = "";
                    switch (seriesSelection.getSeriesIndex()) {
                    case 0:
                        units = " " + (isMetric ? getString(R.string.long_unit1_detail_4)
                                : getString(R.string.long_unit2_detail_4));
                        break;
                    case 1:
                        units = " " + (isMetric ? getString(R.string.long_unit1_detail_2)
                                : getString(R.string.long_unit2_detail_2));
                        break;
                    }
                    UIFunctionUtils.showMessage(mContext, true, (int) seriesSelection.getValue() + units);
                }
            }
        });

        chartLayout.addView(mChartView);
    } else {
        setCorrectText();
    }
}

From source file:com.saulcintero.moveon.fragments.Summary3.java

private void lineChartView_type2(final int type) {
    if (paintChartView) {
        txt1.setVisibility(View.GONE);

        TypedValue outValue1 = new TypedValue();
        TypedValue outValue2 = new TypedValue();
        TypedValue outValue3 = new TypedValue();
        TypedValue outValue4 = new TypedValue();
        mContext.getResources().getValue(R.dimen.line2_axis_title_text_size_value, outValue1, true);
        mContext.getResources().getValue(R.dimen.line2_chart_title_text_size_value, outValue2, true);
        mContext.getResources().getValue(R.dimen.line2_labels_text_size_value, outValue3, true);
        mContext.getResources().getValue(R.dimen.line2_legend_text_size_value, outValue4, true);
        float line2AxisTitleTextSizeValue = outValue1.getFloat();
        float line2CharTitleTextSizeValue = outValue2.getFloat();
        float line2LabelsTextSizeValue = outValue3.getFloat();
        float line2LegendTextSizeValue = outValue4.getFloat();

        XYMultipleSeriesDataset mDataset = null;
        XYMultipleSeriesRenderer mRenderer = null;
        switch (type) {
        case 1://w  ww.jav a  2 s.co  m
            mDataset = getDataset_type2(1);
            break;
        case 2:
            mDataset = getDataset_type2(2);
            break;
        }
        mRenderer = getRenderer_type2(type);
        mRenderer.setApplyBackgroundColor(true);
        mRenderer.setBackgroundColor(Color.TRANSPARENT);
        mRenderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01));
        mRenderer.setAxisTitleTextSize(line2AxisTitleTextSizeValue);
        mRenderer.setChartTitleTextSize(line2CharTitleTextSizeValue);
        mRenderer.setLabelsTextSize(line2LabelsTextSizeValue);
        mRenderer.setLegendTextSize(line2LegendTextSizeValue);
        mRenderer.setMargins(new int[] { 12, 25, 12, 12 });
        mRenderer.setZoomButtonsVisible(true);
        mRenderer.setPointSize(10);
        mRenderer.setClickEnabled(true);
        mChartView = ChartFactory.getLineChartView(getActivity(), mDataset, mRenderer);

        mChartView.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();

                if (seriesSelection != null) {
                    switch (type) {
                    case 1:
                        UIFunctionUtils.showMessage(mContext, true,
                                (int) seriesSelection.getValue() + " "
                                        + (isMetric ? getString(R.string.long_unit1_detail_4)
                                                : getString(R.string.long_unit2_detail_4)));
                        break;
                    case 2:
                        UIFunctionUtils.showMessage(mContext, true,
                                (int) seriesSelection.getValue() + " "
                                        + (isMetric ? getString(R.string.long_unit1_detail_2)
                                                : getString(R.string.long_unit2_detail_2)));
                        break;
                    }
                }
            }
        });

        chartLayout.addView(mChartView);
    } else {
        setCorrectText();
    }
}

From source file:io.doist.datetimepicker.time.TimePickerClockDelegate.java

public TimePickerClockDelegate(TimePicker delegator, Context context, AttributeSet attrs, int defStyleAttr,
        int defStyleRes) {
    super(delegator, context);

    // process style attributes
    final TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.TimePicker, defStyleAttr,
            defStyleRes);/* ww  w .  j  a v  a2  s  .  co  m*/
    final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final Resources res = mContext.getResources();

    mSelectHours = res.getString(R.string.select_hours);
    mSelectMinutes = res.getString(R.string.select_minutes);

    String[] amPmStrings = DateTimeUtilsCompat.getBestAmPmStrings(mCurrentLocale);
    mAmText = amPmStrings[0];
    mPmText = amPmStrings[1];

    final int layoutResourceId = a.getResourceId(R.styleable.TimePicker_layout, R.layout.time_picker_holo);
    final View mainView = inflater.inflate(layoutResourceId, delegator);

    mHeaderView = mainView.findViewById(R.id.time_header);
    mHeaderView.setBackground(a.getDrawable(R.styleable.TimePicker_headerBackground));

    // Set up hour/minute labels.
    mHourView = (TextView) mHeaderView.findViewById(R.id.hours);
    mHourView.setOnClickListener(mClickListener);
    ViewCompat.setAccessibilityDelegate(mHourView, new ClickActionDelegate(context, R.string.select_hours));
    mSeparatorView = (TextView) mHeaderView.findViewById(R.id.separator);
    mMinuteView = (TextView) mHeaderView.findViewById(R.id.minutes);
    mMinuteView.setOnClickListener(mClickListener);
    ViewCompat.setAccessibilityDelegate(mMinuteView, new ClickActionDelegate(context, R.string.select_minutes));

    final int headerTimeTextAppearance = a.getResourceId(R.styleable.TimePicker_headerTimeTextAppearance, 0);
    if (headerTimeTextAppearance != 0) {
        mHourView.setTextAppearance(context, headerTimeTextAppearance);
        mSeparatorView.setTextAppearance(context, headerTimeTextAppearance);
        mMinuteView.setTextAppearance(context, headerTimeTextAppearance);
    }

    // Now that we have text appearances out of the way, make sure the hour
    // and minute views are correctly sized.
    mHourView.setMinWidth(computeStableWidth(mHourView, 24));
    mMinuteView.setMinWidth(computeStableWidth(mMinuteView, 60));

    // TODO: This can be removed once we support themed color state lists.
    final int headerSelectedTextColor = a.getColor(R.styleable.TimePicker_headerSelectedTextColor,
            res.getColor(R.color.timepicker_default_selector_color_material));
    mHourView.setTextColor(ViewStateUtils.addStateIfMissing(mHourView.getTextColors(),
            android.R.attr.state_selected, headerSelectedTextColor));
    mMinuteView.setTextColor(ViewStateUtils.addStateIfMissing(mMinuteView.getTextColors(),
            android.R.attr.state_selected, headerSelectedTextColor));

    // Set up AM/PM labels.
    // Set up AM/PM labels.
    mAmPmLayout = mHeaderView.findViewById(R.id.ampm_layout);
    mAmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.am_label);
    mAmLabel.setText(mAmText);
    mAmLabel.setOnClickListener(mClickListener);
    mPmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.pm_label);
    mPmLabel.setText(mPmText);
    mPmLabel.setOnClickListener(mClickListener);

    final int headerAmPmTextAppearance = a.getResourceId(R.styleable.TimePicker_headerAmPmTextAppearance, 0);
    if (headerAmPmTextAppearance != 0) {
        mAmLabel.setTextAppearance(context, headerAmPmTextAppearance);
        mPmLabel.setTextAppearance(context, headerAmPmTextAppearance);
    }

    a.recycle();

    // Pull disabled alpha from theme.
    final TypedValue outValue = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true);
    mDisabledAlpha = outValue.getFloat();

    mRadialTimePickerView = (RadialTimePickerView) mainView.findViewById(R.id.radial_picker);

    setupListeners();

    mAllowAutoAdvance = true;

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();

    // Initialize with current time
    final Calendar calendar = Calendar.getInstance(mCurrentLocale);
    final int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
    final int currentMinute = calendar.get(Calendar.MINUTE);
    initialize(currentHour, currentMinute, false /* 12h */, HOUR_INDEX);
}

From source file:com.github.cpmproto.categorystepfragment.base.GuidedStepListFragment.java

/**
 * {@inheritDoc}//from   w  w  w  . j  a  v  a  2s. c o m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG)
        Log.v(TAG, "onCreateView");

    resolveTheme();
    inflater = getThemeInflater(inflater);

    rootLayout = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment, container, false);

    rootLayout.setFocusOutStart(isFocusOutStartAllowed());
    rootLayout.setFocusOutEnd(isFocusOutEndAllowed());
    rootLayout.setBackgroundColor(Color.TRANSPARENT);
    rootLayout.setOnKeyPress(this);

    ViewGroup guidanceContainer = (ViewGroup) rootLayout.findViewById(R.id.content_fragment);
    guidanceContainer.setVisibility(View.INVISIBLE);

    ViewGroup actionContainer = (ViewGroup) rootLayout.findViewById(R.id.action_fragment);

    View actionsView = mActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(actionsView);

    View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(buttonActionsView);

    GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() {

        @Override
        public void onImeOpen() {
            runImeAnimations(true);
        }

        @Override
        public void onImeClose() {
            runImeAnimations(false);
        }

        @Override
        public long onGuidedActionEditedAndProceed(GuidedAction action) {
            return GuidedStepListFragment.this.onGuidedActionEditedAndProceed(action);
        }

        @Override
        public void onGuidedActionEditCanceled(GuidedAction action) {
            GuidedStepListFragment.this.onGuidedActionEditCanceled(action);
        }
    };

    mAdapter = new GuidedActionAdapter(getActionsByKey(), new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepListFragment.this.onGuidedActionClicked(action);
            if (isSubActionsExpanded()) {
                collapseSubActions();
            } else if (action.hasSubActions()) {
                expandSubActions(action);
            }
        }
    }, this, mActionsStylist, false);

    mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepListFragment.this.onGuidedActionClicked(action);
        }
    }, this, mButtonActionsStylist, false);

    mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            if (mActionsStylist.isInExpandTransition()) {
                return;
            }
            if (GuidedStepListFragment.this.onSubGuidedActionClicked(action)) {
                collapseSubActions();
            }
            rootLayout.setOnSubcategoryfocus(false);
            setActions(mActions, action.toString());
        }
    }, this, mActionsStylist, true);

    mAdapterGroup = new GuidedActionAdapterGroup();
    mAdapterGroup.addAdpter(mAdapter, mButtonAdapter);
    mAdapterGroup.addAdpter(mSubAdapter, null);
    mAdapterGroup.setEditListener(editListener);
    mActionsStylist.setEditListener(editListener);

    mActionsStylist.getActionsGridView().setAdapter(mAdapter);
    if (mActionsStylist.getSubActionsGridView() != null) {
        mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter);
    }
    mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter);
    if (mButtonActions.size() == 0) {
        // when there is no button actions, we don't need show the second panel, but keep
        // the width zero to run ChangeBounds transition.
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams();
        lp.weight = 0;
        buttonActionsView.setLayoutParams(lp);
    } else {
        // when there are two actions panel, we need adjust the weight of action to
        // guidedActionContentWidthWeightTwoPanels.
        Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity();
        TypedValue typedValue = new TypedValue();
        if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) {
            View actionsRoot = rootLayout.findViewById(R.id.action_fragment_root);
            float weight = typedValue.getFloat();
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams();
            lp.weight = weight;
            actionsRoot.setLayoutParams(lp);
        }
    }

    int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex
            : getFirstCheckedAction();
    setSelectedActionPosition(pos);
    setSelectedButtonActionPosition(0);

    return rootLayout;
}

From source file:fiskinfoo.no.sintef.fiskinfoo.MapFragment.java

private void createProximityAlertSetupDialog() {
    final Dialog dialog = dialogInterface.getDialog(getActivity(), R.layout.dialog_proximity_alert_create,
            R.string.create_proximity_alert);

    Button setProximityAlertWatcherButton = (Button) dialog
            .findViewById(R.id.create_proximity_alert_create_alert_watcher_button);
    Button stopCurrentProximityAlertWatcherButton = (Button) dialog
            .findViewById(R.id.create_proximity_alert_stop_existing_alert_button);
    Button cancelButton = (Button) dialog.findViewById(R.id.create_proximity_alert_cancel_button);
    SeekBar seekbar = (SeekBar) dialog.findViewById(R.id.create_proximity_alert_seekBar);
    final EditText radiusEditText = (EditText) dialog.findViewById(R.id.create_proximity_alert_range_edit_text);
    final Switch formatSwitch = (Switch) dialog.findViewById(R.id.create_proximity_alert_format_switch);

    final double seekBarStepSize = (double) (getResources()
            .getInteger(R.integer.proximity_alert_maximum_warning_range_meters)
            - getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters)) / 100;

    radiusEditText.setText(//from   w w  w  .j  a v  a  2  s  . c  o  m
            String.valueOf(getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters)));

    formatSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                buttonView.setText(getString(R.string.range_format_nautical_miles));
            } else {
                buttonView.setText(getString(R.string.range_format_meters));
            }
        }
    });

    seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                String range = String.valueOf(
                        (int) (getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters)
                                + (seekBarStepSize * progress)));
                radiusEditText.setText(range);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    setProximityAlertWatcherButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String toastText;

            if (proximityAlertWatcher == null) {
                toastText = getString(R.string.proximity_alert_set);
            } else {

                toastText = getString(R.string.proximity_alert_replace);
            }

            if (proximityAlertWatcher != null) {
                proximityAlertWatcher.cancel(true);
            }

            mGpsLocationTracker = new GpsLocationTracker(getActivity());
            double latitude, longitude;

            if (mGpsLocationTracker.canGetLocation()) {
                latitude = mGpsLocationTracker.getLatitude();
                cachedLat = latitude;
                longitude = mGpsLocationTracker.getLongitude();
                cachedLon = longitude;
            } else {
                mGpsLocationTracker.showSettingsAlert();
                return;
            }

            if (formatSwitch.isChecked()) {
                cachedDistance = Double.valueOf(radiusEditText.getText().toString())
                        * getResources().getInteger(R.integer.meters_per_nautical_mile);
            } else {
                cachedDistance = Double.valueOf(radiusEditText.getText().toString());
            }

            dialog.dismiss();

            Response response;

            try {
                String apiName = "fishingfacility";
                String format = "OLEX";
                String filePath;
                String fileName = "collisionCheckToolsFile";

                response = barentswatchApi.getApi().geoDataDownload(apiName, format);

                if (response == null) {
                    Log.d(TAG, "RESPONSE == NULL");
                    throw new InternalError();
                }

                if (fiskInfoUtility.isExternalStorageWritable()) {
                    String directoryPath = Environment
                            .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString();
                    String directoryName = "FiskInfo";
                    filePath = directoryPath + "/" + directoryName + "/";
                    InputStream zippedInputStream = null;

                    try {
                        TypedInput responseInput = response.getBody();
                        zippedInputStream = responseInput.in();
                        zippedInputStream = new GZIPInputStream(zippedInputStream);

                        InputSource inputSource = new InputSource(zippedInputStream);
                        InputStream input = new BufferedInputStream(inputSource.getByteStream());
                        byte data[];
                        data = FiskInfoUtility.toByteArray(input);

                        InputStream inputStream = new ByteArrayInputStream(data);
                        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
                        FiskInfoPolygon2D serializablePolygon2D = new FiskInfoPolygon2D();

                        String line;
                        boolean startSet = false;
                        String[] convertedLine;
                        List<Point> shape = new ArrayList<>();
                        while ((line = reader.readLine()) != null) {
                            Point currPoint = new Point();
                            if (line.length() == 0 || line.equals("")) {
                                continue;
                            }
                            if (Character.isLetter(line.charAt(0))) {
                                continue;
                            }

                            convertedLine = line.split("\\s+");

                            if (line.length() > 150) {
                                Log.d(TAG, "line " + line);
                            }

                            if (convertedLine[0].startsWith("3sl")) {
                                continue;
                            }

                            if (convertedLine[3].equalsIgnoreCase("Garnstart") && startSet) {
                                if (shape.size() == 1) {
                                    // Point

                                    serializablePolygon2D.addPoint(shape.get(0));
                                    shape = new ArrayList<>();
                                } else if (shape.size() == 2) {

                                    // line
                                    serializablePolygon2D.addLine(new Line(shape.get(0), shape.get(1)));
                                    shape = new ArrayList<>();
                                } else {

                                    serializablePolygon2D.addPolygon(new Polygon(shape));
                                    shape = new ArrayList<>();
                                }
                                startSet = false;
                            }

                            if (convertedLine[3].equalsIgnoreCase("Garnstart") && !startSet) {
                                double lat = Double.parseDouble(convertedLine[0]) / 60;
                                double lon = Double.parseDouble(convertedLine[1]) / 60;
                                currPoint.setNewPointValues(lat, lon);
                                shape.add(currPoint);
                                startSet = true;
                            } else if (convertedLine[3].equalsIgnoreCase("Brunsirkel")) {
                                double lat = Double.parseDouble(convertedLine[0]) / 60;
                                double lon = Double.parseDouble(convertedLine[1]) / 60;
                                currPoint.setNewPointValues(lat, lon);
                                shape.add(currPoint);
                            }
                        }

                        reader.close();
                        new FiskInfoUtility().serializeFiskInfoPolygon2D(filePath + fileName + "." + format,
                                serializablePolygon2D);

                        tools = serializablePolygon2D;

                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (ArrayIndexOutOfBoundsException e) {
                        Log.e(TAG, "Error when trying to serialize file.");
                        Toast error = Toast.makeText(getActivity(), "Ingen redskaper i omrdet du definerte",
                                Toast.LENGTH_LONG);
                        e.printStackTrace();
                        error.show();
                        return;
                    } finally {
                        try {
                            if (zippedInputStream != null) {
                                zippedInputStream.close();
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                } else {
                    Toast.makeText(v.getContext(), R.string.download_failed, Toast.LENGTH_LONG).show();
                    dialog.dismiss();
                    return;
                }

            } catch (Exception e) {
                Log.d(TAG, "Could not download tools file");
                Toast.makeText(getActivity(), R.string.download_failed, Toast.LENGTH_LONG).show();
            }

            runScheduledAlarm(getResources().getInteger(R.integer.zero),
                    getResources().getInteger(R.integer.proximity_alert_interval_time_seconds));

            Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
        }
    });

    if (proximityAlertWatcher != null) {
        TypedValue outValue = new TypedValue();
        stopCurrentProximityAlertWatcherButton.setVisibility(View.VISIBLE);

        getResources().getValue(R.dimen.proximity_alert_dialog_button_text_size_small, outValue, true);
        float textSize = outValue.getFloat();

        setProximityAlertWatcherButton.setTextSize(textSize);
        stopCurrentProximityAlertWatcherButton.setTextSize(textSize);
        cancelButton.setTextSize(textSize);

        stopCurrentProximityAlertWatcherButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                proximityAlertWatcher.cancel(true);
                proximityAlertWatcher = null;
                dialog.dismiss();
            }
        });
    }

    cancelButton.setOnClickListener(onClickListenerInterface.getDismissDialogListener(dialog));

    dialog.show();
}

From source file:com.appeaser.sublimepickerlibrary.timepicker.RadialTimePickerView.java

private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    Context context = getContext();

    // Pull disabled alpha from theme.
    final TypedValue outValue = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true);
    mDisabledAlpha = outValue.getFloat();

    // process style attributes
    final Resources res = getResources();
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RadialTimePickerView, defStyleAttr,
            defStyleRes);//from w w  w.j av  a2s. co  m

    mTypeface = Typeface.create("sans-serif", Typeface.NORMAL);

    // Initialize all alpha values to opaque.
    for (int i = 0; i < mAlpha.length; i++) {
        mAlpha[i] = new IntHolder(ALPHA_OPAQUE);
    }

    mTextColor[HOURS] = a.getColorStateList(R.styleable.RadialTimePickerView_spNumbersTextColor);
    mTextColor[HOURS_INNER] = a.getColorStateList(R.styleable.RadialTimePickerView_spNumbersInnerTextColor);
    mTextColor[MINUTES] = mTextColor[HOURS];

    mPaint[HOURS] = new Paint();
    mPaint[HOURS].setAntiAlias(true);
    mPaint[HOURS].setTextAlign(Paint.Align.CENTER);

    mPaint[MINUTES] = new Paint();
    mPaint[MINUTES].setAntiAlias(true);
    mPaint[MINUTES].setTextAlign(Paint.Align.CENTER);

    final ColorStateList selectorColors = a
            .getColorStateList(R.styleable.RadialTimePickerView_spNumbersSelectorColor);

    int selectorActivatedColor = Color.BLACK;
    if (selectorColors != null) {
        selectorActivatedColor = selectorColors
                .getColorForState(SUtils.resolveStateSet(SUtils.STATE_ENABLED | SUtils.STATE_ACTIVATED), 0);
    }

    mPaintCenter.setColor(selectorActivatedColor);
    mPaintCenter.setAntiAlias(true);

    final int[] activatedStateSet = SUtils.resolveStateSet(SUtils.STATE_ENABLED | SUtils.STATE_ACTIVATED);

    mSelectorColor = selectorActivatedColor;
    mSelectorDotColor = mTextColor[HOURS].getColorForState(activatedStateSet, 0);

    mPaintSelector[HOURS][SELECTOR_CIRCLE] = new Paint();
    mPaintSelector[HOURS][SELECTOR_CIRCLE].setAntiAlias(true);

    mPaintSelector[HOURS][SELECTOR_DOT] = new Paint();
    mPaintSelector[HOURS][SELECTOR_DOT].setAntiAlias(true);

    mPaintSelector[HOURS][SELECTOR_LINE] = new Paint();
    mPaintSelector[HOURS][SELECTOR_LINE].setAntiAlias(true);
    mPaintSelector[HOURS][SELECTOR_LINE].setStrokeWidth(2);

    mPaintSelector[MINUTES][SELECTOR_CIRCLE] = new Paint();
    mPaintSelector[MINUTES][SELECTOR_CIRCLE].setAntiAlias(true);

    mPaintSelector[MINUTES][SELECTOR_DOT] = new Paint();
    mPaintSelector[MINUTES][SELECTOR_DOT].setAntiAlias(true);

    mPaintSelector[MINUTES][SELECTOR_LINE] = new Paint();
    mPaintSelector[MINUTES][SELECTOR_LINE].setAntiAlias(true);
    mPaintSelector[MINUTES][SELECTOR_LINE].setStrokeWidth(2);

    mPaintBackground.setColor(a.getColor(R.styleable.RadialTimePickerView_spNumbersBackgroundColor,
            ContextCompat.getColor(context, R.color.timepicker_default_numbers_background_color_material)));
    mPaintBackground.setAntiAlias(true);

    mSelectorRadius = res.getDimensionPixelSize(R.dimen.sp_timepicker_selector_radius);
    mSelectorStroke = res.getDimensionPixelSize(R.dimen.sp_timepicker_selector_stroke);
    mSelectorDotRadius = res.getDimensionPixelSize(R.dimen.sp_timepicker_selector_dot_radius);
    mCenterDotRadius = res.getDimensionPixelSize(R.dimen.sp_timepicker_center_dot_radius);

    mTextSize[HOURS] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_size_normal);
    mTextSize[MINUTES] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_size_normal);
    mTextSize[HOURS_INNER] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_size_inner);

    mTextInset[HOURS] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_inset_normal);
    mTextInset[MINUTES] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_inset_normal);
    mTextInset[HOURS_INNER] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_inset_inner);

    mShowHours = true;
    mIs24HourMode = false;
    mAmOrPm = AM;

    // Set up accessibility components.
    mTouchHelper = new RadialPickerTouchHelper();
    ViewCompat.setAccessibilityDelegate(this, mTouchHelper);

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    initHoursAndMinutesText();
    initData();

    a.recycle();

    // Initial values
    final Calendar calendar = Calendar.getInstance(Locale.getDefault());
    final int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
    final int currentMinute = calendar.get(Calendar.MINUTE);

    setCurrentHourInternal(currentHour, false, false);
    setCurrentMinuteInternal(currentMinute, false);

    setHapticFeedbackEnabled(true);
}

From source file:com.klinker.android.sliding.MultiShrinkScroller.java

/**
 * Create a new instance of MultiShrinkScroller.
 * @param context//  w  ww.  j  av a 2s.  co m
 * @param attrs
 * @param defStyleAttr
 */
public MultiShrinkScroller(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    setFocusable(false);
    setWillNotDraw(false);

    edgeGlowBottom = new EdgeEffect(context);
    edgeGlowTop = new EdgeEffect(context);
    scroller = new Scroller(context, INTERPOLATOR);
    touchSlop = configuration.getScaledTouchSlop();
    minimumVelocity = configuration.getScaledMinimumFlingVelocity();
    maximumVelocity = configuration.getScaledMaximumFlingVelocity();
    transparentStartHeight = (int) getResources().getDimension(R.dimen.sliding_starting_empty_height);
    toolbarElevation = getResources().getDimension(R.dimen.sliding_toolbar_elevation);
    isTwoPanel = getResources().getBoolean(R.bool.sliding_two_panel);
    maximumTitleMargin = (int) getResources().getDimension(R.dimen.sliding_title_initial_margin);

    dismissDistanceOnScroll = (int) getResources().getDimension(R.dimen.sliding_dismiss_distance_on_scroll);
    dismissDistanceOnRelease = (int) getResources().getDimension(R.dimen.sliding_dismiss_distance_on_release);
    snapToTopSlopHeight = (int) getResources().getDimension(R.dimen.sliding_snap_to_top_slop_height);

    final TypedValue photoRatio = new TypedValue();
    getResources().getValue(R.dimen.sliding_landscape_photo_ratio, photoRatio, true);
    landscapePhotoRatio = photoRatio.getFloat();

    final TypedArray attributeArray = context
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    actionBarSize = attributeArray.getDimensionPixelSize(0, 0);
    minimumHeaderHeight = actionBarSize;
    attributeArray.recycle();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        textSizePathInterpolator = new PathInterpolator(X1, Y1, X2, Y2);
    } else {
        textSizePathInterpolator = null;
    }
}

From source file:com.tr4android.support.extension.picker.time.RadialTimePickerView.java

public RadialTimePickerView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs);

    // Pull disabled alpha from theme.
    final TypedValue outValue = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true);
    mDisabledAlpha = outValue.getFloat();

    // process style attributes
    final Resources res = getResources();
    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TimePickerDialog, defStyleAttr,
            defStyleRes);//from ww w  . j a  v  a  2  s.  c om

    mTypeface = Typeface.create("sans-serif", Typeface.NORMAL);

    // Initialize all alpha values to opaque.
    for (int i = 0; i < mAlpha.length; i++) {
        mAlpha[i] = new IntHolder(ALPHA_OPAQUE);
    }

    mTextColor[HOURS] = a.getColorStateList(R.styleable.TimePickerDialog_numbersTextColor);
    if (mTextColor[HOURS] == null) {
        mTextColor[HOURS] = PickerThemeUtils.getTextColorPrimaryActivatedStateList(context);
    }
    mTextColor[HOURS_INNER] = a.getColorStateList(R.styleable.TimePickerDialog_numbersInnerTextColor);
    if (mTextColor[HOURS_INNER] == null) {
        mTextColor[HOURS_INNER] = PickerThemeUtils.getTextColorSecondaryActivatedStateList(context);
    }
    mTextColor[MINUTES] = mTextColor[HOURS];

    mPaint[HOURS] = new Paint();
    mPaint[HOURS].setAntiAlias(true);
    mPaint[HOURS].setTextAlign(Paint.Align.CENTER);

    mPaint[MINUTES] = new Paint();
    mPaint[MINUTES].setAntiAlias(true);
    mPaint[MINUTES].setTextAlign(Paint.Align.CENTER);

    final int[] selectedStateSet = new int[] { android.R.attr.state_enabled, android.R.attr.state_selected };

    // Set up number selected color, if available.
    final ColorStateList numbersSelectorColor;
    if (a.hasValue(R.styleable.TimePickerDialog_numbersSelectorColor)) {
        numbersSelectorColor = a.getColorStateList(R.styleable.TimePickerDialog_numbersSelectorColor);
    } else {
        final TypedArray ta = context.obtainStyledAttributes(new int[] { R.attr.colorControlActivated });
        numbersSelectorColor = ta.getColorStateList(0);
        ta.recycle();
    }
    final int selectorActivatedColor = numbersSelectorColor.getColorForState(selectedStateSet, 0);

    mPaintCenter.setColor(selectorActivatedColor);
    mPaintCenter.setAntiAlias(true);

    mSelectorColor = selectorActivatedColor;
    mSelectorDotColor = mTextColor[HOURS].getColorForState(selectedStateSet, 0);

    mPaintSelector[HOURS][SELECTOR_CIRCLE] = new Paint();
    mPaintSelector[HOURS][SELECTOR_CIRCLE].setAntiAlias(true);

    mPaintSelector[HOURS][SELECTOR_DOT] = new Paint();
    mPaintSelector[HOURS][SELECTOR_DOT].setAntiAlias(true);

    mPaintSelector[HOURS][SELECTOR_LINE] = new Paint();
    mPaintSelector[HOURS][SELECTOR_LINE].setAntiAlias(true);
    mPaintSelector[HOURS][SELECTOR_LINE].setStrokeWidth(2);

    mPaintSelector[MINUTES][SELECTOR_CIRCLE] = new Paint();
    mPaintSelector[MINUTES][SELECTOR_CIRCLE].setAntiAlias(true);

    mPaintSelector[MINUTES][SELECTOR_DOT] = new Paint();
    mPaintSelector[MINUTES][SELECTOR_DOT].setAntiAlias(true);

    mPaintSelector[MINUTES][SELECTOR_LINE] = new Paint();
    mPaintSelector[MINUTES][SELECTOR_LINE].setAntiAlias(true);
    mPaintSelector[MINUTES][SELECTOR_LINE].setStrokeWidth(2);

    mPaintBackground.setColor(a.getColor(R.styleable.TimePickerDialog_numbersBackgroundColor,
            ContextCompat.getColor(context, android.R.color.transparent)));
    mPaintBackground.setAntiAlias(true);

    mSelectorRadius = res.getDimensionPixelSize(R.dimen.timepicker_selector_radius);
    mSelectorStroke = res.getDimensionPixelSize(R.dimen.timepicker_selector_stroke);
    mSelectorDotRadius = res.getDimensionPixelSize(R.dimen.timepicker_selector_dot_radius);
    mCenterDotRadius = res.getDimensionPixelSize(R.dimen.timepicker_center_dot_radius);

    mTextSize[HOURS] = res.getDimensionPixelSize(R.dimen.timepicker_text_size_normal);
    mTextSize[MINUTES] = res.getDimensionPixelSize(R.dimen.timepicker_text_size_normal);
    mTextSize[HOURS_INNER] = res.getDimensionPixelSize(R.dimen.timepicker_text_size_inner);

    mTextInset[HOURS] = res.getDimensionPixelSize(R.dimen.timepicker_text_inset_normal);
    mTextInset[MINUTES] = res.getDimensionPixelSize(R.dimen.timepicker_text_inset_normal);
    mTextInset[HOURS_INNER] = res.getDimensionPixelSize(R.dimen.timepicker_text_inset_inner);

    mShowHours = true;
    mIs24HourMode = false;
    mAmOrPm = AM;

    // Set up accessibility components.
    mTouchHelper = new RadialPickerTouchHelper();
    ViewCompat.setAccessibilityDelegate(this, mTouchHelper);

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    initHoursAndMinutesText();
    initData();

    a.recycle();

    // Initial values
    final Calendar calendar = Calendar.getInstance(Locale.getDefault());
    final int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
    final int currentMinute = calendar.get(Calendar.MINUTE);

    setCurrentHourInternal(currentHour, false, false);
    setCurrentMinuteInternal(currentMinute, false);

    setHapticFeedbackEnabled(true);
}