Java Code Examples for com.wangjie.androidbucket.utils.ABTextUtil

The following examples show how to use com.wangjie.androidbucket.utils.ABTextUtil. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: DraggableFlagView   Source File: DraggableFlagView.java    License: Apache License 2.0 6 votes vote down vote up
private void init(Context context) {
    this.context = context;

    setBackgroundColor(Color.TRANSPARENT);

    // 设置绘制flag的paint
    paint = new Paint();
    paint.setColor(patientColor);
    paint.setAntiAlias(true);

    // 设置绘制文字的paint
    textPaint = new TextPaint();
    textPaint.setAntiAlias(true);
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(ABTextUtil.sp2px(context, 12));
    textPaint.setTextAlign(Paint.Align.CENTER);
    textFontMetrics = textPaint.getFontMetrics();

}
 
Example 2
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
    View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.layout_all_note_item
            , viewGroup, false);
    if(i==0){
            StaggeredGridLayoutManager.LayoutParams lp=(StaggeredGridLayoutManager.LayoutParams)view.getLayoutParams();

        lp.setMargins(ABTextUtil.dip2px(viewGroup.getContext(), 8),ABTextUtil.dip2px(viewGroup.getContext(),8),
                ABTextUtil.dip2px(viewGroup.getContext(),8),ABTextUtil.dip2px(viewGroup.getContext(),8));
        view.setLayoutParams(lp);
    }
    return new GroupViewHolder(view);
}
 
Example 3
protected void initInConstructor() {
    this.rfacItemDrawableSizePx = ABTextUtil.dip2px(this.getContext(), 24.0F);
    this.contentView = new LinearLayout(this.getContext());
    this.contentView.setLayoutParams(new LayoutParams(-1, -1));
    this.contentView.setOrientation(LinearLayout.VERTICAL);
    scrollView=new ScrollView(this.getContext());
    scrollView.addView(contentView);
    scrollView.setOverScrollMode(OVER_SCROLL_NEVER);
    this.setRootView(scrollView);
}
 
Example 4
public MyRapidFloatingActionContentLabelList setItems(List<RFACLabelItem> items) {
    if(!ABTextUtil.isEmpty(items)) {
        this.items = items;
    }

    return this;
}
 
Example 5
Source Project: RxAndroidEventsSample   Source File: RxBus.java    License: Apache License 2.0 5 votes vote down vote up
public void unregister(@NonNull Object tag, @NonNull Observable observable) {
    List<Subject> subjects = subjectMapper.get(tag);
    if (null != subjects) {
        subjects.remove((Subject) observable);
        if (ABTextUtil.isEmpty(subjects)) {
            subjectMapper.remove(tag);
        }
    }

    if (DEBUG) Log.d(TAG, "[unregister]subjectMapper: " + subjectMapper);
}
 
Example 6
Source Project: RxAndroidEventsSample   Source File: RxBus.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void post(@NonNull Object tag, @NonNull Object content) {
    List<Subject> subjectList = subjectMapper.get(tag);

    if (!ABTextUtil.isEmpty(subjectList)) {
        for (Subject subject : subjectList) {
            subject.onNext(content);
        }
    }
    if (DEBUG) Log.d(TAG, "[send]subjectMapper: " + subjectMapper);
}
 
Example 7
public void clear() {
    if (!ABTextUtil.isEmpty(registeredObservable)) {
        for (ObservableWrapper observableWrapper : registeredObservable) {
            RxBus.get().unregister(observableWrapper.getTag(), observableWrapper.getObservable());
        }
    }
}
 
Example 8
Source Project: RxAndroidEventsSample   Source File: TabFeedContainer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onLoadReeds(List<Feed> feedList) {
    if (!ABTextUtil.isEmpty(feedList)) {
        int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
        int insertPos = firstVisibleItemPosition < 0 ? 0 : firstVisibleItemPosition + 1;
        adapter.getList().addAll(insertPos, feedList);
        adapter.notifyItemInserted(insertPos);
    }

}
 
Example 9
Source Project: RxAndroidEventsSample   Source File: TabFeedContainer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deleteFeed() {
    List<Feed> list = adapter.getList();
    if (!ABTextUtil.isEmpty(list)) {
        list.remove(0);
        adapter.notifyItemRemoved(0);
    }
}
 
Example 10
Source Project: DraggableFlagView   Source File: DraggableFlagView.java    License: Apache License 2.0 5 votes vote down vote up
/**
     * 根据移动的距离来刷新原来的圆半径大小
     *
     * @param distance
     */
    private void refreshCurRadiusByMoveDistance(int distance) {
        if (distance > maxMoveLength) {
            isArrivedMaxMoved = true;
            curRadius = 0;
        } else {
            isArrivedMaxMoved = false;
            float calcRadius = (1 - 1f * distance / maxMoveLength) * originRadius;
            float maxRadius = ABTextUtil.dip2px(context, 2);
            curRadius = (int) Math.max(calcRadius, maxRadius);
//            Logger.d(TAG, "[refreshCurRadiusByMoveDistance]curRadius: " + curRadius + ", calcRadius: " + calcRadius + ", maxRadius: " + maxRadius);
        }

    }
 
Example 11
private void refreshItems() {
    if(ABTextUtil.isEmpty(this.items)) {
        throw new RuntimeException(this.getClass().getSimpleName() + "[items] can not be empty!");
    } else {
        this.contentView.removeAllViews();
        int i = 0;

        for(int size = this.items.size(); i < size; ++i) {
            RFACLabelItem item = (RFACLabelItem)this.items.get(i);
            View itemView = LayoutInflater.from(this.getContext()).inflate(com.wangjie.rapidfloatingactionbutton.R.layout.rfab__content_label_list_item, (ViewGroup)null);
            View rootView = (ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_root_view));
            TextView labelTv = (TextView)ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_label_tv);
            ImageView iconIv = (ImageView)ABViewUtil.obtainView(itemView, com.wangjie.rapidfloatingactionbutton.R.id.rfab__content_label_list_icon_iv);
            rootView.setOnClickListener(this);
            labelTv.setOnClickListener(this);
            iconIv.setOnClickListener(this);
            rootView.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
            labelTv.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
            iconIv.setTag(com.wangjie.rapidfloatingactionbutton.R.id.rfab__id_content_label_list_item_position, Integer.valueOf(i));
            CircleButtonProperties circleButtonProperties = (new CircleButtonProperties()).setStandardSize(RFABSize.MINI).setShadowColor(this.iconShadowColor).setShadowRadius(this.iconShadowRadius).setShadowDx(this.iconShadowDx).setShadowDy(this.iconShadowDy);
            int shadowOffsetHalf = circleButtonProperties.getShadowOffsetHalf();
            int minPadding = ABTextUtil.dip2px(this.getContext(), 8.0F);
            int realItemSize;
            if(shadowOffsetHalf < minPadding) {
                realItemSize = minPadding - shadowOffsetHalf;
                rootView.setPadding(0, realItemSize, 0, realItemSize);
            }

            realItemSize = circleButtonProperties.getRealSizePx(this.getContext());
            android.widget.LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams)iconIv.getLayoutParams();
            if(null == lp) {
                lp = new android.widget.LinearLayout.LayoutParams(-2, -2);
            }

            int rfabRealSize = this.onRapidFloatingActionListener.obtainRFAButton().getRfabProperties().getRealSizePx(this.getContext());
            lp.rightMargin = (rfabRealSize - realItemSize) / 2;
            lp.width = realItemSize;
            lp.height = realItemSize;
            iconIv.setLayoutParams(lp);
            Integer normalColor = item.getIconNormalColor();
            Integer pressedColor = item.getIconPressedColor();
            CircleButtonDrawable rfacNormalDrawable = new CircleButtonDrawable(this.getContext(), circleButtonProperties, null == normalColor?this.getResources().getColor(com.wangjie.rapidfloatingactionbutton.R.color.rfab__color_background_normal):normalColor.intValue());
            CircleButtonDrawable rfacPressedDrawable = new CircleButtonDrawable(this.getContext(), circleButtonProperties, null == pressedColor?this.getResources().getColor(com.wangjie.rapidfloatingactionbutton.R.color.rfab__color_background_pressed):pressedColor.intValue());
            if(Build.VERSION.SDK_INT > 11) {
                iconIv.setLayerType(1, rfacNormalDrawable.getPaint());
            }

            ABViewUtil.setBackgroundDrawable(iconIv, ABShape.selectorClickSimple(rfacNormalDrawable, rfacPressedDrawable));
            int padding = ABTextUtil.dip2px(this.getContext(), 8.0F) + shadowOffsetHalf;
            iconIv.setPadding(padding, padding, padding, padding);
            String label = item.getLabel();
            if(ABTextUtil.isEmpty(label)) {
                labelTv.setVisibility(GONE);
            } else {
                if(item.isLabelTextBold()) {
                    labelTv.getPaint().setFakeBoldText(true);
                }

                labelTv.setVisibility(VISIBLE);
                labelTv.setText(label);
                Drawable resId = item.getLabelBackgroundDrawable();
                if(null != resId) {
                    ABViewUtil.setBackgroundDrawable(labelTv, resId);
                }

                Integer drawable = item.getLabelColor();
                if(null != drawable) {
                    labelTv.setTextColor(drawable.intValue());
                }

                Integer labelSize = item.getLabelSizeSp();
                if(null != labelSize) {
                    labelTv.setTextSize(2, (float)labelSize.intValue());
                }
            }

            Drawable var23 = item.getDrawable();
            if(null != var23) {
                iconIv.setVisibility(VISIBLE);
                var23.setBounds(0, 0, this.rfacItemDrawableSizePx, this.rfacItemDrawableSizePx);
                iconIv.setImageDrawable(var23);
            } else {
                int var24;
                if((var24 = item.getResId()) > 0) {
                    iconIv.setVisibility(VISIBLE);
                    iconIv.setImageDrawable(ABImageProcess.getResourceDrawableBounded(this.getContext(), var24, this.rfacItemDrawableSizePx));
                } else {
                    iconIv.setVisibility(GONE);
                }
            }

            this.contentView.addView(itemView);
        }

    }
}
 
Example 12
Source Project: WaveCompat   Source File: SecondWareTestActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onWindowInitialized() {
    super.onWindowInitialized();
    WaveCompat.transitionDefaultInitial(this, ABTextUtil.dip2px(context, 80), backgroundFromColor, Color.GRAY);
}
 
Example 13
public <T> void parserObservableEventAnnotations(Method method) throws Exception {
    if (null == method || !method.isAnnotationPresent(Accept.class)) {
        return;
    }
    Class[] params = method.getParameterTypes();
    // 参数必须是两个,第1个必须是Object类型的tag
    if (null == params || 2 != params.length || !Object.class.isAssignableFrom(params[0])) {
        throw new Exception("the method[" + method.getName() + "] must defined xxx(Object tag, T object)");
    }

    Accept accept = method.getAnnotation(Accept.class);
    AcceptType[] acceptTypes = accept.value();

    // 默认clazz参数类型
    Class<T> targetClazz = params[1];
    // 默认clazz参数类型的全类名
    String targetTag = targetClazz.getName();
    Class<T> specClazz;
    String specTag;
    int acceptTypeLength = null == acceptTypes ? 0 : acceptTypes.length;
    switch (acceptTypeLength) {
        case 0: // 如果acceptType是空,则说明具体的类型是params[1],所以params[1]不能为Object类型
            if (Object.class.equals(targetClazz)) {
                throw new Exception("the method[" + method.getName() + "] must defined xxx(Object tag, T object)");
            }
            registerObservable(method, targetTag, targetClazz, accept.acceptScheduler());
            break;
        case 1: // 如果只有一个,如果acceptType中tag不为空,则使用
            // 默认clazz参数类型,acceptType中指定clazz优先
            specClazz = acceptTypes[0].clazz();
            if (!Object.class.equals(specClazz)) {
                targetClazz = specClazz;
            }
            if (Object.class.equals(targetClazz)) {
                throw new Exception("the method[" + method.getName() + "] must defined xxx(Object tag, T object) OR clazz of @AcceptType");
            }
            targetTag = targetClazz.getName();
            // 默认tag参数类型的全类名,acceptType中指定tag优先
            specTag = acceptTypes[0].tag();
            if (!ABTextUtil.isEmpty(specTag)) {
                targetTag = specTag;
            }
            registerObservable(method, targetTag, targetClazz, accept.acceptScheduler());
            break;
        default: // 如果有多个,则params[1]必须是Object
            if (!Object.class.equals(targetClazz)) {
                throw new Exception("the method[" + method.getName() + "] must defined xxx(Object tag, Object object)");
            }
            for (AcceptType acceptType : acceptTypes) {
                specClazz = acceptType.clazz();
                specTag = acceptType.tag();
                // 默认tag参数类型的全名,acceptType中指定tag优先
                registerObservable(method, ABTextUtil.isEmpty(specTag) ? specClazz.getName() : specTag, specClazz, accept.acceptScheduler());
            }
            break;
    }


}