Java Code Examples for android.text.TextUtils

The following are top voted examples for showing how to use android.text.TextUtils. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: Kits.java   Source Code and License 10 votes vote down vote up
public static String getNetworkTypeName(Context context) {
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo;
    String type = NETWORK_TYPE_DISCONNECT;
    if (manager == null || (networkInfo = manager.getActiveNetworkInfo()) == null) {
        return type;
    }

    if (networkInfo.isConnected()) {
        String typeName = networkInfo.getTypeName();
        if ("WIFI".equalsIgnoreCase(typeName)) {
            type = NETWORK_TYPE_WIFI;
        } else if ("MOBILE".equalsIgnoreCase(typeName)) {
            String proxyHost = android.net.Proxy.getDefaultHost();
            type = TextUtils.isEmpty(proxyHost) ? (isFastMobileNetwork(context) ? NETWORK_TYPE_3G : NETWORK_TYPE_2G)
                    : NETWORK_TYPE_WAP;
        } else {
            type = NETWORK_TYPE_UNKNOWN;
        }
    }
    return type;
}
 
Example 2
Project: OpenYOLO-Android   File: AssetRelationshipHelper.java   Source Code and License 7 votes vote down vote up
/**
 * Setup the helper and validate the input params.
 *
 * @param context Context
 * @param clientPackageName The client app's package name
 * @param sourceAssetStatements Asset statements from the 'source' (client) app
 * @param targetAssetStatements Asset statements from the various 'targets' referenced by the
 *     'source' (client) app
 */
public AssetRelationshipHelper(@NonNull Context context, @NonNull String clientPackageName,
            @NonNull List<AssetStatement> sourceAssetStatements, @NonNull List<AssetStatement>
            targetAssetStatements) {

    require(context, notNullValue());
    require(!TextUtils.isEmpty(clientPackageName), "mClientPackageName must not be null or "
                + "empty");
    require(sourceAssetStatements, notNullValue());
    require(targetAssetStatements, notNullValue());

    this.mContext = context.getApplicationContext();
    this.mClientPackageName = clientPackageName;
    this.mSourceAssetStatements = sourceAssetStatements;
    this.mTargetAssetStatements = targetAssetStatements;
}
 
Example 3
Project: Renrentou   File: Kits.java   Source Code and License 7 votes vote down vote up
public static String getNetworkTypeName(Context context) {
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo;
    String type = NETWORK_TYPE_DISCONNECT;
    if (manager == null || (networkInfo = manager.getActiveNetworkInfo()) == null) {
        return type;
    }

    if (networkInfo.isConnected()) {
        String typeName = networkInfo.getTypeName();
        if ("WIFI".equalsIgnoreCase(typeName)) {
            type = NETWORK_TYPE_WIFI;
        } else if ("MOBILE".equalsIgnoreCase(typeName)) {
            String proxyHost = android.net.Proxy.getDefaultHost();
            type = TextUtils.isEmpty(proxyHost) ? (isFastMobileNetwork(context) ? NETWORK_TYPE_3G : NETWORK_TYPE_2G)
                    : NETWORK_TYPE_WAP;
        } else {
            type = NETWORK_TYPE_UNKNOWN;
        }
    }
    return type;
}
 
Example 4
Project: Phoenix-for-VK   File: FeedbackViewBinder.java   Source Code and License 6 votes vote down vote up
/**
 * Отображение аватара первого в списке пользователя на ImageView.
 * Если у пользователя нет аватара, то будет отображено изображение
 * неизвестного пользователя
 *
 * @param owners    массив пользователей
 * @param imageView вьюв
 */
private void showFirstUserAvatarOnImageView(List<Owner> owners, ImageView imageView) {
    if (owners == null || owners.size() == 0 || TextUtils.isEmpty(owners.get(0).getMaxSquareAvatar())) {
        PicassoInstance.with()
                .load(R.drawable.ic_avatar_unknown)
                .tag(Constants.PICASSO_TAG)
                .into(imageView);
    } else {
        String url = owners.get(0).getMaxSquareAvatar();
        PicassoInstance.with()
                .load(url)
                .tag(Constants.PICASSO_TAG)
                .transform(transformation)
                .into(imageView);
    }
}
 
Example 5
Project: GitHub   File: LazyHeaders.java   Source Code and License 6 votes vote down vote up
/**
 * Ensures that the default header will pass OkHttp3's checks for header values.
 *
 * <p>See #2331.
 */
@VisibleForTesting
static String getSanitizedUserAgent() {
  String defaultUserAgent = System.getProperty("http.agent");
  if (TextUtils.isEmpty(defaultUserAgent)) {
    return defaultUserAgent;
  }

  int length = defaultUserAgent.length();
  StringBuilder sb = new StringBuilder(defaultUserAgent.length());
  for (int i = 0; i < length; i++) {
    char c = defaultUserAgent.charAt(i);
    if ((c > '\u001f' || c == '\t') && c < '\u007f') {
      sb.append(c);
    } else {
      sb.append('?');
    }
  }
  return sb.toString();
}
 
Example 6
Project: LQRWeChat-master   File: DeleteContactMessage.java   Source Code and License 6 votes vote down vote up
public byte[] encode() {
    JSONObject var1 = new JSONObject();

    try {
        if (!TextUtils.isEmpty(this.getContact_id())) {
            var1.put("contact_id", this.contact_id);
        }

        if (this.getJSONUserInfo() != null) {
            var1.put("bribery", this.getJSONUserInfo());
        }
    } catch (JSONException var4) {
        var4.printStackTrace();
    }

    try {
        return var1.toString().getBytes("UTF-8");
    } catch (UnsupportedEncodingException var3) {
        var3.printStackTrace();
        return null;
    }
}
 
Example 7
Project: Leanplum-Android-SDK   File: Leanplum.java   Source Code and License 6 votes vote down vote up
/**
 * Manually track purchase event with currency code in your application. It is advised to use
 * {@link Leanplum#trackGooglePlayPurchase} instead for in-app purchases.
 *
 * @param event Name of the event.
 * @param value The value of the event. Can be price.
 * @param currencyCode The currency code corresponding to the price.
 * @param params Key-value pairs with metrics or data associated with the event. Parameters can be
 * strings or numbers. You can use up to 200 different parameter names in your app.
 */
public static void trackPurchase(final String event, double value, String currencyCode,
    Map<String, ?> params) {
  try {
    if (TextUtils.isEmpty(event)) {
      Log.w("trackPurchase - Empty event parameter provided.");
    }

    final Map<String, String> requestArgs = new HashMap<>();
    if (!TextUtils.isEmpty(currencyCode)) {
      requestArgs.put(Constants.Params.IAP_CURRENCY_CODE, currencyCode);
    }

    LeanplumInternal.track(event, value, null, params, requestArgs);
  } catch (Throwable t) {
    Log.e("trackPurchase - Failed to track purchase event.");
    Util.handleException(t);
  }
}
 
Example 8
Project: android-project-gallery   File: PersistentCookieStore.java   Source Code and License 6 votes vote down vote up
/**
 * Construct a persistent cookie store.
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context) {
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new ConcurrentHashMap<String, Cookie>();

    // Load any previously stored cookies into the store
    String storedCookieNames = cookiePrefs.getString(COOKIE_NAME_STORE, null);
    if (storedCookieNames != null) {
        String[] cookieNames = TextUtils.split(storedCookieNames, ",");
        for (String name : cookieNames) {
            String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
            if (encodedCookie != null) {
                Cookie decodedCookie = decodeCookie(encodedCookie);
                if (decodedCookie != null) {
                    cookies.put(name, decodedCookie);
                }
            }
        }

        // Clear out expired cookies
        clearExpired(new Date());
    }
}
 
Example 9
Project: Android-Code-Demos   File: MainActivity.java   Source Code and License 6 votes vote down vote up
private PApplet getSketch(String stringExtra) {
    if (TextUtils.isEmpty(stringExtra)) {
        return null;
    }

    if (getString(R.string.simple_sketch_one).equals(stringExtra)) {
        return new SimpleSketchOne(this);
    } else if (getString(R.string.simple_sketch_two).equals(stringExtra)) {
        return new SimpleSketchTwo(this);
    } else if (getString(R.string.sensor_sketch).equals(stringExtra)) {
        return new SensorSketch(this);
    } else if (getString(R.string.box2d_sketch).equals(stringExtra)) {
        return new Box2DSketch(this);
    } else if (getString(R.string.wallpapers_sketch).equals(stringExtra)) {
        return new WallpapersSketch(this);
    } else if (getString(R.string.compass_sketch).equals(stringExtra)) {
        return new CompassSketch(this);
    } else if (getString(R.string.location_sketch).equals(stringExtra)) {
        return new LocationSketch(this);
    }
    return null;
}
 
Example 10
Project: Virtualview-Android   File: ViewManager.java   Source Code and License 6 votes vote down vote up
public void recycle(ViewBase v) {
    if (null != v) {
        String type = v.getViewType();
        if (!TextUtils.isEmpty(type)) {
            v.reset();
            List<ViewBase> vList = mViewCache.get(type);
            if (null == vList) {
                vList = new LinkedList<>();
                mViewCache.put(type, vList);
            }
            vList.add(v);
        } else {
            Log.e(TAG, "recycle type invalidate:" + type);
            RuntimeException here = new RuntimeException("here");
            here.fillInStackTrace();
            Log.w(TAG, "Called: " + this, here);
        }
    }
}
 
Example 11
Project: weex-3d-map   File: Textarea.java   Source Code and License 6 votes vote down vote up
@Override
protected void appleStyleAfterCreated(WXEditText editText) {
  super.appleStyleAfterCreated(editText);
  String rowsStr = (String) getDomObject().getStyles().get(Constants.Name.ROWS);

  int rows = TextAreaEditTextDomObject.DEFAULT_ROWS;
  try{
    if(!TextUtils.isEmpty(rowsStr)) {
      rows = Integer.parseInt(rowsStr);
    }
  }catch (NumberFormatException e){
    //ignore
    e.printStackTrace();
  }

  editText.setLines(rows);
  editText.setMinLines(rows);
}
 
Example 12
Project: weex-uikit   File: WXComponent.java   Source Code and License 6 votes vote down vote up
public void setBorderColor(String key, String borderColor) {
  if (!TextUtils.isEmpty(borderColor)) {
    int colorInt = WXResourceUtils.getColor(borderColor);
    if (colorInt != Integer.MIN_VALUE) {
      switch (key) {
        case Constants.Name.BORDER_COLOR:
          getOrCreateBorder().setBorderColor(Spacing.ALL, colorInt);
          break;
        case Constants.Name.BORDER_TOP_COLOR:
          getOrCreateBorder().setBorderColor(Spacing.TOP, colorInt);
          break;
        case Constants.Name.BORDER_RIGHT_COLOR:
          getOrCreateBorder().setBorderColor(Spacing.RIGHT, colorInt);
          break;
        case Constants.Name.BORDER_BOTTOM_COLOR:
          getOrCreateBorder().setBorderColor(Spacing.BOTTOM, colorInt);
          break;
        case Constants.Name.BORDER_LEFT_COLOR:
          getOrCreateBorder().setBorderColor(Spacing.LEFT, colorInt);
          break;
      }
    }
  }
}
 
Example 13
Project: RLibrary   File: MD5Utils.java   Source Code and License 6 votes vote down vote up
public static boolean checkMD5(String md5, File updateFile) {
    if (TextUtils.isEmpty(md5) || updateFile == null) {
        Log.e(TAG, "MD5 string empty or updateFile null");
        return false;
    }

    String calculatedDigest = md5(updateFile);
    if (calculatedDigest == null) {
        Log.e(TAG, "calculatedDigest null");
        return false;
    }

    Log.v(TAG, "Calculated digest: " + calculatedDigest);
    Log.v(TAG, "Provided digest: " + md5);

    return calculatedDigest.equalsIgnoreCase(md5);
}
 
Example 14
Project: letv   File: LetvBaseActivity.java   Source Code and License 6 votes vote down vote up
public void addFragments(Fragment... fragments) {
    if (fragments != null && fragments.length != 0) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        for (Fragment fragment : fragments) {
            if (fragment instanceof LetvFragmentListener) {
                LetvFragmentListener listener = (LetvFragmentListener) fragment;
                String tag = listener.getTagName();
                if (!TextUtils.isEmpty(tag)) {
                    int fragmentRes = listener.getContainerId();
                    if (fragmentRes > 0 && fragmentManager.findFragmentByTag(tag) == null) {
                        transaction.add(fragmentRes, fragment, tag);
                    }
                }
            }
        }
        try {
            transaction.commitAllowingStateLoss();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
Example 15
Project: keepass2android   File: Suggest.java   Source Code and License 6 votes vote down vote up
private void removeDupes() {
    final ArrayList<CharSequence> suggestions = mSuggestions;
    if (suggestions.size() < 2) return;
    int i = 1;
    // Don't cache suggestions.size(), since we may be removing items
    while (i < suggestions.size()) {
        final CharSequence cur = suggestions.get(i);
        // Compare each candidate with each previous candidate
        for (int j = 0; j < i; j++) {
            CharSequence previous = suggestions.get(j);
            if (TextUtils.equals(cur, previous)) {
                removeFromSuggestions(i);
                i--;
                break;
            }
        }
        i++;
    }
}
 
Example 16
Project: FinalProject   File: FrescoImageView.java   Source Code and License 6 votes vote down vote up
@Override
public void loadView(String lowUrl, String url, int defaultResID) {
    try {
        mThumbnailPath = null;
        mThumbnailUrl = url;
        mLowThumbnailUrl = url;
        mDefaultResID = defaultResID;
        if (!TextUtils.isEmpty(mThumbnailUrl)
                && (mThumbnailUrl.startsWith(FrescoController.HTTP_PERFIX)
                || mThumbnailUrl.startsWith(FrescoController.HTTPS_PERFIX))) {

            this.getHierarchy().setPlaceholderImage(defaultResID);

            this.setSourceController();

            return;
        }

        this.getHierarchy().setPlaceholderImage(defaultResID);
        this.setResourceController();

    }catch (OutOfMemoryError e){
        e.printStackTrace();
    }
}
 
Example 17
Project: boohee_v5.6   File: WechatMoments.java   Source Code and License 6 votes vote down vote up
protected void userInfor(String str) {
    if (!TextUtils.isEmpty(this.a) && !TextUtils.isEmpty(this.b)) {
        g gVar = new g(this, 23);
        gVar.a(this.a, this.b);
        try {
            gVar.a(this.listener);
        } catch (Throwable th) {
            Ln.e(th);
            if (this.listener != null) {
                this.listener.onError(this, 8, th);
            }
        }
    } else if (this.listener != null) {
        this.listener.onError(this, 8, new Throwable("The params of appID or appSecret is missing !"));
    }
}
 
Example 18
Project: letv   File: AuthTask.java   Source Code and License 6 votes vote down vote up
public synchronized String auth(String str) {
    String a;
    if (!str.contains("bizcontext=")) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(str);
        stringBuilder.append("&bizcontext=\"");
        stringBuilder.append(new com.alipay.sdk.sys.a(this.c).toString());
        stringBuilder.append("\"");
        str = stringBuilder.toString();
    }
    Context context = this.c;
    if (a(context)) {
        a = new h(context).a(str);
        if (!TextUtils.equals(a, Constants.CALLBACK_FAILD)) {
            if (TextUtils.isEmpty(a)) {
                a = l.a();
            }
        }
    }
    a = b(context, str);
    return a;
}
 
Example 19
Project: smart-asset-iot-android-demo   File: MainActivity.java   Source Code and License 6 votes vote down vote up
@OnClick(R.id.submit)
void submit() {
    UIUtils.hideKeyboard(this);
    if (!ClientUtils.isNetworkConnected(this)) {
        UIUtils.showInternetConnectionAlertDialog(this);
        return;
    }
    String value = assetIdEdit.getText().toString();
    if (TextUtils.isEmpty(value)) {
        assetIdEditContainer.setErrorEnabled(true);
        assetIdEditContainer.setError(getString(R.string.asset_id_empty));
        return;
    }
    if (presenter.validate(value)) {
        presenter.register(value);
        showLoading(true);
        enableAllViews(false, shakeLayout, shakeTitleLayout, photoLayout, photoTitleLayout);
    } else {
        assetIdEditContainer.setError(getString(R.string.error_get_asset_id));
    }

}
 
Example 20
Project: simple-share-android   File: RootedStorageProvider.java   Source Code and License 6 votes vote down vote up
@Override
public String renameDocument(String documentId, String displayName) throws FileNotFoundException {
    // Since this provider treats renames as generating a completely new
    // docId, we're okay with letting the MIME type change.
    displayName = FileUtils.buildValidFatFilename(displayName);

    final RootFile before = getRootFileForDocId(documentId);
    final RootFile after = new RootFile(before.getParent(), displayName);

    if(!RootCommands.renameRootTarget(before, after)){
        throw new IllegalStateException("Failed to rename " + before);
    }
    final String afterDocId = getDocIdForRootFile(new RootFile(after.getParent(), displayName));
    if (!TextUtils.equals(documentId, afterDocId)) {
        notifyDocumentsChanged(documentId);
        return afterDocId;
    } else {
        return null;
    }
}
 
Example 21
Project: Ghost-Android   File: ChipsEditText.java   Source Code and License 6 votes vote down vote up
public CharSequence terminateToken(CharSequence text) {
    int i = text.length();
    int lastNonSpaceIdx = i-1;
    while (lastNonSpaceIdx >= 0 && text.charAt(lastNonSpaceIdx) == ' ') {
        --lastNonSpaceIdx;
    }
    if (lastNonSpaceIdx >= 0 && text.charAt(lastNonSpaceIdx-1) == ',') {
        return text;
    } else if (text instanceof Spanned) {
        SpannableString sp = new SpannableString(text + ",");
        TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0);
        return sp;
    } else {
        return text + ",";
    }
}
 
Example 22
Project: decoy   File: AVChatUI.java   Source Code and License 6 votes vote down vote up
private void configFromPreference(SharedPreferences preferences) {
    videoCropRatio = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_vie_crop_ratio_key), "0"));
    videoAutoRotate = preferences.getBoolean(context.getString(R.string.nrtc_setting_vie_rotation_key), true);
    videoQuality = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_vie_quality_key), 0 + ""));
    serverRecordAudio = preferences.getBoolean(context.getString(R.string.nrtc_setting_other_server_record_audio_key), false);
    serverRecordVideo = preferences.getBoolean(context.getString(R.string.nrtc_setting_other_server_record_video_key), false);
    defaultFrontCamera = preferences.getBoolean(context.getString(R.string.nrtc_setting_vie_default_front_camera_key), true);
    autoCallProximity = preferences.getBoolean(context.getString(R.string.nrtc_setting_voe_call_proximity_key), true);
    videoHwEncoderMode = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_vie_hw_encoder_key), 0 + ""));
    videoHwDecoderMode = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_vie_hw_decoder_key), 0 + ""));
    videoFpsReported = preferences.getBoolean(context.getString(R.string.nrtc_setting_vie_fps_reported_key), true);
    audioEffectAecMode = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_voe_audio_aec_key), 2 + ""));
    audioEffectNsMode = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_voe_audio_ns_key), 2 + ""));
    String value1 = preferences.getString(context.getString(R.string.nrtc_setting_vie_max_bitrate_key), 0 + "");
    videoMaxBitrate = Integer.parseInt(TextUtils.isDigitsOnly(value1) && !TextUtils.isEmpty(value1) ? value1 : 0 + "");
    String value2 = preferences.getString(context.getString(R.string.nrtc_setting_other_device_default_rotation_key), 0 + "");
    deviceDefaultRotation = Integer.parseInt(TextUtils.isDigitsOnly(value2) && !TextUtils.isEmpty(value2) ? value2 : 0 + "");
    String value3 = preferences.getString(context.getString(R.string.nrtc_setting_other_device_rotation_fixed_offset_key), 0 + "");
    deviceRotationOffset = Integer.parseInt(TextUtils.isDigitsOnly(value3) && !TextUtils.isEmpty(value3) ? value3 : 0 + "");
    audioHighQuality = preferences.getBoolean(context.getString(R.string.nrtc_setting_voe_high_quality_key), false);
    audioDtx = preferences.getBoolean(context.getString(R.string.nrtc_setting_voe_dtx_key), true);
    webrtcCompat = preferences.getBoolean(context.getString(R.string.nrtc_setting_other_webrtc_compat_key), true);
}
 
Example 23
Project: YZxing   File: DecodeUtils.java   Source Code and License 6 votes vote down vote up
@Override
protected void onPostExecute(Result result) {
    super.onPostExecute(result);
    if (result != null) {
        String text = result.getText();
        if (!TextUtils.isEmpty(text)) {
            Intent intent = new Intent(mContext.get(), ShowResultActivity.class);
            intent.putExtra(Constant.EXTRA_RESULT_TEXT_FROM_PIC, text);
            mContext.get().startActivity(intent);
            if (mContext.get() instanceof Activity) ((Activity) mContext.get()).finish();
        }
    } else {
        Toast.makeText(mContext.get(), "解码失败", Toast.LENGTH_SHORT).show();
    }

}
 
Example 24
Project: TransLinkMe-App   File: SearchFragment.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onQueryTextChange(String newText) {

    if (TextUtils.isEmpty(newText)) {
        mRecyclerView.setVisibility(View.GONE);
        mSomethingWrongLayout.setVisibility(View.GONE);
        mWelcomeLayout.setVisibility(View.VISIBLE);
    }

    if (newText.length() > 5) {
        Toast.makeText(getContext(), "Bus stops contain 5 digits.", Toast.LENGTH_SHORT).show();
        mSearchView.setQuery(newText.substring(0, 5), false);
    }

    return true;
}
 
Example 25
Project: boohee_v5.6   File: MiPushClient.java   Source Code and License 6 votes vote down vote up
public static void subscribe(Context context, String str, String str2) {
    if (!TextUtils.isEmpty(a.a(context).c()) && !TextUtils.isEmpty(str)) {
        if (System.currentTimeMillis() - topicSubscribedTime(context, str) > com.umeng
                .analytics.a.h) {
            org.apache.thrift.b oVar = new o();
            oVar.a(generatePacketID());
            oVar.b(a.a(context).c());
            oVar.c(str);
            oVar.d(context.getPackageName());
            oVar.e(str2);
            g.a(context).a(oVar, com.xiaomi.xmpush.thrift.a.Subscription, null);
        } else if (1 == PushMessageHelper.getPushMode(context)) {
            PushMessageHandler.a(context, str2, 0, null, str);
        } else {
            List arrayList = new ArrayList();
            arrayList.add(str);
            PushMessageHelper.sendCommandMessageBroadcast(context, PushMessageHelper
                    .generateCommandMessage(COMMAND_SUBSCRIBE_TOPIC, arrayList, 0, null, null));
        }
    }
}
 
Example 26
Project: weex-3d-map   File: WXAnimationBean.java   Source Code and License 6 votes vote down vote up
private static Pair<Float, Float> parsePivot(@Nullable String transformOrigin,
                                             int width, int height) {
  if (!TextUtils.isEmpty(transformOrigin)) {
    int firstSpace = transformOrigin.indexOf(FunctionParser.SPACE);
    if (firstSpace != -1) {
      int i = firstSpace;
      for (; i < transformOrigin.length(); i++) {
        if (transformOrigin.charAt(i) != FunctionParser.SPACE) {
          break;
        }
      }
      if (i < transformOrigin.length() && transformOrigin.charAt(i) != FunctionParser.SPACE) {
        List<String> list = new ArrayList<>(2);
        list.add(transformOrigin.substring(0, firstSpace).trim());
        list.add(transformOrigin.substring(i, transformOrigin.length()).trim());
        return parsePivot(list, width, height);
      }
    }
  }
  return parsePivot(Arrays.asList(WXAnimationBean.Style.CENTER,
                                  WXAnimationBean.Style.CENTER), width, height);
}
 
Example 27
Project: XinFramework   File: SPCookieStore.java   Source Code and License 6 votes vote down vote up
public SPCookieStore(Context context) {
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, Context.MODE_PRIVATE);
    cookies = new HashMap<>();

    //将持久化的cookies缓存到内存中,数据结构为 Map<Url.host, Map<CookieToken, Cookie>>
    Map<String, ?> prefsMap = cookiePrefs.getAll();
    for (Map.Entry<String, ?> entry : prefsMap.entrySet()) {
        if ((entry.getValue()) != null && !entry.getKey().startsWith(COOKIE_NAME_PREFIX)) {
            //获取url对应的所有cookie的key,用","分割
            String[] cookieNames = TextUtils.split((String) entry.getValue(), ",");
            for (String name : cookieNames) {
                //根据对应cookie的Key,从xml中获取cookie的真实值
                String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
                if (encodedCookie != null) {
                    Cookie decodedCookie = EntityCookie.decodeCookie(encodedCookie);
                    if (decodedCookie != null) {
                        if (!cookies.containsKey(entry.getKey())) {
                            cookies.put(entry.getKey(), new ConcurrentHashMap<String, Cookie>());
                        }
                        cookies.get(entry.getKey()).put(name, decodedCookie);
                    }
                }
            }
        }
    }
}
 
Example 28
Project: XiaoHuaCharge   File: LoadingDialog.java   Source Code and License 6 votes vote down vote up
public static void showProgress(Context context, CharSequence message) {
    mLoadingProgress = new LoadingDialog(context, R.style.loading_dialog);//自定义style文件主要让北京变成透明并去掉标题部分<!-- 自定义loading dialog -->
    mLoadingProgress.setCanceledOnTouchOutside(false);
    mLoadingProgress.setTitle("");
    mLoadingProgress.setContentView(R.layout.loading_layout);
    if (message == null || TextUtils.isEmpty(message)) {
        mLoadingProgress.findViewById(R.id.loading_tv).setVisibility(View.GONE);
    } else {
        TextView tv = (TextView) mLoadingProgress.findViewById(R.id.loading_tv);
        load = (RelativeLayout) mLoadingProgress.findViewById(R.id.loading_container);
        tv.setText(message);
    }

    new Handler().post(new Runnable() {
        @Override
        public void run() {
            AlphaAnimation alphaAnimation = new AlphaAnimation(0.8f, 0.3f);
            alphaAnimation.setDuration(1000);
            alphaAnimation.setRepeatMode(AlphaAnimation.REVERSE);
            alphaAnimation.setRepeatCount(AlphaAnimation.INFINITE);
            load.startAnimation(alphaAnimation);
        }
    });
    mLoadingProgress.setCancelable(false);
    mLoadingProgress.show();
}
 
Example 29
Project: boohee_v5.6   File: DietShareActivity.java   Source Code and License 6 votes vote down vote up
protected void onPostExecute(Bitmap bitmap) {
    if (bitmap != null) {
        String filePath = FileUtil.getPNGImagePath(DietShareActivity.this.activity,
                bitmap, "SHARE_4_LINECHART");
        if (!TextUtils.isEmpty(filePath)) {
            if (DietShareActivity.this.mShareBoohee) {
                StatusPostTextActivity.comeWithPicture(DietShareActivity.this.activity,
                        filePath);
            } else {
                ShareManager.shareLocalImage(DietShareActivity.this.activity, filePath);
            }
        }
        if (bitmap != null && !bitmap.isRecycled()) {
            bitmap.recycle();
        }
    }
}
 
Example 30
Project: BubbleAlert   File: BblDialogManager.java   Source Code and License 6 votes vote down vote up
public static void showEditTextBblDialog(FragmentManager fm, LayoutInflater inflater, String content,
                                         String ok, String cancel, String drawText,
                                         IDialogListener dialogListener, Context context, String textContent,
                                         String hintText, boolean isMultiline, String TAG) {
    BblContentFragment fragment = BblContentFragment.newInstance(TAG);

    if (TextUtils.isEmpty(content)) {

        content = context.getString(R.string.err_server_error);
    }
    fragment.setContent(content, ok, cancel, null, null)
            .setHasEditText(true)
            .setMultiLine(isMultiline)
            .setHintText(hintText)
            .setTextContent(textContent)
            .setDialogListener(dialogListener);
    BblDialog sampleDialog = new BblDialog();
    sampleDialog.setHasEditText(true)
            .setContentFragment(fragment, R.layout.layout_bbl_content, inflater, content, drawText, context)
            .setDisMissCallBack(null);
    fm.beginTransaction().add(sampleDialog, "Test").commit();
}
 
Example 31
Project: CSipSimple   File: Local.java   Source Code and License 6 votes vote down vote up
public String getLocalIpAddresses() {
    ArrayList<String> addresses = new ArrayList<String>();
    try {
        for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en
                .hasMoreElements();) {
            NetworkInterface intf = en.nextElement();
            for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr
                    .hasMoreElements();) {
                InetAddress inetAddress = enumIpAddr.nextElement();
                if (!inetAddress.isLoopbackAddress()) {
                    addresses.add(inetAddress.getHostAddress().toString());
                }
            }
        }
    } catch (SocketException ex) {
        Log.e(THIS_FILE, "Impossible to get ip address", ex);
    }
    return TextUtils.join("\n", addresses);
}
 
Example 32
Project: Mobike   File: PersistentCookieStore.java   Source Code and License 6 votes vote down vote up
/**
 * Construct getUrl persistent cookie store.
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context) {
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new ConcurrentHashMap<String, Cookie>();

    // Load any previously stored cookies into the store
    String storedCookieNames = cookiePrefs.getString(COOKIE_NAME_STORE, null);
    if (storedCookieNames != null) {
        String[] cookieNames = TextUtils.split(storedCookieNames, ",");
        for (String name : cookieNames) {
            String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
            if (encodedCookie != null) {
                Cookie decodedCookie = decodeCookie(encodedCookie);
                if (decodedCookie != null) {
                    cookies.put(name, decodedCookie);
                }
            }
        }

        // Clear out expired cookies
        clearExpired(new Date());
    }
}
 
Example 33
Project: rongyunDemo   File: SealUserInfoManager.java   Source Code and License 6 votes vote down vote up
/**
 * 异步接口,获取1个好友信息
 *
 * @param userID 好友ID
 * @param callback 获取好友信息回调
 */
public void getFriendByID(final String userID, final ResultCallback<Friend> callback) {
    if (TextUtils.isEmpty(userID)) {
        if (callback != null)
            callback.onError(null);
    } else {
        mWorkHandler.post(new Runnable() {
            @Override
            public void run() {
                Friend friend = null;
                if (mFriendDao != null) {
                    friend = mFriendDao.queryBuilder().where(FriendDao.Properties.UserId.eq(userID)).unique();
                }
                if (callback != null)
                    callback.onCallback(friend);
            }
        });
    }
}
 
Example 34
Project: letv   File: AuthActivity.java   Source Code and License 5 votes vote down vote up
private boolean a(String str) {
    if (TextUtils.isEmpty(str) || str.startsWith("http://") || str.startsWith("https://")) {
        return false;
    }
    if (!"SDKLite://h5quit".equalsIgnoreCase(str)) {
        if (TextUtils.equals(str, this.d)) {
            str = str + "?resultCode=150";
        }
        h.a((Activity) this, str);
    }
    finish();
    return true;
}
 
Example 35
Project: iosched-reader   File: LUtils.java   Source Code and License 5 votes vote down vote up
public void startActivityWithTransition(Intent intent, final View clickedView,
                                            final String transitionName) {
        ActivityOptions options = null;
        if (hasL() && clickedView != null && !TextUtils.isEmpty(transitionName)) {
//            options = ActivityOptions.makeSceneTransitionAnimation(
//                    mActivity, clickedView, transitionName);
        }

        mActivity.startActivity(intent, (options != null) ? options.toBundle() : null);
    }
 
Example 36
Project: rongyunDemo   File: ContactsFragment.java   Source Code and License 5 votes vote down vote up
private String replaceFirstCharacterWithUppercase(String spelling) {
    if (!TextUtils.isEmpty(spelling)) {
        char first = spelling.charAt(0);
        char newFirst = first;
        if (first >= 'a' && first <= 'z') {
            newFirst -= 32;
        }
        return spelling.replaceFirst(String.valueOf(first), String.valueOf(newFirst));
    } else {
        return "#";
    }
}
 
Example 37
Project: airgram   File: MessagesStorage.java   Source Code and License 5 votes vote down vote up
public ArrayList<TLRPC.User> getUsers(final ArrayList<Integer> uids) {
    ArrayList<TLRPC.User> users = new ArrayList<>();
    try {
        getUsersInternal(TextUtils.join(",", uids), users);
    } catch (Exception e) {
        users.clear();
        FileLog.e("tmessages", e);
    }
    return users;
}
 
Example 38
Project: androidtools   File: DateUtils.java   Source Code and License 5 votes vote down vote up
/**
 * Calculates the number of days in which two dates differ, whether or not to take absolute values.
 *
 * @param date1 first date
 * @param date2 Second date
 * @param isAbs Do you take absolute values?
 * @return dim dd
 */
public static int getDaysUnAbs(String date1, String date2, boolean isAbs) {
    int day = 0;
    if (TextUtils.isEmpty(date1) || TextUtils.isEmpty(date2))
        return 0;
    try {
        Date date = mDataFormat.parse(date1);
        Date myDate = mDataFormat.parse(date2);
        day = (int) ((date.getTime() - myDate.getTime()) / (24 * 60 * 60 * 1000));
    } catch (ParseException e) {
        e.printStackTrace();
        Log.e(TAG, e.getMessage());
    }
    return isAbs ? Math.abs(day) : day;
}
 
Example 39
Project: LuaViewPlayground   File: UDCanvas.java   Source Code and License 5 votes vote down vote up
@Override
public Varargs invoke(Varargs args) {
    if (args.narg() >= 2) {
        final String typeface = args.optjstring(2, null);
        if (!TextUtils.isEmpty(typeface)) {
            getDefaultPaint(null).setTypeface(getLuaResourceFinder().findTypeface(typeface));
        }
    }
    return UDCanvas.this;
}
 
Example 40
Project: Tangram-Android   File: PojoGroupBasicAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public Range<Integer> getCardRange(String id) {
    if (TextUtils.isEmpty(id)) {
        return Range.create(0, 0);
    }

    List<Card> cards = getGroups();
    for (int i = 0, size = cards.size(); i < size; i++) {
        Card c = cards.get(i);
        if (id.equals(c.id)) {
            return getCardRange(c);
        }
    }
    return Range.create(0, 0);
}
 
Example 41
Project: CloudFirestore   File: Rating.java   Source Code and License 5 votes vote down vote up
public Rating(FirebaseUser user, double rating, String text) {
    this.userId = user.getUid();
    this.userName = user.getDisplayName();
    if (TextUtils.isEmpty(this.userName)) {
        this.userName = user.getEmail();
    }

    this.rating = rating;
    this.text = text;
}
 
Example 42
Project: ImageClassify   File: TagImagePresenter.java   Source Code and License 5 votes vote down vote up
@Override
public void setImageTask(ImageTask imageTask, ViewFlipper viewFlipper) {
    if (imageTask == null) {
        //为空
        iTagImageView.setImageTaskFailed(mContext.getString(R.string.str_unknown_error));
        return;
    }

    //获得该任务中所有的图片,然后开始遍历添加每一页的图片和相关数据
    List<Images> imagesList = imageTask.getImages();
    mTaskAmount = imagesList.size();
    for (int index = 0; index < mTaskAmount; index++) {
        //添加每一页的备选标签的List
        selectedOptionTagViewList.add(index, new ArrayList<>(imagesList.get(index).getOption_labels()));
        //用户输入的Tag的List,设置用户输入的标签(当用户修改结果的时候会有数据,初次获取任务不会有数据)
        int ii = 1;
        if ((imagesList.get(index).getManual_labels().size() == 1)
                && (TextUtils.isEmpty(imagesList.get(index).getManual_labels().get(0).getLabel_name())
                || imagesList.get(index).getManual_labels().get(0).getLabel_name().equals("null"))){
            inputedManualTagList.add(index, new ArrayList<Label>());
        }else {
            inputedManualTagList.add(index, new ArrayList<>(imagesList.get(index).getManual_labels()));
        }
        //添加item到viewFlipper
        viewFlipper.addView(addTask(viewFlipper, imagesList.get(index), index + 1, mTaskAmount));
    }
    //添加打标签结果页
    viewFlipper.addView(addTagResultView(viewFlipper));
}
 
Example 43
Project: TYT   File: CB_ManageDetailsFragment_WarehouseInfo.java   Source Code and License 5 votes vote down vote up
/**
 * 操作电话号码:委托人
 */
@Click(R.id.tv_orderDelivery_businessEnterpriseContactTelephone)
void createWeituoren() {
    if (!TextUtils.isEmpty(businessEnterpriseContactTelephone)) {
        callNumber(businessEnterpriseContactTelephone);
    }
}
 
Example 44
Project: SlidingSwitch   File: SlidingSwitch.java   Source Code and License 5 votes vote down vote up
private TextView buildTextView(Context context, CharSequence text) {
    TextView textView = new TextView(context);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1);
    textView.setLayoutParams(params);
    textView.setTextColor(mTextColor);
    textView.setText(text);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTextSize);
    textView.setMaxLines(3);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity(Gravity.CENTER);
    textView.setPadding(mPaddingHorizontal, mPaddingVertical, mPaddingHorizontal, mPaddingVertical);
    return textView;
}
 
Example 45
Project: nativead   File: BaseThreadFactory.java   Source Code and License 5 votes vote down vote up
/**
 * @param threadPriority 线程优先级 一般为 Thread.NORM_PRIORITY - 1 就可以
 * @param poolName       线程工厂名字,如ImageDownload
 */
public BaseThreadFactory(int threadPriority, String poolName) {
	if (TextUtils.isEmpty(poolName)) {
		mPoolName = "default" + mPoolCounter.get();
	} else {
		mPoolName = poolName;
	}
	mThreadPriority = threadPriority;
	mThreadGroup = new ThreadGroup(mPoolName);
	mPoolCounter.getAndIncrement();
}
 
Example 46
Project: CXJPadProject   File: SobotChatActivity.java   Source Code and License 5 votes vote down vote up
/**
 * 连接客服时,需要排队
 * 显示排队的处理逻辑
 * @param num		当前排队的位置
 * @param status	当前转人工的返回状态,如果是7,就说明排队已经达到最大值,可以直接留言。
 */
private void createCustomerQueue(String num, int status){
	if (customerState == CustomerState.Queuing && !TextUtils.isEmpty(num)
			&& Integer.parseInt(num) > 0) {
		stopUserInfoTimeTask();
		stopCustomTimeTask();
		stopInputListener();

		queueNum = Integer.parseInt(num);
		//显示当前排队的位置
		if (status != ZhiChiConstant.transfer_robot_custom_max_status){
			showInLineHint();
		}

		if (type == ZhiChiConstant.type_custom_only) {
			showLogicTitle(getResString("sobot_in_line_title"),false);
			setBottomView(ZhiChiConstant.bottomViewtype_onlycustomer_paidui);
			SobotMsgManager.getInstance(getApplication()).getConfig().bottomViewtype = ZhiChiConstant.bottomViewtype_onlycustomer_paidui;
		} else {
			showLogicTitle(initModel.getRobotName(),false);
			setBottomView(ZhiChiConstant.bottomViewtype_paidui);
			SobotMsgManager.getInstance(getApplication()).getConfig().bottomViewtype = ZhiChiConstant.bottomViewtype_paidui;
		}

		queueTimes = queueTimes + 1;
		if (type == ZhiChiConstant.type_custom_first) {
			if (queueTimes == 1) {
				//如果当前为人工优先模式那么在第一次收到
				remindRobotMessage(handler);
			}
		}
	}
}
 
Example 47
Project: boohee_v5.6   File: DietShareActivity.java   Source Code and License 5 votes vote down vote up
public static void comeOnBaby(Context context, String recordOn) {
    if (context != null) {
        if (TextUtils.isEmpty(recordOn)) {
            recordOn = DateFormatUtils.date2string(new Date(), "yyyy-MM-dd");
        }
        MobclickAgent.onEvent(context, Event.DIET_SHARE_CLICK);
        Intent intent = new Intent(context, DietShareActivity.class);
        intent.putExtra(KEY_RECORD_ON, recordOn);
        context.startActivity(intent);
    }
}
 
Example 48
Project: JsoupSample   File: ZhiZhuJsoupManager.java   Source Code and License 5 votes vote down vote up
public List<MagneticModel> getList() {
    List<MagneticModel> listModels = new ArrayList<>();
    MagneticModel magneticModel;
    Elements a = document.select("div.list").select("a[href]:not(.desc):not(.asc)");
    for (Element element : a) {
        if (!TextUtils.equals("点击搜索", element.text())) {
            magneticModel = new MagneticModel();
            magneticModel.title = element.text();
            magneticModel.url = element.select("a[href]").attr("abs:href");
            listModels.add(magneticModel);
        }
    }
    return listModels;
}
 
Example 49
Project: NeoTerm   File: Tab.java   Source Code and License 5 votes vote down vote up
@Override
public final void writeToParcel(final Parcel parcel, final int flags) {
    TextUtils.writeToParcel(title, parcel, flags);
    parcel.writeInt(iconId);
    parcel.writeParcelable(iconBitmap, flags);
    parcel.writeInt(closeable ? 1 : 0);
    parcel.writeInt(closeButtonIconId);
    parcel.writeParcelable(closeButtonIconBitmap, flags);
    parcel.writeParcelable(backgroundColor, flags);
    parcel.writeParcelable(titleTextColor, flags);
    parcel.writeBundle(parameters);
}
 
Example 50
Project: TripBuyer   File: LCIMLocalCacheUtils.java   Source Code and License 5 votes vote down vote up
/**
 * 异步下载文件到指定位置
 *
 * @param url       需要下载远程地址
 * @param localPath 下载到本地的文件存放的位置
 * @param overlay   是否覆盖原文件
 * @param callback  下载完后的回调
 */
public static void downloadFile(final String url, final String localPath,
                                boolean overlay, final DownLoadCallback callback) {
  if (TextUtils.isEmpty(url) || TextUtils.isEmpty(localPath)) {
    throw new IllegalArgumentException("url or localPath can not be null");
  } else if (!overlay && isFileExist(localPath)) {
    if (null != callback) {
      callback.done(null);
    }
  } else {
    addDownloadCallback(url, callback);
    if (!isDownloadingFile.contains(url)) {
      new AsyncTask<Void, Void, Exception>() {
        @Override
        protected Exception doInBackground(Void... params) {
          return downloadWithOKHttp(url, localPath);
        }

        @Override
        protected void onPostExecute(Exception e) {
          executeDownloadCallBack(url, e);
          isDownloadingFile.remove(url);
        }
      }.execute();
    }
  }
}
 
Example 51
Project: stynico   File: LoginActivity.java   Source Code and License 5 votes vote down vote up
private void attemptLogin()
  {
      mEmailView.setError(null);
      mPasswordView.setError(null);
      String email = mEmailView.getText().toString();
      String password = mPasswordView.getText().toString();

      boolean cancel = false;
      View focusView = null;

      if (!TextUtils.isEmpty(password) && !isPasswordValid(password))
{
          mPasswordView.setError(getString(R.string.error_invalid_password));
          focusView = mPasswordView;
          cancel = true;
      }

      if (TextUtils.isEmpty(email))
{
          mEmailView.setError(getString(R.string.error_field_required));
          focusView = mEmailView;
          cancel = true;
      }
else if (!isEmailValid(email))
{
          mEmailView.setError(getString(R.string.error_invalid_email));
          focusView = mEmailView;
          cancel = true;
      }

      if (cancel)
{
          focusView.requestFocus();
      }
else
{
          lxwLogin(email, password);
          // showProgress(true,email,password);
      }
  }
 
Example 52
Project: react-native-udesk   File: JsonUtils.java   Source Code and License 5 votes vote down vote up
public static SurveyOptionsModel parseSurveyOptions(String response){
	
	SurveyOptionsModel optionsMode = new SurveyOptionsModel();
	if (TextUtils.isEmpty(response)) {
		return optionsMode;
	}
	
	try {
		JSONObject json = new JSONObject(response);
		JSONObject result = json.getJSONObject("result");
		if (result.has("title")) {
			optionsMode.setTitle(result.getString("title"));
		}
		if (result.has("desc")) {
			optionsMode.setDesc(result.getString("desc"));
		}
		if (result.has("options")) {
			
			List<OptionsModel> options = new ArrayList<OptionsModel>();
			JSONArray optionsArray = result.optJSONArray("options");
			if (optionsArray != null && optionsArray.length() > 0) {
				for (int i = 0; i < optionsArray.length(); i++) {
					JSONObject data = optionsArray.optJSONObject(i);
					OptionsModel optionItem = new OptionsModel();
					optionItem.setId(data.optString("id"));
					optionItem.setText(data.getString("text"));
					options.add(optionItem);
				}
			}
			optionsMode.setOptions(options);
		}
	} catch (JSONException e) {
		e.printStackTrace();
	}
	return optionsMode;
	
}
 
Example 53
Project: SelectName   File: ChooseNameActivity.java   Source Code and License 5 votes vote down vote up
protected boolean attest() {

        // validate
        String etFirstNameString = etFirstName.getText().toString().trim();
        if (TextUtils.isEmpty(etFirstNameString)) {
            ToastUtils.e("本版本只支持单字姓氏,请输入单字姓氏").show();
            return false;
        }


        return true;
    }
 
Example 54
Project: cute-currency-view   File: CuteCurrencyView.java   Source Code and License 5 votes vote down vote up
public void startAnimation() {

        actualEditText.setVisibility(INVISIBLE);
        animatedPlaceholder.setVisibility(INVISIBLE);

        if (TextUtils.isEmpty(actualEditText.getText())
                && TextUtils.isEmpty(actualEditText.getHint())) {
            // don't do anything if everything is empty
            // but make the EditText visible and say bye to placeholder
            actualEditText.setVisibility(VISIBLE);
            animatedPlaceholder.setVisibility(GONE);
            return;
        }

        TextPaint paint = new TextPaint();
        paint.set(actualEditText.getPaint());

        // decides what is going to be animated
        if (TextUtils.isEmpty(actualEditText.getText())) {
            // animate hint
            paint.setColor(actualEditText.getCurrentHintTextColor());
            animateCharSequence(actualEditText.getHint(), paint);
        } else {
            // animate text
            paint.setColor(actualEditText.getCurrentTextColor());
            animateCharSequence(actualEditText.getText(), paint);
        }

    }
 
Example 55
Project: BootStepView   File: AddSpaceTextWatcher.java   Source Code and License 5 votes vote down vote up
/**
 * 设置输入字符
 *
 * @param charSequence
 * @return 返回设置成功失败
 * @see [类、类#方法、类#成员]
 */
public boolean setText(CharSequence charSequence) {
    if (editText != null && !TextUtils.isEmpty(charSequence) && computeSpaceCount(charSequence) <= maxLenght) {
        isSetText = true;
        editText.removeTextChangedListener(this);
        editText.setText(charSequence);
        editText.addTextChangedListener(this);
        return true;
    }
    return false;
}
 
Example 56
Project: letv   File: StarActivity.java   Source Code and License 5 votes vote down vote up
private void drawStarVoteNum(String num, String unit) {
    if (!TextUtils.isEmpty(num) && !TextUtils.isEmpty(unit)) {
        String str = num + " " + unit;
        int start = num.length();
        int end = str.length();
        SpannableStringBuilder sb = new SpannableStringBuilder(str);
        sb.setSpan(new ForegroundColorSpan(getResources().getColor(2131493270)), start, end, 33);
        sb.setSpan(new StyleSpan(1), 0, start, 33);
        sb.setSpan(new AbsoluteSizeSpan(getResources().getDimensionPixelSize(2131165477)), start, end, 33);
        this.mStarRankVoteNum.setText(sb);
    }
}
 
Example 57
Project: letv   File: LetvWoFlowActivity.java   Source Code and License 5 votes vote down vote up
public void showUI() {
    IWoUtil woUtil = (IWoUtil) JarLoader.invokeStaticMethod(JarLoader.loadClass(this, JarConstant.LETV_WO_NAME, JarConstant.LETV_WO_PACKAGENAME, "util.WoUtil"), "getInstance", null, null);
    this.yewofanwei = woUtil.getWoBusinessScope(this);
    this.yewotiaokuan = woUtil.getWoBusinessTerms(this);
    this.mOrderYewufangwei.setText(getString(2131101211, new Object[]{this.yewofanwei}));
    this.mUnOrderYewufangwei.setText(getString(2131101211, new Object[]{this.yewofanwei}));
    this.mOrderText.setText(Html.fromHtml(this.yewotiaokuan));
    this.mUnOrderText.setText(Html.fromHtml(this.yewotiaokuan));
    final IWoFlowManager woFlowManager = (IWoFlowManager) JarLoader.invokeStaticMethod(JarLoader.loadClass(this, JarConstant.LETV_WO_NAME, JarConstant.LETV_WO_PACKAGENAME, "WoFlowManager"), "getInstance", null, null);
    woFlowManager.isUserOrder(this, new LetvWoFlowListener() {
        public void onResponseOrderInfo(boolean isSupportProvince, boolean isOrder, boolean isUnOrderSure, String freeUrl, boolean isSmsSuccess) {
            if (LetvWoFlowActivity.this != null) {
                LogInfo.log("ZSM", "showUI == > " + isOrder);
                LetvWoFlowActivity.this.phoneNum = woFlowManager.getMobilePhoneNumber(LetvWoFlowActivity.this);
                if (TextUtils.isEmpty(woFlowManager.getPhoneNum(LetvWoFlowActivity.this))) {
                    LogInfo.log("king", "LetvWoFlowActivity.this.finish()");
                    LetvWoFlowActivity.this.finish();
                }
                if (!isOrder && LetvWoFlowActivity.this.unOrder) {
                    LogInfo.log("ZSM", "未订购  退订  进入无需退订页");
                    LetvWoFlowActivity.this.mHandler.sendEmptyMessage(9);
                } else if (isOrder && LetvWoFlowActivity.this.unOrder) {
                    LogInfo.log("ZSM", "已经订购 退订  进入退订页");
                    LetvWoFlowActivity.this.mHandler.sendEmptyMessage(2);
                } else if (!isOrder || woFlowManager.isUserUnOrder()) {
                    LogInfo.log("ZSM", "未订购  非退订  进入订购页");
                    LetvWoFlowActivity.this.mHandler.sendEmptyMessage(1);
                } else if (isOrder) {
                    LetvWoFlowActivity.this.mHandler.sendEmptyMessage(4);
                }
            }
        }
    }, true, true);
}
 
Example 58
Project: simple-keyboard   File: InputMethodSettingsImpl.java   Source Code and License 5 votes vote down vote up
/**
 * Initialize internal states of this object.
 * @param context the context for this application.
 * @param prefScreen a PreferenceScreen of PreferenceActivity or PreferenceFragment.
 * @return true if this application is an IME and has two or more subtypes, false otherwise.
 */
public boolean init(final Context context, final PreferenceScreen prefScreen) {
    mContext = context;
    mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    mImi = getMyImi(context, mImm);
    if (mImi == null || mImi.getSubtypeCount() <= 1) {
        return false;
    }
    mSubtypeEnablerPreference = new Preference(context);
    mSubtypeEnablerPreference
            .setOnPreferenceClickListener(new OnPreferenceClickListener() {
                @Override
                public boolean onPreferenceClick(Preference preference) {
                    final CharSequence title = getSubtypeEnablerTitle(context);
                    final Intent intent =
                            new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
                    intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId());
                    if (!TextUtils.isEmpty(title)) {
                        intent.putExtra(Intent.EXTRA_TITLE, title);
                    }
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                            | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    context.startActivity(intent);
                    return true;
                }
            });
    prefScreen.addPreference(mSubtypeEnablerPreference);
    updateSubtypeEnabler();
    return true;
}
 
Example 59
Project: RxEasyHttp   File: EasyHttp.java   Source Code and License 5 votes vote down vote up
/**
 * 调试模式,第二个参数表示所有catch住的log是否需要打印<br>
 * 一般来说,这些异常是由于不标准的数据格式,或者特殊需要主动产生的,
 * 并不是框架错误,如果不想每次打印,这里可以关闭异常显示
 */
public EasyHttp debug(String tag, boolean isPrintException) {
    String tempTag = TextUtils.isEmpty(tag)?"RxEasyHttp_":tag;
    if(isPrintException){
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(tempTag, isPrintException);
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        okHttpClientBuilder.addInterceptor(loggingInterceptor);
    }
    HttpLog.customTagPrefix = tempTag;
    HttpLog.allowE = isPrintException;
    HttpLog.allowD = isPrintException;
    HttpLog.allowI = isPrintException;
    HttpLog.allowV = isPrintException;
    return this;
}
 
Example 60
Project: CSipSimple   File: Help.java   Source Code and License 5 votes vote down vote up
public View getCustomView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  	View v = inflater.inflate(R.layout.help, container, false);
      ListView lv = (ListView) v.findViewById(android.R.id.list);
      lv.setOnItemClickListener(this);
      
      
      ArrayList<HelpEntry> items = new ArrayList<HelpEntry>();

      // FAQ
if(!TextUtils.isEmpty(CustomDistribution.getFaqLink())) {
	items.add(new HelpEntry(android.R.drawable.ic_menu_info_details, R.string.faq, FAQ));
}

// Issue list 
if(CustomDistribution.showIssueList()) {
	items.add(new HelpEntry(android.R.drawable.ic_menu_view, R.string.view_existing_issues, OPEN_ISSUES));
}

// Log collector
if(!TextUtils.isEmpty(CustomDistribution.getSupportEmail()) ) {
	if(isRecording()) {
        items.add(new HelpEntry( android.R.drawable.ic_menu_send , R.string.send_logs, SEND_LOGS));
	}else {
        items.add(new HelpEntry( android.R.drawable.ic_menu_save , R.string.record_logs, START_LOGS));
	}
}

      items.add(new HelpEntry(android.R.drawable.ic_menu_gallery, R.string.legal_information, LEGALS));
      
      if(NightlyUpdater.isNightlyBuild(getActivity())){
	items.add(new HelpEntry(R.drawable.ic_launcher_nightly, R.string.update_nightly_build, NIGHTLY));
}

      lv.setAdapter(new HelpArrayAdapter(getActivity(), items));
      
      TextView tv = (TextView) v.findViewById(android.R.id.text1);
      tv.setText(CollectLogs.getApplicationInfo(getActivity()));
      
      return v;
  }