Codota Logo
LikeView
Code IndexAdd Codota to your IDE (free)

How to use
LikeView
in
cn.izouxiang.likeview

Best Java code snippets using cn.izouxiang.likeview.LikeView (Showing top 9 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: zFxiang/LikeView

/**
 * 修改数值
 *
 * @param number 新值
 */
public void setNumber(long number) {
  setNumber(number, false);
}
origin: zFxiang/LikeView

/**
 * 激活并且给数值加1
 */
public void activateAndPlusOne() {
  add(1);
  activate();
}
origin: zFxiang/LikeView

/**
 * 切换当前状态
 */
public void trigger() {
  if (isActivated) {
    if (!notAllowedCancel) {
      deactivateAndTallyDown();
    }
  } else {
    activateAndPlusOne();
  }
}
origin: zFxiang/LikeView

@Override
protected void onDraw(Canvas canvas) {
  drawGraph(canvas);
  drawNumber(canvas);
}
origin: zFxiang/LikeView

  graphColor = textColor = Color.parseColor("#888888");
  animateColor = Color.parseColor("#ca5f5f");
  textSize = sp2px(14);
  isActivated = false;
  animateDuration = 300L;
  distance = dp2px(3);
  graphStrokeWidth = dp2px(3);
  textStrokeWidth = dp2px(2);
  graphTextHeightRatio = 1.3f;
  autoMeasureMaxTextWidth = true;
  gravity = GRAVITY_CENTER;
} else {
  TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.LikeView);
  try {
    number = ta.getInt(R.styleable.LikeView_number, 0);
    textColor = ta.getColor(R.styleable.LikeView_textColor, Color.parseColor("#888888"));
    animateColor = ta.getColor(R.styleable.LikeView_animateColor, Color.parseColor("#ca5f5f"));
    textSize = ta.getDimensionPixelSize(R.styleable.LikeView_textSize, sp2px(14));
    isActivated = ta.getBoolean(R.styleable.LikeView_isActivated, false);
    autoMeasureMaxTextWidth = ta.getBoolean(R.styleable.LikeView_autoMeasureMaxWidth, true);
    notAllowedCancel = ta.getBoolean(R.styleable.LikeView_notAllowedCancel, false);
    animateDuration = ta.getInt(R.styleable.LikeView_animateDuration, 300);
    distance = ta.getDimensionPixelSize(R.styleable.LikeView_distance, dp2px(3));
    graphStrokeWidth = ta.getDimensionPixelSize(R.styleable.LikeView_graphStrokeWidth, dp2px(3));
    textStrokeWidth = ta.getDimensionPixelSize(R.styleable.LikeView_textStrokeWidth, dp2px(2));
    graphTextHeightRatio = ta.getFloat(R.styleable.LikeView_graphTextHeightRatio, 1.3f);
    gravity = ta.getInteger(R.styleable.LikeView_gravity,GRAVITY_CENTER);
origin: zFxiang/LikeView

final SSEntity entity = ssEntities.get(position);
holder.like.setActivated(entity.isLike);
holder.like.setNumber(entity.likeNum);
holder.like.setCallback(new LikeView.SimpleCallback() {
  @Override
  public void activate(LikeView view) {
holder.comment.setNumber(entity.commentNum);
holder.comment.setGraphAdapter(CommentPathAdapter.getInstance());
holder.comment.setCallback(new LikeView.SimpleCallback(){
  @Override
  public boolean onClick(LikeView view) {
origin: zFxiang/LikeView

/**
 * 取消激活并且给数组减1
 */
public void deactivateAndTallyDown() {
  add(-1);
  deactivate();
}
origin: zFxiang/LikeView

/**
 * 修改数值
 *
 * @param number  新值
 * @param animate 是否启用动画
 */
public void setNumber(long number, boolean animate) {
  if (animate) {
    add(number - this.number);
  } else {
    this.number = number;
    postInvalidate();
  }
}
origin: zFxiang/LikeView

/**
 * 画图形
 */
private void drawGraph(Canvas canvas) {
  canvas.save();
  canvas.translate(graphStartX, graphStartY);
  canvas.clipPath(graphPath);
  float radial = (float) (graphLength * Math.sqrt(2) / 2f);
  if (!isGraphAnimateRunning) {//如果不是动画中,就直接绘画
    if (isActivated) {
      //绘制激活状态
      canvas.drawCircle(graphLength / 2, graphLength / 2, radial, animatePaint);
    } else {
      //绘制图形
      canvas.drawPath(graphPath, graphPaint);
    }
  } else { //是动画中就要按比例绘画
    //修改外圈图形比例
    drawGraphPathByScale(canvas, 1 - graphAnimateScale);
    //修改内圈圆形比例
    canvas.drawCircle(graphLength / 2, graphLength / 2, radial * graphAnimateScale, animatePaint);
  }
  canvas.restore();
}
cn.izouxiang.likeviewLikeView

Javadoc

Created by zouxiang on 2016/11/23.

Most used methods

  • setNumber
    修改数值
  • activate
    激活
  • activateAndPlusOne
    激活并且给数值加1
  • add
    在原先的数值上加值
  • deactivate
    取消激活
  • deactivateAndTallyDown
    取消激活并且给数组减1
  • dp2px
  • drawGraph
    画图形
  • drawGraphPathByScale
    将图形缩放绘画
  • drawNumber
    画数字
  • getContext
  • getGraphPath
  • getContext,
  • getGraphPath,
  • getHeight,
  • getPaddingBottom,
  • getPaddingLeft,
  • getPaddingRight,
  • getPaddingTop,
  • getResources,
  • getWidth,
  • graphAnimate

Popular in Java

  • Finding current android device location
  • getContentResolver (Context)
  • startActivity (Activity)
  • getExternalFilesDir (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JFrame (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now