• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BidiFormatter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.support.v4.text.BidiFormatter的典型用法代码示例。如果您正苦于以下问题:Java BidiFormatter类的具体用法?Java BidiFormatter怎么用?Java BidiFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BidiFormatter类属于android.support.v4.text包,在下文中一共展示了BidiFormatter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAppInfo

import android.support.v4.text.BidiFormatter; //导入依赖的package包/类
public static Single<AppInfo> getAppInfo(final Context context, String pkgName) {
  return SingleJust.just(pkgName).map(new Function<String, AppInfo>() {
    @Override
    public AppInfo apply(String s) throws Exception {
      PackageManager packageManager = context.getPackageManager();
      PackageInfo packageInfo = packageManager.getPackageInfo(s, 0);

      AppInfo info = new AppInfo();
      info.packageName = packageInfo.packageName;
      info.appName = BidiFormatter.getInstance()
          .unicodeWrap(packageInfo.applicationInfo.loadLabel(packageManager)).toString();
      info.time = Math.max(packageInfo.lastUpdateTime, packageInfo.firstInstallTime);
      info.installTime = packageInfo.firstInstallTime;
      info.updateTime = packageInfo.lastUpdateTime;
      info.applicationInfo = packageInfo.applicationInfo;

      LocalImageLoader.initAdd(context, info);
      return info;
    }
  });

}
 
开发者ID:8enet,项目名称:AppOpsX,代码行数:23,代码来源:Helper.java


示例2: getArticleAge

import android.support.v4.text.BidiFormatter; //导入依赖的package包/类
private static String getArticleAge(SnippetArticle article) {
    if (article.mPublishTimestampMilliseconds == 0) return "";

    // DateUtils.getRelativeTimeSpanString(...) calls through to TimeZone.getDefault(). If this
    // has never been called before it loads the current time zone from disk. In most likelihood
    // this will have been called previously and the current time zone will have been cached,
    // but in some cases (eg instrumentation tests) it will cause a strict mode violation.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    CharSequence relativeTimeSpan;
    try {
        long time = SystemClock.elapsedRealtime();
        relativeTimeSpan =
                DateUtils.getRelativeTimeSpanString(article.mPublishTimestampMilliseconds,
                        System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS);
        RecordHistogram.recordTimesHistogram("Android.StrictMode.SnippetUIBuildTime",
                SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }

    // We add a dash before the elapsed time, e.g. " - 14 minutes ago".
    return String.format(ARTICLE_AGE_FORMAT_STRING,
            BidiFormatter.getInstance().unicodeWrap(relativeTimeSpan));
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:25,代码来源:SnippetArticleViewHolder.java


示例3: onCreate

import android.support.v4.text.BidiFormatter; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.bidiformater_support);

    String formattedText = String.format(text, phone);

    TextView tv_sample = (TextView) findViewById(R.id.textview_without_bidiformatter);
    tv_sample.setText(formattedText);

    TextView tv_bidiformatter = (TextView) findViewById(R.id.textview_with_bidiformatter);
    String wrappedPhone = BidiFormatter.getInstance(true /* rtlContext */).unicodeWrap(phone);
    formattedText = String.format(text, wrappedPhone);
    tv_bidiformatter.setText(formattedText);
}
 
开发者ID:reknih,项目名称:informant-droid,代码行数:17,代码来源:BidiFormatterSupport.java


示例4: updateStorageUsage

import android.support.v4.text.BidiFormatter; //导入依赖的package包/类
public void updateStorageUsage(long totalMemory, long lowMemory, long medMemory,
                               long highMemory) {
    Context context = mColorBar.getContext();

    BidiFormatter bidiFormatter = BidiFormatter.getInstance();

    String sizeStr = bidiFormatter.unicodeWrap(
            Formatter.formatShortFileSize(context, lowMemory));
    mFreeSizeText.setText(context.getString(R.string.apps_list_header_memory, sizeStr));

    sizeStr = bidiFormatter.unicodeWrap(
            Formatter.formatShortFileSize(context, medMemory));
    mCacheSizeText.setText(context.getString(R.string.apps_list_header_memory, sizeStr));

    sizeStr = bidiFormatter.unicodeWrap(
            Formatter.formatShortFileSize(context, highMemory));
    mSystemSizeText.setText(context.getString(R.string.apps_list_header_memory, sizeStr));

    mColorBar.setRatios((float) highMemory / (float) totalMemory,
            (float) medMemory / (float) totalMemory,
            (float) lowMemory / (float) totalMemory);
}
 
开发者ID:Frozen-Developers,项目名称:android-cache-cleaner,代码行数:23,代码来源:AppsListAdapter.java


示例5: setChipText

import android.support.v4.text.BidiFormatter; //导入依赖的package包/类
public void setChipText(@Nullable CharSequence chipText) {
  if (this.chipText != chipText) {
    this.chipText = BidiFormatter.getInstance().unicodeWrap(chipText);
    chipTextWidthDirty = true;

    invalidateSelf();
    onSizeChange();
  }
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:10,代码来源:ChipDrawable.java


示例6: onBindViewHolder

import android.support.v4.text.BidiFormatter; //导入依赖的package包/类
public void onBindViewHolder(SnippetArticle article) {
    super.onBindViewHolder();

    // No longer listen for offline status changes to the old article.
    if (mArticle != null) mArticle.setOfflineStatusChangeRunnable(null);

    mArticle = article;
    updateLayout();

    mHeadlineTextView.setText(mArticle.mTitle);

    // DateUtils.getRelativeTimeSpanString(...) calls through to TimeZone.getDefault(). If this
    // has never been called before it loads the current time zone from disk. In most likelihood
    // this will have been called previously and the current time zone will have been cached,
    // but in some cases (eg instrumentation tests) it will cause a strict mode violation.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        long time = SystemClock.elapsedRealtime();
        CharSequence relativeTimeSpan = DateUtils.getRelativeTimeSpanString(
                mArticle.mPublishTimestampMilliseconds, System.currentTimeMillis(),
                DateUtils.MINUTE_IN_MILLIS);
        RecordHistogram.recordTimesHistogram("Android.StrictMode.SnippetUIBuildTime",
                SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS);

        // We format the publisher here so that having a publisher name in an RTL language
        // doesn't mess up the formatting on an LTR device and vice versa.
        String publisherAttribution = String.format(PUBLISHER_FORMAT_STRING,
                BidiFormatter.getInstance().unicodeWrap(mArticle.mPublisher), relativeTimeSpan);
        mPublisherTextView.setText(publisherAttribution);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }

    // The favicon of the publisher should match the TextView height.
    int widthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    mPublisherTextView.measure(widthSpec, heightSpec);
    mPublisherFaviconSizePx = mPublisherTextView.getMeasuredHeight();

    mArticleSnippetTextView.setText(mArticle.mPreviewText);

    // If there's still a pending thumbnail fetch, cancel it.
    cancelImageFetch();

    // If the article has a thumbnail already, reuse it. Otherwise start a fetch.
    // mThumbnailView's visibility is modified in updateLayout().
    if (mThumbnailView.getVisibility() == View.VISIBLE) {
        if (mArticle.getThumbnailBitmap() != null) {
            mThumbnailView.setImageBitmap(mArticle.getThumbnailBitmap());
        } else {
            mThumbnailView.setImageResource(R.drawable.ic_snippet_thumbnail_placeholder);
            mImageCallback = new FetchImageCallback(this, mArticle);
            mNewTabPageManager.getSuggestionsSource()
                    .fetchSuggestionImage(mArticle, mImageCallback);
        }
    }

    // Set the favicon of the publisher.
    try {
        fetchFaviconFromLocalCache(new URI(mArticle.mUrl), true);
    } catch (URISyntaxException e) {
        setDefaultFaviconOnView();
    }

    mOfflineBadge.setVisibility(View.GONE);
    if (SnippetsConfig.isOfflineBadgeEnabled()) {
        Runnable offlineChecker = new Runnable() {
            @Override
            public void run() {
                if (mArticle.getOfflinePageOfflineId() != null || mArticle.mIsDownloadedAsset) {
                    mOfflineBadge.setVisibility(View.VISIBLE);
                }
            }
        };
        mArticle.setOfflineStatusChangeRunnable(offlineChecker);
        offlineChecker.run();
    }

    mRecyclerView.onSnippetBound(itemView);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:81,代码来源:SnippetArticleViewHolder.java


示例7: getPublisherString

import android.support.v4.text.BidiFormatter; //导入依赖的package包/类
private static String getPublisherString(SnippetArticle article) {
    // We format the publisher here so that having a publisher name in an RTL language
    // doesn't mess up the formatting on an LTR device and vice versa.
    return BidiFormatter.getInstance().unicodeWrap(article.mPublisher);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:6,代码来源:SnippetArticleViewHolder.java


示例8: onMeasure

import android.support.v4.text.BidiFormatter; //导入依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    Rect bounds = new Rect();
    Drawable background = getBackground();
    if (background != null) {
        background.getPadding(bounds);
    }

    int wMode = MeasureSpec.getMode(widthMeasureSpec);
    int maxW = MeasureSpec.getSize(widthMeasureSpec) - bounds.left - bounds.right;

    TextView messageView = (TextView) getChildAt(0);
    messageView.measure(MeasureSpec.makeMeasureSpec(maxW, wMode), heightMeasureSpec);
    View timeView = getChildAt(1);
    timeView.measure(MeasureSpec.makeMeasureSpec(maxW, wMode), heightMeasureSpec);

    Layout textLayout = messageView.getLayout();

    int contentW = messageView.getMeasuredWidth();
    int timeW = timeView.getMeasuredWidth();
    boolean isRtl = BidiFormatter.getInstance().isRtl(messageView.getText().toString());

    if (messageView.getLayout().getLineCount() < 5 && !isRtl) {
        contentW = 0;
        for (int i = 0; i < textLayout.getLineCount(); i++) {
            contentW = Math.max(contentW, (int) textLayout.getLineWidth(i));
        }
    }

    int lastLineW = (int) textLayout.getLineWidth(textLayout.getLineCount() - 1);

    if (isRtl) {
        lastLineW = contentW;
    }

    int fullContentW, fullContentH;

    if (isRtl) {
        fullContentW = contentW;
        fullContentH = messageView.getMeasuredHeight() + timeView.getMeasuredHeight();
    } else {
        if (lastLineW + timeW < contentW) {
            // Nothing to do
            fullContentW = contentW;
            fullContentH = messageView.getMeasuredHeight();
        } else if (lastLineW + timeW < maxW) {
            fullContentW = lastLineW + timeW;
            fullContentH = messageView.getMeasuredHeight();
        } else {
            fullContentW = contentW;
            fullContentH = messageView.getMeasuredHeight() + timeView.getMeasuredHeight();
        }
    }

    setMeasuredDimension(fullContentW + bounds.left + bounds.right, fullContentH + bounds.top + bounds.bottom);
}
 
开发者ID:actorapp,项目名称:actor-platform,代码行数:57,代码来源:BubbleTextContainer.java



注:本文中的android.support.v4.text.BidiFormatter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ControlExtension类代码示例发布时间:2022-05-22
下一篇:
Java LocalizationProtocol类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap