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:Main.java

public static int getRandomColor() {
    List<Integer> colors = new ArrayList<>();
    colors.add(Color.BLACK);//  w  w w .  j a  v a2  s. com
    colors.add(Color.RED);
    colors.add(Color.GREEN);
    colors.add(Color.BLUE);
    colors.add(Color.YELLOW);
    colors.add(Color.GRAY);
    colors.add(Color.MAGENTA);
    colors.add(Color.CYAN);
    colors.add(Color.LTGRAY);
    return colors.get(new Random().nextInt(colors.size()));
}

From source file:com.tfc.baseandroid.ui.fragment.FragmentB.java

@SuppressLint("SetTextI18n")
@Nullable//w w  w.jav  a2s  .  com
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.f_fragment, container, false);

    FrameLayout flRoot = (FrameLayout) view.findViewById(R.id.f_fragment_fl_root);
    TextView tvTitle = (TextView) view.findViewById(R.id.f_fragment_tv_title);

    flRoot.setBackgroundColor(Color.MAGENTA);
    tvTitle.setText("Fragment B");

    return view;
}

From source file:com.example.android.supportv4.graphics.DrawableCompatActivity.java

private void setColorTint() {
    DrawableCompat.setTint(mDrawable, Color.MAGENTA);
}

From source file:ca.farrelltonsolar.classic.MonitorActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    navigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager()
            .findFragmentById(R.id.navigation_drawer);
    // Set up the drawer.
    DrawerLayout layout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navigationDrawerFragment.setUp(R.id.navigation_drawer, layout);
    stl = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    stl.setDividerColors(Color.RED);
    stl.setSelectedIndicatorColors(Color.BLUE, Color.CYAN, Color.GREEN, Color.MAGENTA, Color.YELLOW);
    viewPager = (ViewPager) findViewById(R.id.pager);
    setupActionBar();//from  w  w  w.  j a v  a2s . c  om
    Log.d(getClass().getName(), "onCreate");
}

From source file:tellit.com.tellit.service.gcm.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*from w  ww  .  j a v  a  2  s  . c  om*/
 */
private void sendNotification(String message) {
    Intent notificationIntent = new Intent(this, Tellit.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    notificationIntent.putExtra("chat", "");
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, notificationIntent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Tellit").setContentText(message)
            .setAutoCancel(true).setVibrate(new long[] { 1000 }).setLights(Color.MAGENTA, 3000, 3000)
            .setWhen(System.currentTimeMillis()).setSound(defaultSoundUri).setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:android.support.v7.content.res.AppCompatColorStateListInflater.java

/**
 * Fill in this object based on the contents of an XML "selector" element.
 *//*from   www  .j  a v  a2s .  c o  m*/
private static ColorStateList inflate(@NonNull Resources r, @NonNull XmlPullParser parser,
        @NonNull AttributeSet attrs, @Nullable Resources.Theme theme)
        throws XmlPullParserException, IOException {
    final int innerDepth = parser.getDepth() + 1;
    int depth;
    int type;
    int defaultColor = DEFAULT_COLOR;

    int[][] stateSpecList = new int[20][];
    int[] colorList = new int[stateSpecList.length];
    int listSize = 0;

    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
        if (type != XmlPullParser.START_TAG || depth > innerDepth || !parser.getName().equals("item")) {
            continue;
        }

        final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.ColorStateListItem);
        final int baseColor = a.getColor(R.styleable.ColorStateListItem_android_color, Color.MAGENTA);

        float alphaMod = 1.0f;
        if (a.hasValue(R.styleable.ColorStateListItem_android_alpha)) {
            alphaMod = a.getFloat(R.styleable.ColorStateListItem_android_alpha, alphaMod);
        } else if (a.hasValue(R.styleable.ColorStateListItem_alpha)) {
            alphaMod = a.getFloat(R.styleable.ColorStateListItem_alpha, alphaMod);
        }

        a.recycle();

        // Parse all unrecognized attributes as state specifiers.
        int j = 0;
        final int numAttrs = attrs.getAttributeCount();
        int[] stateSpec = new int[numAttrs];
        for (int i = 0; i < numAttrs; i++) {
            final int stateResId = attrs.getAttributeNameResource(i);
            if (stateResId != android.R.attr.color && stateResId != android.R.attr.alpha
                    && stateResId != R.attr.alpha) {
                // Unrecognized attribute, add to state set
                stateSpec[j++] = attrs.getAttributeBooleanValue(i, false) ? stateResId : -stateResId;
            }
        }
        stateSpec = StateSet.trimStateSet(stateSpec, j);

        // Apply alpha modulation. If we couldn't resolve the color or
        // alpha yet, the default values leave us enough information to
        // modulate again during applyTheme().
        final int color = modulateColorAlpha(baseColor, alphaMod);
        if (listSize == 0 || stateSpec.length == 0) {
            defaultColor = color;
        }

        colorList = GrowingArrayUtils.append(colorList, listSize, color);
        stateSpecList = GrowingArrayUtils.append(stateSpecList, listSize, stateSpec);
        listSize++;
    }

    int[] colors = new int[listSize];
    int[][] stateSpecs = new int[listSize][];
    System.arraycopy(colorList, 0, colors, 0, listSize);
    System.arraycopy(stateSpecList, 0, stateSpecs, 0, listSize);

    return new ColorStateList(stateSpecs, colors);
}

From source file:com.bilibili.magicasakura.utils.ColorStateListUtils.java

static ColorStateList inflateColorStateList(Context context, XmlPullParser parser, AttributeSet attrs)
        throws IOException, XmlPullParserException {
    final int innerDepth = parser.getDepth() + 1;
    int depth;//from  w w w .  j a v a 2s  .  co m
    int type;

    LinkedList<int[]> stateList = new LinkedList<>();
    LinkedList<Integer> colorList = new LinkedList<>();

    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
        if (type != XmlPullParser.START_TAG || depth > innerDepth || !parser.getName().equals("item")) {
            continue;
        }

        TypedArray a1 = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.color });
        final int value = a1.getResourceId(0, Color.MAGENTA);
        final int baseColor = value == Color.MAGENTA ? Color.MAGENTA
                : ThemeUtils.replaceColorById(context, value);
        a1.recycle();
        TypedArray a2 = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.alpha });
        final float alphaMod = a2.getFloat(0, 1.0f);
        a2.recycle();
        colorList.add(alphaMod != 1.0f
                ? ColorUtils.setAlphaComponent(baseColor, Math.round(Color.alpha(baseColor) * alphaMod))
                : baseColor);

        stateList.add(extractStateSet(attrs));
    }

    if (stateList.size() > 0 && stateList.size() == colorList.size()) {
        int[] colors = new int[colorList.size()];
        for (int i = 0; i < colorList.size(); i++) {
            colors[i] = colorList.get(i);
        }
        return new ColorStateList(stateList.toArray(new int[stateList.size()][]), colors);
    }
    return null;
}

From source file:com.example.textviewsample.MainActivityFragment.java

private void styleSourceCode() {
    TypefaceSpan codeSpan = new TypefaceSpan(getActivity(), "SourceCodePro-Regular");
    TypefaceSpan codeSpan2 = new TypefaceSpan(getActivity(), "SourceCodePro-Bold", Typeface.BOLD);
    ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.MAGENTA);
    ForegroundColorSpan colorSpan2 = new ForegroundColorSpan(Color.BLUE);

    SpannableString title = new SpannableString(getString(R.string.code_sample));
    title.setSpan(codeSpan, 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    title.setSpan(codeSpan2, 19, 23, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    title.setSpan(colorSpan, 4, 15, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    title.setSpan(colorSpan2, 19, 23, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    sourceCodeText.setText(title);/*from w  w  w  .j a  v a  2 s.  c  om*/
}

From source file:im.vector.adapters.RoomAdapter.java

@Override
protected RecyclerView.ViewHolder createSubViewHolder(ViewGroup viewGroup, int viewType) {
    final LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());

    View itemView;// ww  w. j  av a  2 s.  c o  m

    if (viewType == TYPE_HEADER_PUBLIC_ROOM) {
        //TODO replace by a empty view ?
        itemView = inflater.inflate(R.layout.adapter_section_header_public_room, viewGroup, false);
        itemView.setBackgroundColor(Color.MAGENTA);
        return new HeaderViewHolder(itemView);
    } else {
        switch (viewType) {
        case TYPE_ROOM:
            itemView = inflater.inflate(R.layout.adapter_item_room_view, viewGroup, false);
            return new RoomViewHolder(itemView);
        case TYPE_PUBLIC_ROOM:
            itemView = inflater.inflate(R.layout.adapter_item_public_room_view, viewGroup, false);
            return new PublicRoomViewHolder(itemView);
        }
    }
    return null;
}

From source file:com.cwx.daytodayaccount.fragment.SlidingTabsColorsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // BEGIN_INCLUDE (populate_tabs)
    /**//w  w w.  j av  a 2s  . co  m
     * Populate our tab list with tabs. Each item contains a title, indicator color and divider
     * color, which are used by {@link SlidingTabLayout}.
     */
    mTabs.add(new SamplePagerItem(getString(R.string.tab_account), // Title
            Color.rgb(0, 188, 212), // Indicator color
            Color.GRAY // Divider color
    ));

    mTabs.add(new SamplePagerItem(getString(R.string.tab_notifications), // Title
            Color.MAGENTA, // Indicator color
            Color.GRAY // Divider color
    ));

    mTabs.add(new SamplePagerItem(getString(R.string.tab_diarys), // Title
            Color.rgb(255, 179, 0), // Indicator color
            Color.GRAY // Divider color
    ));

    mTabs.add(new SamplePagerItem(getString(R.string.tab_photos), // Title
            Color.rgb(102, 187, 106), // Indicator color
            Color.GRAY // Divider color
    ));

    mTabs.add(new SamplePagerItem(getString(R.string.tab_guanyin), // Title
            Color.YELLOW, // Indicator color
            Color.GRAY // Divider color
    ));

    mTabs.add(new SamplePagerItem(getString(R.string.tab_settings), // Title
            Color.BLUE, // Indicator color
            Color.GRAY // Divider color
    ));
    // END_INCLUDE (populate_tabs)
}