Example usage for android.graphics Color MAGENTA

List of usage examples for android.graphics Color MAGENTA

Introduction

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

Prototype

int MAGENTA

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

Click Source Link

Usage

From source file:com.example.android.mediaeffects.MediaEffectsFragment.java

private void initEffect() {
    EffectFactory effectFactory = mEffectContext.getFactory();
    if (mEffect != null) {
        mEffect.release();// ww w.  jav  a  2s .  c  o  m
    }
    // Initialize the correct effect based on the selected menu/action item
    switch (mCurrentEffect) {

    case R.id.none:
        break;

    case R.id.autofix:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_AUTOFIX);
        mEffect.setParameter("scale", 0.5f);
        break;

    case R.id.bw:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_BLACKWHITE);
        mEffect.setParameter("black", .1f);
        mEffect.setParameter("white", .7f);
        break;

    case R.id.brightness:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_BRIGHTNESS);
        mEffect.setParameter("brightness", 2.0f);
        break;

    case R.id.contrast:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_CONTRAST);
        mEffect.setParameter("contrast", 1.4f);
        break;

    case R.id.crossprocess:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_CROSSPROCESS);
        break;

    case R.id.documentary:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_DOCUMENTARY);
        break;

    case R.id.duotone:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_DUOTONE);
        mEffect.setParameter("first_color", Color.YELLOW);
        mEffect.setParameter("second_color", Color.DKGRAY);
        break;

    case R.id.filllight:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FILLLIGHT);
        mEffect.setParameter("strength", .8f);
        break;

    case R.id.fisheye:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FISHEYE);
        mEffect.setParameter("scale", .5f);
        break;

    case R.id.flipvert:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FLIP);
        mEffect.setParameter("vertical", true);
        break;

    case R.id.fliphor:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_FLIP);
        mEffect.setParameter("horizontal", true);
        break;

    case R.id.grain:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_GRAIN);
        mEffect.setParameter("strength", 1.0f);
        break;

    case R.id.grayscale:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_GRAYSCALE);
        break;

    case R.id.lomoish:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_LOMOISH);
        break;

    case R.id.negative:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_NEGATIVE);
        break;

    case R.id.posterize:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_POSTERIZE);
        break;

    case R.id.rotate:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_ROTATE);
        mEffect.setParameter("angle", 180);
        break;

    case R.id.saturate:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_SATURATE);
        mEffect.setParameter("scale", .5f);
        break;

    case R.id.sepia:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_SEPIA);
        break;

    case R.id.sharpen:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_SHARPEN);
        break;

    case R.id.temperature:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_TEMPERATURE);
        mEffect.setParameter("scale", .9f);
        break;

    case R.id.tint:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_TINT);
        mEffect.setParameter("tint", Color.MAGENTA);
        break;

    case R.id.vignette:
        mEffect = effectFactory.createEffect(EffectFactory.EFFECT_VIGNETTE);
        mEffect.setParameter("scale", .5f);
        break;

    default:
        break;
    }
}

From source file:com.TwentyCodes.android.IOIOTruck.NavigationActivity.java

/**
 * called when the directions overlay is generated
 * (non-Javadoc)//from w  ww  .  j  ava  2 s .  c  o m
 * @see com.TwentyCodes.android.overlays.DirectionsOverlay.OnDirectionsCompleteListener#onDirectionsComplete(com.TwentyCodes.android.overlays.DirectionsOverlay)
 */
@Override
public void onDirectionsComplete(DirectionsOverlay directionsOverlay) {
    ArrayList<PathOverlay> path = directionsOverlay.getPath();

    if (path.size() > 0) {
        mWayPoints = new ArrayList<PathOverlay>();
        ArrayList<GeoPoint> points = new ArrayList<GeoPoint>();
        points.add(path.get(0).getStartPoint());
        for (PathOverlay item : path)
            if (item.getEndPoint() != null) {
                points.add(item.getEndPoint());
                mWayPoints.add(new PathOverlay(item.getEndPoint(), 5, Color.GRAY));
            }

        mPoints = points;
        mMap.setDestination(points.get(0));
        mWayPoints.add(new PathOverlay(points.get(0), 5, Color.MAGENTA));
        mMap.getMap().getOverlays().addAll(mWayPoints);
        mWayPoints.addAll(path);
    }
}

From source file:com.example.android.navigationdrawerexample.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    StrictMode.enableDefaults(); //STRICT MODE ENABLED

    db = new DBHelper(this);
    session = new Session(getApplicationContext());

    inflatedView = getLayoutInflater().inflate(R.layout.full_layout, null);
    mTitle = mDrawerTitle = getTitle();//from  w  w w .j a  v  a 2s. c  o  m
    login_layout = (RelativeLayout) findViewById(R.id.login_layout);
    //   order_list_layout= (RelativeLayout) findViewById(R.id.order_list_layout);
    signup_layout = (RelativeLayout) findViewById(R.id.signup_layout);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    actionBar = getActionBar();

    text = (TextView) inflatedView.findViewById(R.id.user_name);
    login_option = (TextView) inflatedView.findViewById(R.id.textView1);

    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    order_list = (ListView) findViewById(R.id.order_list);

    final LayoutInflater factory = getLayoutInflater();

    final View vendor_menu = factory.inflate(R.layout.vendor_menu, null);
    final View order_menu = factory.inflate(R.layout.my_order, null);
    menu_list = (ListView) vendor_menu.findViewById(R.id.menu_list);
    // loginPopup= (TextView) vendor_menu.findViewById(R.id.menu_title);
    // Log.d
    //menu_list.addView(order_menu,0);

    Signup = (Button) findViewById(R.id.Signup);
    Gosignup = (Button) findViewById(R.id.Gosignup);
    Login = (ImageButton) findViewById(R.id.Login);

    Sign_username = (EditText) findViewById(R.id.SignUsername);
    Sign_name = (EditText) findViewById(R.id.vendor);
    Sign_pass = (EditText) findViewById(R.id.SignPass);
    Sign_cpass = (EditText) findViewById(R.id.SignCpass);
    Sign_phone = (EditText) findViewById(R.id.Phone);

    Login_pass = (EditText) findViewById(R.id.Logpass);
    Login_email = (EditText) findViewById(R.id.Logusername);

    // Log_username= (EditText) findViewById(R.id.Logusername);

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener

    adapter = new MyAdapter(this);
    //adapter2=new MyAdapter2(this);
    // menu_adapter=new MyAdapter2(this);
    mDrawerList.setAdapter(adapter);
    mDrawerList.setDividerHeight(0);
    //mDrawerList.setAdapter(adapter);
    // order_list.setAdapter(adapter2);
    // menu_list.setAdapter(menu_adapter);

    menu_list.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, adapter.mPlanetTitles));

    ImageView floatoption = new ImageView(this);
    floatoption.setImageResource(R.drawable.foption);

    ImageView floatadd = new ImageView(this);
    floatadd.setImageResource(R.drawable.fplus);

    floatin = new ImageView(this);
    floatin.setImageResource(R.drawable.flogin);

    floatout = new ImageView(this);
    floatout.setImageResource(R.drawable.flogout);

    ImageView floatrefresh = new ImageView(this);
    floatrefresh.setImageResource(R.drawable.refresh);

    itemBuilder = new SubActionButton.Builder(this);

    loginout = itemBuilder.setContentView(floatin).build();
    refresh = itemBuilder.setContentView(floatrefresh).build();
    additem = itemBuilder.setContentView(floatadd).build();

    actionButton = new FloatingActionButton.Builder(this).setContentView(floatoption).build();

    actionMenu = new FloatingActionMenu.Builder(this).addSubActionView(loginout).addSubActionView(additem)
            .addSubActionView(refresh)

            // ...
            .attachTo(actionButton).build();

    Signup.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {

            View v = mDrawerList.getChildAt(0);
            View v2 = mDrawerList.getChildAt(5);

            text = (TextView) v.findViewById(R.id.user_name);
            login_option = (TextView) v2.findViewById(R.id.textView1);
            profile = (ImageView) v.findViewById(R.id.user_image);
            profile.setImageResource(R.drawable.welcome);
            text.setTextSize(20);
            text.setTextColor(Color.MAGENTA);
            text.setText("" + Sign_name.getText().toString());

            login_option.setText("Logout");

            floatout.setImageResource(R.drawable.flogout);
            // loginout.setContentView(floatout);
            long id = db.Insert(Sign_username.getText().toString(), Sign_name.getText().toString(),
                    Sign_pass.getText().toString(), Sign_phone.getText().toString());

            Log.d("This is-----------==", (String) text.getText() + id);

            //mDrawerList.invalidateViews();

            //mDrawerList.removeViewAt(0);
            adapter.notifyDataSetChanged();

            loginout.removeView(floatin);
            loginout.setContentView(floatout);

            order_list.setVisibility(View.VISIBLE);
            signup_layout.setVisibility(View.INVISIBLE);
            login_layout.setVisibility(View.INVISIBLE);

        }
    });

    Login.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            user_name = Login_email.getText().toString();
            user_pass = Login_pass.getText().toString();

            new GetAllCustomerTask().execute(new ApiConnector());
            new Order_details().execute(new ApiConnector());

        }
    });

    if (!session.getusename().equals("")) {
        user_id = session.getusename();
        user_name = session.getusename();
        user_pass = session.getpassword();
        login_layout.setVisibility(View.INVISIBLE);
        new GetAllCustomerTask().execute(new ApiConnector());
        // new Order_details().execute(new ApiConnector());
        // View vt = mDrawerList.getChildAt(0);
        //login_check(jsonArray);

        //new Order_details().execute(new ApiConnector());
    }

    additem.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (logged_in) {
                Intent i = new Intent(getApplicationContext(), Add_Item.class);
                startActivity(i);
            } else
                Toast.makeText(getApplicationContext(), "You Need To Login...", Toast.LENGTH_LONG).show();

        }
    });
    loginout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (logged_in) {
                session.setusename("", "");
                finish();
                startActivity(getIntent());
                Toast.makeText(getApplicationContext(), "You are Loged Out", Toast.LENGTH_SHORT).show();
            } else
                Toast.makeText(getApplicationContext(), "You Need To Login...", Toast.LENGTH_LONG).show();

        }
    });

    Login.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            user_name = Login_email.getText().toString();
            user_pass = Login_pass.getText().toString();
            new GetAllCustomerTask().execute(new ApiConnector());
            //   new Order_details().execute(new ApiConnector());

        }
    });

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    order_list.setOnItemClickListener(new OrderItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    ActionBar actionBar = getActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(0xFF3BBD8F));

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            text = (TextView) inflatedView.findViewById(R.id.user_name);
            Log.d("Thit is----------------", (String) text.getText());
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }

}

From source file:com.bfemmer.portdawgtoolkit.DashboardFragment.java

private RadarData getRadarData() {
    ArrayList<String> labels = new ArrayList<>();
    labels.add("F2F");
    labels.add("EPR");
    labels.add("IMR");
    labels.add("TFAT");
    labels.add("UGR");
    labels.add("UOO");
    labels.add("VEH");
    labels.add("483");

    ArrayList<Entry> entries = new ArrayList<>();
    entries.add(new Entry(80, 0));
    entries.add(new Entry(100, 1));
    entries.add(new Entry(100, 2));
    entries.add(new Entry(100, 3));
    entries.add(new Entry(100, 4));
    entries.add(new Entry(100, 5));
    entries.add(new Entry(20, 6));
    entries.add(new Entry(60, 7));

    ArrayList<Entry> entries2 = new ArrayList<>();
    entries2.add(new Entry(60, 0));
    entries2.add(new Entry(100, 1));
    entries2.add(new Entry(80, 2));
    entries2.add(new Entry(100, 3));
    entries2.add(new Entry(100, 4));
    entries2.add(new Entry(60, 5));
    entries2.add(new Entry(100, 6));
    entries2.add(new Entry(0, 7));

    ArrayList<Entry> entries3 = new ArrayList<>();
    entries3.add(new Entry(100, 0));
    entries3.add(new Entry(80, 1));
    entries3.add(new Entry(80, 2));
    entries3.add(new Entry(80, 3));
    entries3.add(new Entry(80, 4));
    entries3.add(new Entry(60, 5));
    entries3.add(new Entry(100, 6));
    entries3.add(new Entry(50, 7));

    ArrayList<Entry> entries4 = new ArrayList<>();
    entries4.add(new Entry(70, 0));
    entries4.add(new Entry(85, 1));
    entries4.add(new Entry(85, 2));
    entries4.add(new Entry(85, 3));
    entries4.add(new Entry(100, 4));
    entries4.add(new Entry(100, 5));
    entries4.add(new Entry(75, 6));
    entries4.add(new Entry(75, 7));

    ArrayList<Entry> entries5 = new ArrayList<>();
    entries5.add(new Entry(65, 0));
    entries5.add(new Entry(65, 1));
    entries5.add(new Entry(65, 2));
    entries5.add(new Entry(65, 3));
    entries5.add(new Entry(65, 4));
    entries5.add(new Entry(65, 5));
    entries5.add(new Entry(65, 6));
    entries5.add(new Entry(65, 7));

    ArrayList<Entry> entries6 = new ArrayList<>();
    entries6.add(new Entry(25, 0));
    entries6.add(new Entry(55, 1));
    entries6.add(new Entry(25, 2));
    entries6.add(new Entry(55, 3));
    entries6.add(new Entry(25, 4));
    entries6.add(new Entry(55, 5));
    entries6.add(new Entry(25, 6));
    entries6.add(new Entry(55, 7));

    ArrayList<Entry> entries7 = new ArrayList<>();
    entries7.add(new Entry(30, 0));
    entries7.add(new Entry(30, 1));
    entries7.add(new Entry(30, 2));
    entries7.add(new Entry(30, 3));
    entries7.add(new Entry(30, 4));
    entries7.add(new Entry(30, 5));
    entries7.add(new Entry(30, 6));
    entries7.add(new Entry(30, 7));

    //        ArrayList<Entry> entries = new ArrayList<>();
    //        entries.add(new Entry(0.8f, 0));
    //        entries.add(new Entry(1f, 1));
    //        entries.add(new Entry(1f, 2));
    //        entries.add(new Entry(1f, 3));
    //        entries.add(new Entry(1f, 4));
    //        entries.add(new Entry(1f, 5));
    //        entries.add(new Entry(0.2f, 6));
    //        entries.add(new Entry(0.6f, 7));
    ////w  w  w  .j a  v  a2  s.  com
    //        ArrayList<Entry> entries2 = new ArrayList<>();
    //        entries2.add(new Entry(0.6f, 0));
    //        entries2.add(new Entry(1f, 1));
    //        entries2.add(new Entry(0.8f, 2));
    //        entries2.add(new Entry(1f, 3));
    //        entries2.add(new Entry(1f, 4));
    //        entries2.add(new Entry(0.6f, 5));
    //        entries2.add(new Entry(1f, 6));
    //        entries2.add(new Entry(0f, 7));
    //
    //        ArrayList<Entry> entries3 = new ArrayList<>();
    //        entries3.add(new Entry(1f, 0));
    //        entries3.add(new Entry(0.8f, 1));
    //        entries3.add(new Entry(0.8f, 2));
    //        entries3.add(new Entry(0.8f, 3));
    //        entries3.add(new Entry(0.8f, 4));
    //        entries3.add(new Entry(0.6f, 5));
    //        entries3.add(new Entry(1f, 6));
    //        entries3.add(new Entry(0.5f, 7));

    RadarDataSet radardataset = new RadarDataSet(entries, "Fleet");
    RadarDataSet cargoradardataset = new RadarDataSet(entries2, "Cargo");
    RadarDataSet rampradardataset = new RadarDataSet(entries3, "Ramp");
    RadarDataSet paxradardataset = new RadarDataSet(entries4, "Pax");
    RadarDataSet atocradardataset = new RadarDataSet(entries5, "ATOC");
    RadarDataSet lpradardataset = new RadarDataSet(entries6, "L/P");
    RadarDataSet shradardataset = new RadarDataSet(entries7, "S/H");

    radardataset.setColor(Color.BLUE);
    cargoradardataset.setColor(Color.RED);
    rampradardataset.setColor(Color.GREEN);
    paxradardataset.setColor(Color.YELLOW);
    atocradardataset.setColor(Color.CYAN);
    lpradardataset.setColor(Color.MAGENTA);
    shradardataset.setColor(Color.DKGRAY);

    radardataset.setDrawFilled(false);
    cargoradardataset.setDrawFilled(false);
    rampradardataset.setDrawFilled(false);
    paxradardataset.setDrawFilled(false);
    atocradardataset.setDrawFilled(false);
    lpradardataset.setDrawFilled(false);
    shradardataset.setDrawFilled(false);

    List<RadarDataSet> radarDataSets = new ArrayList<>();
    radarDataSets.add(radardataset);
    radarDataSets.add(cargoradardataset);
    radarDataSets.add(rampradardataset);
    radarDataSets.add(paxradardataset);
    radarDataSets.add(atocradardataset);
    radarDataSets.add(lpradardataset);
    radarDataSets.add(shradardataset);

    RadarData data = new RadarData(labels, radarDataSets);

    return data;
}

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;/*w w  w.j ava2s. c  om*/
}

From source file:com.google.blockly.android.ui.AbstractBlockView.java

/**
 * This is a developer testing function subclasses can call to draw dots at the model's location
 * of all connections on this block.  Never called by default.
 *
 * @param c The canvas to draw on./*from  ww  w  . j  a  va  2 s .c om*/
 */
protected void drawConnectorCenters(Canvas c) {
    List<Connection> connections = mBlock.getAllConnections();
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.FILL);
    for (int i = 0; i < connections.size(); i++) {
        Connection conn = connections.get(i);
        if (conn.inDragMode()) {
            if (conn.isConnected()) {
                paint.setColor(Color.RED);
            } else {
                paint.setColor(Color.MAGENTA);
            }
        } else {
            if (conn.isConnected()) {
                paint.setColor(Color.GREEN);
            } else {
                paint.setColor(Color.CYAN);
            }
        }

        // Compute connector position relative to this view from its offset to block origin in
        // Workspace coordinates.
        mTempWorkspacePoint.set(conn.getPosition().x - mBlock.getPosition().x,
                conn.getPosition().y - mBlock.getPosition().y);
        mHelper.workspaceToVirtualViewDelta(mTempWorkspacePoint, mTempConnectionPosition);
        if (mHelper.useRtl()) {
            // In RTL mode, add block view size to x coordinate. This is counter-intuitive, but
            // equivalent to "x = size - (-x)", with the inner negation "-x" undoing the
            // side-effect of workspaceToVirtualViewDelta reversing the x coordinate. This is,
            // the addition mirrors the re-negated in-block x coordinate w.r.t. the right-hand
            // side of the block view, which is the origin of the block in RTL mode.
            mTempConnectionPosition.x += mBlockViewSize.x;
        }
        c.drawCircle(mTempConnectionPosition.x, mTempConnectionPosition.y, 10, paint);
    }
}

From source file:xyz.berial.textinputlayout.TextInputLayout.java

private int getThemeAttrColor(int attr) {
    TypedValue tv = new TypedValue();
    if (getContext().getTheme().resolveAttribute(attr, tv, true)) {
        return tv.data;
    } else {/*from  w ww  . j a v a2 s  .c  o m*/
        return Color.MAGENTA;
    }
}

From source file:org.buffer.android.buffertextinputlayout.BufferTextInputLayout.java

/**
 * Whether the error functionality is enabled or not in this layout. Enabling this
 * functionality before setting an error message via {@link #setError(CharSequence)}, will mean
 * that this layout will not change size when an error is displayed.
 *
 * @attr ref android.support.design.R.styleable#TextInputLayout_errorEnabled
 *///from ww w  . j  a  v a2 s .  c  om
public void setErrorEnabled(boolean enabled) {
    if (errorEnabled != enabled) {
        if (errorView != null) {
            ViewCompat.animate(errorView).cancel();
        }
        if (enabled) {
            errorView = new TextView(getContext());
            boolean useDefaultColor = false;
            try {
                TextViewCompat.setTextAppearance(errorView, errorTextAppearance);
                if (Build.VERSION.SDK_INT >= 23
                        && errorView.getTextColors().getDefaultColor() == Color.MAGENTA) {
                    // Caused by our theme not extending from Theme.Design*. On API 23 and
                    // above, unresolved theme attrs result in MAGENTA rather than an exception.
                    // Flag so that we use a decent default
                    useDefaultColor = true;
                }
            } catch (Exception e) {
                // Caused by our theme not extending from Theme.Design*. Flag so that we use
                // a decent default
                useDefaultColor = true;
            }
            if (useDefaultColor) {
                // Probably caused by our theme not extending from Theme.Design*. Instead
                // we manually set something appropriate
                TextViewCompat.setTextAppearance(errorView,
                        android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Caption);
                errorView.setTextColor(
                        ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light));
            }
            errorView.setVisibility(INVISIBLE);
            ViewCompat.setAccessibilityLiveRegion(errorView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
            addIndicator(errorView, 0);
        } else {
            errorShown = false;
            updateEditTextBackground();
            removeIndicator(errorView);
            errorView = null;
        }
        errorEnabled = enabled;
    }
}

From source file:android.support.design.widget.TextInputLayout.java

/**
 * Whether the error functionality is enabled or not in this layout. Enabling this
 * functionality before setting an error message via {@link #setError(CharSequence)}, will mean
 * that this layout will not change size when an error is displayed.
 *
 * @attr ref android.support.design.R.styleable#TextInputLayout_errorEnabled
 *//*  ww  w.ja  va 2  s.co  m*/
public void setErrorEnabled(boolean enabled) {
    if (mErrorEnabled != enabled) {
        if (mErrorView != null) {
            ViewCompat.animate(mErrorView).cancel();
        }

        if (enabled) {
            mErrorView = new AppCompatTextView(getContext());
            mErrorView.setId(R.id.textinput_error);
            if (mTypeface != null) {
                mErrorView.setTypeface(mTypeface);
            }
            boolean useDefaultColor = false;
            try {
                TextViewCompat.setTextAppearance(mErrorView, mErrorTextAppearance);

                if (Build.VERSION.SDK_INT >= 23
                        && mErrorView.getTextColors().getDefaultColor() == Color.MAGENTA) {
                    // Caused by our theme not extending from Theme.Design*. On API 23 and
                    // above, unresolved theme attrs result in MAGENTA rather than an exception.
                    // Flag so that we use a decent default
                    useDefaultColor = true;
                }
            } catch (Exception e) {
                // Caused by our theme not extending from Theme.Design*. Flag so that we use
                // a decent default
                useDefaultColor = true;
            }
            if (useDefaultColor) {
                // Probably caused by our theme not extending from Theme.Design*. Instead
                // we manually set something appropriate
                TextViewCompat.setTextAppearance(mErrorView,
                        android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Caption);
                mErrorView.setTextColor(
                        ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light));
            }
            mErrorView.setVisibility(INVISIBLE);
            ViewCompat.setAccessibilityLiveRegion(mErrorView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
            addIndicator(mErrorView, 0);
        } else {
            mErrorShown = false;
            updateEditTextBackground();
            removeIndicator(mErrorView);
            mErrorView = null;
        }
        mErrorEnabled = enabled;
    }
}

From source file:com.commonsware.cwac.crossport.design.widget.TextInputLayout.java

/**
   * Whether the error functionality is enabled or not in this layout. Enabling this
   * functionality before setting an error message via {@link #setError(CharSequence)}, will mean
   * that this layout will not change size when an error is displayed.
 *
 * @attr ref android.support.design.R.styleable#TextInputLayout_errorEnabled
 *///w  w w  .j  a v  a 2  s . c om
public void setErrorEnabled(boolean enabled) {
    if (mErrorEnabled != enabled) {
        if (mErrorView != null) {
            mErrorView.animate().cancel();
        }

        if (enabled) {
            mErrorView = new TextView(getContext());
            mErrorView.setId(R.id.textinput_error);
            if (mTypeface != null) {
                mErrorView.setTypeface(mTypeface);
            }
            boolean useDefaultColor = false;
            try {
                TextViewCompat.setTextAppearance(mErrorView, mErrorTextAppearance);

                if (Build.VERSION.SDK_INT >= 23
                        && mErrorView.getTextColors().getDefaultColor() == Color.MAGENTA) {
                    // Caused by our theme not extending from Theme.Design*. On API 23 and
                    // above, unresolved theme attrs result in MAGENTA rather than an exception.
                    // Flag so that we use a decent default
                    useDefaultColor = true;
                }
            } catch (Exception e) {
                // Caused by our theme not extending from Theme.Design*. Flag so that we use
                // a decent default
                useDefaultColor = true;
            }
            if (useDefaultColor) {
                // Probably caused by our theme not extending from Theme.Design*. Instead
                // we manually set something appropriate
                TextViewCompat.setTextAppearance(mErrorView, android.R.style.TextAppearance_Material_Caption);
                mErrorView.setTextColor(
                        ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light));
            }
            mErrorView.setVisibility(INVISIBLE);
            ViewCompat.setAccessibilityLiveRegion(mErrorView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
            addIndicator(mErrorView, 0);
        } else {
            mErrorShown = false;
            updateEditTextBackground();
            removeIndicator(mErrorView);
            mErrorView = null;
        }
        mErrorEnabled = enabled;
    }
}