Example usage for android.graphics Color parseColor

List of usage examples for android.graphics Color parseColor

Introduction

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

Prototype

@ColorInt
public static int parseColor(@Size(min = 1) String colorString) 

Source Link

Document

Parse the color string, and return the corresponding color-int.

Usage

From source file:com.example.sam14240619331555.food_app.SlidingTabLayout.java

public void colorChange(int position) {
    for (int i = 0; i < mTabStrip.getChildCount(); i++) {
        if (i != position) {
            title.get(i).setTextColor(textColor);
        } else {/* w  w w  .  ja  v a2  s . co m*/
            title.get(i).setTextColor(Color.parseColor("#f5f5f5"));
        }
    }
}

From source file:com.insthub.O2OMobile.Fragment.A2_MenuFragment.java

private void changeTextColor(View view) {
    if (view == mHome) {
        mHomeIco.setImageResource(R.drawable.a3_ico_home_selected);
        mIssureIcon.setImageResource(R.drawable.a3_ico_issue);
        mReceiveIcon.setImageResource(R.drawable.a3_ico_receive);
        mInviteIcon.setImageResource(R.drawable.a3_ico_friends);
        mMessageIcon.setImageResource(R.drawable.a3_ico_message);

        mHomeText.setTextColor(Color.parseColor("#B3EF69"));
        mIssuanceText.setTextColor(Color.parseColor("#FAFCFD"));
        mOrderReceivingText.setTextColor(Color.parseColor("#FAFCFD"));
        mMessageText.setTextColor(Color.parseColor("#FAFCFD"));
        mInviteText.setTextColor(Color.parseColor("#FAFCFD"));

        mHomeArrow.setImageResource(R.drawable.ico_right_green);
        mIssuanceArrow.setImageResource(R.drawable.ico_right_grey);
        mOrderReceivingArrow.setImageResource(R.drawable.ico_right_grey);
        mMessageArrow.setImageResource(R.drawable.ico_right_grey);
        mInviteArrow.setImageResource(R.drawable.ico_right_grey);
    } else if (view == mIssuance) {
        mHomeIco.setImageResource(R.drawable.a3_ico_home);
        mIssureIcon.setImageResource(R.drawable.a3_ico_issue_selected);
        mReceiveIcon.setImageResource(R.drawable.a3_ico_receive);
        mInviteIcon.setImageResource(R.drawable.a3_ico_friends);
        mMessageIcon.setImageResource(R.drawable.a3_ico_message);

        mHomeText.setTextColor(Color.parseColor("#FAFCFD"));
        mIssuanceText.setTextColor(Color.parseColor("#B3EF69"));
        mOrderReceivingText.setTextColor(Color.parseColor("#FAFCFD"));
        mMessageText.setTextColor(Color.parseColor("#FAFCFD"));
        mInviteText.setTextColor(Color.parseColor("#FAFCFD"));

        mHomeArrow.setImageResource(R.drawable.ico_right_grey);
        mIssuanceArrow.setImageResource(R.drawable.ico_right_green);
        mOrderReceivingArrow.setImageResource(R.drawable.ico_right_grey);
        mMessageArrow.setImageResource(R.drawable.ico_right_grey);
        mInviteArrow.setImageResource(R.drawable.ico_right_grey);
    } else if (view == mOrderReceiving) {
        mHomeIco.setImageResource(R.drawable.a3_ico_home);
        mIssureIcon.setImageResource(R.drawable.a3_ico_issue);
        mReceiveIcon.setImageResource(R.drawable.a3_ico_receive_selected);
        mInviteIcon.setImageResource(R.drawable.a3_ico_friends);
        mMessageIcon.setImageResource(R.drawable.a3_ico_message);

        mHomeText.setTextColor(Color.parseColor("#FAFCFD"));
        mIssuanceText.setTextColor(Color.parseColor("#FAFCFD"));
        mOrderReceivingText.setTextColor(Color.parseColor("#B3EF69"));
        mMessageText.setTextColor(Color.parseColor("#FAFCFD"));
        mInviteText.setTextColor(Color.parseColor("#FAFCFD"));

        mHomeArrow.setImageResource(R.drawable.ico_right_green);
        mIssuanceArrow.setImageResource(R.drawable.ico_right_green);
        mOrderReceivingArrow.setImageResource(R.drawable.ico_right_green);
        mMessageArrow.setImageResource(R.drawable.ico_right_grey);
        mInviteArrow.setImageResource(R.drawable.ico_right_grey);
    } else if (view == mMessage) {
        mHomeIco.setImageResource(R.drawable.a3_ico_home);
        mIssureIcon.setImageResource(R.drawable.a3_ico_issue);
        mReceiveIcon.setImageResource(R.drawable.a3_ico_receive);
        mInviteIcon.setImageResource(R.drawable.a3_ico_friends);
        mMessageIcon.setImageResource(R.drawable.a3_ico_message_selected);

        mHomeText.setTextColor(Color.parseColor("#FAFCFD"));
        mIssuanceText.setTextColor(Color.parseColor("#FAFCFD"));
        mOrderReceivingText.setTextColor(Color.parseColor("#FAFCFD"));
        mMessageText.setTextColor(Color.parseColor("#B3EF69"));
        mInviteText.setTextColor(Color.parseColor("#FAFCFD"));

        mHomeArrow.setImageResource(R.drawable.ico_right_grey);
        mIssuanceArrow.setImageResource(R.drawable.ico_right_grey);
        mOrderReceivingArrow.setImageResource(R.drawable.ico_right_grey);
        mMessageArrow.setImageResource(R.drawable.ico_right_green);
        mInviteArrow.setImageResource(R.drawable.ico_right_grey);
    } else if (view == mInvite) {
        mHomeIco.setImageResource(R.drawable.a3_ico_home);
        mIssureIcon.setImageResource(R.drawable.a3_ico_issue);
        mReceiveIcon.setImageResource(R.drawable.a3_ico_receive);
        mInviteIcon.setImageResource(R.drawable.a3_ico_friends_selected);
        mMessageIcon.setImageResource(R.drawable.a3_ico_message);

        mHomeText.setTextColor(Color.parseColor("#FAFCFD"));
        mIssuanceText.setTextColor(Color.parseColor("#FAFCFD"));
        mOrderReceivingText.setTextColor(Color.parseColor("#FAFCFD"));
        mMessageText.setTextColor(Color.parseColor("#FAFCFD"));
        mInviteText.setTextColor(Color.parseColor("#B3EF69"));

        mHomeArrow.setImageResource(R.drawable.ico_right_grey);
        mIssuanceArrow.setImageResource(R.drawable.ico_right_grey);
        mOrderReceivingArrow.setImageResource(R.drawable.ico_right_grey);
        mMessageArrow.setImageResource(R.drawable.ico_right_grey);
        mInviteArrow.setImageResource(R.drawable.ico_right_green);
    }/*from   w  w w .  j a  va  2 s  .  c  o  m*/
}

From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setThemeColors() {
    ThemeManager.Theme theme = global.mThemeManager.getActiveTheme("appthemepref");
    int headerColor = Color.parseColor(theme.getValue("header_color"));
    findViewById(R.id.srtoolbar).setBackgroundColor(headerColor);
    sortBtn.getBackground().setColorFilter(headerColor, PorterDuff.Mode.ADD);
    addButton.getBackground().setColorFilter(headerColor, PorterDuff.Mode.ADD);
    refreshButton.getBackground().setColorFilter(headerColor, PorterDuff.Mode.ADD);
    tabs.setBackgroundColor(headerColor);
    tabs.setInidicatorColor(Color.parseColor(theme.getValue("tab_indicator")));
    tabs.setTextColor(Color.parseColor(theme.getValue("header_text")));
    int buttonIconColor = Color.parseColor("#666666");
    refreshButton.setTextColor(buttonIconColor);
    addButton.setTextColor(buttonIconColor);
    sortBtn.setCompoundDrawables(/*from w  ww .  ja  v a  2 s.  co m*/
            new IconDrawable(this, Iconify.IconValue.fa_sort).color(buttonIconColor).sizeDp(24), null, null,
            null);
    if (global.mRedditData.isLoggedIn()) {
        refreshButton.setCompoundDrawables(
                new IconDrawable(SubredditSelectActivity.this, Iconify.IconValue.fa_refresh)
                        .color(buttonIconColor).sizeDp(24),
                null, null, null);
        refreshButton.setText(R.string.refresh);
    } else {
        refreshButton
                .setCompoundDrawables(new IconDrawable(SubredditSelectActivity.this, Iconify.IconValue.fa_key)
                        .color(buttonIconColor).sizeDp(24), null, null, null);
        refreshButton.setText(R.string.login);
    }
    refreshButton.setCompoundDrawablePadding(6);
}

From source file:mp.paschalis.App.java

public static void setStyleErrorDirection(TextView pTextView) {
    pTextView.setTextColor(Color.parseColor("#C2022C"));
    pTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25);

}

From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.main_frag, container, false);
    setRetainInstance(true);/* w  w w . j a  v a  2 s .com*/
    listView = (android.support.v7.widget.RecyclerView) rootView.findViewById(R.id.listView);
    mToolbarContainer = (AppBarLayout) getActivity().findViewById(R.id.lin);
    fastScroller = (FastScroller) rootView.findViewById(R.id.fastscroll);
    fastScroller.setPressedHandleColor(Color.parseColor(fabSkin));
    listView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (adapter != null && stopAnims) {
                stopAnimation();
                stopAnims = false;
            }
            return false;
        }
    });
    mToolbarContainer.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (adapter != null && stopAnims) {
                stopAnimation();
                stopAnims = false;
            }
            return false;
        }
    });

    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.activity_main_swipe_refresh_layout);

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            loadlist((CURRENT_PATH), false, openMode);
        }
    });
    buttons = (LinearLayout) getActivity().findViewById(R.id.buttons);
    pathbar = (LinearLayout) getActivity().findViewById(R.id.pathbar);
    SHOW_THUMBS = sharedPref.getBoolean("showThumbs", true);
    res = getResources();
    pathname = (TextView) getActivity().findViewById(R.id.pathname);
    mFullPath = (TextView) getActivity().findViewById(R.id.fullpath);
    //String itemsstring = res.getString(R.string.items);// TODO: 23/5/2017 use or delete
    apk = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.ic_doc_apk_grid));
    mToolbarContainer.setBackgroundColor(MainActivity.currentTab == 1 ? skinTwoColor : skin_color);

    if (!sharedPref.getBoolean("intelliHideToolbar", true)) {
        AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) getActivity()
                .findViewById(R.id.action_bar).getLayoutParams();
        params.setScrollFlags(0);
        mToolbarContainer.setExpanded(true, true);
    }

    //   listView.setPadding(listView.getPaddingLeft(), paddingTop, listView.getPaddingRight(), listView.getPaddingBottom());
    return rootView;
}

From source file:com.example.volunteerhandbook.MainActivity.java

void loop_what_I_thought() {
    thoughts = getResources().getStringArray(R.array.what_I_thought);
    int lines = thoughts.length / 4;
    container = (FrameLayout) findViewById(R.id.main_content_frame);
    LinearLayout[] textBox = new LinearLayout[3];
    endY = container.getHeight() - 100f;
    h = (float) container.getHeight();
    hBox = 0;/* www  .  ja  v a2 s .com*/
    /*
    for (int k=0; k<3; k++){
       textBox[k]=new LinearLayout(this);
       textBox[k].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    textBox[k].setOrientation(1);
    }
    */
    //LinearLayout tmp=(LinearLayout) getLayoutInflater().inflate(R.layout.one_line, null);
    //TextView  tmpTxt=(TextView)tmp.findViewById(R.id.oneLine);
    //tmp.removeView(tmpTxt);
    int[] color = new int[4];
    color[3] = Color.parseColor("#66FF66");
    color[1] = Color.parseColor("#FF9900");
    color[2] = Color.parseColor("#0099FF");
    color[0] = Color.parseColor("#00FF00");
    toMove = new TextView[thoughts.length];
    int textSize = 24;
    for (int i = 0; i < thoughts.length; i++) {
        toMove[i] = new TextView(this);
        toMove[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        toMove[i].setText(thoughts[i]);
        toMove[i].setTextSize(textSize);
        toMove[i].getPaint().setFakeBoldText(true);
        toMove[i].setTextColor(color[1] - 0x20202 * i);
        //textBox.addView(toMove);
    }
    int boxHeight = (lines + 1) * (int) (textSize * 1.5);
    for (int k = 0; k < 3; k++) {
        textBox[k].removeAllViews();
        for (int i = 0; i < thoughts.length / 4; i++) {
            TextView v = toMove[iTh++ % thoughts.length];
            v.setTextColor(color[k]);
            textBox[k].addView(v);
        }
        //toMove.setTranslationY(600);
        //container.addView(textBox);
        container.addView(textBox[k]);
        textBox[k].setX(20);
        textBox[k].setY(2 * boxHeight + hBox);
        hBox += boxHeight; //textBox[k].getHeight();
        float startY = textBox[k].getY();
        endY = (-1) * boxHeight;
        int duration = (int) (((startY - endY) / (3 * boxHeight)) * 20000);
        ValueAnimator bounceAnim = ObjectAnimator.ofFloat(textBox[k], "y", startY, endY);
        bounceAnim.setDuration(duration);
        bounceAnim.setInterpolator(new LinearInterpolator());
        final LinearLayout iBox = textBox[k];
        bounceAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                loopNewBox(iBox);
            }
        });
        bounceAnim.start();
    }

}

From source file:com.openerp.support.calendar.OECalendar.java

/**
 * Creating own OpenERP Mobile calendar upon Mobile device
 * /*from www. ja v a  2s. co  m*/
 * @param account
 *            : for which OpenERP calendar created
 * @return long : the OpenERP Mobile calendar_id
 */
public long createCalendar(Account account) {
    cr = context.getContentResolver();
    values = new ContentValues();
    values.put(Calendars.ACCOUNT_NAME, account.name);
    values.put(CalendarContract.Calendars.ACCOUNT_TYPE, account.type);
    values.put(Calendars.NAME, account.name);
    values.put(Calendars.CALENDAR_DISPLAY_NAME, account.name);
    values.put(Calendars.CALENDAR_COLOR, Color.parseColor("#cc0000"));
    values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_OWNER);
    values.put(Calendars.OWNER_ACCOUNT, account.name);
    values.put(Calendars.SYNC_EVENTS, 1);
    values.put(Calendars.VISIBLE, 1);
    values.put(CalendarContract.Calendars.CALENDAR_TIME_ZONE, TimeZone.getDefault().getID());
    creationUri = asSyncAdapter(Calendars.CONTENT_URI, account.name, account.type);
    uri = cr.insert(creationUri, values);
    created_Calendar_id = Long.parseLong(uri.getLastPathSegment());
    return created_Calendar_id;
}

From source file:at.alladin.rmbt.android.views.ResultGraphView.java

private void redraw(JSONArray result) {
    try {//from ww  w .j  av a  2  s .  c om
        JSONObject curve = result.getJSONObject(0).getJSONObject("speed_curve");
        if (curve != null) {
            uploadArray = curve.getJSONArray("upload");
            downloadArray = curve.getJSONArray("download");
            signalArray = curve.getJSONArray("signal");
        }

        //System.out.println(signalArray);

        long maxTimeUpload = result.getJSONObject(0).optLong("time_ul_ms")
                + result.getJSONObject(0).optLong("duration_upload_ms");
        long timeElapsed = Math.round((double) maxTimeUpload / 1000);

        if (signalGraph != null && signalArray != null && signalArray.length() > 0
                && signalGraph.getGraphs().size() < 1) {
            Log.d("ResultGraphView", "DRAWING SIGNAL GRAPH\n" + signalArray);

            final long maxTimeSignal = signalArray.optJSONObject(signalArray.length() - 1)
                    .optLong("time_elapsed");
            final long timeElapsedMs = Math.max(maxTimeSignal, maxTimeUpload);
            timeElapsed = Math.round((double) timeElapsedMs / 1000);

            signalGraph.getLabelHMaxList().clear();
            signalGraph.addLabelHMax(String.valueOf(timeElapsed < 7 ? 7 : timeElapsed));
            signalGraph.updateGrid((int) timeElapsed, 4);
            /* [{"network_type":"WLAN","time_elapsed":0,"signal_strength":-56},
             * {"network_type":"WLAN","time_elapsed":10121,"signal_strength":-55},
             * {"network_type":"WLAN","time_elapsed":37478,"signal_strength":-57}]
             */
            MinMax<Integer> signalBoundsRsrp = NetworkUtil
                    .getSignalStrengthBounds(InformationCollector.SINGAL_TYPE_RSRP);
            MinMax<Integer> signalBoundsWlan = NetworkUtil
                    .getSignalStrengthBounds(InformationCollector.SINGAL_TYPE_WLAN);
            MinMax<Integer> signalBoundsMobile = NetworkUtil
                    .getSignalStrengthBounds(InformationCollector.SINGAL_TYPE_MOBILE);

            List<GraphService> signalList = new ArrayList<GraphService>();

            boolean has4G = false;
            boolean has3G = false;
            boolean hasWlan = false;
            String lastNetworkType = "";
            String lastCatTechnology = "";

            GraphService curGraph = null;

            double prevValue = 0d;

            boolean hasSignalCategoryChanged = false;
            double lastLabelYPosition = -1d;
            double time = 0d;
            double signalChangeStartTime = 0d;
            double value = 0d;
            double oldValidValue = 0d;

            System.out.println("MAXTIME: " + timeElapsedMs);

            for (int i = 0; i < signalArray.length(); i++) {
                JSONObject signalObject = signalArray.getJSONObject(i);
                String networkType = signalObject.optString("network_type");
                String catTechnology = signalObject.optString("cat_technology");
                //set proper signal strength attribute
                String signalAttribute = "signal_strength";
                String signalColor = "#ffffff";

                time = i > 0 ? ((double) signalObject.getInt("time_elapsed") / (double) timeElapsedMs) : 0d;

                oldValidValue = value > 0d ? value : oldValidValue;

                if ("LTE".equals(networkType)) {
                    if (!lastNetworkType.equals(networkType) && !lastCatTechnology.equals(catTechnology)) {
                        if (curGraph != null) {
                            curGraph.addValue((1 - prevValue), time);
                        }

                        GraphService newGraph = StaticGraph.addGraph(signalGraph,
                                Color.parseColor(COLOR_SIGNAL_4G), signalArray.length() == 1 ? true : false);
                        signalList.add(newGraph);
                        if (curGraph != null) {
                            curGraph.addValue((1 - prevValue), time);
                        }
                        signalChangeStartTime = time;
                        hasSignalCategoryChanged = true;
                        curGraph = newGraph;
                    }
                    has4G = true;
                    signalAttribute = "lte_rsrp";
                    signalColor = COLOR_SIGNAL_4G;
                    value = getRelativeSignal(signalBoundsRsrp, signalAttribute, signalObject);
                } else if ("WLAN".equals(networkType)) {
                    if (!lastNetworkType.equals(networkType) && !lastCatTechnology.equals(catTechnology)) {
                        if (curGraph != null) {
                            curGraph.addValue((1 - prevValue), time);
                        }

                        GraphService newGraph = StaticGraph.addGraph(signalGraph,
                                Color.parseColor(COLOR_SIGNAL_WLAN), signalArray.length() == 1 ? true : false);
                        signalList.add(newGraph);

                        if (curGraph != null) {
                            curGraph.addValue((1 - prevValue), time);
                        }
                        signalChangeStartTime = time;
                        hasSignalCategoryChanged = true;
                        curGraph = newGraph;
                    }
                    hasWlan = true;
                    signalAttribute = "signal_strength";
                    signalColor = COLOR_SIGNAL_WLAN;
                    value = getRelativeSignal(signalBoundsWlan, signalAttribute, signalObject);
                } else {
                    if (!lastNetworkType.equals(networkType)) {
                        signalChangeStartTime = time;
                        hasSignalCategoryChanged = true;

                        if (curGraph != null) {
                            curGraph.addValue((1 - prevValue), time);
                        }

                        if ((!lastCatTechnology.equals(catTechnology)) && ("4G".equals(lastCatTechnology)
                                || "WLAN".equals(lastCatTechnology) || "".equals(lastCatTechnology))) {

                            GraphService newGraph = StaticGraph.addGraph(signalGraph,
                                    Color.parseColor(COLOR_SIGNAL_3G),
                                    signalArray.length() == 1 ? true : false);

                            signalList.add(newGraph);
                            if (curGraph != null) {
                                curGraph.addValue((1 - prevValue), time);
                            }
                            curGraph = newGraph;
                        }
                    }
                    has3G = true;
                    signalAttribute = "signal_strength";
                    signalColor = COLOR_SIGNAL_3G;
                    value = getRelativeSignal(signalBoundsMobile, signalAttribute, signalObject);
                }

                if (value > 0d) {
                    System.out.println("SIGNAL: " + value + "@" + time + " = " + signalObject);
                    if (value >= 0d && curGraph != null) {
                        if (hasSignalCategoryChanged) {
                            curGraph.addValue((1 - value), signalChangeStartTime);
                            hasSignalCategoryChanged = false;

                            if (lastLabelYPosition == -1d) {
                                lastLabelYPosition = (float) (1 - (value > 0d ? value : prevValue));
                            } else {
                                if (Math.abs(signalChangeStartTime - time) < .125d) {
                                    float curPosition = (float) (1 - (value > 0d ? value : prevValue));
                                    if (Math.abs(curPosition - lastLabelYPosition) <= .11d) {
                                        lastLabelYPosition = curPosition
                                                + (curPosition > lastLabelYPosition ? +.1d : -.1d);
                                    } else {
                                        lastLabelYPosition = curPosition;
                                    }
                                } else {
                                    lastLabelYPosition = (float) (1 - (value > 0d ? value : prevValue));
                                }
                            }

                            //lastLabelXPosition = (float) time;                        
                            double labelDiff = lastLabelYPosition - (1 - value);

                            System.out.println("i" + i + " -> " + lastLabelYPosition + " : " + (1 - value)
                                    + " diff: " + Math.abs(labelDiff) + " istoolow (<.09d)? "
                                    + (Math.abs(labelDiff) < .09d));
                            if (Math.abs(labelDiff) < .09d && i == 0) {
                                if (labelDiff < 0d) {
                                    lastLabelYPosition = lastLabelYPosition < .50d ? lastLabelYPosition - .075d
                                            : lastLabelYPosition + .075d;
                                } else {
                                    lastLabelYPosition = lastLabelYPosition < .50d ? lastLabelYPosition + .075d
                                            : lastLabelYPosition - .075d;
                                }
                            }

                            signalGraph.addLabel((float) signalChangeStartTime, (float) lastLabelYPosition,
                                    networkType, signalColor);
                        }

                        //System.out.println("ADDING VALUE TO GRAPH " + (1 - value) + " on: " + time);
                        curGraph.addValue((1 - value), time);
                        prevValue = value;
                    }
                }

                lastNetworkType = networkType;
                lastCatTechnology = catTechnology;
            }

            //draw signal graph to the end
            if (prevValue > 0 && curGraph != null) {
                curGraph.addValue((1 - prevValue), 1f);
            }

            signalGraph.clearLabels(CustomizableGraphView.LABELLIST_VERTICAL_MAX);
            signalGraph.clearLabels(CustomizableGraphView.LABELLIST_VERTICAL_MIN);

            if (has3G) {
                signalGraph.addLabelVMax(String.valueOf(signalBoundsMobile.max), COLOR_SIGNAL_3G);
                signalGraph.addLabelVMin(String.valueOf(signalBoundsMobile.min), COLOR_SIGNAL_3G);
            }
            if (has4G) {
                signalGraph.addLabelVMax(String.valueOf(signalBoundsRsrp.max), COLOR_SIGNAL_4G);
                signalGraph.addLabelVMin(String.valueOf(signalBoundsRsrp.min), COLOR_SIGNAL_4G);
            }
            if (hasWlan) {
                signalGraph.addLabelVMax(String.valueOf(signalBoundsWlan.max), COLOR_SIGNAL_WLAN);
                signalGraph.addLabelVMin(String.valueOf(signalBoundsWlan.min), COLOR_SIGNAL_WLAN);
            }
            //signalGraph.repaint(getContext());
        } else if (signalGraph != null && signalGraph.getGraphs().size() > 0) {
            Log.d("ResultGraphView", "REDRAWING SIGNAL GRAPH");
            //signalGraph.repaint(getContext());
            signalGraph.invalidate();
        }

        signalProgress.setVisibility(View.GONE);

        if (uploadArray != null && uploadArray != null && uploadArray.length() > 0
                && ulGraph.getGraphs().size() < 1) {
            Log.d("ResultGraphView", "DRAWING UL GRAPH");
            drawCurve(uploadArray, ulGraph, COLOR_UL_GRAPH, String
                    .valueOf(Math.round(result.getJSONObject(0).optDouble("duration_upload_ms") / 1000d)));

            addStaticMarker(signalArray, signalGraph, COLOR_UL_GRAPH, 70,
                    result.getJSONObject(0).optDouble("time_ul_ms"),
                    result.getJSONObject(0).optDouble("time_ul_ms")
                            + result.getJSONObject(0).optDouble("duration_upload_ms"),
                    timeElapsed * 1000);

            double timeUl = result.getJSONObject(0).optDouble("duration_upload_ms");
            long timeElapsedUl = Math.round(timeUl / 1000);
            ulGraph.setRowLinesLabelList(SPEED_LABELS);
            ulGraph.updateGrid((int) timeElapsedUl, 4.5f);
        } else if (uploadArray.length() > 0 && ulGraph != null && ulGraph.getGraphs().size() > 0) {
            Log.d("ResultGraphView", "REDRAWING UL GRAPH");
            //ulGraph.repaint(getContext());
            ulGraph.invalidate();
        }

        ulProgress.setVisibility(View.GONE);

        if (downloadArray != null && downloadArray != null && downloadArray.length() > 0
                && dlGraph.getGraphs().size() < 1) {
            Log.d("ResultGraphView", "DRAWING DL GRAPH");
            drawCurve(downloadArray, dlGraph, COLOR_DL_GRAPH, String
                    .valueOf(Math.round(result.getJSONObject(0).optDouble("duration_download_ms") / 1000d)));
            addStaticMarker(signalArray, signalGraph, COLOR_DL_GRAPH, 70,
                    result.getJSONObject(0).optDouble("time_dl_ms"),
                    result.getJSONObject(0).optDouble("time_dl_ms")
                            + result.getJSONObject(0).optDouble("duration_download_ms"),
                    timeElapsed * 1000);

            double timeDl = result.getJSONObject(0).optDouble("duration_download_ms");
            long timeElapsedDl = Math.round(timeDl / 1000);
            dlGraph.setRowLinesLabelList(SPEED_LABELS);
            dlGraph.updateGrid((int) timeElapsedDl, 4.5f);
        } else if (downloadArray.length() > 0 && dlGraph != null && dlGraph.getGraphs().size() > 0) {
            Log.d("ResultGraphView", "REDRAWING DL GRAPH");
            //dlGraph.repaint(getContext());
            dlGraph.invalidate();
        }

        dlProgress.setVisibility(View.GONE);

    } catch (Exception e) {
        if (signalGraph != null) {
            signalGraph.invalidate();
        }
        if (ulGraph != null) {
            ulGraph.invalidate();
        }
        if (dlGraph != null) {
            dlGraph.invalidate();
        }
        e.printStackTrace();
        //TODO show no data available view 
    }
}

From source file:com.amaze.filemanager.fragments.ProcessViewer.java

public void processResults(final DataPackage b) {
    if (!running)
        return;/*from w w  w. j a  va 2  s .  co m*/
    if (getResources() == null)
        return;
    if (b != null) {
        int id = b.getId();
        final Integer id1 = new Integer(id);
        if (!CancelledCopyIds.contains(id1)) {
            if (CopyIds.contains(id1)) {
                boolean completed = b.isCompleted();
                View process = rootView.findViewWithTag("copy" + id);
                if (completed) {
                    try {
                        rootView.removeViewInLayout(process);
                        CopyIds.remove(CopyIds.indexOf(id1));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    String name = b.getName();
                    int p1 = b.getP1();
                    int p2 = b.getP2();
                    long total = b.getTotal();
                    long done = b.getDone();
                    boolean move = b.isMove();
                    String text = utils.getString(getActivity(), R.string.copying) + "\n" + name + "\n"
                            + utils.readableFileSize(done) + "/" + utils.readableFileSize(total) + "\n" + p1
                            + "%";
                    if (move) {
                        text = utils.getString(getActivity(), R.string.moving) + "\n" + name + "\n"
                                + utils.readableFileSize(done) + "/" + utils.readableFileSize(total) + "\n" + p1
                                + "%";
                    }
                    ((TextView) process.findViewById(R.id.progressText)).setText(text);
                    ProgressBar p = (ProgressBar) process.findViewById(R.id.progressBar1);
                    p.setProgress(p1);
                    p.setSecondaryProgress(p2);
                }
            } else {
                CardView root = (android.support.v7.widget.CardView) getActivity().getLayoutInflater()
                        .inflate(R.layout.processrow, null);
                root.setTag("copy" + id);

                ImageButton cancel = (ImageButton) root.findViewById(R.id.delete_button);
                TextView progressText = (TextView) root.findViewById(R.id.progressText);

                Drawable icon = icons.getCopyDrawable();
                boolean move = b.isMove();
                if (move) {
                    icon = icons.getCutDrawable();
                }
                if (mainActivity.theme1 == 1) {

                    cancel.setImageResource(R.drawable.ic_action_cancel);
                    root.setCardBackgroundColor(R.color.cardView_foreground);
                    root.setCardElevation(0f);
                    progressText.setTextColor(Color.WHITE);
                } else {

                    icon.setColorFilter(Color.parseColor("#666666"), PorterDuff.Mode.SRC_ATOP);
                    progressText.setTextColor(Color.BLACK);
                }

                ((ImageView) root.findViewById(R.id.progressImage)).setImageDrawable(icon);
                cancel.setOnClickListener(new View.OnClickListener() {

                    public void onClick(View p1) {
                        Toast.makeText(getActivity(), utils.getString(getActivity(), R.string.stopping),
                                Toast.LENGTH_LONG).show();
                        Intent i = new Intent("copycancel");
                        i.putExtra("id", id1);
                        getActivity().sendBroadcast(i);
                        rootView.removeView(rootView.findViewWithTag("copy" + id1));

                        CopyIds.remove(CopyIds.indexOf(id1));
                        CancelledCopyIds.add(id1);
                        // TODO: Implement this method
                    }
                });

                String name = b.getName();
                int p1 = b.getP1();
                int p2 = b.getP2();

                String text = utils.getString(getActivity(), R.string.copying) + "\n" + name;
                if (move) {
                    text = utils.getString(getActivity(), R.string.moving) + "\n" + name;
                }
                progressText.setText(text);
                ProgressBar p = (ProgressBar) root.findViewById(R.id.progressBar1);
                p.setProgress(p1);
                p.setSecondaryProgress(p2);
                CopyIds.add(id1);
                rootView.addView(root);
            }
        }
    }
}