text:
package com.ztory.lib.sleek.base.element;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build.VERSION;
import android.util.Log;
import android.view.MotionEvent;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
import com.ztory.lib.sleek.Sleek;
import com.ztory.lib.sleek.SleekCanvas;
import com.ztory.lib.sleek.SleekCanvasInfo;
import com.ztory.lib.sleek.SleekParent;
import com.ztory.lib.sleek.SleekPrioCounter;
import com.ztory.lib.sleek.assumption.Assumeable;
import com.ztory.lib.sleek.base.SleekBaseComposite;
import com.ztory.lib.sleek.base.SleekColorArea;
import com.ztory.lib.sleek.base.SleekParam;
import com.ztory.lib.sleek.base.element.css.CSS;
import com.ztory.lib.sleek.base.element.css.CSSblock;
import com.ztory.lib.sleek.base.element.css.CSSblockBase;
import com.ztory.lib.sleek.base.image.SleekBaseImage;
import com.ztory.lib.sleek.base.text.SleekViewText;
import com.ztory.lib.sleek.contract.ISleekAnimRun;
import com.ztory.lib.sleek.contract.ISleekCallback;
import com.ztory.lib.sleek.contract.ISleekDrawView;
import com.ztory.lib.sleek.layout.IComputeInt;
import com.ztory.lib.sleek.layout.SL;
import com.ztory.lib.sleek.util.Calc;
import com.ztory.lib.sleek.util.UtilDownload;
import com.ztory.lib.sleek.util.UtilExecutor;
import com.ztory.lib.sleek.util.UtilPx;
import com.ztory.lib.sleek.util.UtilResources;
import com.ztory.lib.sleek.val.ValPair;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;

/**
 * NOTE:
 * Styling and layout in SleekElement is calculated as if CSS is set to:
 * box-sizing: border-box;
 * background-repeat: no-repeat;
 * background-position: center;
 * Created by jonruna on 2017-04-07.
 */
public class SleekElement extends SleekBaseComposite {

  public static final String CSS_BLOCK_ANIMATION_KEY = "SleekElement.isAnimationCSSblock";

  protected static final Executor
      SHADOW_EXECUTOR = UtilExecutor.createExecutor(
          SleekElement.class.getName() + "_SHADOW_EXECUTOR", 1
      ),
      BITMAP_EXECUTOR = UtilExecutor.createExecutor(
          SleekElement.class.getName() + "_BITMAP_EXECUTOR", 1
      );

  protected Executor
      bitmapDownloadExecutor = UtilExecutor.NETWORK_QUAD,
      bitmapShadowExecutor = SHADOW_EXECUTOR,
      bitmapLoadExecutor = BITMAP_EXECUTOR;

  protected final List<CSSblock> elementCSSlist = new ArrayList<>(4);

  protected final CSSblock elementCSS = new CSSblockBase(12);

  protected String elementString = null;

  protected final SleekColorArea elementBackground = new SleekColorArea(
      SleekColorArea.COLOR_TRANSPARENT,
      SleekColorArea.ANTI_ALIASED_FALSE,
      SleekParam.DEFAULT_TOUCHABLE
  );
  protected final SleekColorArea elementBorder = new SleekColorArea(
      SleekColorArea.COLOR_TRANSPARENT,
      SleekColorArea.ANTI_ALIASED_FALSE,
      SleekParam.DEFAULT_TOUCHABLE
  );
  protected SleekViewText elementText = null;
  protected Integer elementTextShadowColor = null;
  protected Integer elementTextShadowBlurRadius = null;
  protected Integer elementTextShadowOffsetX = null;
  protected Integer elementTextShadowOffsetY = null;

  protected Paint elementShadowBitmapPaint;
  protected final List<Bitmap> elementShadowBitmapList = new ArrayList<>();
  protected volatile int shadowViewSizeW;
  protected volatile int shadowViewSizeH;

  protected int elementBackgroundColor = SleekColorArea.COLOR_TRANSPARENT;
  protected int elementBorderColor = SleekColorArea.COLOR_TRANSPARENT;
  protected final Rect elementBorderWidth = new Rect();
  protected int elementBorderRadius = 0;
  protected float elementShadowRadius = 0;
  protected float elementShadowOffsetX = 0;
  protected float elementShadowOffsetY = 0;
  protected int elementShadowColor = 0;

  protected Rect paddingRect;

  protected String elementBackgroundSize = null;
  protected boolean elementBackgroundSizeIsCover = false;

  protected boolean localElementBackgroundImageUrl;
  protected String elementBackgroundImageUrl = null;
  protected SleekBaseImage elementBackgroundImage = null;

  protected boolean wrapTextWidth = false, wrapTextHeight = false;

  private Bitmap.Config defaultBitmapConfig = Config.ARGB_8888;

  public SleekElement() {
    this(false, SleekPrioCounter.next());
  }

  public SleekElement(boolean isFixedPosition) {
    this(isFixedPosition, SleekPrioCounter.next());
  }

  public SleekElement(SleekParam sleekParam) {
    this(sleekParam.fixed, sleekParam.priority);
  }

  public SleekElement(boolean isFixedPosition, int theTouchPrio) {
    super(isFixedPosition, theTouchPrio);
    setDimensionIgnoreBounds(true);
  }

  public void setClickAction(
      final CSSblock pressedCSS,
      final CSSblock clickedCSS,
      final Assumeable<SleekCSSanim> clickAction
  ) {
    getBackground().getTouchHandler().setClickAction(
        false,
        new Runnable() { @Override public void run() {
          removeCSSnoRefresh(pressedCSS);//clear previous click animation CSS
          removeCSSnoRefresh(clickedCSS);//clear previous click animation CSS
          addCSStransition(pressedCSS);
        }}, new Runnable() { @Override public void run() {
          removeCSStransition(pressedCSS);
        }}, new Runnable() { @Override public void run() {
          SleekCSSanim clickCSSanim = addCSStransition(clickedCSS);
          clickCSSanim.setDuration(SleekCSSanim.ANIM_DURATION_SHORT_HALF)
              .setDoneListener(new ISleekDrawView() {
                @Override
                public void drawView(Sleek sleek, Canvas canvas, SleekCanvasInfo info) {
                  removeCSStransition(pressedCSS, clickedCSS)
                      .setDuration(SleekCSSanim.ANIM_DURATION_SHORT_HALF);
                }
              });
          if (clickAction != null) {
            clickAction.assume(clickCSSanim);
          }
        }}
    );
  }

  public void setWrapTextWidth(boolean shouldWrapTextWidth) {
    wrapTextWidth = shouldWrapTextWidth;
    if (elementText != null) {
      elementText.setWrapWidth(wrapTextWidth);
    }
  }

  public void setWrapTextHeight(boolean shouldWrapTextHeight) {
    wrapTextHeight = shouldWrapTextHeight;
    if (elementText != null) {
      elementText.setWrapHeight(wrapTextHeight);
    }
  }

  @Override
  public void onSleekParentAdd(SleekCanvas sleekCanvas, SleekParent composite) {
    super.onSleekParentAdd(sleekCanvas, composite);

    if (elementBackgroundImage != null) {
      elementBackgroundImage.onSleekParentAdd(sleekCanvas, SleekElement.this);
    }

    requestLayout();// Needs to be called in order for children to call their onSleekCanvasResize().
  }

  @Override
  public void onSleekParentRemove(SleekCanvas sleekCanvas, SleekParent composite) {
    super.onSleekParentRemove(sleekCanvas, composite);

    if (elementBackgroundImage != null) {
      elementBackgroundImage.onSleekParentRemove(sleekCanvas, SleekElement.this);
    }
  }

  public void refreshCSS() {

    if (elementCSS.size() > 0) {
      elementCSS.clear();
    }

    for (CSSblock iterBlock : elementCSSlist) {
      elementCSS.putAll(iterBlock);//will overwrite existing keys
    }

    applyCSS();
    reloadTextState();
    resetSleekBounds();// refreshes text padding and background-image positioning
    if (addedToParent && loaded) {
      reloadShadowBitmap(false);
    }
  }

  /**
   * NOTE: If applyCSS() has not been called prior to this then padding will not be initialized.
   * @return a Rect with padding values
   */
  public Rect getPadding() {
    if (paddingRect != null) {
      return paddingRect;
    } else {
      return new Rect();
    }
  }

  public void applyCSS() {

    // No need to apply CSS properties if there are none
    if (elementCSS.size() == 0) {
      return;
    }

    Integer backgroundColor = elementCSS.getBackgroundColor();
    if (backgroundColor != null) {
      elementBackgroundColor = backgroundColor;
    } else {
      elementBackgroundColor = SleekColorArea.COLOR_TRANSPARENT;
    }
    elementBackground.getPaint().setColor(elementBackgroundColor);

    Integer borderColor = elementCSS.getBorderColor();
    if (borderColor != null) {
      elementBorderColor = borderColor;
    } else {
      elementBorderColor = SleekColorArea.COLOR_TRANSPARENT;
    }
    elementBorder.getPaint().setColor(elementBorderColor);

    Rect borderWidth = elementCSS.getBorderWidth();
    if (borderWidth != null) {
      elementBorderWidth.set(borderWidth);
    } else {
      elementBorderWidth.set(0, 0, 0, 0);
    }

    Integer borderRadius = elementCSS.getBorderRadius();
    if (borderRadius != null) {
      elementBorderRadius = borderRadius;
    } else {
      elementBorderRadius = 0;
    }

    if (elementBorderRadius > elementBorderWidth.left) {
      elementBackground.getPaint().setAntiAlias(true);
      elementBackground.setRounded(elementBorderRadius - elementBorderWidth.left);
    }
    else {
      elementBackground.getPaint().setAntiAlias(false);
      elementBackground.setRounded(0);
    }
    elementBorder.getPaint().setAntiAlias(elementBorderRadius > 0);
    elementBorder.setRounded(elementBorderRadius);

    Integer boxShadowBlurRadius = elementCSS.getBoxShadowBlurRadius();
    if (boxShadowBlurRadius != null && boxShadowBlurRadius > 0) {
      Integer boxShadowOffsetX = elementCSS.getBoxShadowOffsetX();
      Integer boxShadowOffsetY = elementCSS.getBoxShadowOffsetY();
      Integer boxShadowColor = elementCSS.getBoxShadowColor();

      if (boxShadowOffsetX != null && boxShadowOffsetY != null && boxShadowColor != null) {
        elementShadowRadius = boxShadowBlurRadius;
        elementShadowOffsetX = boxShadowOffsetX;
        elementShadowOffsetY = boxShadowOffsetY;
        elementShadowColor = boxShadowColor;
        elementShadowBitmapPaint = new Paint();
        elementShadowBitmapPaint.setColor(elementBackgroundColor);
        elementShadowBitmapPaint.setAntiAlias(true);
      } else {
        elementShadowRadius = 0;
      }
    } else {
      elementShadowRadius = 0;
    }

    Integer color = elementCSS.getColor();
    if (color != null) {
      createText();
      elementText.setTextColor(color);
    }

    Integer fontSize = elementCSS.getFontSize();
    if (fontSize != null) {
      createText();
      elementText.setTextSize(fontSize);
    }

    Integer lineHeight = elementCSS.getLineHeight();
    if (lineHeight != null) {
      createText();
      elementText.setTextLineHeight(lineHeight);
    } else if (fontSize != null) {
      //if fontSize is set then use that as line-height if line-height is not specified
      elementText.setTextLineHeight(fontSize);
    }

    String textAlign = elementCSS.getTextAlign();
    if (lineHeight != null) {
      createText();
      if (textAlign.equals("center")) {
        elementText.setTextAlignInt(SleekViewText.ALIGN_CENTER);
      } else if (textAlign.equals("right")) {
        elementText.setTextAlignInt(SleekViewText.ALIGN_RIGHT);
      } else if (textAlign.equals("left")) {
        elementText.setTextAlignInt(SleekViewText.ALIGN_LEFT);
      }
    }

    String verticalAlign = elementCSS.getVerticalAlign();
    if (verticalAlign != null) {
      createText();
      if (verticalAlign.equals("middle")) {
        elementText.setTextAlignVertInt(SleekViewText.ALIGN_CENTER);
      } else if (verticalAlign.equals("bottom")) {
        elementText.setTextAlignVertInt(SleekViewText.ALIGN_BOTTOM);
      } else if (verticalAlign.equals("top")) {
        elementText.setTextAlignVertInt(SleekViewText.ALIGN_TOP);
      }
    }

    elementTextShadowColor = elementCSS.getTextShadowColor();
    if (elementTextShadowColor != null && elementTextShadowColor != SleekColorArea.COLOR_TRANSPARENT) {
      elementTextShadowBlurRadius = elementCSS.getTextShadowBlurRadius();
      elementTextShadowOffsetX = elementCSS.getTextShadowOffsetX();
      elementTextShadowOffsetY = elementCSS.getTextShadowOffsetY();
    } else {
      elementTextShadowColor = null;
      elementTextShadowBlurRadius = null;
      elementTextShadowOffsetX = null;
      elementTextShadowOffsetY = null;
    }

    paddingRect = elementCSS.getPadding();

    String oldElementBackgroundImageUrl = elementBackgroundImageUrl;
    elementBackgroundImageUrl = elementCSS.getBackgroundImage();
    if (elementBackgroundImageUrl != null) {
      if (!elementBackgroundImageUrl.equals(oldElementBackgroundImageUrl)) {
        localElementBackgroundImageUrl = !elementBackgroundImageUrl.startsWith("https://")
            && !elementBackgroundImageUrl.startsWith("http://");
        createBackgroundImage();
        reloadBackgroundImage();
      }
    } else if (elementBackgroundImage != null) {
      initBackgroundImageBitmapFetcher();
      elementBackgroundImage.onSleekUnload();
    }

    elementBackgroundSize = elementCSS.getBackgroundSize();
    elementBackgroundSizeIsCover = CSS.Value.COVER.equals(elementBackgroundSize);
  }

  public Interpolator getDefaultInterpolator() {
    if (VERSION.SDK_INT >= 21) {
      return new PathInterpolator(0.785f, 0.135f, 0.150f, 0.860f);// easeInOutCirc
    } else {
      return new AccelerateDecelerateInterpolator();
    }
  }

  public SleekCSSanim addCSStransition(CSSblock... cssBlockArray) {
    SleekCSSanim cssAnimation = new SleekCSSanim(this, SleekCSSanim.ADD_CSS, cssBlockArray);
    cssAnimation.setInterpolator(getDefaultInterpolator());
    setSleekAnimView(cssAnimation);
    return cssAnimation;
  }

  public SleekCSSanim removeCSStransition(CSSblock... cssBlockArray) {
    SleekCSSanim cssAnimation = new SleekCSSanim(this, SleekCSSanim.REMOVE_CSS, cssBlockArray);
    cssAnimation.setInterpolator(getDefaultInterpolator());
    setSleekAnimView(cssAnimation);
    return cssAnimation;
  }

  public SleekElement addCSSnoRefresh(CSSblock cssBlock) {
    elementCSSlist.add(cssBlock);
    return this;
  }

  public SleekElement addCSS(CSSblock... cssBlocks) {
    for (CSSblock iterBlock : cssBlocks) {
      elementCSSlist.add(iterBlock);
    }
    refreshCSS();
    return this;
  }

  public boolean removeCSSnoRefresh(CSSblock cssBlock) {
    return elementCSSlist.remove(cssBlock);
  }

  public boolean removeCSS(CSSblock cssBlock) {
    boolean removedItem = elementCSSlist.remove(cssBlock);
    refreshCSS();
    return removedItem;
  }

  public int removeCSSblocksRaw(CSSblock... cssBlock) {
    int removedBlocks = 0;
    for (CSSblock iterBlock : cssBlock) {
      if (removeCSSnoRefresh(iterBlock)) {
        removedBlocks++;
      }
    }
    return removedBlocks;
  }

  public boolean containsCSSblock(CSSblock cssBlock) {
    return elementCSSlist.contains(cssBlock);
  }

  public int removeAnimationCSSblocks() {
    int removedBlocks = 0;
    for (int i = elementCSSlist.size() - 1 ; i >= 0; i--) {
      if (elementCSSlist.get(i).get(CSS_BLOCK_ANIMATION_KEY) != null) {
        elementCSSlist.remove(i);
        removedBlocks++;
      }
    }
    return removedBlocks;
  }

  public void setElementString(String theElementString) {
    elementString = theElementString;
    createText();
    elementText.setTextString(elementString);
    reloadTextState();
    invalidateSafe();
  }

  public String getElementString() {
    return elementString;
  }

  public Paint getBgPaint() {
    if (elementShadowRadius > 0) {
      return elementShadowBitmapPaint;
    } else {
      return elementBackground.getPaint();
    }
  }

  public SleekColorArea getBackground() {
    return elementBackground;
  }

  public void createText() {
    if (elementText != null) {
      return;
    }
    elementText = new SleekViewText(SleekParam.DEFAULT);
    elementText.setWrapWidth(wrapTextWidth);
    elementText.setWrapHeight(wrapTextHeight);
  }

  public SleekViewText getText() {
    return elementText;
  }

  public void createBackgroundImage() {
    // Default to fade anim for remote images
    createBackgroundImage(!localElementBackgroundImageUrl);
  }

  public void createBackgroundImage(boolean fadeAnimOnLoad) {
    if (elementBackgroundImage != null) {
      return;
    }

    elementBackgroundImage = new SleekBaseImage(elementBorderRadius, SleekParam.DEFAULT);
    elementBackgroundImage.setFadeAnimOnLoad(fadeAnimOnLoad);
    elementBackgroundImage.setBitmapListener(new ISleekCallback<SleekBaseImage>() {
      @Override
      public void sleekCallback(SleekBaseImage sleekBaseImage) {
        positionBackgroundImage();
      }
    });
  }

  public void positionBackgroundImage() {

    if (elementBackgroundImage == null || elementBackgroundImage.getBitmap() == null) {
      return;
    }

    //NOTE: Background logic for "cover" and "contain" is calculated as if this CSS was set:
    //      background-position: center center;

    final int bitmapW = elementBackgroundImage.getBitmap().getWidth();
    final int bitmapH = elementBackgroundImage.getBitmap().getHeight();
    int backgroundX = 0;
    int backgroundY = 0;
    int backgroundWidth = bitmapW;
    int backgroundHeight = bitmapH;
    final int imgContainerW = elementBackground.getSleekW();
    final int imgContainerH = elementBackground.getSleekH();

    if (!elementBackgroundSizeIsCover) {
      // Reset source rect
      elementBackgroundImage.getSourceRect().set(0, 0, backgroundWidth, backgroundHeight);
      elementBackgroundImage.setShaderMatrix();
    }

    if (elementBackgroundSize != null) {

      if (elementBackgroundSizeIsCover) {
        /*
        cover
        A keyword that is the inverse of contain.
        Scales the image as large as possible and maintains image aspect
        ratio (image doesn't get squished). The image "covers" the entire
        width or height of the container. When the image and container have
        different dimensions, the image is clipped either left/right or top/bottom.
         */
        float bitmapScale;
        float elementRatio = Calc.divide(imgContainerW, imgContainerH);
        float bitmapRatio = Calc.divide(backgroundWidth, backgroundHeight);
        if (bitmapRatio > elementRatio) {
          bitmapScale = Calc.divide(imgContainerH, bitmapH);
          backgroundWidth = Calc.multiplyToInt(imgContainerH, bitmapRatio);
          backgroundX = (int) Calc.divide(imgContainerW - backgroundWidth, 2.0f);
        } else {
          bitmapScale = Calc.divide(imgContainerW, bitmapW);
          backgroundHeight = Calc.divideToInt(imgContainerW, bitmapRatio);
          backgroundY = (int) Calc.divide(imgContainerH - backgroundHeight, 2.0f);
        }

        int sourceTop = Calc.multiplyToInt(Calc.divide(backgroundY, bitmapScale), -1.0f);
        int sourceBottom = bitmapH - sourceTop;
        int sourceLeft = Calc.multiplyToInt(Calc.divide(backgroundX, bitmapScale), -1.0f);
        int sourceRight = bitmapW - sourceLeft;
        elementBackgroundImage.getSourceRect().set(
            sourceLeft, sourceTop, sourceRight, sourceBottom
        );
        elementBackgroundImage.setShaderMatrix();

        //Reset drawing position
        backgroundX = 0;
        backgroundY = 0;

        // Reset drawing size to element size
        backgroundWidth = imgContainerW;
        backgroundHeight = imgContainerH;
      } else if (elementBackgroundSize.equals(CSS.Value.CONTAIN)) {
        /*
        contain
        A keyword that scales the image as large as possible and maintains image aspect
        ratio (image doesn't get squished). Image is letterboxed within the container.
        When the image and container have different dimensions, the empty
        areas (either top/bottom of left/right) are filled with the background-color.
         */
        float elementRatio = Calc.divide(imgContainerW, imgContainerH);
        float bitmapRatio = Calc.divide(backgroundWidth, backgroundHeight);
        if (bitmapRatio > elementRatio) {
          backgroundWidth = imgContainerW;
          backgroundHeight = (int) Calc.divide(imgContainerW, bitmapRatio);
          backgroundY = (int) Calc.divide(imgContainerH - backgroundHeight, 2.0f);
        } else {
          backgroundHeight = imgContainerH;
          backgroundWidth = (int) Calc.multiply(imgContainerH, bitmapRatio);
          backgroundX = (int) Calc.divide(imgContainerW - backgroundWidth, 2.0f);
        }
      }
    }

    if (backgroundX > 0) {// Used for dynamic-corner-radius on CONTAIN background-image
      float borderRadiusModif = elementBackground.getRoundedRadius() - backgroundX;
      if (borderRadiusModif < 0) {
        borderRadiusModif = 0;
      }
      elementBackgroundImage.setRoundedRadius(borderRadiusModif);
    } else if (backgroundY > 0) {// Used for dynamic-corner-radius on CONTAIN background-image
      float borderRadiusModif = elementBackground.getRoundedRadius() - backgroundY;
      if (borderRadiusModif < 0) {
        borderRadiusModif = 0;
      }
      elementBackgroundImage.setRoundedRadius(borderRadiusModif);
    } else {
      if (elementBorderColor == SleekColorArea.COLOR_TRANSPARENT) {
        elementBackgroundImage.setRoundedRadius(elementBorderRadius);
      } else if (elementBorderRadius > elementBorderWidth.left) {
        elementBackgroundImage.setRoundedRadius(elementBorderRadius - elementBorderWidth.left);
      } else {
        elementBackgroundImage.setRoundedRadius(0);
      }
    }

    elementBackgroundImage.setSleekBounds(
        backgroundX + elementBorderWidth.left,
        backgroundY + elementBorderWidth.top,
        backgroundWidth,
        backgroundHeight
    );
  }

  public void reloadBackgroundImage() {

    initBackgroundImageBitmapFetcher();

    if (elementBackgroundImageUrl != null) {
      if (loaded && addedToParent) {
        elementBackgroundImage.onSleekUnload();
        mSlkCanvas.loadSleek(elementBackgroundImage);
        checkSetLocalBackground();
      }
    }
  }

  public void setDefaultBitmapConfig(Bitmap.Config config) {
    defaultBitmapConfig = config;
  }

  public Bitmap.Config getDefaultBitmapConfig() {
    return defaultBitmapConfig;
  }

  //TODO THIS IS DEBUG CODE
//  private static final AtomicInteger debugCounter = new AtomicInteger(0);
//  private final double randomDbl = debugCounter.incrementAndGet();

  protected File getDownloadedBitmapFile() {
    return UtilDownload.downloadUrl(elementBackgroundImageUrl);
    //TODO THIS IS DEBUG CODE
    //return UtilDownload.downloadUrl("http://lorempixel.com/400/400/people/" + "?" + randomDbl);
  }

  protected volatile File bitmapFile = null;

  protected Runnable bitmapLoaderRun = new Runnable() {
    @Override
    public void run() {

      final File finalBitmapFile = bitmapFile;
      bitmapFile = null;

      if (finalBitmapFile == null) {
        return;
      }

      if ((isSleekLoadable() && !isSleekLoaded()) || !isAddedToParent()) {
        return;
      }

      // https://stackoverflow.com/questions/3117429/garbage-collector-in-android
      System.gc();

      // Ensure one fullscreen ARGB_8888 bitmap can be loaded into memory
      int minRequiredMemory = getCanvasWidth() * getCanvasHeight() * 8;
      while (UtilDownload.getAvailableMemory() < minRequiredMemory) {

        Log.d("SleekElement memstats",
            "memstats WAITING | avail: " + UtilDownload.getAvailableMemory() +
                " | minRequiredMemory: " + minRequiredMemory
        );

        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }

        if ((isSleekLoadable() && !isSleekLoaded()) || !isAddedToParent()) {
          return;
        }
      }

      Bitmap bitmap = null;
      FileInputStream fis = null;
      try {

        fis = new FileInputStream(finalBitmapFile);
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPreferredConfig = getDefaultBitmapConfig();
        bitmap = BitmapFactory.decodeStream(fis, null, options);
        fis.close();
      } catch (Exception e) {
        UtilDownload.closeSafe(fis);
        e.printStackTrace();
      }

      if ((isSleekLoadable() && !isSleekLoaded()) || !isAddedToParent()) {
        //bitmap.recycle();
        bitmap = null;
      }

      if (bitmap != null) {
        // Attempt to prepare bitmap for drawing in order to prevent...
        // ...FPS-lag when drawn for first time in the Android UI.
        // https://developer.android.com/reference/android/graphics/Bitmap.html#prepareToDraw()
        bitmap.prepareToDraw();

//        try {
//          System.gc();
//          Thread.sleep(34);
//        } catch (InterruptedException e) {
//          e.printStackTrace();
//        }
      }

      final Bitmap finalBitmap = bitmap;
      addPreDrawSafe(mSlkCanvas, new ISleekAnimRun() {
        @Override
        public void run(SleekCanvasInfo info) {
          elementBackgroundImage.setBitmap(finalBitmap);
        }
      });
    }
  };

  protected Runnable bitmapFetcherRun = new Runnable() {
    @Override
    public void run() {

      bitmapFile = null;

      if ((isSleekLoadable() && !isSleekLoaded()) || !isAddedToParent()) {
        return;
      }

      final File bmFile = getDownloadedBitmapFile();

      if (bmFile == null) {
        return;
      }

      if ((isSleekLoadable() && !isSleekLoaded()) || !isAddedToParent()) {
        return;
      }

      bitmapFile = bmFile;

      bitmapLoadExecutor.execute(bitmapLoaderRun);
    }
  };

  public void initBackgroundImageBitmapFetcher() {
    if (elementBackgroundImageUrl == null || localElementBackgroundImageUrl) {
      elementBackgroundImage.setBitmapFetcher(null, null, null);//clear fetcher
    } else {
      elementBackgroundImage.setBitmapFetcher(
          bitmapDownloadExecutor,
          bitmapFetcherRun
      );
    }
  }

  public void checkSetLocalBackground() {

    if (elementBackgroundImageUrl != null && localElementBackgroundImageUrl) {

      // DEBUG CODE, because we have no drawable resources in sleek library.
//      int resId = UtilPx.getDefaultContext().getResources().getIdentifier(
//          elementBackgroundImageUrl,
//          "drawable",
//          "android"
//      );
//      elementBackgroundImage.setBitmap(UtilResources.getBitmap(resId));

      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inPreferredConfig = getDefaultBitmapConfig();
      Bitmap bitmapResource = BitmapFactory.decodeResource(
          UtilPx.getDefaultContext().getResources(),
          UtilResources.getResourceIdDrawable(elementBackgroundImageUrl),
          options
      );
      elementBackgroundImage.setBitmap(bitmapResource);
    }
  }

  public SleekBaseImage getBackgroundImage() {
    return elementBackgroundImage;
  }

  public void wrapBackgroundImageSize(
      final boolean wrapWidth,
      final boolean wrapHeight,
      final boolean executeSleekCanvasResize
  ) {
    createBackgroundImage();//ensure background image is created if null
    getBackgroundImage().setBitmapListener(new ISleekCallback<SleekBaseImage>() {
      @Override
      public void sleekCallback(SleekBaseImage sleekBaseImage) {

        if (sleekBaseImage.getBitmap() != null) {
          final int bitmapWidth = sleekBaseImage.getBitmap().getWidth();
          final int bitmapHeight = sleekBaseImage.getBitmap().getHeight();
          final float bitmapRatio = Calc.divide(bitmapWidth, bitmapHeight);
          if (wrapWidth && wrapHeight) {
            SleekElement.this.getLayout()
                .w(SL.W.ABSOLUTE, bitmapWidth, null)
                .h(SL.H.ABSOLUTE, bitmapHeight, null);
          } else if (wrapWidth) {
            SleekElement.this.getLayout().w(SL.W.COMPUTE, 0, null, 0, new IComputeInt() {
              @Override
              public int compute(SleekCanvasInfo info) {
                int computedH = SleekElement.this.getLayout().computeSizeH(SleekElement.this, info);
                return Calc.multiplyToInt(computedH, bitmapRatio);
              }
            });
          } else if (wrapHeight) {
            SleekElement.this.getLayout().h(SL.H.COMPUTE, 0, null, 0, new IComputeInt() {
              @Override
              public int compute(SleekCanvasInfo info) {
                int computedW = SleekElement.this.getLayout().computeSizeW(SleekElement.this, info);
                return Calc.divideToInt(computedW, bitmapRatio);
              }
            });
          }

          if (executeSleekCanvasResize) {
            SleekElement.this.executeSleekCanvasResize();
          } else {
            SleekElement.this.requestLayout();
          }
        }
      }
    });
  }

  public CSSblock getCSS() {
    return elementCSS;
  }

  public void drawBorder(Canvas canvas, SleekCanvasInfo info) {
    if (elementBorderColor == SleekColorArea.COLOR_TRANSPARENT) {
      return;
    }
    elementBorder.onSleekDraw(canvas, info);
  }

  @Override
  public void drawView(Sleek view, Canvas canvas, SleekCanvasInfo info) {

    canvas.save();
    canvas.translate(sleekX, sleekY);

    //TODO DEBUG
//    drawShadowBitmap(canvas, info);
//    elementBorder.getPaint().setColor(0x99ff0000);
//    drawBorder(canvas, info);
    //TODO DEBUG

    if (!drawShadowBitmap(canvas, info)) {
      drawBorder(canvas, info);
      elementBackground.onSleekDraw(canvas, info);
      if (elementBackgroundImage != null) {
        elementBackgroundImage.onSleekDraw(canvas, info);
      }
    } else if (elementBackgroundImage != null) {
      elementBackgroundImage.onSleekDraw(canvas, info);
    }

    if (elementText != null) {
      elementText.onSleekDraw(canvas, info);
    }

    for (Sleek iterView : views) {
      //if (iterView.shouldBeDrawn()) iterView.draw(canvas, info);// dont need to check this, if this view is loaded it should draw its children
      iterView.onSleekDraw(canvas, info);
    }

    canvas.restore();
  }

  public void reloadTextState() {
    if (elementText != null && elementString != null) {
      elementText.initText();
      reloadTextShadow();
    }
  }

  protected void reloadTextShadow() {
    if (elementTextShadowColor != null
        && elementTextShadowColor != SleekColorArea.COLOR_TRANSPARENT
        ) {
      elementText.getTextPaint().setShadowLayer(
          elementTextShadowBlurRadius,
          elementTextShadowOffsetX,
          elementTextShadowOffsetY,
          elementTextShadowColor
      );
    } else {
      elementText.getTextPaint().clearShadowLayer();
    }
  }

  public void resetSleekBounds() {
    setSleekBounds(getSleekX(), getSleekY(), getSleekW(), getSleekH());
  }

  @Override
  public void setSleekBounds(float x, float y, int w, int h) {

    if (elementText != null) {
      final int textOldW = elementText.getSleekW();
      final int textOldH = elementText.getSleekH();
      if (paddingRect != null) {
        elementText.setSleekBounds(
            paddingRect.left + elementBorderWidth.left,
            paddingRect.top + elementBorderWidth.top,
            w - paddingRect.left - paddingRect.right
                - elementBorderWidth.left - elementBorderWidth.right,
            h - paddingRect.top - paddingRect.bottom
                - elementBorderWidth.top - elementBorderWidth.bottom
        );
      } else {
        elementText.setSleekBounds(
            elementBorderWidth.left,
            elementBorderWidth.top,
            w - elementBorderWidth.left - elementBorderWidth.right,
            h - elementBorderWidth.top - elementBorderWidth.bottom
        );
      }

      if (elementString != null) {
        // Refresh text bounds if size has changed
        if (textOldW != elementText.getSleekW() || textOldH != elementText.getSleekH()) {
          //Log.d("SleekElement", "SleekElement | Refresh text bounds if size has changed");
          elementText.setMaxWrapWidth(elementText.getSleekW());
          elementText.setMaxWrapHeight(elementText.getSleekH());
          reloadTextState();
        }
      }
    }

    int elementWidth = w;
    int elementHeight = h;

    if ((wrapTextWidth || wrapTextHeight) && elementText != null) {

      int paddingTopBottom = paddingRect != null ? paddingRect.top + paddingRect.bottom : 0;
      int paddingLeftRight = paddingRect != null ? paddingRect.left + paddingRect.right : 0;

      paddingTopBottom = paddingTopBottom + elementBorderWidth.top + elementBorderWidth.bottom;
      paddingLeftRight = paddingLeftRight + elementBorderWidth.left + elementBorderWidth.right;

      if (wrapTextWidth) {//wrap only width
        elementWidth = elementText.getSleekW() + paddingLeftRight;
      }

      if (wrapTextHeight) {//wrap only height
        elementHeight = elementText.getSleekH() + paddingTopBottom;
      }
    }

    super.setSleekBounds(x, y, elementWidth, elementHeight);

    elementBorder.setSleekBounds(
        0,
        0,
        elementWidth,
        elementHeight
    );
    elementBackground.setSleekBounds(
        elementBorder.getSleekX() + elementBorderWidth.left,
        elementBorder.getSleekY() + elementBorderWidth.top,
        elementBorder.getSleekW() - elementBorderWidth.left - elementBorderWidth.right,
        elementBorder.getSleekH() - elementBorderWidth.top - elementBorderWidth.bottom
    );

    if (loaded && addedToParent) {
      positionBackgroundImage();
    }
  }

  protected void setElementShadowBitmap(List<Bitmap> theShadowBitmapList) {

    if (elementShadowBitmapList.size() > 0) {
      for (Bitmap iterShadowBitmap : elementShadowBitmapList) {
        if (iterShadowBitmap != null) {
          //iterShadowBitmap.recycle();
        }
      }
      elementShadowBitmapList.clear();
    }

    if (theShadowBitmapList != null) {
      elementShadowBitmapList.addAll(theShadowBitmapList);
    }
  }

  @Override
  public void onSleekCanvasResize(SleekCanvasInfo info) {
    super.onSleekCanvasResize(info);
  }

  public void reloadShadowBitmap(boolean allowBgThreadLoad) {
    if (elementShadowRadius > 0) {
      if (allowBgThreadLoad) {

        //TODO Maybe exeute on UI-thread if view is within viewport when this method is called ?

        bitmapShadowExecutor.execute(new Runnable() {
          @Override
          public void run() {

            if ((isSleekLoadable() && !isSleekLoaded()) || !isAddedToParent()) {
              return;
            }

            final List<Bitmap> shadowBitmapList = generateShadowBitmap();

            if ((isSleekLoadable() && !isSleekLoaded()) || !isAddedToParent()) {
              return;
            }

            addPreDrawSafe(mSlkCanvas, new ISleekAnimRun() {
              @Override
              public void run(SleekCanvasInfo info) {
                if (loaded && addedToParent) {
                  setElementShadowBitmap(shadowBitmapList);
                }
              }
            });
          }
        });
      } else {
        setElementShadowBitmap(generateShadowBitmap());
      }
    }
    else {
      setElementShadowBitmap(null);
    }
  }

  @Override
  public void onSleekLoad(SleekCanvasInfo info) {

    final boolean alreadyLoaded = loaded;

    super.onSleekLoad(info);

    if (alreadyLoaded) {
      return;
    }

    reloadShadowBitmap(true);

    if (elementBackgroundImage != null) {
      elementBackgroundImage.onSleekLoad(info);
      checkSetLocalBackground();
    }
  }

  @Override
  public void onSleekUnload() {
    super.onSleekUnload();
    setElementShadowBitmap(null);
    if (elementBackgroundImage != null) {
      elementBackgroundImage.onSleekUnload();
    }
    bitmapFile = null;
  }

  @Override
  public boolean onSleekTouchEvent(MotionEvent event, SleekCanvasInfo info) {

    if (touchHandler.onSleekTouchEvent(event, info)) {
      return true;
    }

    event.offsetLocation(-sleekX, -sleekY);

    touchEventReturn = false;

    if (touchable) {
      for (int i = views.size() - 1; i >= 0; i--) {
        if (views.get(i).isSleekTouchable() && views.get(i).onSleekTouchEvent(event, info)) {
          touchEventReturn = true;
          break;
        }
      }
    }

    if (!touchEventReturn) {
      touchEventReturn = elementBackground.getTouchHandler().onSleekTouchEvent(event, info);
    }

    event.offsetLocation(sleekX, sleekY);

    return touchEventReturn;
  }

  protected final Rect shadowSrcRect = new Rect();
  protected final RectF shadowDstRectF = new RectF();

  protected boolean drawShadowBitmap(Canvas canvas, SleekCanvasInfo info) {

    if (elementShadowBitmapList.size() < 4) {
      return false;
    }

    //TODO FIX SO THAT ALPHA ANIMATION WORKS AS IT SHOULD WITH MIDDLE AREA AND BORDER AREAS !!!!
    //TODO Maybe we can set bitmap-bg-paint to alpha==255, and shadow to delta of real...
    //TODO ... bg-alpha and its shadow-alpha ????
    //TODO NEED TO add interface that is called HasAlpha and has getAlpha and setAlpha methods.

    final boolean drawBgRectBeforeShadow = elementBorderColor == SleekColorArea.COLOR_TRANSPARENT;

    if (drawBgRectBeforeShadow) {
      canvas.drawRect(
          elementBorderRadius,
          elementBorderRadius,
          sleekW - elementBorderRadius,
          sleekH - elementBorderRadius,
          elementShadowBitmapPaint
      );
    }

    /*
    // LOW PRIO since why would we want alpha bg-elements with shadow?
    // If we implement alpha bg with shadow then shadowBitmaps need to contain "hidden" ...
    // ... shadow-edges as well, so that they shine through.
    // Draw middle area of shadow, if bg has alpha we need to draw this because otherwise...
    // ...there is a "hole" in the middle since shadow will only be drawn along edges.
    float shadowBgTopOffset = elementShadowOffsetY > 0 ? elementShadowOffsetY : 0;
    float shadowBgBottomOffset = elementShadowOffsetY < 0 ? elementShadowOffsetY : 0;
    float shadowBgLeftOffset = elementShadowOffsetX > 0 ? elementShadowOffsetX : 0;
    float shadowBgRightOffset = elementShadowOffsetX < 0 ? elementShadowOffsetX : 0;
    elementBackground.getPaint().setColor(0x99ff00ff);
    canvas.drawRect(
            elementBorderRadius + shadowBgLeftOffset,
            elementBorderRadius + shadowBgTopOffset,
            sleekW - elementBorderRadius + shadowBgRightOffset,
            sleekH - elementBorderRadius + shadowBgBottomOffset,
            elementBackground.getPaint()//using elementBackground.getPaint to have correct Alpha
    );
    elementBackground.getPaint().setColor(elementBackgroundColor);
    */

    //TODO REFACTOR CODE IN THIS METHOD TO BE EASIER TO READ !

    float leftOffset = 0;
    if (elementShadowOffsetX < 0) {
      leftOffset = elementShadowOffsetX;
    }

    float topOffset = 0;
    if (elementShadowOffsetY < 0) {
      topOffset = elementShadowOffsetY;
    }

    //int stretchedWidthDelta = sleekW - shadowViewSizeW;
    int stretchedHeightDelta = sleekH - shadowViewSizeH;
    Bitmap currentBitmap;
    int currentBitmapW;
    int currentBitmapH;
    final Bitmap leftBitmap = elementShadowBitmapList.get(2);
    final int leftBitmapW = leftBitmap.getWidth();
    final int leftBitmapH = leftBitmap.getHeight();
    final Bitmap rightBitmap = elementShadowBitmapList.get(3);
    final int rightBitmapW = rightBitmap.getWidth();
    final int rightBitmapH = rightBitmap.getHeight();
    final int westCornerWidth;
    final int eastCornerWidth;
    final int rightEdgeModifier;
    if (rightBitmapW > leftBitmapW) {
      westCornerWidth = rightBitmapW + elementBorderWidth.left;
      eastCornerWidth = rightBitmapW + elementBorderWidth.right;
      rightEdgeModifier = elementBorderWidth.right;
    } else {
      westCornerWidth = leftBitmapW + elementBorderWidth.left;
      eastCornerWidth = leftBitmapW + elementBorderWidth.right;
      rightEdgeModifier = leftBitmapW - rightBitmapW + elementBorderWidth.right;
    }

    if (elementBorderRadius > 0
        && elementBorderRadius + elementBorderRadius >= sleekW - elementBorderWidth.left - elementBorderWidth.right
        && elementBorderRadius + elementBorderRadius >= sleekH
        ) {// Special case for round SleekElement instances, does not draw WEST and EAST bitmaps.
      //DRAW unscaled Top-Bitmap
      canvas.drawBitmap(
          elementShadowBitmapList.get(0),
          -elementShadowRadius + leftOffset,
          -elementShadowRadius + topOffset,
          elementShadowBitmapPaint
      );
      //DRAW unscaled Bottom-Bitmap
      canvas.drawBitmap(
          elementShadowBitmapList.get(1),
          -elementShadowRadius + leftOffset,
          sleekH - elementBorderRadius,
          elementShadowBitmapPaint
      );
    } else {
      if (elementBorderRadius > 0
          && elementBorderRadius + elementBorderRadius >= sleekW - elementBorderWidth.left - elementBorderWidth.right
          ) {

        // Draw unscaled TOP and BOTTOM bitmaps, but WEST and EAST will be drawn in regular way.

        //DRAW unscaled Top-Bitmap
        canvas.drawBitmap(
            elementShadowBitmapList.get(0),
            -elementShadowRadius + leftOffset,
            -elementShadowRadius + topOffset,
            elementShadowBitmapPaint
        );
        //DRAW unscaled Bottom-Bitmap
        canvas.drawBitmap(
            elementShadowBitmapList.get(1),
            -elementShadowRadius + leftOffset,
            sleekH - elementBorderRadius,
            elementShadowBitmapPaint
        );
      } else {
        // Top Bitmap Init
        currentBitmap = elementShadowBitmapList.get(0);
        currentBitmapW = currentBitmap.getWidth();
        currentBitmapH = currentBitmap.getHeight();
        // Top-Left-Corner Bitmap
        shadowSrcRect.set(0, 0, westCornerWidth, currentBitmapH);
        shadowDstRectF.set(
            -elementShadowRadius + leftOffset,
            -elementShadowRadius + topOffset,
            -elementShadowRadius + leftOffset + westCornerWidth,
            -elementShadowRadius + topOffset + currentBitmapH
        );
        canvas.drawBitmap(
            currentBitmap,
            shadowSrcRect,
            shadowDstRectF,
            elementShadowBitmapPaint
        );
        // Top-Right-Corner Bitmap
        shadowSrcRect.set(currentBitmapW - eastCornerWidth, 0, currentBitmapW, currentBitmapH);
        shadowDstRectF.set(
            sleekW - elementBorderRadius - rightEdgeModifier,
            -elementShadowRadius + topOffset,
            sleekW + eastCornerWidth - elementBorderRadius - rightEdgeModifier,
            -elementShadowRadius + topOffset + currentBitmapH
        );
        canvas.drawBitmap(
            currentBitmap,
            shadowSrcRect,
            shadowDstRectF,
            elementShadowBitmapPaint
        );
        // Top-Center Bitmap
        shadowSrcRect.set(westCornerWidth, 0, currentBitmapW - eastCornerWidth, currentBitmapH);
        shadowDstRectF.set(
            -elementShadowRadius + leftOffset + westCornerWidth,
            -elementShadowRadius + topOffset,
            sleekW - elementBorderRadius - rightEdgeModifier,
            -elementShadowRadius + topOffset + currentBitmapH
        );
        canvas.drawBitmap(
            currentBitmap,
            shadowSrcRect,
            shadowDstRectF,
            elementShadowBitmapPaint
        );

        // Bottom Bitmap Init
        currentBitmap = elementShadowBitmapList.get(1);
        currentBitmapW = currentBitmap.getWidth();
        currentBitmapH = currentBitmap.getHeight();
        // Bottom-Left-Corner Bitmap
        shadowSrcRect.set(0, 0, westCornerWidth, currentBitmapH);
        shadowDstRectF.set(
            -elementShadowRadius + leftOffset,
            sleekH - elementBorderRadius,
            -elementShadowRadius + leftOffset + westCornerWidth,
            sleekH - elementBorderRadius + currentBitmapH
        );
        canvas.drawBitmap(
            currentBitmap,
            shadowSrcRect,
            shadowDstRectF,
            elementShadowBitmapPaint
        );
        // Bottom-Right-Corner Bitmap
        shadowSrcRect.set(currentBitmapW - eastCornerWidth, 0, currentBitmapW, currentBitmapH);
        shadowDstRectF.set(
            sleekW - elementBorderRadius - rightEdgeModifier,
            sleekH - elementBorderRadius,
            sleekW + eastCornerWidth - elementBorderRadius - rightEdgeModifier,
            sleekH - elementBorderRadius + currentBitmapH
        );
        canvas.drawBitmap(
            currentBitmap,
            shadowSrcRect,
            shadowDstRectF,
            elementShadowBitmapPaint
        );
        // Bottom-Center Bitmap
        shadowSrcRect.set(westCornerWidth, 0, currentBitmapW - eastCornerWidth, currentBitmapH);
        shadowDstRectF.set(
            -elementShadowRadius + leftOffset + westCornerWidth,
            sleekH - elementBorderRadius,
            sleekW - elementBorderRadius - rightEdgeModifier,
            sleekH - elementBorderRadius + currentBitmapH
        );
        canvas.drawBitmap(
            currentBitmap,
            shadowSrcRect,
            shadowDstRectF,
            elementShadowBitmapPaint
        );
      }

      // Left Bitmap
      currentBitmap = leftBitmap;
      currentBitmapW = leftBitmapW;
      currentBitmapH = leftBitmapH;
      shadowSrcRect.set(0, 0, currentBitmapW, currentBitmapH);
      shadowDstRectF.set(
          -elementShadowRadius + leftOffset,
          elementBorderRadius,
          -elementShadowRadius + leftOffset + currentBitmapW,
          elementBorderRadius + currentBitmapH + stretchedHeightDelta
      );
      canvas.drawBitmap(
          currentBitmap,
          shadowSrcRect,
          shadowDstRectF,
          elementShadowBitmapPaint
      );
      //DEBUG DRAW unscaled Left-Bitmap
//    canvas.drawBitmap(
//        elementShadowBitmapList.get(2),
//        -elementShadowRadius + leftOffset,
//        elementBorderRadius,
//        elementShadowBitmapPaint
//    );

      // Right Bitmap
      currentBitmap = rightBitmap;
      currentBitmapW = rightBitmapW;
      currentBitmapH = rightBitmapH;
      shadowSrcRect.set(0, 0, currentBitmapW, currentBitmapH);
      shadowDstRectF.set(
          sleekW - elementBorderRadius,
          elementBorderRadius,
          sleekW - elementBorderRadius + currentBitmapW,
          elementBorderRadius + currentBitmapH + stretchedHeightDelta
      );
      canvas.drawBitmap(
          currentBitmap,
          shadowSrcRect,
          shadowDstRectF,
          elementShadowBitmapPaint
      );
      //DEBUG DRAW unscaled Right-Bitmap
//    canvas.drawBitmap(
//        elementShadowBitmapList.get(3),
//        sleekW - elementBorderRadius,
//        elementBorderRadius,
//        elementShadowBitmapPaint
//    );
    }

    if (!drawBgRectBeforeShadow) {

      // Draw border-rect
      elementShadowBitmapPaint.setColor(elementBorderColor);
      canvas.drawRoundRect(
          new RectF(
              elementBorderRadius,
              elementBorderRadius,
              sleekW - elementBorderRadius,
              sleekH - elementBorderRadius
          ),
          elementBackground.getRoundedRadius(),
          elementBackground.getRoundedRadius(),
          elementShadowBitmapPaint
      );

      // If background-size==COVER and isBitmapLoaded==true then drawing this results in edge-bleed
      if (!elementBackgroundSizeIsCover
          || elementBackgroundImage == null
          || !elementBackgroundImage.isBitmapLoaded()
          || elementBackgroundImage.getPaint().getAlpha() != 255
          ) {
        // Draw background-rect
        elementShadowBitmapPaint.setColor(elementBackgroundColor);
        canvas.drawRoundRect(
            new RectF(
                elementBorderWidth.left,
                elementBorderWidth.top,
                sleekW - elementBorderWidth.right,
                sleekH - elementBorderWidth.bottom
            ),
            elementBackground.getRoundedRadius(),
            elementBackground.getRoundedRadius(),
            elementShadowBitmapPaint
        );
      }
    }

    //DEBUG DRAW regular background for position reference
//    elementBackground.getPaint().setColor(0x99ffffff);
//    elementBackground.onSleekDraw(canvas, info);
//    elementBackground.getPaint().setColor(elementBackgroundColor);

    return true;
  }

  protected List<Bitmap> generateShadowBitmap() {
    ValPair<Point, List<Bitmap>> shadowWHandShadowBitmap = generateShadowBitmap(
        elementShadowRadius,
        sleekW,
        sleekH,
        elementBorderColor,
        elementBorderRadius,
        elementBackgroundColor,
        elementShadowOffsetX,
        elementShadowOffsetY,
        elementShadowColor
    );
    if (shadowWHandShadowBitmap != null) {
      shadowViewSizeW = shadowWHandShadowBitmap.valueOne.x;
      shadowViewSizeH = shadowWHandShadowBitmap.valueOne.y;
      return shadowWHandShadowBitmap.valueTwo;
    }
    return null;
  }

  protected static ValPair<Point, List<Bitmap>> generateShadowBitmap(
      final float elementShadowRadius,
      final int sleekW,
      final int sleekH,
      final int elementBorderColor,
      final int elementBorderRadius,
      final int elementBackgroundColor,
      final float elementShadowOffsetX,
      final float elementShadowOffsetY,
      final int elementShadowColor
  ) {

    if (elementShadowRadius <= 0) {
      return null;
    }

    //TODO Refactor Shadow Bitmaps:
    //TODO Change so that corners and sides are generated instead of TOP/BOTTOM/LEFT/RIGHT ...
    //TODO ...this way we can have large enough corners to get glow in both X-/Y-axis for when...
    //TODO ...we stretch the shadow. As it is now large offset in Y-axis will result in...
    //TODO ...stretched corner-glow when corner-radius ends outside of TOP or BOTTOM Bitmap.

    //TODO BONUS TASK AFTER "Refactor Shadow Bitmaps":
    //TODO Move out drawShadowOnBitmap() method from generateShadowBitmap() in SleekElement,
    //TODO   so that its easy to customize if you want to draw shadow with RenderScript in a
    //TODO   subclass, or some other totally *WILD* way of drawing shadows!

    /*
    // LOW PRIO since why would we want alpha bg-elements with shadow?
    // If we implement alpha bg with shadow then shadowBitmaps need to contain "hidden" ...
    // ... shadow-edges as well, so that they shine through when y-offset is 100px for on a...
    // ... 400x400px box for example, in that example we want the shadow to be drawn behind...
    // ... background at pos Y==100px !
     */

    final int shadowSleekW = sleekW;
    final int shadowSleekH = sleekH;

//    long timestamp = System.currentTimeMillis();

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);
    if (elementBorderColor != SleekColorArea.COLOR_TRANSPARENT) {
      paint.setColor(elementBorderColor);
    } else {
      paint.setColor(elementBackgroundColor);
    }
    paint.setShadowLayer(
        elementShadowRadius,
        elementShadowOffsetX,
        elementShadowOffsetY,
        elementShadowColor
    );

    List<Bitmap> returnList = new ArrayList<>(4);
    int bitmapW, bitmapH;
    Bitmap bitmap;
    Canvas canvas;
    final float cornerWidth = elementShadowRadius;
    final float cornerHeight = elementShadowRadius;
    float translateX, translateY;

    //____________________ -START- Top Bitmap ____________________
    bitmapW = (int) (shadowSleekW + cornerWidth + cornerWidth + Math.abs(elementShadowOffsetX));
    bitmapH = (int) (elementBorderRadius + cornerHeight);
    if (elementShadowOffsetY < 0) {
      bitmapH = bitmapH - (int) elementShadowOffsetY;
    }
    if (bitmapW < 1) {
      bitmapW = 1;
    }
    if (bitmapH < 1) {
      bitmapH = 1;
    }
    bitmap = Bitmap.createBitmap(bitmapW, bitmapH, Bitmap.Config.ARGB_8888);
    bitmap.eraseColor(Color.TRANSPARENT);
    //bitmap.eraseColor(0x66ff00ff);
    canvas = new Canvas(bitmap);
    translateX = 0;
    translateY = 0;
    if (elementShadowOffsetX < 0) {
      translateX = -elementShadowOffsetX;
    }

    if (elementShadowOffsetY < 0) {
      translateY = -elementShadowOffsetY;
    }
    canvas.translate(translateX, translateY);
    canvas.drawRoundRect(
        new RectF(cornerWidth, cornerHeight, cornerWidth + shadowSleekW, cornerHeight + shadowSleekH),
        elementBorderRadius,
        elementBorderRadius,
        paint
    );
    bitmap.prepareToDraw();
    returnList.add(bitmap);
    //____________________ - END - Top Bitmap ____________________

    //____________________ -START- Bottom Bitmap ____________________
    bitmapW = (int) (shadowSleekW + cornerWidth + cornerWidth + Math.abs(elementShadowOffsetX));
    bitmapH = (int) (elementBorderRadius + cornerHeight);
    if (elementShadowOffsetY > 0) {
      bitmapH = bitmapH + (int) elementShadowOffsetY;
    }
    if (bitmapW < 1) {
      bitmapW = 1;
    }
    if (bitmapH < 1) {
      bitmapH = 1;
    }
    bitmap = Bitmap.createBitmap(bitmapW, bitmapH, Bitmap.Config.ARGB_8888);
    bitmap.eraseColor(Color.TRANSPARENT);
    //bitmap.eraseColor(0x66ff00ff);
    canvas = new Canvas(bitmap);
    if (elementShadowOffsetX < 0) {
      canvas.translate(-elementShadowOffsetX, -shadowSleekH - elementShadowRadius + elementBorderRadius);
    } else {
      canvas.translate(0, -shadowSleekH - elementShadowRadius + elementBorderRadius);
    }
    canvas.drawRoundRect(
        new RectF(cornerWidth, cornerHeight, cornerWidth + shadowSleekW, cornerHeight + shadowSleekH),
        elementBorderRadius,
        elementBorderRadius,
        paint
    );
    bitmap.prepareToDraw();
    returnList.add(bitmap);
    //____________________ - END - Bottom Bitmap ____________________

    //____________________ -START- Left Bitmap ____________________
    bitmapW = (int) (elementBorderRadius + cornerWidth);// - elementShadowOffsetX);
    if (elementShadowOffsetX < 0) {
      bitmapW = bitmapW - (int) elementShadowOffsetX;
    }
    bitmapH = (int) (shadowSleekH - elementBorderRadius - elementBorderRadius);
    if (bitmapW < 1) {
      bitmapW = 1;
    }
    if (bitmapH < 1) {
      bitmapH = 1;
    }
    bitmap = Bitmap.createBitmap(bitmapW, bitmapH, Bitmap.Config.ARGB_8888);
    bitmap.eraseColor(Color.TRANSPARENT);
    //bitmap.eraseColor(0x99ff0000);
    canvas = new Canvas(bitmap);
    if (elementShadowOffsetX < 0) {
      canvas.translate(-elementShadowOffsetX, -cornerHeight - elementBorderRadius);
    } else {
      canvas.translate(0, -cornerHeight - elementBorderRadius);
    }
    canvas.drawRoundRect(
        new RectF(cornerWidth, cornerHeight, cornerWidth + shadowSleekW, cornerHeight + shadowSleekH),
        elementBorderRadius,
        elementBorderRadius,
        paint
    );
    bitmap.prepareToDraw();
    returnList.add(bitmap);
    //____________________ - END - Left Bitmap ____________________

    //____________________ -START- Right Bitmap ____________________
    bitmapW = (int) (elementBorderRadius + cornerWidth);
    if (elementShadowOffsetX > 0) {
      bitmapW = bitmapW + (int) elementShadowOffsetX;
    }
    bitmapH = (int) (shadowSleekH - elementBorderRadius - elementBorderRadius);
    if (bitmapW < 1) {
      bitmapW = 1;
    }
    if (bitmapH < 1) {
      bitmapH = 1;
    }
    bitmap = Bitmap.createBitmap(bitmapW, bitmapH, Bitmap.Config.ARGB_8888);
    bitmap.eraseColor(Color.TRANSPARENT);
    //bitmap.eraseColor(0x66000000);
    canvas = new Canvas(bitmap);
    //canvas.translate(0, - elementBorderRadius - elementBorderRadius);
    canvas.translate(
        -shadowSleekW - elementShadowRadius + elementBorderRadius,
        -cornerHeight - elementBorderRadius
    );
    canvas.drawRoundRect(
        new RectF(cornerWidth, cornerHeight, cornerWidth + shadowSleekW, cornerHeight + shadowSleekH),
        elementBorderRadius,
        elementBorderRadius,
        paint
    );
    bitmap.prepareToDraw();
    returnList.add(bitmap);
    //____________________ - END - Right Bitmap ____________________

//    shadowViewSizeW = shadowSleekW;
//    shadowViewSizeH = shadowSleekH;

//    Log.d("SleekElement",
//        "SleekElement | generateShadowBitmap() took: "
//            + (System.currentTimeMillis() - timestamp) + "ms"
//    );

    //return returnList;
    return new ValPair<>(new Point(shadowSleekW, shadowSleekH), returnList);
  }
}


text:
package net.opengis.gml.impl;

import java.math.BigInteger;

import net.opengis.gml.AbstractCoverageType;
import net.opengis.gml.DomainSetType;
import net.opengis.gml.GmlPackage;
import net.opengis.gml.RangeSetType;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.BasicFeatureMap;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 *
 * An implementation of the model object 'Abstract Coverage Type'.
 *
 *

 * The following features are implemented:
 *

 *
{@link net.opengis.gml.impl.AbstractCoverageTypeImpl#getDomainSetGroup Domain Set Group}

 *
{@link net.opengis.gml.impl.AbstractCoverageTypeImpl#getDomainSet Domain Set}

 *
{@link net.opengis.gml.impl.AbstractCoverageTypeImpl#getRangeSet Range Set}

 *
{@link net.opengis.gml.impl.AbstractCoverageTypeImpl#getDimension Dimension}

 *

 *

 *
 * @generated
 */
public abstract class AbstractCoverageTypeImpl extends AbstractFeatureTypeImpl implements AbstractCoverageType {
	/**
	 * The cached value of the '{@link #getDomainSetGroup() Domain Set Group}' attribute list.
	 *
	 *
	 * @see #getDomainSetGroup()
	 * @generated
	 * @ordered
	 */
	protected FeatureMap domainSetGroup;

	/**
	 * The cached value of the '{@link #getRangeSet() Range Set}' containment reference.
	 *
	 *
	 * @see #getRangeSet()
	 * @generated
	 * @ordered
	 */
	protected RangeSetType rangeSet;

	/**
	 * The default value of the '{@link #getDimension() Dimension}' attribute.
	 *
	 *
	 * @see #getDimension()
	 * @generated
	 * @ordered
	 */
	protected static final BigInteger DIMENSION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDimension() Dimension}' attribute.
	 *
	 *
	 * @see #getDimension()
	 * @generated
	 * @ordered
	 */
	protected BigInteger dimension = DIMENSION_EDEFAULT;

	/**
	 *
	 *
	 * @generated
	 */
	protected AbstractCoverageTypeImpl() {
		super();
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return GmlPackage.eINSTANCE.getAbstractCoverageType();
	}

	/**
	 *
	 *
	 * @generated
	 */
	public FeatureMap getDomainSetGroup() {
		if (domainSetGroup == null) {
			domainSetGroup = new BasicFeatureMap(this, GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET_GROUP);
		}
		return domainSetGroup;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public DomainSetType getDomainSet() {
		return (DomainSetType)getDomainSetGroup().get(GmlPackage.eINSTANCE.getAbstractCoverageType_DomainSet(), true);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public NotificationChain basicSetDomainSet(DomainSetType newDomainSet, NotificationChain msgs) {
		return ((FeatureMap.Internal)getDomainSetGroup()).basicAdd(GmlPackage.eINSTANCE.getAbstractCoverageType_DomainSet(), newDomainSet, msgs);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public void setDomainSet(DomainSetType newDomainSet) {
		((FeatureMap.Internal)getDomainSetGroup()).set(GmlPackage.eINSTANCE.getAbstractCoverageType_DomainSet(), newDomainSet);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public RangeSetType getRangeSet() {
		return rangeSet;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public NotificationChain basicSetRangeSet(RangeSetType newRangeSet, NotificationChain msgs) {
		RangeSetType oldRangeSet = rangeSet;
		rangeSet = newRangeSet;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GmlPackage.ABSTRACT_COVERAGE_TYPE__RANGE_SET, oldRangeSet, newRangeSet);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public void setRangeSet(RangeSetType newRangeSet) {
		if (newRangeSet != rangeSet) {
			NotificationChain msgs = null;
			if (rangeSet != null)
				msgs = ((InternalEObject)rangeSet).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GmlPackage.ABSTRACT_COVERAGE_TYPE__RANGE_SET, null, msgs);
			if (newRangeSet != null)
				msgs = ((InternalEObject)newRangeSet).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GmlPackage.ABSTRACT_COVERAGE_TYPE__RANGE_SET, null, msgs);
			msgs = basicSetRangeSet(newRangeSet, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GmlPackage.ABSTRACT_COVERAGE_TYPE__RANGE_SET, newRangeSet, newRangeSet));
	}

	/**
	 *
	 *
	 * @generated
	 */
	public BigInteger getDimension() {
		return dimension;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public void setDimension(BigInteger newDimension) {
		BigInteger oldDimension = dimension;
		dimension = newDimension;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GmlPackage.ABSTRACT_COVERAGE_TYPE__DIMENSION, oldDimension, dimension));
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET_GROUP:
				return ((InternalEList<?>)getDomainSetGroup()).basicRemove(otherEnd, msgs);
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET:
				return basicSetDomainSet(null, msgs);
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__RANGE_SET:
				return basicSetRangeSet(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET_GROUP:
				if (coreType) return getDomainSetGroup();
				return ((FeatureMap.Internal)getDomainSetGroup()).getWrapper();
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET:
				return getDomainSet();
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__RANGE_SET:
				return getRangeSet();
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DIMENSION:
				return getDimension();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET_GROUP:
				((FeatureMap.Internal)getDomainSetGroup()).set(newValue);
				return;
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET:
				setDomainSet((DomainSetType)newValue);
				return;
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__RANGE_SET:
				setRangeSet((RangeSetType)newValue);
				return;
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DIMENSION:
				setDimension((BigInteger)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET_GROUP:
				getDomainSetGroup().clear();
				return;
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET:
				setDomainSet((DomainSetType)null);
				return;
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__RANGE_SET:
				setRangeSet((RangeSetType)null);
				return;
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DIMENSION:
				setDimension(DIMENSION_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET_GROUP:
				return domainSetGroup != null && !domainSetGroup.isEmpty();
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DOMAIN_SET:
				return getDomainSet() != null;
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__RANGE_SET:
				return rangeSet != null;
			case GmlPackage.ABSTRACT_COVERAGE_TYPE__DIMENSION:
				return DIMENSION_EDEFAULT == null ? dimension != null : !DIMENSION_EDEFAULT.equals(dimension);
		}
		return super.eIsSet(featureID);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (domainSetGroup: ");
		result.append(domainSetGroup);
		result.append(", dimension: ");
		result.append(dimension);
		result.append(')');
		return result.toString();
	}

} //AbstractCoverageTypeImpl

redpajama_set_name: RedPajamaGithub


text:
#include <Network\NetworkListener.h>

namespace RL {
namespace Network {

NetworkListener::NetworkListener() {
    receiveAddress = Poco::Net::SocketAddress(Poco::Net::IPAddress(), 49003);
    dataSocket.setBlocking(false);
    dataSocket.bind(receiveAddress, false);

    buffer.fill(0);

    sizeOfLastPacket = 0;
}

NetworkListener::~NetworkListener() {
    dataSocket.close();
}

Poco::Net::SocketAddress NetworkListener::checkforPacket() {
    Poco::Net::SocketAddress sender;

    try {
        sizeOfLastPacket = dataSocket.receiveFrom(buffer.data(),
                    RL::Network::NETMESSAGE_SIZE, sender);
    } catch (Poco::TimeoutException &e) {
        sizeOfLastPacket = 0;
    }

    return sender;
}

int NetworkListener::getLastPacketSize() const {
    return sizeOfLastPacket;
}

} /* namespace Network */
} /* namespace RL */


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.nbandroid.netbeans.gradle.launch;

import javax.annotation.Nullable;

/**
 * Description what to do when the project is launched.
 *
 * @author radim
 */
public interface LaunchConfiguration {

    public static final String MODE_DEBUG = "debug";
    public static final String MODE_RELEASE = "release";

    public enum Action {
        MAIN,
        ACTIVITY,
        DO_NOTHING
    }

    /**
     * Mode used to select target device for launch.
     */
    public enum TargetMode {
        AUTO,
        MANUAL;
    }

    @Deprecated
    Action getLaunchAction();

    /**
     * A class name of executed activity or {@code null} if not applicable.
     */
    @Deprecated
    @Nullable
    String getActivityName();

    // TODO extract as this does not belong to project config.
    /**
     * Debug or release mode.
     */
    String getMode();

    TargetMode getTargetMode();

    String getEmulatorOptions();

    @Nullable
    String getInstrumentationRunner();
}


text:
package com.adamheins.dervish.builder;

import com.adamheins.dervish.function.Function;

/**
 * The FunctionBuilder class allows trees of Functions to be easily built from a
 * serial stream of constituting functions.
 *
 * @author Adam
 */
public class FunctionBuilder {

    // Current node in the tree, which is the one that was most recently added.
    private FunctionNode current;

    /**
     * Constructor.
     */
    public FunctionBuilder() {
        current = null;
    }

    /**
     * Add a new function into the tree.
     *
     * @param function The function to be added to the tree.
     * @param bracketDepth The number of brackets in which the function is
     *         nested.
     */
    public void add(Function function, int bracketDepth) {
        FunctionNode node = new FunctionNode(function, bracketDepth);

        if (current!= null)
            current.add(node);

        current = node;
    }

    /**
     * Get the root function in the function-tree.
     *
     * @return The root function.
     */
    private Function getRoot() {

        FunctionNode rootNode = current;
        while (rootNode.getParent() != null)
            rootNode = rootNode.getParent();
        return rootNode.getFunction();
    }

    /**
     * Gets the root function after it has been built. The function is
     * automatically evaluated first, to put it into its simplest form.
     *
     * It should be fine if additional nodes are added after this function is
     * called.
     *
     * @return The root function.
     */
    public Function getFunction() {
        return getRoot().evaluate();
    }
}


text:
## Copyright 2015 JAXIO http://www.jaxio.com
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
##    http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
$output.java($WebModelSupport, "GenericToOneAssociation")##

$output.require("java.io.Serializable")##
$output.require("com.jaxio.jpa.querybyexample.Identifiable")##
$output.require($WebPermissionSupport, "GenericPermission")##
$output.require($WebUtil, "MessageUtil")##

/**
 * Controller that allows you to manage an entity's x-to-one association.
 */
public abstract class $output.currentClass<E extends Identifiable<PK>, PK extends Serializable> {
    protected  GenericController<E, PK> controller;
    protected  GenericPermission<E> permission;
    protected  MessageUtil messageUtil;
    protected  String labelKey;

    public ${output.currentClass}(String labelKey, GenericController<E, PK> controller) {
        this.labelKey = labelKey;
        this.controller = controller;
        this.messageUtil = controller.getMessageUtil();
        this.permission = controller.getPermission();
    }

    protected abstract E get();

    protected abstract void set(E e);

    /**
     * Helper for the autoComplete component.
     */
    public E getSelected() {
        return get();
    }

    /**
     * Handles ajax autoComplete event and regular page postback.
     */
    public void setSelected(E selected) {
        set(selected);
    }

    public String add() {
        return controller.create();
    }

    public String edit() {
        return controller.edit(get());
    }

    public String view() {
        return controller.view(get());
    }
}


text:
package com.emergya.selenium.drivers;

import org.openqa.selenium.By;
import org.openqa.selenium.ie.InternetExplorerDriver;

/**
 * Custom driver for internet explorer
 *
 * @author Jose Antonio Sanchez <jasanchez@emergya.com>
 * @author Alejandro Gomez <agommor@gmail.com>
 */
public class EmergyaIEDriver extends InternetExplorerDriver implements EmergyaWebDriver {

    /**
     * Main window handler to perform windows switch later.
     */
    private String mainWindowHandler;

    /**
     * Constructor
     */
    public EmergyaIEDriver() {
        super();
        mainWindowHandler = EmergyaWebDriverUtil.getCurrentWindowHandler(this);
    }

    // **** Basic operation methods section ****//
    /**
     * Checks if an element exists in the DOM
     *
     * @param selector
     *            By element
     * @return True if the element exists in the DOM and false in the opposite
     *         case
     */
    public boolean existsElement(By selector) {
        return EmergyaWebDriverUtil.existsElement(this, selector);
    }

    /**
     * Checks if an element exists in the DOM and is displayed
     *
     * @param selector
     *            By element
     * @return True if the element exists in the DOM and is displayed and false
     *         in the opposite case
     */
    public boolean isElementDisplayed(By selector) {
        return EmergyaWebDriverUtil.isElementDisplayed(this, selector);
    }

    /**
     * Clicks on an element after wait and if it is displayed
     *
     * @param selector
     *            By element
     */
    public void clickIfExists(By selector) {
        EmergyaWebDriverUtil.clickIfExists(this, selector);
    }

    // **** Javascript methods section ****//
    /**
     * Executes JavaScript in the context of the currently window
     *
     * @param script
     *            The JavaScript to execute
     * @return Boolean, Long, String, List, WebElement Or null
     */
    public Object executeJavaScript(String script) {
        return EmergyaWebDriverUtil.executeJavaScript(this, script);
    }

    /**
     * Puts the focus on an element through its id
     *
     * @param driver
     *            WebDriver element
     * @param id
     *            string with the id of an element
     */
    public void focus(String id) {
        EmergyaWebDriverUtil.focus(this, id);
    }

    // **** Screenshot methods section ****//
    /**
     * Saves a screenshot in a path with a timestamp
     *
     * @param folderPath
     *            to save the screenshot
     * @param baseFileName
     *            file name
     */
    public void saveScreenshotPath(String folderPath, String baseFileName) {
        EmergyaWebDriverUtil.saveScreenshotPath(this, folderPath, baseFileName);
    }

    /**
     * Saves a screenshot in the default path
     *
     * @param driver
     *            WebDriver element
     */
    public void saveScreenshotDefault() {
        EmergyaWebDriverUtil.saveScreenshotDefault(this);
    }

    // **** Sleep method ****//
    /**
     * Stops the execution during some seconds
     *
     * @param seconds
     *            time to stop the execution
     */
    public void sleep(int seconds) {
        EmergyaWebDriverUtil.sleep(seconds);
    }

    // **** Keyboard events methods section ****//
    /**
     * Presses a keyboard key
     *
     * @param key
     *            to press
     * @param sleepTime
     *            time to wait before and after to press the key
     */
    public void pressKey(int key, int sleepTime) {
        EmergyaWebDriverUtil.pressKey(key, sleepTime);
    }

    /**
     * Releases a keyboard key
     *
     * @param key
     *            to release
     * @param sleepTime
     *            time to wait before and after to release the key
     */
    public void releaseKey(int key, int sleepTime) {
        EmergyaWebDriverUtil.releaseKey(key, sleepTime);
    }

    /**
     * Presses and releases a keyboard key
     *
     * @param key
     *            to press and release
     */
    public void pressReleaseKey(int key) {
        EmergyaWebDriverUtil.pressReleaseKey(key);
    }

    // **** Mouse events methods section ****//
    /**
     * Moves the mouse over an element
     *
     * @param selector
     *            By element
     */
    public void moveMouseOverElement(By selector) {
        EmergyaWebDriverUtil.moveMouseOverElement(this, selector);
    }

    /**
     * Moves the mouse out of an element
     *
     * @param selector
     *            By element
     */
    public void moveMouseOutElement(By selector) {
        EmergyaWebDriverUtil.moveMouseOutElement(this, selector);
    }

    /**
     * Clicks with the mouse on an element
     *
     * @param selector
     *            By element
     */
    public void clickOnWithMouse(By selector) {
        EmergyaWebDriverUtil.clickOnWithMouse(this, selector);
    }

    /**
     * Clicks with the mouse out of an element
     *
     * @param selector
     *            By element
     */
    public void clickOutWithMouse(By selector) {
        EmergyaWebDriverUtil.clickOutWithMouse(this, selector);
    }

    /**
     * Double clicks with the mouse on an element
     *
     * @param selector
     *            By element
     */
    public void doubleClickOnWithMouse(By selector) {
        EmergyaWebDriverUtil.doubleClickOnWithMouse(this, selector);

    }

    // **** Wait methods section ****//
    /**
     * It sleeps the driver for X seconds. If the element is visible in the
     * page, the execution continue without waiting X seconds
     *
     * @param selector
     *            By element for wait
     * @param seconds
     *            to be slept
     * @return true if the element exist in the DOM and false in the opposite
     *         case
     */
    public boolean wait(By selector, long seconds) {
        return EmergyaWebDriverUtil.wait(this, selector, seconds);
    }

    /**
     * It sleeps the driver for X seconds. If the element is visible in the
     * page, the execution continue without waiting X seconds
     *
     * @param selector
     *            By element for wait
     * @param seconds
     *            to be slept
     * @return true if the element is visible in the page and false in the
     *         opposite case
     */
    public boolean waitUntilVisible(By selector, long seconds) {
        return EmergyaWebDriverUtil.waitUntilVisible(this, selector, seconds);
    }

    /**
     * It sleeps the driver for X seconds. If the element is clickable in the
     * page, the execution continue without waiting X seconds
     *
     * @param selector
     *            By element for wait
     * @param seconds
     *            to be slept
     * @return true if the element is clickable in the page and false in the
     *         opposite case
     */
    public boolean waitUntilElementClickable(By selector, long seconds) {
        return EmergyaWebDriverUtil.waitUntilElementClickable(this, selector, seconds);
    }

    /**
     * It sleeps the driver for X seconds. If the text is present in element,
     * the execution continue without waiting X seconds
     *
     * @param selector
     *            By element for wait
     * @param seconds
     *            to be slept
     * @param text
     *            to be find
     * @return true If the text is present in element, and false in the opposite
     *         case
     */
    public boolean waitUntilTextPresent(By selector, long seconds, String text) {
        return EmergyaWebDriverUtil.waitUntilTextPresent(this, selector, seconds, text);
    }

    /**
     * @see EmergyaWebDriver#switchToMainwindow()
     */
    @Override
    public void switchToMainwindow() {
        this.sleep(1);
        this.switchTo().window(mainWindowHandler);
        this.sleep(1);
    }

    /**
     * @see EmergyaWebDriver#isCurrentWindowOpen()
     */
    @Override
    public Boolean isCurrentWindowOpen() {
        return EmergyaWebDriverUtil.isCurrentWindowOpen(this);
    }

}


text:
Métodos Empacotadores

String -> Valores

Integer, Float, Long, Double, Character
Ex: Integer.parseInt()
Boolean
Ex: boolean b = new Boolean("true") .booleanValue();

Obs: Só passara números para valores, não funcionara com letras


text:
* These are types of data structures
* They are also important parts of the Java Memory Model (JMM)

# Heap
* Where all objects are stored

# Stack
* Allows us to have methods
  * parameters
  * where to return to
* Stores local variables
* Last in first out (LIFO)
  * think of a stack of plates

```
public static void main(String[] args) {
  methodOne();
}

static void methodOne() {
  methodTwo();
}

static void methodTwo() {
  Person john = new Person();
  int x = 5;
}
```


text:
import csvio
import numpy as np
from sklearn.decomposition import PCA
from sklearn import svm

X = csvio.load_csv_data("../data/train_inputs.csv")
X = np.array(X)
y = csvio.load_csv_data("train_outputs.csv")

pca = PCA(n_components=500)
pcaX = pca.fit_transform(X)
X_kaggle = csvio.load_csv_data("test_inputs.csv")
X_kaggle = np.array(X_kaggle)
pcaKaggle = pca.transform(X_kaggle)

lin_clf = svm.LinearSVC()
pred = lin_clf.predict(pcaKaggle)
csvio.write_csv_output([int(x) for x in pred], "svm_test.csv")


text:
import React from 'react';
import PropTypes from 'prop-types';
import { numberProp } from './props';

// eslint is broken doesn't like when we just check the props without "using" them
/* eslint-disable react/no-unused-prop-types */
module.exports = class Stop extends React.Component {
  static propTypes = {
    stopColor: PropTypes.string,
    stopOpacity: numberProp,
    children: PropTypes.node,
  };

  static defaultProps = {
    stopColor: '#000',
    stopOpacity: 1,
  };

  render() {
    const { children, ...rest } = this.props;
    return <svg_stop {...rest}>{children}</svg_stop>;
  }
};


text:
package org.multibit.hd.ui.fest.use_cases.standard.credentials;

import com.google.common.util.concurrent.Uninterruptibles;
import org.fest.swing.fixture.FrameFixture;
import org.multibit.hd.core.dto.CoreMessageKey;
import org.multibit.hd.ui.fest.use_cases.AbstractFestUseCase;
import org.multibit.hd.ui.languages.Languages;
import org.multibit.hd.ui.languages.MessageKey;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.fest.swing.timing.Timeout.timeout;

/**
 *
Use case to provide the following to FEST testing:

 *

 *
Click "restore" button with a hardware wallet attached

 *

 *
 * @since 0.0.5
 */
public class RestoreButtonHardwareWalletUseCase extends AbstractFestUseCase {

  public RestoreButtonHardwareWalletUseCase(FrameFixture window) {
    super(window);
  }

  @Override
  public void execute(Map<String, Object> parameters) {

    // Fixed time to unlock
    pauseForWalletUnlock();

    // Test for successful wallet load
    assertLabelContainsValue(
      CoreMessageKey.WALLET_LOADING.getKey(),
      Languages.safeText(CoreMessageKey.WALLET_LOADED_OK));

    // Wait for Finish button to appear
    window
      .button(MessageKey.FINISH.getKey())
      .requireVisible()
        // Allow a short time to overcome initialisation delays
      .requireEnabled(timeout(1, TimeUnit.SECONDS));

    // Click on the Restore button
    window
      .button(MessageKey.RESTORE.getKey())
      .click();

    // Allow time for the wizard hand over to take place
    pauseForViewReset();

    // Click on the Next button, which selects the last backup and starts the actual restore
    window
      .button(MessageKey.NEXT.getKey())
      .requireVisible()
        // Allow a short time to overcome initialisation delays
      .requireEnabled();

    // Click on the Next button
    window
      .button(MessageKey.NEXT.getKey())
      .click();

    // Wait for the restore screen to open and the wallet to load
    Uninterruptibles.sleepUninterruptibly(4, TimeUnit.SECONDS);

    // Test for successful wallet load
    assertLabelContainsValue(
      MessageKey.WALLET_CREATED_STATUS.getKey(),
      Languages.safeText(MessageKey.WALLET_CREATED_STATUS));

    // Click on the Finish button
    window
      .button(MessageKey.FINISH.getKey())
        // Allow a short time to overcome initialisation delays
      .requireEnabled(timeout(1, TimeUnit.SECONDS))
      .click();

    // Expect a handover to the credentials wizard
  }
}


text:
package com.github.forhacks.evolve2048;

import java.util.ArrayList;

class InputNeuron extends Neuron {

    private double value;

    InputNeuron() {
        super(new ArrayList<>(), null);
    }

    void setValue(int value, int maxvalue) {
        if (value != 0)
            this.value = Math.log(value) / Math.log(maxvalue);
        this._value = this.value;
    }

    public double[] getData() {

        return new double[] {_value, 0, 0, 0, 0};

    }

    public void mutate(Layer prev) {}

}


text:
//======================================================================================
// Copyright 5AM Solutions Inc, Yale University
//
// Distributed under the OSI-approved BSD 3-Clause License.
// See http://ncip.github.com/caarray/LICENSE.txt for details.
//======================================================================================
package gov.nih.nci.copynumberconverter;

/**
 * Specifies copy number data file column mapping info.
 * @author dharley
 *
 */
public class ColumnInfo {

    private final String probeNameColumnHeader;
    private final String chromosomeIdColumnHeader;
    private final String chromosomePositionColumnHeader;
    private final String log2RatiosColumnHeader;
    private final String delimiter;
    private final boolean isUsingPrefix;
    private final String hybridizationName;

    /**
     * Wrapper object to encapsulate all data column mapping info.
     *
     * @param probeNameColumnHeader the name of the input file column which contains probe names.
     * @param chromosomeIdColumnHeader the name of the input file column which contains chromosome IDs (can be null).
     * @param chromosomePositionColumnHeader the name of the input file column which contains chromosome positions (can
     * be null).
     * @param log2RatiosColumnHeader the name of the input file column which contains log2ration data.
     * @param delimiter the delimiter used in a multi-hybridization input file to seperate hybridization name from
     * log2RatiosColumnHeader.
     * @param isUsingPrefix indicates whether or not the multi-hybridization input file uses the hybridization name as
     * a prefix (false means it is a suffix, andvalue is ignored in single hybridization cases).
     * @param hybridizationName the name of the hybridization for single-hybridization input files (null indicates
     * multi-hybridization case)
     */
    @SuppressWarnings({ "PMD.ExcessiveParameterList" })
    public ColumnInfo(final String probeNameColumnHeader, final String chromosomeIdColumnHeader,
            final String chromosomePositionColumnHeader, final String log2RatiosColumnHeader,
            final String delimiter, final boolean isUsingPrefix, final String hybridizationName) {
        this.probeNameColumnHeader = probeNameColumnHeader;
        this.chromosomeIdColumnHeader = chromosomeIdColumnHeader;
        this.chromosomePositionColumnHeader = chromosomePositionColumnHeader;
        this.log2RatiosColumnHeader = log2RatiosColumnHeader;
        this.delimiter = delimiter;
        this.isUsingPrefix = isUsingPrefix;
        this.hybridizationName = hybridizationName;
    }

    /**
     * Gets probeNameColumnHeader.
     * @return probeNameColumnHeader the header
     */
    public String getProbeNameColumnHeader() {
        return probeNameColumnHeader;
    }

    /**
     * Gets chromosomeIdColumnHeader.
     * @return chromosomeIdColumnHeader the header
     */
    public String getChromosomeIdColumnHeader() {
        return chromosomeIdColumnHeader;
    }

    /**
     * Gets chromosomePositionColumnHeader.
     * @return chromosomePositionColumnHeader the header
     */
    public String getChromosomePositionColumnHeader() {
        return chromosomePositionColumnHeader;
    }

    /**
     * Gets log2RatiosColumnHeader.
     * @return log2RatiosColumnHeader the header
     */
    public String getLog2RatiosColumnHeader() {
        return log2RatiosColumnHeader;
    }

    /**
     * Gets delimiter.
     * @return delimiter the header delimiter
     */
    public String getDelimiter() {
        return delimiter;
    }

    /**
     * Gets isUsingPrefix.
     * @return isUsingPrefix if is using prefix
     */
    public boolean isUsingPrefix() {
        return isUsingPrefix;
    }

    /**
     * Gets hybridizationName.
     * @return hybridizationName the header

     */
    public String getHybridizationName() {
        return hybridizationName;
    }
}


text:
import os

ROOT_DIR=os.path.dirname(os.path.abspath(__file__))
CONFIG_PATH=ROOT_DIR + '/res'


text:
/**
 * Dependency GraphData parser
 *
 * @class DependencyParser
 * @constructor
 * @author Yoshiaki Sugimoto <sugimoto@wnotes.net>
 * @param {Object} dependencies
 */
function DependencyParser(dependencies) {
    /**
     * dependencies
     *
     * @property dependencies
     * @type Object
     */
    this.dependencies = dependencies;

    /**
     * Depend Node relation data
     *
     * @property nodes
     * @type Array
     */
    this.nodes = [];

    /**
     * Depend Link relation data
     *
     * @property links
     * @type Array
     */
    this.links = [];

    /**
     * NodeSet stack
     *
     * @property nodeSet
     * @type Object
     */
    this.nodeSet = {};

    /**
     * Module prefixes
     *
     * @property prefixes
     * @type Object
     */
    this.prefixes = {};

    /**
     * Node index
     *
     * @property nodeIndex
     * @type Number
     */
    this.nodeIndex = 0;
}

/**
 * Parse and analytic dependency
 *
 * @method parse
 * @param {Array} regecColormatchers
 * @return {Object}
 */
DependencyParser.prototype.parse = function(regexColormatchers) {
    var that      = this,
        idx       = 0,
        groupRegexIdentifiers,
        node,
        key,
        i,
        size;

    // analysis dependency links
    this.dependencies.links.forEach(function(link) {
        that.parseNodeSet(link);
    });

    groupRegexIdentifiers = this.getGroupRegexIdentifiers(regexColormatchers);
    size                  = groupRegexIdentifiers.length;

    for ( key in this.nodeSet ) {
        if ( ! this.nodeSet.hasOwnProperty(key) ) {
            continue;
        }

        node        = this.nodeSet[key];
        node.group  = 0;
        node.weight = node.source;

        for ( i = 0; i < size; ++i ) {
            if ( (new RegExp(groupRegexIdentifiers[i])).test(key) ) {
                node.group = i + 1;
                break;
            }
        }

        this.nodes.push(node);
        console.log("Pushing node : idx=" + idx + ", name=" + key + ", groupId=" + node.group + ", source=" + node.source + ", dest=" + node.dest + ", weight=" + node.weight);
        idx++;
    }

    return {
        nodes: this.nodes,
        links: this.links
    };
};

/**
 * Parse node set
 *
 * @method parseNodeSet
 * @param {Object} link
 * @return {Void}
 */
DependencyParser.prototype.parseNodeSet = function(link) {
    var source,
        dest;

    // find source
    source = this.nodeSet[link.source];
    if ( ! source ) {
        this.nodeSet[link.source] = source = {
            idx:    this.nodeIndex++,
            name:   link.source,
            source: 1,
            dest:   0
        };
    }
    source.source++;

    // find dest
    dest = this.nodeSet[link.dest];
    if ( ! dest ) {
        this.nodeSet[link.dest] = dest = {
            idx:    this.nodeIndex++,
            name:   link.dest,
            source: 0,
            dest:   1
        };
    }
    dest.dest++;

    this.updatePrefix(link.source);
    this.updatePrefix(link.dest);

    this.links.push({
        source: source.idx,
        target: dest.idx,

        sourceNode: source,
        targetNode: dest
    });

    console.log('Pushing link : source="' + source.idx + '", target="' + dest.idx);
};

/**
 * Get group regex ideintifiers
 *
 * @method getGroupRegexIdentifiers
 * @param {Array} matchers
 * @return {Array}
 */
DependencyParser.prototype.getGroupRegexIdentifiers = function(matchers) {
    var prefix = [],
        key,
        sorted;

    for ( key in this.prefixes ) {
        if ( this.prefixes.hasOwnProperty(key) ) {
            prefix.push({
                key:   key,
                value: this.prefixes[key]
            });
        }
    }

    sorted = prefix.slice(0).sort(function(a, b) {
        return b.value - a.value;
    });

    if ( ! matchers ) {
        matchers = [];
        sorted.forEach(function(v) {
            matchers.push('^' + v.key + '.*');
        });
    }

    return matchers;
};

/**
 * Add stack prefix string
 *
 * @method updatePrefix
 * @param {String} name
 * @return {Void}
 */
DependencyParser.prototype.updatePrefix = function(name) {
    var prefix = name.slice(0, 2);

    if ( ! (prefix in this.prefixes) ) {
        this.prefixes[prefix] = 1;
    } else {
        this.prefixes[prefix]++;
    }
};

// node or browser
if ( typeof process !== 'undefined' ) {
    module.exports = DependencyParser;
} else {
    this.DependencyParser = DependencyParser;
}


text:
cask 'ftdi-vcp-driver' do
  if MacOS.release <= :mountain_lion
    version '2.2.18'
    sha256 '248f582527175ab07334f6a1255c8be2da4dfc36da49e26d39a2f61f5b7ba2e7'
    pkg 'FTDIUSBSerialDriver_10_4_10_5_10_6_10_7.mpkg'
  else
    version '2.3'
    sha256 '08e7fab56d20832ea609bfb2758130279ba49722084298a952796a009b82442d'
    pkg 'FTDIUSBSerial.pkg'
  end

  url "http://www.ftdichip.com/Drivers/VCP/MacOSX/FTDIUSBSerialDriver_v#{version.gsub('.','_')}.dmg"
  name 'FTDI VCP Driver'
  homepage 'http://www.ftdichip.com/Drivers/VCP.htm'
  license :gratis

  uninstall :pkgutil => 'com.FTDI.ftdiusbserialdriverinstaller.*',
            :kext    => 'com.FTDI.driver.FTDIUSBSerialDriver',
            :delete  => '/Library/Extensions/FTDIUSBSerialDriver.kext'

  caveats do
    reboot

    <<-EOC.undent
      If you don't want to reboot, you can load the driver using the following
      command:

        sudo /sbin/kextload -b com.FTDI.driver.FTDIUSBSerialDriver

      Once you've rebooted or loaded the driver, you can connect your FTDI
      based cable to a USB port and it will show up in /dev, usually like this:

        /dev/tty.usbserial-XXXXXXXX

      where XXXXXXXX is a random ID, based on the serial number of your FTDI
      based cable.

      NOTE: If your FTDI based cable was already connected before you installed
      the driver, you'll need to unplug the cable from the USB port and
      reconnect it for it to show up in /dev.
    EOC
  end

end


text:
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Mail\BaseMailTrait;

class AskCompletion extends Mailable
{
    use Queueable, SerializesModels;

    public $options;
    public $data;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($user)
    {
        $this->user = $user;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('emails.ask.customer')->to($this->user->email,$this->user->name);
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?attr/colorControlHighlight">
    <item android:drawable="@color/button_background"/>
</ripple>
<!-- From: file:/home/juan/Escritorio/Isly/app/src/main/res/drawable/raised_button_background.xml -->


text:
'''
Test_provTools.py
  Defines unit tests for provTools.py from src/derivation/.
'''

#############
#  IMPORTS  #
#############
# standard python packages
import inspect, os, sqlite3, sys, unittest
from StringIO import StringIO
# ------------------------------------------------------ #
# import sibling packages HERE!!!
packagePath  = os.path.abspath( __file__ + "/../../../src" )
sys.path.append( packagePath )

from derivation import Node, FactNode
# ------------------------------------------------------ #

#####################
#  TEST PROV TOOLS  #
#####################
class Test_provTools( unittest.TestCase ) :

  #################
  #  CREATE NODE  #
  #################
  def test_createNode_provTools( self ) :
    return None

#########################
#  THREAD OF EXECUTION  #
#########################
# use this main if running this script exclusively.
if __name__ == "__main__" :
    unittest.main( verbosity=2 )

#########
#  EOF  #
#########


text:
<!DOCTYPE html>

    <title>purescript-indexeddb demo</title>

      <input id="recordInput" type="text" placeholder="Type something here"/>
      <button id="addRecord">Save Record</button>

Records in Database:


text:
namespace app { namespace Fuse { namespace Animations { struct MixerHandle__Fuse_Animations_KeyframeInterpolation; } } }

namespace app {
namespace Uno {
namespace Collections {

::uInterfaceType* IEnumerator__Fuse_Animations_MixerHandle_Fuse_Animations_KeyframeInterpolation___typeof();

struct IEnumerator__Fuse_Animations_MixerHandle_Fuse_Animations_KeyframeInterpolation_
{
    ::app::Fuse::Animations::MixerHandle__Fuse_Animations_KeyframeInterpolation*(*__fp_get_Current)(void*);

    static ::app::Fuse::Animations::MixerHandle__Fuse_Animations_KeyframeInterpolation* Current(::uObject* __this) { return ((IEnumerator__Fuse_Animations_MixerHandle_Fuse_Animations_KeyframeInterpolation_*)uGetInterfacePtr(__this, IEnumerator__Fuse_Animations_MixerHandle_Fuse_Animations_KeyframeInterpolation___typeof()))->__fp_get_Current((::uByte*)__this + (__this->__obj_type->TypeType == uTypeTypeStruct ? sizeof(::uObject) : 0)); }
};

}}}

#endif


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Symb. bot. upsal. 20(no. 2): 119 (1974)

#### Original name
Collema senecionis F. Wilson

### Remarks
null


text:
namespace Google.Cloud.AppEngine.V1.Snippets
{
    // [START appengine_v1_generated_AuthorizedCertificates_UpdateAuthorizedCertificate_async]
    using Google.Cloud.AppEngine.V1;
    using Google.Protobuf.WellKnownTypes;
    using System.Threading.Tasks;

    public sealed partial class GeneratedAuthorizedCertificatesClientSnippets
    {
        /// <summary>Snippet for UpdateAuthorizedCertificateAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated and should be regarded as a code template only.
        /// It will require modifications to work:
        /// - It may require correct/in-range values for request initialization.
        /// - It may require specifying regional endpoints when creating the service client as shown in
        ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
        /// </remarks>
        public async Task UpdateAuthorizedCertificateRequestObjectAsync()
        {
            // Create client
            AuthorizedCertificatesClient authorizedCertificatesClient = await AuthorizedCertificatesClient.CreateAsync();
            // Initialize request argument(s)
            UpdateAuthorizedCertificateRequest request = new UpdateAuthorizedCertificateRequest
            {
                Name = "",
                Certificate = new AuthorizedCertificate(),
                UpdateMask = new FieldMask(),
            };
            // Make the request
            AuthorizedCertificate response = await authorizedCertificatesClient.UpdateAuthorizedCertificateAsync(request);
        }
    }
    // [END appengine_v1_generated_AuthorizedCertificates_UpdateAuthorizedCertificate_async]
}