question

Alan avatar image
Alan asked Alan commented

Item colouring

Hi Clover Dev,

Is it possible to get the colour that each item uses in the register app.

Can I get it from the API or is there some algorithm clover uses?

(Not an urgent issue!)

Thanks

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Jeffrey Blattman avatar image
Jeffrey Blattman answered Alan commented

The color we use is an implementation detail and is subject to change at any point.

    mGroupUuidColumnIndex = newCursor.getColumnIndex(InventoryContract.Item.ITEM_GROUP_UUID);
    mUuidColumnIndex = newCursor.getColumnIndex(InventoryContract.Item.UUID);
    ...
    String itemId = cursor.getString(mUuidColumnIndex);
    String groupId = cursor.getString(mGroupUuidColumnIndex);

    String seed = isGroup ? groupId : itemId;
    if (!TextUtils.isEmpty(seed)) {
      random.setSeed(seed.hashCode());
      vc.colorGroup.setBackgroundColor(Color.argb(180, random.nextInt(128), random.nextInt(128), random.nextInt(128)));
    }

Basically, seeding with a per-item (or group) constant, then picking a color at "random".

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Alan avatar image Alan commented ·

Thats funny, thanks for taking the time Jeff!

0 Likes 0 ·

Welcome to the
Clover Developer Community