Example usage for android.graphics Color DKGRAY

List of usage examples for android.graphics Color DKGRAY

Introduction

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

Prototype

int DKGRAY

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

Click Source Link

Usage

From source file:io.puzzlebox.jigsaw.ui.EEGFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    v = inflater.inflate(R.layout.fragment_eeg, container, false);

    //      requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    //      setContentView(R.layout.main);
    //      getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);

    progressBarAttention = (ProgressBar) v.findViewById(R.id.progressBarAttention);
    final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
    ShapeDrawable progressBarAttentionDrawable = new ShapeDrawable(
            new RoundRectShape(roundedCorners, null, null));
    String progressBarAttentionColor = "#FF0000";
    progressBarAttentionDrawable.getPaint().setColor(Color.parseColor(progressBarAttentionColor));
    ClipDrawable progressAttention = new ClipDrawable(progressBarAttentionDrawable, Gravity.LEFT,
            ClipDrawable.HORIZONTAL);//  w  w w . j  a v  a 2s  .c o m
    progressBarAttention.setProgressDrawable(progressAttention);
    progressBarAttention
            .setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));

    progressBarMeditation = (ProgressBar) v.findViewById(R.id.progressBarMeditation);
    ShapeDrawable progressBarMeditationDrawable = new ShapeDrawable(
            new RoundRectShape(roundedCorners, null, null));
    String progressBarMeditationColor = "#0000FF";
    progressBarMeditationDrawable.getPaint().setColor(Color.parseColor(progressBarMeditationColor));
    ClipDrawable progressMeditation = new ClipDrawable(progressBarMeditationDrawable, Gravity.LEFT,
            ClipDrawable.HORIZONTAL);
    progressBarMeditation.setProgressDrawable(progressMeditation);
    progressBarMeditation
            .setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));

    progressBarSignal = (ProgressBar) v.findViewById(R.id.progressBarSignal);
    ShapeDrawable progressBarSignalDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null));
    String progressBarSignalColor = "#00FF00";
    progressBarSignalDrawable.getPaint().setColor(Color.parseColor(progressBarSignalColor));
    ClipDrawable progressSignal = new ClipDrawable(progressBarSignalDrawable, Gravity.LEFT,
            ClipDrawable.HORIZONTAL);
    progressBarSignal.setProgressDrawable(progressSignal);
    progressBarSignal.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));
    //      progressBarSignal.setProgress(tgSignal);

    progressBarPower = (ProgressBar) v.findViewById(R.id.progressBarPower);
    ShapeDrawable progressBarPowerDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null));
    String progressBarPowerColor = "#FFFF00";
    progressBarPowerDrawable.getPaint().setColor(Color.parseColor(progressBarPowerColor));
    ClipDrawable progressPower = new ClipDrawable(progressBarPowerDrawable, Gravity.LEFT,
            ClipDrawable.HORIZONTAL);
    progressBarPower.setProgressDrawable(progressPower);
    progressBarPower.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));

    progressBarBlink = (ProgressBar) v.findViewById(R.id.progressBarBlink);
    //      ShapeDrawable progressBarRangeDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null,null));
    ShapeDrawable progressBarRangeDrawable = new ShapeDrawable();
    //      String progressBarRangeColor = "#FF00FF";
    //      String progressBarRangeColor = "#990099";
    String progressBarRangeColor = "#BBBBBB";
    progressBarRangeDrawable.getPaint().setColor(Color.parseColor(progressBarRangeColor));
    ClipDrawable progressRange = new ClipDrawable(progressBarRangeDrawable, Gravity.LEFT,
            ClipDrawable.HORIZONTAL);
    progressBarBlink.setProgressDrawable(progressRange);
    progressBarBlink.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal));

    progressBarBlink.setMax(ThinkGearService.blinkRangeMax);

    // setup the Raw EEG History plot
    eegRawHistoryPlot = (XYPlot) v.findViewById(R.id.eegRawHistoryPlot);
    //      eegRawHistorySeries = new SimpleXYSeries("Raw EEG");
    eegRawHistorySeries = new SimpleXYSeries("");

    // Use index value as xVal, instead of explicit, user provided xVals.
    //      eegRawHistorySeries.useImplicitXVals();

    // Setup the boundary mode, boundary values only applicable in FIXED mode.

    if (eegRawHistoryPlot != null) {

        //         eegRawHistoryPlot.setDomainBoundaries(0, EEG_RAW_HISTORY_SIZE, BoundaryMode.FIXED);
        //         eegRawHistoryPlot.setDomainBoundaries(0, ThinkGearService.EEG_RAW_HISTORY_SIZE, BoundaryMode.FIXED);
        //      eegRawHistoryPlot.setDomainBoundaries(0, EEG_RAW_HISTORY_SIZE, BoundaryMode.AUTO);
        //      eegRawHistoryPlot.setRangeBoundaries(-32767, 32767, BoundaryMode.FIXED);
        //      eegRawHistoryPlot.setRangeBoundaries(-32767, 32767, BoundaryMode.AUTO);
        //         eegRawHistoryPlot.setRangeBoundaries(-256, 256, BoundaryMode.GROW);
        eegRawHistoryPlot.setDomainBoundaries(0, ThinkGearService.EEG_RAW_FREQUENCY, BoundaryMode.FIXED);
        eegRawHistoryPlot.setRangeBoundaries(0, 1, BoundaryMode.GROW);

        eegRawHistoryPlot.addSeries(eegRawHistorySeries,
                new LineAndPointFormatter(Color.rgb(200, 100, 100), Color.BLACK, null, null));

        // Thin out domain and range tick values so they don't overlap
        eegRawHistoryPlot.setDomainStepValue(5);
        eegRawHistoryPlot.setTicksPerRangeLabel(3);

        //      eegRawHistoryPlot.setRangeLabel("Amplitude");

        // Sets the dimensions of the widget to exactly contain the text contents
        eegRawHistoryPlot.getDomainLabelWidget().pack();
        eegRawHistoryPlot.getRangeLabelWidget().pack();

        // Only display whole numbers in labels
        eegRawHistoryPlot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0"));
        eegRawHistoryPlot.getGraphWidget().setRangeValueFormat(new DecimalFormat("0"));

        // Hide domain and range labels
        eegRawHistoryPlot.getGraphWidget().setDomainLabelWidth(0);
        eegRawHistoryPlot.getGraphWidget().setRangeLabelWidth(0);

        // Hide legend
        eegRawHistoryPlot.getLegendWidget().setVisible(false);

        // setGridPadding(float left, float top, float right, float bottom)
        eegRawHistoryPlot.getGraphWidget().setGridPadding(0, 0, 0, 0);

        //      eegRawHistoryPlot.getGraphWidget().setDrawMarkersEnabled(false);

        //      final PlotStatistics histStats = new PlotStatistics(1000, false);
        //      eegRawHistoryPlot.addListener(histStats);

    }

    seekBarAttention = (SeekBar) v.findViewById(R.id.seekBarAttention);
    seekBarAttention.setOnSeekBarChangeListener(this);
    seekBarMeditation = (SeekBar) v.findViewById(R.id.seekBarMeditation);
    seekBarMeditation.setOnSeekBarChangeListener(this);

    //      spinnerEEG = (Spinner) v.findViewById(R.id.spinnerEEG);

    String[] items = new String[] { "NeuroSky MindWave Mobile", "Emotiv Insight", "InteraXon Muse" };

    //      if (ThinkGearService.eegConnected || ThinkGearService.eegConnecting)
    //         items = new String[] {"NeuroSky MindWave Mobile", "Emotiv Insight", "InteraXon Muse"};
    if (MuseService.eegConnected || MuseService.eegConnecting)
        items = new String[] { "InteraXon Muse", "Emotiv Insight", "NeuroSky MindWave Mobile" };

    spinnerEEG = (Spinner) v.findViewById(R.id.spinnerEEG);

    //      ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity().getApplicationContext(),
    //              android.R.layout.simple_spinner_item, items);

    ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity().getApplicationContext(),
            R.layout.spinner_item, items);

    //      ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_item,list);

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerEEG.setAdapter(adapter);

    if (android.os.Build.VERSION.SDK_INT >= 16)
        spinnerEEG.setPopupBackgroundDrawable(new ColorDrawable(Color.DKGRAY));

    //      imageViewStatus = (ImageView) v.findViewById(R.id.imageViewStatus);

    textViewSessionTime = (TextView) v.findViewById(R.id.textViewSessionTime);

    Button connectEEG = (Button) v.findViewById(R.id.buttonConnectEEG);
    connectEEG.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            connectHeadset();
        }
    });

    if (ThinkGearService.eegConnected) {
        connectEEG.setText("Disconnect EEG");
        spinnerEEG.setEnabled(false);
    }
    if (MuseService.eegConnected) {
        connectEEG.setText("Disconnect EEG");
        //         spinnerEEG.setSelection(spinnerEEG.getPosition(DEFAULT_CURRENCY_TYPE));
        //         spinnerEEG.setSelection(spinnerEEG.getAdapter(). .getPosition(DEFAULT_CURRENCY_TYPE));
        spinnerEEG.setEnabled(false);
    }

    //      Button saveSession = (Button) v.findViewById(R.id.buttonSaveSession);
    //      saveSession.setOnClickListener(new View.OnClickListener() {
    //         @Override
    //         public void onClick(View v) {
    //
    //            Intent intent = new Intent(getActivity(), CreateSessionFileInGoogleDrive.class);
    //            startActivity(intent);
    //
    ////            Toast.makeText((getActivity()),
    ////                    "Session data saved to Google Drive",
    ////                    Toast.LENGTH_SHORT).show();
    //         }
    //      });

    //      Button exportToCSV = (Button) v.findViewById(R.id.buttonExportCSV);
    //      exportToCSV.setOnClickListener(new View.OnClickListener() {
    //         @Override
    //         public void onClick(View v) {
    //            Log.d(TAG, "SessionSingleton.getInstance().exportDataToCSV");
    ////            String path = SessionSingleton.getInstance().getTimestampPS4();
    //            SessionSingleton.getInstance().exportDataToCSV(null, null);
    //
    //            Toast.makeText((getActivity()),
    //                    "Session data exported to:\n" + SessionSingleton.getInstance().getTimestampPS4() + ".csv",
    //                    Toast.LENGTH_LONG).show();
    //         }
    //      });

    Button resetSession = (Button) v.findViewById(R.id.buttonResetSession);
    resetSession.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            resetSession();

        }
    });

    intentThinkGear = new Intent(getActivity(), ThinkGearService.class);
    intentMuse = new Intent(getActivity(), MuseService.class);

    /**
     * Update settings according to default UI
     */

    updateScreenLayout();

    updatePowerThresholds();
    updatePower();

    return v;

}

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

private void drawGaugeNeedle(Canvas canvas, int count, int Scale) {
    canvas.save(Canvas.MATRIX_SAVE_FLAG);
    float divisor = 360.0f / Scale;

    canvas.rotate((float) (divisor * count), 100, 100);

    //Inside// ww w  . ja v a 2  s  .  c om
    Paint needleInsidePaint = new Paint();
    needleInsidePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    needleInsidePaint.setColor(Color.WHITE);
    needleInsidePaint.setStrokeWidth(4);
    needleInsidePaint.setAntiAlias(true);

    Paint needleEdgePaint = new Paint();
    needleEdgePaint.setStyle(Paint.Style.STROKE);
    needleEdgePaint.setColor(Color.DKGRAY);
    needleEdgePaint.setStrokeWidth(0.5f);
    needleEdgePaint.setAntiAlias(true);

    canvas.drawOval(new RectF(95, 95, 105, 105), needleInsidePaint);
    canvas.drawOval(new RectF(95, 96, 105, 105), needleEdgePaint);

    Path needleInside = new Path();
    needleInside.moveTo(98, 98);
    needleInside.lineTo(100, 20);
    needleInside.lineTo(102, 102);
    canvas.drawPath(needleInside, needleInsidePaint);

    Path needleEdge = new Path();
    needleInside.moveTo(99, 99);
    needleInside.lineTo(99, 19);
    needleInside.lineTo(103, 103);

    canvas.drawPath(needleEdge, needleEdgePaint);
    canvas.restore();
}

From source file:com.timothy.android.api.fragment.PageFragmentNew.java

public void setAllComponent(List<HtmlCleanAPI.HtmlContent> hcList) {
    Log.i(LOG_TAG, "setAllComponent()...");
    for (HtmlCleanAPI.HtmlContent hc : hcList) {
        String tag = hc.getTag();
        String content = hc.getContent();
        if (StringUtil.isEmpty(content))
            continue;

        String contentMBlank = StringUtil.mergeBlank(content);
        if (StringUtil.isEmpty(contentMBlank))
            continue;

        String contentRBlank = StringUtil.rmvEnter(StringUtil.trim(contentMBlank));
        if (StringUtil.isEmpty(contentRBlank))
            continue;

        String contentRSpecial = StringUtil.rmvSpecial(contentRBlank);
        if (StringUtil.isEmpty(contentRSpecial))
            continue;

        Log.i(LOG_TAG, "tag:" + tag);
        Log.i(LOG_TAG, "content:" + contentRSpecial);

        if (tag.equalsIgnoreCase("P")) {
            final TextView tagPTV = new TextView(mContext);
            tagPTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 3, 2, 3);/*from   w  w w.j  a v  a  2s .c o  m*/
            tagPTV.setLayoutParams(lp);
            tagPTV.setPadding(3, 3, 3, 3);
            tagPTV.setPaddingRelative(3, 3, 3, 3);
            tagPTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagPTV.setTextColor(Color.BLACK);
            tagPTV.setText(contentRSpecial);
            tagPTV.setTextSize(TEXT_SIZE);
            tagPTV.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagPTV.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagPTV);

        } else if (tag.equalsIgnoreCase("pre")) {
            final TextView tagPre = new TextView(mContext);
            tagPre.setBackgroundColor(Color.parseColor("#D2EADE"));
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagPre.setLayoutParams(lp);
            tagPre.setPadding(2, 2, 2, 2);
            tagPre.setPaddingRelative(2, 2, 2, 2);
            tagPre.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagPre.setTextColor(Color.BLACK);
            //            String contentRSpecial = StringUtil.rmvSpecial(content);
            tagPre.setText(StringUtil.rmvSpecial(content));
            tagPre.setTextSize(TEXT_SIZE);
            tagPre.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagPre.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagPre);
        } else if (tag.equalsIgnoreCase("dt") || tag.equalsIgnoreCase("H1") || tag.equalsIgnoreCase("H2")
                || tag.equalsIgnoreCase("H3")) {//title
            TextView tagDtHTV = new TextView(mContext);
            tagDtHTV.setBackgroundColor(Color.DKGRAY);
            tagDtHTV.setTypeface(null, Typeface.BOLD);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 0, 2, 0);
            tagDtHTV.setLayoutParams(lp);
            tagDtHTV.setPadding(2, 2, 2, 2);
            tagDtHTV.setPaddingRelative(2, 2, 2, 2);
            tagDtHTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagDtHTV.setTextColor(Color.WHITE);
            tagDtHTV.setText(contentRSpecial);
            tagDtHTV.setTextSize(TEXT_SIZE);
            lineLayout.addView(tagDtHTV);
        } else if (tag.equalsIgnoreCase("dd")) {
            final TextView tagDD = new TextView(mContext);
            tagDD.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagDD.setLayoutParams(lp);
            tagDD.setPadding(3, 3, 3, 3);
            tagDD.setPaddingRelative(3, 3, 3, 3);
            tagDD.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagDD.setTextColor(Color.BLACK);
            tagDD.setText(contentRSpecial);
            tagDD.setTextSize(TEXT_SIZE);
            tagDD.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagDD.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagDD);
        } else if (tag.equalsIgnoreCase("li")) {
            final TextView tagLigTV = new TextView(mContext);
            tagLigTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagLigTV.setLayoutParams(lp);
            tagLigTV.setPaddingRelative(2, 2, 2, 2);
            tagLigTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagLigTV.setTextColor(Color.BLACK);
            tagLigTV.setText(contentRSpecial);
            tagLigTV.setTextSize(TEXT_SIZE);
            tagLigTV.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagLigTV.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagLigTV);
        } else if (tag.equalsIgnoreCase("img")) {
            final TextView imgTV = new TextView(mContext);
            imgTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            imgTV.setLayoutParams(lp);
            imgTV.setPaddingRelative(2, 2, 2, 2);
            imgTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            imgTV.setTextColor(Color.BLACK);
            imgTV.setText(content);
            imgTV.setTextSize(TEXT_SIZE);
            lineLayout.addView(imgTV);

            ImageView imageView = new ImageView(mContext);
            LinearLayout.LayoutParams imgLP = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            imageView.setLayoutParams(imgLP);
            Bitmap localBt = getLoacalBitmap(baseFolder + File.separator + content);
            imageView.setImageBitmap(localBt);
            lineLayout.addView(imageView);
        }
    }
}

From source file:org.sensapp.android.sensappdroid.activities.GraphDisplayerActivity.java

static public int getColorFromString(String color) {
    if (color.equals("Blue"))
        return Color.BLUE;
    if (color.equals("Cyan"))
        return Color.CYAN;
    if (color.equals("Dark gray"))
        return Color.DKGRAY;
    if (color.equals("Gray"))
        return Color.GRAY;
    if (color.equals("Green"))
        return Color.GREEN;
    if (color.equals("Light gray"))
        return Color.LTGRAY;
    if (color.equals("Magenta"))
        return Color.MAGENTA;
    if (color.equals("Red"))
        return Color.RED;
    if (color.equals("Yellow"))
        return Color.YELLOW;
    return -1;// ww  w . ja va 2  s .c  om
}

From source file:com.cesarsk.say_it.ui.fragments.SettingsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    // Use an activity context to get the rewarded video instance.
    mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(getActivity());
    mRewardedVideoAd.setRewardedVideoAdListener(this);

    loadRewardedVideoAd();/*from  w  ww . ja v  a  2  s  .c o  m*/

    PackageInfo pInfo = null;
    try {
        pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    String version = pInfo.versionName;
    final Preference app_version = getPreferenceManager().findPreference("app_version");
    app_version.setSummary("Version: " + version + " (Click for Privacy Policy)");

    final Context context = getActivity();

    if (context instanceof Callback) {
        mCallback = (Callback) context;
    } else {
        throw new IllegalStateException("Owner must implement URLCallback interface");
    }

    // add listeners for non-default actions
    Preference preference = findPreference(KEY_1);
    preference.setOnPreferenceClickListener(this);

    Preference open_source_licenses = findPreference(KEY_2);
    open_source_licenses.setOnPreferenceClickListener(this);

    Preference rate_us = getPreferenceManager().findPreference("rate_us");
    rate_us.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            rateUs(getActivity());
            return false;
        }
    });

    Preference contact_us = getPreferenceManager().findPreference("contact_us");
    contact_us.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            shareToMail(emails, "[CONTACT US - SAY IT!]", getActivity());
            return false;
        }
    });

    Preference bug_report = getPreferenceManager().findPreference("bug_report");
    bug_report.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            shareToMail(emails, "[CONTACT US - SAY IT!]", getActivity());
            return false;
        }
    });

    Preference donate_ad = getPreferenceManager().findPreference("donation_ad");
    donate_ad.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            //Launch AD
            if (mRewardedVideoAd.isLoaded()) {
                mRewardedVideoAd.show();
            }
            return false;
        }
    });

    final Preference about_us = getPreferenceManager().findPreference("about_us");
    about_us.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Utility.openURL(getActivity(), "https://lucacesaranoblog.wordpress.com/2017/07/18/about-us/");
            return false;
        }
    });

    final Preference eula = getPreferenceManager().findPreference("eula");
    eula.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Utility.openURL(getActivity(),
                    "https://lucacesaranoblog.wordpress.com/2017/04/28/say-it-eula-agreement/");
            return false;
        }
    });

    /*final Preference github = getPreferenceManager().findPreference("github");
    github.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
        Utility.openURL(getActivity(), "https://github.com/Cesarsk/Say_it");
        return false;
    }
    });*/

    final Preference other_apps = getPreferenceManager().findPreference("other_apps");
    other_apps.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Utility.openURL(getActivity(), "https://play.google.com/store/apps/developer?id=Cesarsk+Dev+Team");
            return false;
        }
    });

    final Preference voice_settings = getPreferenceManager().findPreference("tts_settings");
    voice_settings.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent();
            intent.setAction("com.android.settings.TTS_SETTINGS");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
            return false;
        }
    });

    // compute your public key and store it in base64EncodedPublicKey
    mHelper = new IabHelper(getActivity(), LCSecurity.base64EncodedPublicKey);
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(IabResult result) {
            if (!result.isSuccess()) {
                // Oh no, there was a problem.
                if (MainActivity.isLoggingEnabled)
                    Log.d("Say It!", "Problem setting up In-app Billing: " + result);
            }
            // Hooray, IAB is fully set up!
            if (MainActivity.isLoggingEnabled)
                Log.d("Say It!", "Hooray. IAB is fully set up!" + result);
        }
    });

    mIabPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
        @Override
        public void onIabPurchaseFinished(IabResult result, Purchase info) {
            if (result.isFailure()) {
                Toast.makeText(getActivity(), "Purchase Failed! Perhaps have you already purchased the item?",
                        Toast.LENGTH_SHORT).show();
            } else if (info.getSku().equals(PlayActivity.no_ads_in_app)) {
                UtilitySharedPrefs.loadAdsStatus(getActivity());
                UtilitySharedPrefs.savePrefs(getActivity(), true, MainActivity.NO_ADS_STATUS_KEY);
            }
        }
    };

    mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
            if (result.isFailure()) {
                if (MainActivity.isLoggingEnabled)
                    Toast.makeText(getActivity(), "Query Failed!", Toast.LENGTH_SHORT).show();
                return;
            }

            //Open Purchase Dialog
            try {
                mHelper.flagEndAsync();
                mHelper.launchPurchaseFlow(getActivity(), PlayActivity.no_ads_in_app, 64000,
                        mIabPurchaseFinishedListener);
            } catch (IabHelper.IabAsyncInProgressException e) {
                e.printStackTrace();
            }
        }
    };

    final Preference remove_ads = getPreferenceManager().findPreference("remove_ads");
    if (MainActivity.NO_ADS) {
        remove_ads.setEnabled(false);
        remove_ads.setSummary("Thank you for supporting us ?");
    } else {
        remove_ads.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                //helper to remove ads
                List<String> additionalSkuList = new ArrayList<>();
                additionalSkuList.add(PlayActivity.no_ads_in_app);
                try {
                    mHelper.flagEndAsync();
                    mHelper.queryInventoryAsync(true, additionalSkuList, mQueryFinishedListener);
                } catch (IabHelper.IabAsyncInProgressException e) {
                    e.printStackTrace();
                }
                return false;
            }
        });
    }

    final Preference reset_tutorial = getPreferenceManager().findPreference("reset_showcase");
    reset_tutorial.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Random rand = new Random();
            int randomNum = rand.nextInt((10000 - 10) + 1) + 10; //(max - min) + 1 + min
            MainActivity.id_showcase_playactivity = "" + randomNum;
            Toast.makeText(getActivity(), "Tutorial has been reset", Toast.LENGTH_SHORT).show();
            //MainActivity.id_showcase_fragments = "" + randomNum2;
            //int randomNum2 = rand.nextInt((10000 - 10) + 1) + 10; //(max - min) + 1 + min //These two statements are commented because MaterialShowCase often crashes on fragments and while pressing the back button.
            return false;
        }
    });

    //setting an own Alert Dialog's title color
    final Spannable title = new SpannableString("Delete Recordings");
    title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, title.length(), 0);
    final Spannable message = new SpannableString("Are you sure you want to delete all recordings?");
    message.setSpan(new ForegroundColorSpan(Color.GRAY), 0, message.length(), 0);

    final Preference delete_recordings = getPreferenceManager().findPreference("delete_recordings");
    delete_recordings.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            new AlertDialog.Builder(getActivity()).setTitle(title).setMessage(message)
                    .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            Utility.delete_recordings(getActivity());
                            Toast.makeText(getActivity(), "Recordings deleted!", Toast.LENGTH_SHORT).show();
                        }
                    }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            //do nothing
                        }
                    }).show();
            return true;
        }
    });

    final ListPreference button_vibration = (ListPreference) getPreferenceManager()
            .findPreference("button_vibration");
    button_vibration.setSummary(button_vibration.getEntry());
    final Spannable default_vibration_settings_title = new SpannableString("Vibration Settings");
    default_vibration_settings_title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0,
            default_vibration_settings_title.length(), 0);
    button_vibration.setDialogTitle(default_vibration_settings_title);

    button_vibration.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            String new_value = newValue.toString();
            index_default_vibration = button_vibration.findIndexOfValue(new_value);
            CharSequence[] entries = button_vibration.getEntries();
            UtilitySharedPrefs.savePrefs(getActivity(), new_value, MainActivity.DEFAULT_VIBRATION_KEY);
            button_vibration
                    .setSummary(button_vibration.getEntries()[button_vibration.findIndexOfValue(new_value)]);
            Toast.makeText(getActivity(), String.valueOf(entries[index_default_vibration]), Toast.LENGTH_SHORT)
                    .show();
            UtilitySharedPrefs.loadSettingsPrefs(context);
            return true;
        }
    });

    final ListPreference default_accent = (ListPreference) getPreferenceManager()
            .findPreference("default_accent");
    default_accent.setSummary(default_accent.getEntry());
    final Spannable default_accent_title = new SpannableString("Default Accent");
    default_accent_title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, default_accent_title.length(), 0);
    default_accent.setDialogTitle(default_accent_title);

    default_accent.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            String new_value = newValue.toString();
            index_default_accent = default_accent.findIndexOfValue(new_value);
            CharSequence[] entries = default_accent.getEntries();

            UtilitySharedPrefs.savePrefs(getActivity(), new_value, MainActivity.DEFAULT_ACCENT_KEY);
            default_accent.setSummary(default_accent.getEntries()[default_accent.findIndexOfValue(new_value)]);
            //Toast.makeText(getActivity(), String.valueOf(entries[index_default_accent]), Toast.LENGTH_SHORT).show();
            UtilitySharedPrefs.loadSettingsPrefs(context);
            return true;
        }
    });

    final ListPreference theme_selector = (ListPreference) getPreferenceManager()
            .findPreference("theme_selector");
    final Spannable theme_selector_title = new SpannableString("Theme");
    theme_selector_title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, theme_selector_title.length(), 0);
    theme_selector.setDialogTitle(theme_selector_title);

    theme_selector.setSummary(theme_selector.getEntry());

    theme_selector.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            String new_value = newValue.toString();
            index_default_theme = theme_selector.findIndexOfValue(new_value);
            CharSequence[] entries = theme_selector.getEntries();
            UtilitySharedPrefs.savePrefs(getActivity(), new_value, MainActivity.DEFAULT_THEME_KEY);
            theme_selector.setSummary(theme_selector.getEntries()[theme_selector.findIndexOfValue(new_value)]);
            //Toast.makeText(getActivity(), String.valueOf(entries[index_default_theme]), Toast.LENGTH_SHORT).show();
            UtilitySharedPrefs.loadSettingsPrefs(context);
            Toast.makeText(getActivity(), "Done! Reboot to see changes.", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    Preference acknowledgements = getPreferenceManager().findPreference("acknowledgements");
    acknowledgements.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            final Intent preference_intent = new Intent(getActivity(), FileTextActivity.class);
            Bundle args = new Bundle();
            args.putString(FileTextActivity.PREFERENCE, "acknowledgements");
            preference_intent.putExtras(args);
            startActivity(preference_intent,
                    ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
            return false;
        }
    });

    app_version.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Utility.openURL(getActivity(), "https://lucacesaranoblog.wordpress.com/2017/04/18/privacy-policy/");
            return false;
        }
    });
}

From source file:cn.scujcc.bug.bitcoinplatformandroid.fragment.CandlestickChartsFragment.java

public void updateKines(List<KLine> list) {
    if (list == null) {
        return;/*  ww w.  j av a 2 s .  co  m*/
    }

    mChart.resetTracking();

    ArrayList<CandleEntry> yVals1 = new ArrayList<CandleEntry>();
    ArrayList<String> xVals = new ArrayList<String>();

    for (int i = 0; i < list.size(); i++) {
        // float mult = 400;
        KLine kLine = list.get(i);
        float val = (float) kLine.getVal();

        float high = (float) kLine.getHigh();
        float low = (float) kLine.getLow();

        float open = (float) kLine.getOpen();
        float close = (float) kLine.getClose();

        yVals1.add(new CandleEntry(i, high, low, open, close));
        xVals.add(kLine.getTime());
    }

    CandleDataSet set1 = new CandleDataSet(yVals1, "Data Set");
    set1.setAxisDependency(YAxis.AxisDependency.LEFT);
    //        set1.setColor(Color.rgb(80, 80, 80));
    set1.setShadowColor(Color.DKGRAY);
    set1.setShadowWidth(0.7f);
    set1.setDecreasingColor(Color.RED);
    set1.setDecreasingPaintStyle(Paint.Style.FILL);
    set1.setIncreasingColor(Color.rgb(122, 242, 84));
    set1.setIncreasingPaintStyle(Paint.Style.STROKE);
    set1.setNeutralColor(Color.BLUE);
    //set1.setHighlightLineWidth(1f);

    CandleData data = new CandleData(xVals, set1);

    mChart.setData(data);
    mChart.invalidate();
}

From source file:com.hmatalonga.greenhub.ui.TaskListActivity.java

/**
 * We're gonna setup another ItemDecorator that will draw the red background in the empty space while the items are animating to thier new positions
 * after an item is removed.//from  w  ww  .  j  a  v  a2s .c o m
 */
private void setUpAnimationDecoratorHelper() {
    mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {

        // we want to cache this and not allocate anything repeatedly in the onDraw method
        Drawable background;
        boolean initiated;

        private void init() {
            background = new ColorDrawable(Color.DKGRAY);
            initiated = true;
        }

        @Override
        public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {

            if (!initiated) {
                init();
            }

            // only if animation is in progress
            if (parent.getItemAnimator().isRunning()) {

                // some items might be animating down and some items might be animating up to close the gap left by the removed item
                // this is not exclusive, both movement can be happening at the same time
                // to reproduce this leave just enough items so the first one and the last one would be just a little off screen
                // then remove one from the middle

                // find first child with translationY > 0
                // and last one with translationY < 0
                // we're after a rect that is not covered in recycler-view views at this point in time
                View lastViewComingDown = null;
                View firstViewComingUp = null;

                // this is fixed
                int left = 0;
                int right = parent.getWidth();

                // this we need to find out
                int top = 0;
                int bottom = 0;

                // find relevant translating views
                int childCount = parent.getLayoutManager().getChildCount();
                for (int i = 0; i < childCount; i++) {
                    View child = parent.getLayoutManager().getChildAt(i);
                    if (child.getTranslationY() < 0) {
                        // view is coming down
                        lastViewComingDown = child;
                    } else if (child.getTranslationY() > 0) {
                        // view is coming up
                        if (firstViewComingUp == null) {
                            firstViewComingUp = child;
                        }
                    }
                }

                if (lastViewComingDown != null && firstViewComingUp != null) {
                    // views are coming down AND going up to fill the void
                    top = lastViewComingDown.getBottom() + (int) lastViewComingDown.getTranslationY();
                    bottom = firstViewComingUp.getTop() + (int) firstViewComingUp.getTranslationY();
                } else if (lastViewComingDown != null) {
                    // views are going down to fill the void
                    top = lastViewComingDown.getBottom() + (int) lastViewComingDown.getTranslationY();
                    bottom = lastViewComingDown.getBottom();
                } else if (firstViewComingUp != null) {
                    // views are coming up to fill the void
                    top = firstViewComingUp.getTop();
                    bottom = firstViewComingUp.getTop() + (int) firstViewComingUp.getTranslationY();
                }

                background.setBounds(left, top, right, bottom);
                background.draw(canvas);

            }
            super.onDraw(canvas, parent, state);
        }

    });
}

From source file:com.mobicage.rogerthat.util.ui.UIUtils.java

public static boolean showHintWithImage(final Activity activity, final MainService mainService,
        final SafeRunnable onDismissHandler, final String hintCode, final FontAwesome.Icon hintIcon,
        final int hintResource, final Object... args) {
    final ConfigurationProvider configurationProvider = mainService.getConfigurationProvider();
    final String configkey = "HINT_REPOSITORY";
    final com.mobicage.rogerthat.config.Configuration config = configurationProvider
            .getConfiguration(configkey);
    if (config.get(hintCode, false))
        return false;

    LayoutInflater inflater = activity.getLayoutInflater();
    final View checkboxLayout = inflater.inflate(R.layout.hint, null);
    final TextView message = (TextView) checkboxLayout.findViewById(R.id.message);
    final CheckBox checkBox = (CheckBox) checkboxLayout.findViewById(R.id.checkBox);
    if (hintIcon != null) {
        final ImageView icon = (ImageView) checkboxLayout.findViewById(R.id.icon);
        icon.setImageDrawable(new IconicsDrawable(activity, hintIcon).color(Color.DKGRAY).sizeDp(30));
        icon.setVisibility(View.VISIBLE);
    }//from  ww  w.j ava  2 s .  com
    Resources resources = activity.getResources();
    message.setText(resources.getString(hintResource, args));
    AlertDialog dialog = new AlertDialog.Builder(activity)
            .setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    if (onDismissHandler != null) {
                        onDismissHandler.run();
                    }
                }
            }).setTitle(R.string.activity_hint).setView(checkboxLayout).setPositiveButton(
                    resources.getString(R.string.activity_close_hint), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            if (checkBox.isChecked()) {
                                config.put(hintCode, true);
                                configurationProvider.updateConfigurationNow(configkey, config);
                            }
                            if (onDismissHandler != null) {
                                onDismissHandler.run();
                            }
                        }
                    })
            .create();
    dialog.show();
    int buttonId = mainService.getResources().getIdentifier("android:id/button1", null, null);
    ((Button) dialog.findViewById(buttonId)).setTextColor(LookAndFeelConstants.getPrimaryColor(activity));
    return true;
}

From source file:com.l4digital.fastscroll.FastScroller.java

private void layout(Context context, AttributeSet attrs) {
    inflate(context, R.layout.fastscroller, this);

    setClipChildren(false);//w  ww.j a  v a 2s .  co m
    setOrientation(HORIZONTAL);

    mBubbleView = (TextView) findViewById(R.id.fastscroll_bubble);
    mHandleView = (ImageView) findViewById(R.id.fastscroll_handle);
    mTrackView = (ImageView) findViewById(R.id.fastscroll_track);
    mScrollbar = findViewById(R.id.fastscroll_scrollbar);

    @ColorInt
    int bubbleColor = Color.GRAY;
    @ColorInt
    int handleColor = Color.DKGRAY;
    @ColorInt
    int trackColor = Color.LTGRAY;
    @ColorInt
    int textColor = Color.WHITE;

    boolean hideScrollbar = true;
    boolean showTrack = false;

    if (attrs != null) {
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.FastScrollRecyclerView, 0, 0);

        if (typedArray != null) {
            try {
                bubbleColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_bubbleColor, bubbleColor);
                handleColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_handleColor, handleColor);
                trackColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_trackColor, trackColor);
                textColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_bubbleTextColor, textColor);
                showTrack = typedArray.getBoolean(R.styleable.FastScrollRecyclerView_showTrack, false);
                hideScrollbar = typedArray.getBoolean(R.styleable.FastScrollRecyclerView_hideScrollbar, true);
            } finally {
                typedArray.recycle();
            }
        }
    }

    setTrackColor(trackColor);
    setHandleColor(handleColor);
    setBubbleColor(bubbleColor);
    setBubbleTextColor(textColor);
    setHideScrollbar(hideScrollbar);
    setTrackVisible(showTrack);
}

From source file:org.starfishrespect.myconsumption.android.ui.ChartViewFragment.java

private void init() {
    Log.d(TAG, "init");
    layoutPointData.setVisibility(View.GONE);
    chartLayout.removeAllViews();//from   w  w w  . ja v a 2 s.  c  o  m
    chart = null;
    data = new HashMap<>();
    List<SensorData> sensors = SingleInstance.getUserController().getUser().getSensors();
    if (sensors.size() == 0) {
        textViewNoData.setVisibility(View.VISIBLE);
        textViewNoData.setText(R.string.chart_text_no_sensor);
        refreshingView.setVisibility(View.GONE);
    } else {
        textViewNoData.setText(R.string.chart_text_no_data);
    }
    for (SensorData sensor : sensors) {
        data.put(sensor.getSensorId(), new ChartSerieRendererContainer(sensor));
    }
    textViewNoData.setVisibility(View.VISIBLE);

    originalChartDataset = new XYMultipleSeriesDataset();
    currentChartDataset = new XYMultipleSeriesDataset();
    chartRenderer = new XYMultipleSeriesRenderer();

    chartRenderer.setApplyBackgroundColor(true);
    chartRenderer.setBackgroundColor(Color.WHITE);
    chartRenderer.setAxesColor(Color.DKGRAY);
    chartRenderer.setMarginsColor(Color.WHITE);
    chartRenderer.setGridColor(Color.LTGRAY);
    chartRenderer.setXLabelsColor(Color.DKGRAY);
    chartRenderer.setYLabelsColor(0, Color.DKGRAY);

    //chartRenderer.setZoomEnabled(true);
    //chartRenderer.setPanEnabled(true);
    chartRenderer.setZoomEnabled(true, false);
    chartRenderer.setPanEnabled(true, false);
    chartRenderer.setClickEnabled(true);

    chartRenderer.setShowGrid(true);
    chartRenderer.setXLabelFormat(new DecimalFormat() {
        @Override
        public StringBuffer format(double value, StringBuffer buffer, FieldPosition position) {
            Date dateFormat = new Date(((long) value) * 1000);
            buffer.append(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(dateFormat));
            return buffer;
        }
    });

    chartRenderer.setShowLegend(false);

    minimalX = Integer.MAX_VALUE;
    maximalX = 0;
    maximalY = 0;
}