Java源码示例:com.ingenic.iwds.slpt.view.digital.SlptTimeView

示例1
@Override
public List<SlptViewComponent> buildSlptViewComponent(Service service) {
    init(service);

    List<SlptViewComponent> retVal = new LinkedList<>();

    SlptPictureView bg = new SlptPictureView();
    bg.setImagePicture(SimpleFile.readFileFromAssets(service.getApplicationContext(), "black.png"));
    retVal.add(bg);

    List<byte[]> bitmapBytes = new LinkedList<>();
    for (Drawable d : digits){
        bitmapBytes.add(drawableToBytes(d));
    }
    final byte [][] imagesBytes = bitmapBytes.toArray(new byte[0][]);

    SlptHourHView hh = new SlptHourHView();
    SlptHourLView hl = new SlptHourLView();
    SlptMinuteHView mh = new SlptMinuteHView();
    SlptMinuteLView ml = new SlptMinuteLView();

    for (SlptTimeView c : Arrays.asList(hh, hl, mh, ml)){
        c.setImagePictureArray(imagesBytes);
        retVal.add(c);
    }

    int halfWidth = 320 / 2;
    int halfHeight = 320 / 2;
    int ioffset = (int)offset;
    hh.setStart(ioffset+img_offset,ioffset+img_offset);
    hl.setStart(halfWidth-ioffset,ioffset+img_offset);
    mh.setStart(ioffset+img_offset,halfHeight-ioffset);
    ml.setStart(halfWidth-ioffset,halfHeight-ioffset);

    return retVal;
}