Example usage for android.graphics Color GRAY

List of usage examples for android.graphics Color GRAY

Introduction

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

Prototype

int GRAY

To view the source code for android.graphics Color GRAY.

Click Source Link

Usage

From source file:com.github.shareme.gwsdiscreteseekbar.library.DiscreteSeekBar.java

public DiscreteSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setFocusable(true);//from w  w  w. ja va2s  .c o  m
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;
    mTrackHeight = (int) (1 * density);
    mScrubberHeight = (int) (4 * density);
    int thumbSize = (int) (density * ThumbDrawable.DEFAULT_SIZE_DP);

    //Extra pixels for a touch area of 48dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = (touchBounds - thumbSize) / 2;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscreteSeekBar, defStyleAttr,
            R.style.Widget_DiscreteSeekBar);

    int max = 100;
    int min = 0;
    int value = 0;
    mMirrorForRtl = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_mirrorForRtl, mMirrorForRtl);
    mAllowTrackClick = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_allowTrackClickToDrag, mAllowTrackClick);
    mIndicatorPopupEnabled = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_indicatorPopupEnabled,
            mIndicatorPopupEnabled);
    int indexMax = R.styleable.DiscreteSeekBar_dsb_max;
    int indexMin = R.styleable.DiscreteSeekBar_dsb_min;
    int indexValue = R.styleable.DiscreteSeekBar_dsb_value;
    final TypedValue out = new TypedValue();
    //Not sure why, but we wanted to be able to use dimensions here...
    if (a.getValue(indexMax, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            max = a.getDimensionPixelSize(indexMax, max);
        } else {
            max = a.getInteger(indexMax, max);
        }
    }
    if (a.getValue(indexMin, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            min = a.getDimensionPixelSize(indexMin, min);
        } else {
            min = a.getInteger(indexMin, min);
        }
    }
    if (a.getValue(indexValue, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            value = a.getDimensionPixelSize(indexValue, value);
        } else {
            value = a.getInteger(indexValue, value);
        }
    }

    mMin = min;
    mMax = Math.max(min + 1, max);
    mValue = Math.max(min, Math.min(max, value));
    updateKeyboardRange();

    mIndicatorFormatter = a.getString(R.styleable.DiscreteSeekBar_dsb_indicatorFormatter);

    ColorStateList trackColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_trackColor);
    ColorStateList progressColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_progressColor);
    ColorStateList rippleColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_rippleColor);
    boolean editMode = isInEditMode();
    if (editMode || rippleColor == null) {
        rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY });
    }
    if (editMode || trackColor == null) {
        trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY });
    }
    if (editMode || progressColor == null) {
        progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { DEFAULT_THUMB_COLOR });
    }
    mRipple = SeekBarCompat.getRipple(rippleColor);
    if (isLollipopOrGreater) {
        SeekBarCompat.setBackground(this, mRipple);
    } else {
        mRipple.setCallback(this);
    }

    TrackRectDrawable shapeDrawable = new TrackRectDrawable(trackColor);
    mTrack = shapeDrawable;
    mTrack.setCallback(this);

    shapeDrawable = new TrackRectDrawable(progressColor);
    mScrubber = shapeDrawable;
    mScrubber.setCallback(this);

    mThumb = new ThumbDrawable(progressColor, thumbSize);
    mThumb.setCallback(this);
    mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight());

    if (!editMode) {
        mIndicator = new PopupIndicator(context, attrs, defStyleAttr, convertValueToMessage(mMax));
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

}

From source file:de.uni_weimar.mheinz.androidtouchscope.display.ScopeView.java

private void init() {
    int paddingLeft = getPaddingLeft();
    int paddingTop = getPaddingTop();
    int paddingRight = getPaddingRight();
    int paddingBottom = getPaddingBottom();

    mContentWidth = getWidth() - paddingLeft - paddingRight;
    mContentHeight = getHeight() - paddingTop - paddingBottom;
    mContentCenterY = mContentHeight / 2.0;
    mContentCenterX = mContentWidth / 2.0;
    mTextPos = new Point(5, mContentHeight - 5);

    initDrawable(mDrawableChan1, mPathChan1, HostView.CHAN1_COLOR, mContentWidth, mContentHeight);
    initDrawable(mDrawableChan2, mPathChan2, HostView.CHAN2_COLOR, mContentWidth, mContentHeight);
    initGridH(mDrawableGridH, mPathGridH, Color.GRAY, mContentWidth, mContentHeight);
    initGridV(mDrawableGridV, mPathGridV, Color.GRAY, mContentWidth, mContentHeight);
    initText(mChan1TextPaint, 15, HostView.CHAN1_COLOR, Paint.Align.LEFT);
    initText(mChan2TextPaint, 15, HostView.CHAN2_COLOR, Paint.Align.LEFT);
    initText(mTimeTextPaint, 15, Color.WHITE, Paint.Align.RIGHT);
    initText(mTimeOffsetTextPaint, 15, HostView.TRIGGER_COLOR, Paint.Align.RIGHT);
    initText(mTriggerTextPaint, 15, HostView.TRIGGER_COLOR, Paint.Align.RIGHT);
    initText(mCursorTextPaint, 15, Color.GREEN, Paint.Align.LEFT);

    for (CursorView cursorView : mCursorArray.values()) {
        cursorView.layout(0, 0, mContentWidth, mContentHeight);
        cursorView.update();/*from  w  ww .  ja va  2s  .  c  o m*/
    }
}

From source file:com.progym.custom.fragments.FoodProgressYearlyLineFragment.java

public void setYearProgressData(final Date date, final boolean isLeftIn) {

    final ProgressDialog ringProgressDialog = ProgressDialog.show(getActivity(),
            getResources().getString(R.string.please_wait), getResources().getString(R.string.populating_data),
            true);//  w w w.j a  v  a2  s  . c  o  m
    ringProgressDialog.setCancelable(true);
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                int yMaxAxisValue = 0;

                getActivity().runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            rlRootGraphLayout.removeView(viewChart);
                        } catch (Exception edsx) {
                            edsx.printStackTrace();
                        }

                    }
                });

                DATE = date;
                // Get amount of days in a month to find out average
                int daysInMonth = Utils.getDaysInMonth(date.getMonth(),
                        Integer.valueOf(Utils.formatDate(date, DataBaseUtils.DATE_PATTERN_YYYY)));
                // set January as first month
                date.setMonth(0);
                date.setDate(1);

                int[] x = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };

                final XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
                CategorySeries seriesProtein = new CategorySeries("Protein");
                CategorySeries seriesFat = new CategorySeries("Fat");
                CategorySeries seriesCarbs = new CategorySeries("Carbs");

                List<Ingridient> list;
                Date dt = date;
                for (int element : x) {
                    list = DataBaseUtils.getAllFoodConsumedInMonth(
                            Utils.formatDate(dt, DataBaseUtils.DATE_PATTERN_YYYY_MM));

                    // init "average" data
                    double totalProtein = 0, totalFat = 0, totalCarbs = 0, totalCallories = 0;
                    for (Ingridient ingridient : list) {
                        totalProtein += ingridient.protein;
                        totalFat += ingridient.fat;
                        totalCarbs += ingridient.carbohydrates;
                        totalCallories += ingridient.kkal;
                    }

                    seriesProtein.add((double) Math.round(totalProtein * 100) / 100);
                    seriesFat.add((double) Math.round(totalFat * 100) / 100);
                    seriesCarbs.add((double) Math.round(totalCarbs * 100) / 100);

                    // calculate maximum Y axis values
                    yMaxAxisValue = Math.max(yMaxAxisValue, (int) totalProtein);
                    yMaxAxisValue = Math.max(yMaxAxisValue, (int) totalFat);
                    yMaxAxisValue = Math.max(yMaxAxisValue, (int) totalCarbs);

                    // increment month
                    dt = DateUtils.addMonths(dt, 1);
                }

                int[] colors = new int[] { getActivity().getResources().getColor(R.color.green),
                        getActivity().getResources().getColor(R.color.orange),
                        getActivity().getResources().getColor(R.color.purple) };
                final XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
                setChartSettings(renderer,
                        String.format("Protein/Carbohydrates/Fat statistic for %s year",
                                Utils.getSpecificDateValue(DATE, "yyyy")),
                        "Months", "Amount (g)           ", 0.7, 12.3, 0, yMaxAxisValue + 30, Color.GRAY,
                        Color.LTGRAY);

                renderer.getSeriesRendererAt(0).setDisplayChartValues(true);
                renderer.getSeriesRendererAt(1).setDisplayChartValues(true);
                renderer.getSeriesRendererAt(2).setDisplayChartValues(true);

                renderer.getSeriesRendererAt(0).setChartValuesTextSize(15f);
                renderer.getSeriesRendererAt(1).setChartValuesTextSize(15f);
                renderer.getSeriesRendererAt(2).setChartValuesTextSize(15f);

                // renderer.getSeriesRendererAt(0).setChartValuesTextAlign(Align.CENTER);
                // renderer.getSeriesRendererAt(1).setChartValuesTextAlign(Align.LEFT);
                // renderer.getSeriesRendererAt(2).setChartValuesTextAlign(Align.RIGHT);

                renderer.setXLabels(0);
                // renderer.setYLabels(10);
                // renderer.setXLabelsAlign(Align.LEFT);
                // renderer.setYLabelsAlign(Align.LEFT);
                // renderer.setPanEnabled(true, false);
                renderer.setClickEnabled(false);
                renderer.setZoomEnabled(false);
                renderer.setPanEnabled(false, false);
                renderer.setZoomButtonsVisible(false);
                renderer.setPanLimits(new double[] { 1, 11 });
                // renderer.setZoomEnabled(false);
                // renderer.setZoomRate(1.1f);
                renderer.setShowGrid(true);
                renderer.setShowLegend(true);
                renderer.setFitLegend(true);

                for (int i = 0; i < ActivityWaterProgress.months_short.length; i++) {
                    renderer.addXTextLabel(i + 1, ActivityWaterProgress.months_short[i]);

                }

                dataset.addSeries(seriesProtein.toXYSeries());
                dataset.addSeries(seriesFat.toXYSeries());
                dataset.addSeries(seriesCarbs.toXYSeries());

                getActivity().runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            viewChart = ChartFactory.getLineChartView(getActivity(), dataset,
                                    renderer/* , Type.STACKED */);
                            rlRootGraphLayout.addView(viewChart, 0);
                            if (isLeftIn) {
                                rightIn.setDuration(1000);
                                viewChart.startAnimation(rightIn);
                            } else {
                                leftIn.setDuration(1000);
                                viewChart.startAnimation(leftIn);
                            }
                        } catch (Exception edsx) {
                            edsx.printStackTrace();
                        }

                    }
                });

            } catch (Exception e) {
                e.printStackTrace();
            }
            ringProgressDialog.dismiss();
        }
    }).start();

}

From source file:com.battlelancer.seriesguide.ui.ShowFragment.java

private void populateShow() {
    if (mShowCursor == null) {
        return;//w w  w.ja va2s. co  m
    }

    // title
    mShowTitle = mShowCursor.getString(ShowQuery.TITLE);
    mShowPoster = mShowCursor.getString(ShowQuery.POSTER);

    // status
    if (mShowCursor.getInt(ShowQuery.STATUS) == 1) {
        mTextViewStatus.setTextColor(getResources().getColor(
                Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.textColorSgGreen)));
        mTextViewStatus.setText(getString(R.string.show_isalive));
    } else {
        mTextViewStatus.setTextColor(Color.GRAY);
        mTextViewStatus.setText(getString(R.string.show_isnotalive));
    }

    // release time
    String releaseDay = mShowCursor.getString(ShowQuery.RELEASE_DAY);
    long releaseTime = mShowCursor.getLong(ShowQuery.RELEASE_TIME_MS);
    String releaseCountry = mShowCursor.getString(ShowQuery.RELEASE_COUNTRY);
    if (!TextUtils.isEmpty(releaseDay)) {
        String[] values = TimeTools.formatToShowReleaseTimeAndDay(getActivity(), releaseTime, releaseCountry,
                releaseDay);
        mTextViewReleaseTime.setText(values[1] + " " + values[0]);
    } else {
        mTextViewReleaseTime.setText(null);
    }

    // runtime
    mTextViewRuntime.setText(getString(R.string.runtime_minutes, mShowCursor.getInt(ShowQuery.RUNTIME)));

    // network
    mTextViewNetwork.setText(mShowCursor.getString(ShowQuery.NETWORK));

    // favorite button
    final boolean isFavorite = mShowCursor.getInt(ShowQuery.IS_FAVORITE) == 1;
    mButtonFavorite.setEnabled(true);
    Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mButtonFavorite, 0,
            Utils.resolveAttributeToResourceId(getActivity().getTheme(),
                    isFavorite ? R.attr.drawableStar : R.attr.drawableStar0),
            0, 0);
    mButtonFavorite.setText(isFavorite ? R.string.context_unfavorite : R.string.context_favorite);
    CheatSheet.setup(mButtonFavorite, isFavorite ? R.string.context_unfavorite : R.string.context_favorite);
    mButtonFavorite.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // disable until action is complete
            v.setEnabled(false);
            ShowTools.get(v.getContext()).storeIsFavorite(getShowTvdbId(), !isFavorite);
        }
    });

    // overview
    mTextViewOverview.setText(mShowCursor.getString(ShowQuery.OVERVIEW));

    // country for release time calculation
    // show "unknown" if country is not supported
    mTextViewReleaseCountry.setText(
            TimeTools.isUnsupportedCountry(releaseCountry) ? getString(R.string.unknown) : releaseCountry);

    // original release
    String firstRelease = mShowCursor.getString(ShowQuery.FIRST_RELEASE);
    Utils.setValueOrPlaceholder(mTextViewFirstRelease,
            TimeTools.getShowReleaseYear(firstRelease, releaseTime, releaseCountry));

    // content rating
    Utils.setValueOrPlaceholder(mTextViewContentRating, mShowCursor.getString(ShowQuery.CONTENT_RATING));
    // genres
    Utils.setValueOrPlaceholder(mTextViewGenres,
            Utils.splitAndKitTVDBStrings(mShowCursor.getString(ShowQuery.GENRES)));

    // TVDb rating
    String tvdbRating = mShowCursor.getString(ShowQuery.TVDB_RATING);
    if (!TextUtils.isEmpty(tvdbRating)) {
        mTextViewTvdbRating.setText(tvdbRating);
    }

    // last edit
    long lastEditRaw = mShowCursor.getLong(ShowQuery.LAST_EDIT_MS);
    if (lastEditRaw > 0) {
        mTextViewLastEdit.setText(DateUtils.formatDateTime(getActivity(), lastEditRaw * 1000,
                DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME));
    } else {
        mTextViewLastEdit.setText(R.string.unknown);
    }

    // IMDb button
    String imdbId = mShowCursor.getString(ShowQuery.IMDBID);
    ServiceUtils.setUpImdbButton(imdbId, mButtonImdb, TAG, getActivity());

    // TVDb button
    ServiceUtils.setUpTvdbButton(getShowTvdbId(), mButtonTvdb, TAG);

    // trakt button
    ServiceUtils.setUpTraktButton(getShowTvdbId(), mButtonTrakt, TAG);

    // web search button
    ServiceUtils.setUpWebSearchButton(mShowTitle, mButtonWebSearch, TAG);

    // shout button
    mButtonComments.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getActivity(), TraktShoutsActivity.class);
            i.putExtras(TraktShoutsActivity.createInitBundleShow(mShowTitle, getShowTvdbId()));
            ActivityCompat.startActivity(getActivity(), i, ActivityOptionsCompat
                    .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle());
            fireTrackerEvent("Shouts");
        }
    });

    // poster, full screen poster button
    final View posterContainer = getView().findViewById(R.id.containerShowPoster);
    final ImageView posterView = (ImageView) posterContainer.findViewById(R.id.imageViewShowPoster);
    Utils.loadPoster(getActivity(), posterView, mShowPoster);
    posterContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent fullscreen = new Intent(getActivity(), FullscreenImageActivity.class);
            fullscreen.putExtra(FullscreenImageActivity.InitBundle.IMAGE_PATH,
                    TheTVDB.buildScreenshotUrl(mShowPoster));
            ActivityCompat.startActivity(getActivity(), fullscreen, ActivityOptionsCompat
                    .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle());
        }
    });

    // background
    ImageView background = (ImageView) getView().findViewById(R.id.imageViewShowPosterBackground);
    Utils.loadPosterBackground(getActivity(), background, mShowPoster);

    onLoadTraktRatings(true);
}

From source file:uk.org.crimetalk.fragments.ArticleListFragment.java

@Override
public void onLoadFinished(Loader<List<ArticleListItem>> loader, List<ArticleListItem> data) {

    this.setListAdapter(mArticleListAdapter);

    // The Loader returned no results
    if (data.size() == 0) {

        // The device has Internet so something strange happened
        if (InternetUtils.hasInternet(getActivity())) {

            this.setEmptyText(getResources().getString(R.string.internet_error));
            ((TextView) this.getListView().getEmptyView()).setTextColor(Color.GRAY);
            ((TextView) this.getListView().getEmptyView()).setTextSize(22);

            // The device has no Internet so remind the user
        } else {/*from ww w.ja v a  2  s  .co  m*/

            this.setEmptyText(getResources().getString(R.string.internet_none));
            ((TextView) this.getListView().getEmptyView()).setTextColor(Color.GRAY);
            ((TextView) this.getListView().getEmptyView()).setTextSize(22);

        }

        // The Loader returned results
    } else {

        this.mArticleListAdapter.setData(data);

    }

    // Load is finished, stop refreshing
    mSwipeRefreshLayout.setRefreshing(false);

}

From source file:com.ezio.multiwii.Main.PadMainMultiWiiActivity.java

void updateDashboard1() {

    if (PRVp == null) {
        PRVp = (PitchRollView) findViewById(R.id.PRVp);
        PRVp.SetColor(Color.GREEN);

        PRVr = (PitchRollView) findViewById(R.id.PRVr);
        PRVr.SetColor(Color.GREEN);

        pitchRollCircle = (PitchRollCircleView) findViewById(R.id.PitchRollCircle);
        pitchRollCircle.SetColor(Color.GREEN);

        compass = (CompassView) findViewById(R.id.Mag);
        compass.SetColor(Color.GREEN, Color.YELLOW);

        myCompass = (CompassView) findViewById(R.id.CompassView02);
        myCompass.SetColor(Color.GRAY, Color.LTGRAY);
        myCompass.SetText("N");

        baro = (TextView) findViewById(R.id.textViewBaro);
        BattVoltageTV = (TextView) findViewById(R.id.TextViewBattVoltage);
        PowerSumTV = (TextView) findViewById(R.id.TextViewPowerSum);
    }/*ww  w.  j  ava 2s .  c o  m*/

    myAzimuth = (float) (app.sensors.Heading);
    if (app.D) {
        app.mw.angy = app.sensors.Pitch;
        app.mw.angx = app.sensors.Roll;
    }

    PRVp.SetAngle(app.mw.angy);
    PRVr.SetAngle(app.mw.angx);

    pitchRollCircle.SetRollPitch(app.mw.angx, app.mw.angy);

    if (app.MagMode == 1) {
        compass.SetHeading(-app.mw.head);
        compass.SetText("");

    } else {
        compass.SetHeading(myAzimuth - app.mw.head);
        compass.SetText("FRONT");
    }

    myCompass.SetHeading(myAzimuth);

    baro.setText(String.format("%.2f", app.mw.alt));
    BattVoltageTV.setText(String.valueOf((float) (app.mw.bytevbat / 10.0)));
    PowerSumTV.setText(String.valueOf(app.mw.pMeterSum));
}

From source file:at.flack.MailMainActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    prefs = getActivity().getSharedPreferences("mail", Context.MODE_PRIVATE);
    if (!prefs.getString("mailaddress", "").equals("")) {
        View rootView = inflater.inflate(R.layout.fragment_mail_main, container, false);

        loadmore = new LoadMoreAdapter(inflater.inflate(R.layout.contacts_loadmore, contactList, false));
        contactList = (ListView) rootView.findViewById(R.id.listview);
        TextView padding = new TextView(getActivity());
        padding.setHeight(10);/*from ww  w  . j  a va2s  .  c  om*/
        contactList.addHeaderView(padding);
        contactList.setHeaderDividersEnabled(false);
        contactList.addFooterView(loadmore.getView(), null, false);
        contactList.setFooterDividersEnabled(false);
        progressbar = rootView.findViewById(R.id.load_screen);
        FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
        fab.attachToListView(contactList);
        fab.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent newMail = new Intent(getActivity(), NewMailActivity.class);
                getActivity().startActivity(newMail);
            }
        });

        progressbar = rootView.findViewById(R.id.load_screen);
        if (MainActivity.getMailcontacts() == null)
            progressbar.setVisibility(View.VISIBLE);
        updateContactList(((MainActivity) this.getActivity()));

        swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
        swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                if (getActivity() instanceof MainActivity) {
                    MainActivity.mailprofile = null;
                    ((MainActivity) getActivity()).emailLogin(1, 0, limit);
                }

            }
        });
        contactList.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                int topRowVerticalPosition = (contactList == null || contactList.getChildCount() == 0) ? 0
                        : contactList.getChildAt(0).getTop();
                swipe.setEnabled(topRowVerticalPosition >= 0);
            }
        });

        contactList.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                if (MainActivity.getListItems() == null) {
                    updateContactList((MainActivity) getActivity());
                }
                openMessageActivity(getActivity(), arg2 - 1);
            }

        });

        loadmore.getView().setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                loadmore.setEnabled(false);
                MainActivity.mailprofile = null;
                limit += 12;
                ((MainActivity) getActivity()).emailLogin(1, 0, limit);
            }
        });

        setRetainInstance(true);
        return rootView;
    } else {
        View rootView = inflater.inflate(R.layout.fragment_email_login, container, false);
        final EditText mail = (EditText) rootView.findViewById(R.id.email);
        final EditText password = (EditText) rootView.findViewById(R.id.password);

        final EditText host = (EditText) rootView.findViewById(R.id.host);
        final EditText port = (EditText) rootView.findViewById(R.id.port);
        final EditText smtphost = (EditText) rootView.findViewById(R.id.smtphost);
        final EditText smtpport = (EditText) rootView.findViewById(R.id.smtpport);

        final Button login_button = (Button) rootView.findViewById(R.id.login_button);

        final RadioGroup radioGroup = (RadioGroup) rootView.findViewById(R.id.radioGroup);
        final RadioButton imap = (RadioButton) rootView.findViewById(R.id.radioButtonImap);

        radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                host.setVisibility(View.VISIBLE);
                port.setVisibility(View.VISIBLE);
                smtphost.setVisibility(View.VISIBLE);
                smtpport.setVisibility(View.VISIBLE);
            }
        });

        login_button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                int at = mail.getText().toString().indexOf("@");
                int dot = mail.getText().toString().lastIndexOf(".");
                if (mail.getText().length() <= 0 || at < 0 || dot < 0) {
                    Toast.makeText(MailMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_please_enter_valid_mail),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
                if (password.getText().length() <= 0) {
                    Toast.makeText(MailMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_please_enter_valid_pw),
                            Toast.LENGTH_SHORT).show();
                    return;
                }

                String hostPart = mail.getText().toString().substring(at + 1, dot);

                MailAccounts mailacc = null;
                try {
                    mailacc = MailAccounts.valueOf(hostPart.toUpperCase(Locale.GERMAN));
                } catch (IllegalArgumentException e) {
                }
                if (mailacc == null) {
                    radioGroup.setVisibility(View.VISIBLE);
                    if (host.getText().toString().isEmpty() || port.getText().toString().isEmpty()
                            || smtphost.getText().toString().isEmpty()
                            || smtpport.getText().toString().isEmpty()) {
                        Toast.makeText(MailMainActivity.this.getActivity(),
                                MailMainActivity.this.getActivity().getResources().getString(
                                        R.string.activity_mail_enter_more_information),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                    prefs.edit().putString("mailsmtp", smtphost.getText().toString()).apply();
                    prefs.edit().putInt("mailsmtpport", Integer.parseInt(smtpport.getText().toString()));
                    prefs.edit().putString("mailimap", host.getText().toString()).apply();
                    prefs.edit().putInt("mailimapport", Integer.parseInt(port.getText().toString())).apply();
                    prefs.edit().putBoolean("mailuseimap", imap.isChecked()).apply();
                }

                login_button.setEnabled(false);
                login_button.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
                prefs.edit().putString("mailaddress", mail.getText().toString()).apply();
                prefs.edit().putString("mailpassword", password.getText().toString()).apply();

                if (mailacc != null) {
                    prefs.edit().putString("mailsmtp", mailacc.getSmtpHost()).apply();
                    prefs.edit().putInt("mailsmtpport", mailacc.getSMTPPort());
                    prefs.edit().putString("mailimap", mailacc.getHost()).apply();
                    prefs.edit().putInt("mailimapport", mailacc.getPort()).apply();
                    prefs.edit().putBoolean("mailuseimap", true).apply();
                }

                prefs.edit().commit();
                ((MainActivity) getActivity()).emailLogin(0);
            }
        });

        setRetainInstance(true);

        return rootView;
    }
}

From source file:bluetoothchat.BluetoothChatFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    statusTextView = (TextView) view.findViewById(R.id.bluetoothStatus);
    imageGive = (ImageView) view.findViewById(R.id.imageViewGive);
    imageReceive = (ImageView) view.findViewById(R.id.imageView2);
    btnAccept = (Button) view.findViewById(R.id.imageButton);
    btnDecline = (Button) view.findViewById(R.id.imageButton2);
    rl = (RelativeLayout) view.findViewById(R.id.rlBlth);

    btnEnableSwap = (Button) view.findViewById(R.id.enableSwap);
    if (mBluetoothAdapter.isEnabled())
        btnEnableSwap.setText("Connect a device");

    btnEnableSwap.setOnClickListener(new View.OnClickListener() {
        @Override// w ww  .  j a v a 2 s .c o m
        public void onClick(View view) {
            //enable bluetooth if not enabled
            if (!mBluetoothAdapter.isEnabled()) {
                EnableBluetooth();
            } else {
                // Launch the DeviceListActivity to see devices and do scan
                Intent serverIntent = new Intent(getActivity(), DeviceListActivity.class);
                startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_SECURE);
            }
        }
    });

    btnAccept.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Iaccepted = true;
            imageGive.buildDrawingCache();
            imageGive.setImageBitmap(bitmapOverlay(imageGive.getDrawingCache()));
            sendMessage(toJSon("accept", null, true));
            //if both accepted change the sticker status
            if (otherAccepted) {
                changeStickerdbStatus(stickerNameRecieve, false);
                changeStickerdbStatus(stickerNameGive, true);
                resultGUI("The stickers were successfully swapped", true);
                notifyActivityStickerStatusChange.notifyChange();
                new setUpListStickers().execute("");
                setupCustomView();
                updateSwapCount();
            }

        }
    });

    btnDecline.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            resultGUI("The stickers were not swapped, Transaction was cancelled", false);
            sendMessage(toJSon("accept", null, false));

        }
    });

    rl.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (mChatService == null)
                Toast.makeText(getActivity(), "Connect to a device first", Toast.LENGTH_LONG).show();

        }
    });

    btnAccept.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN);
    btnDecline.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN);

    // if(! mBluetoothAdapter.isEnabled())
    btnAccept.setVisibility(View.INVISIBLE);
    btnDecline.setVisibility(View.INVISIBLE);

    if (rl == null)
        android.util.Log.d("HEREEEE", "IT IS NUULLL");
    else {
        android.util.Log.d("HEREEEE", " not null");
    }
    view.findViewById(R.id.imageViewGive).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mChatService != null && connectionLost == false) {
                if (!otherAccepted && (!Iaccepted || otherAccepted)) {
                    if (list.size() != 0) {
                        setupCustomView();
                        mSweetSheet3.toggle();
                        //nasty hack to bring the buttons to the background
                        //otherwise they go on top of the sweetSheet
                        if (mSweetSheet3.isShow()) {
                            if (btnAccept.isEnabled()) {
                                isHideAccept = true;
                                btnAccept.setEnabled(false);
                            }
                            if (btnDecline.isEnabled()) {
                                isHideDecline = true;
                                btnDecline.setEnabled(false);
                            }
                        } else {
                            if (isHideAccept) {
                                isHideAccept = false;
                                btnAccept.setEnabled(true);
                            }
                            if (isHideDecline) {
                                isHideDecline = false;
                                btnDecline.setEnabled(true);

                            }
                        }

                    } else {
                        Toast.makeText(getActivity(), "You don't have any stickers to swap", Toast.LENGTH_LONG)
                                .show();
                    }

                }
            } else {
                Toast.makeText(getActivity(), "Connect to a device first", Toast.LENGTH_LONG).show();
            }
        }

        ;
    });
}

From source file:com.flashgugu.library.widgets.paginationseekbar.PaginationSeekBar.java

public PaginationSeekBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFocusable(true);//from  w  w  w.j  a  v a  2  s . com
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;
    mTrackHeight = (int) (1 * density);
    mScrubberHeight = (int) (4 * density);
    int thumbSize = (int) (density * ThumbDrawable.DEFAULT_SIZE_DP);

    //Extra pixels for a touch area of 48dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = (touchBounds - thumbSize) / 2;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PaginationSeekBar,
            R.attr.paginationSeekBarStyle, defStyle);

    int max = 100;
    int min = 0;
    int value = 1;
    mMirrorForRtl = a.getBoolean(R.styleable.PaginationSeekBar_psb_mirrorForRtl, mMirrorForRtl);
    mAllowTrackClick = a.getBoolean(R.styleable.PaginationSeekBar_psb_allowTrackClickToDrag, mAllowTrackClick);

    int indexMax = R.styleable.PaginationSeekBar_psb_max;
    int indexMin = R.styleable.PaginationSeekBar_psb_min;
    int indexValue = R.styleable.PaginationSeekBar_psb_value;
    pageCountPerOneBoard = R.styleable.PaginationSeekBar_psb_pageCountPerOneBoard;
    final TypedValue out = new TypedValue();
    //Not sure why, but we wanted to be able to use dimensions here...
    if (a.getValue(indexMax, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            max = a.getDimensionPixelSize(indexMax, max);
        } else {
            max = a.getInteger(indexMax, max);
        }
    }
    if (a.getValue(indexMin, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            min = a.getDimensionPixelSize(indexMin, min);
        } else {
            min = a.getInteger(indexMin, min);
        }
    }
    if (a.getValue(indexValue, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            value = a.getDimensionPixelSize(indexValue, value);
        } else {
            value = a.getInteger(indexValue, value);
        }
    }
    if (a.getValue(pageCountPerOneBoard, out)) {
        pageCountPerOneBoard = a.getInteger(pageCountPerOneBoard, pageCountPerOneBoard);
    }
    mMin = min;
    mMax = Math.max(min + 1, max);
    mValue = Math.max(min, Math.min(max, value));
    updateKeyboardRange();

    mIndicatorFormatter = a.getString(R.styleable.PaginationSeekBar_psb_indicatorFormatter);

    ColorStateList trackColor = a.getColorStateList(R.styleable.PaginationSeekBar_psb_trackColor);
    ColorStateList progressColor = a.getColorStateList(R.styleable.PaginationSeekBar_psb_progressColor);
    ColorStateList rippleColor = a.getColorStateList(R.styleable.PaginationSeekBar_psb_rippleColor);
    int thumbTextColor = a.getColor(R.styleable.PaginationSeekBar_psb_thumbTextColor, Color.WHITE);
    boolean editMode = isInEditMode();
    if (editMode && rippleColor == null) {
        rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY });
    }
    if (editMode && trackColor == null) {
        trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY });
    }
    if (editMode && progressColor == null) {
        progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { 0xff009688 });
    }
    if (editMode && thumbTextColor == 0) {
        thumbTextColor = Color.WHITE;
    }
    mRipple = SeekBarCompat.getRipple(rippleColor);
    if (isLollipopOrGreater) {
        SeekBarCompat.setBackground(this, mRipple);
    } else {
        mRipple.setCallback(this);
    }

    TrackRectDrawable shapeDrawable = new TrackRectDrawable(trackColor);
    mTrack = shapeDrawable;
    mTrack.setCallback(this);

    shapeDrawable = new TrackRectDrawable(progressColor);
    mScrubber = shapeDrawable;
    mScrubber.setCallback(this);

    ThumbDrawable thumbDrawable = new ThumbDrawable(progressColor, thumbTextColor, thumbSize, mValue);
    mThumb = thumbDrawable;
    mThumb.setCallback(this);
    mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight());

    if (!editMode) {
        mIndicator = new PopupIndicator(context, attrs, defStyle, convertValueToMessage(mMax));
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

    initPagecountPerOneboard(pageCountPerOneBoard);

}

From source file:com.mightyworkouts.seekbar.DiscreteSeekBar.java

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

    MightyWorkoutHelper.printLog(CommonUtils.WARN, this.getClass().getName(), "CONSTRUCTOR DiscreteSeekBar");
    setFocusable(true);//from  w w w. j  av  a 2s . c o m

    setWillNotDraw(false);

    /*bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.green_slider_thumb)
        .copy(Bitmap.Config.ARGB_8888, true);*/

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;
    mTrackHeight = (int) (4 * density);
    mScrubberHeight = (int) (4 * density);
    int thumbSize = (int) (density * ThumbDrawable.DEFAULT_SIZE_DP);

    //Extra pixels for a touch area of 48dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = (touchBounds - thumbSize) / 2;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscreteSeekBar, defStyleAttr,
            R.style.Widget_DiscreteSeekBar);

    int max = 100;
    int min = 0;
    int value = 0;
    mMirrorForRtl = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_mirrorForRtl, mMirrorForRtl);
    mAllowTrackClick = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_allowTrackClickToDrag, mAllowTrackClick);
    mIndicatorPopupEnabled = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_indicatorPopupEnabled,
            mIndicatorPopupEnabled);
    int indexMax = R.styleable.DiscreteSeekBar_dsb_max;
    int indexMin = R.styleable.DiscreteSeekBar_dsb_min;
    int indexValue = R.styleable.DiscreteSeekBar_dsb_value;
    final TypedValue out = new TypedValue();
    //Not sure why, but we wanted to be able to use dimensions here...
    if (a.getValue(indexMax, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            max = a.getDimensionPixelSize(indexMax, max);
        } else {
            max = a.getInteger(indexMax, max);
        }
    }
    if (a.getValue(indexMin, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            min = a.getDimensionPixelSize(indexMin, min);
        } else {
            min = a.getInteger(indexMin, min);
        }
    }
    if (a.getValue(indexValue, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            value = a.getDimensionPixelSize(indexValue, value);
        } else {
            value = a.getInteger(indexValue, value);
        }
    }

    mMin = min;
    mMax = Math.max(min + 1, max);
    mValue = Math.max(min, Math.min(max, value));
    updateKeyboardRange();

    mIndicatorFormatter = a.getString(R.styleable.DiscreteSeekBar_dsb_indicatorFormatter);

    ColorStateList trackColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_trackColor);
    ColorStateList progressColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_progressColor);
    ColorStateList rippleColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_rippleColor);
    boolean editMode = isInEditMode();
    if (editMode || rippleColor == null) {
        rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY });
    }
    if (editMode || trackColor == null) {
        trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY });
    }
    if (editMode || progressColor == null) {
        progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { DEFAULT_THUMB_COLOR });
    }
    mRipple = SeekBarCompat.getRipple(context, rippleColor);
    if (isLollipopOrGreater) {
        SeekBarCompat.setBackground(this, mRipple);
    } else {
        mRipple.setCallback(this);
    }

    TrackRectDrawable shapeDrawable = new TrackRectDrawable(context, trackColor);
    mTrack = shapeDrawable;
    mTrack.setCallback(this);

    shapeDrawable = new TrackRectDrawable(context, progressColor);
    mScrubber = shapeDrawable;
    mScrubber.setCallback(this);

    mThumb = new ThumbDrawable(bitmap, context, progressColor, thumbSize);
    mThumb.setCallback(this);
    mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight());

    if (!editMode) {
        mIndicator = new PopupIndicator(context, attrs, defStyleAttr, convertValueToMessage(mMax));
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

}