Java Code Examples for android.text.TextUtils.isEmpty()

The following are Jave code examples for showing how to use isEmpty() of the android.text.TextUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: boohee_v5.6   File: UMWXHandler.java   View Source Code Vote up 7 votes
private void parseMediaType() {
    if (!TextUtils.isEmpty(this.mShareContent) && this.mShareMedia == null) {
        this.mShareType = "text";
    } else if (this.mShareMedia != null && (this.mShareMedia instanceof UMEmoji)) {
        this.mShareType = TYPE_EMOJI;
    } else if (TextUtils.isEmpty(this.mShareContent) && this.mShareMedia != null && (this
            .mShareMedia instanceof UMImage)) {
        this.mShareType = "image";
    } else if (this.mShareMedia != null && (this.mShareMedia instanceof UMusic)) {
        this.mShareType = TYPE_MUSIC;
    } else if (this.mShareMedia != null && (this.mShareMedia instanceof UMVideo)) {
        this.mShareType = TYPE_VIDEO;
    } else if (!TextUtils.isEmpty(this.mShareContent) && this.mShareMedia != null && (this
            .mShareMedia instanceof UMImage)) {
        this.mShareType = TYPE_TEXT_IMAGE;
    }
}
 
Example 2
Project: Melophile   File: UserHandler.java   View Source Code Vote up 6 votes
public List<Track> queryFavorites(String id){
    if(!TextUtils.isEmpty(id)){
        Cursor cursor=provider.query(Users.buildFavoritesUri(id),null,null,null,null);
        if(cursor!=null){
            List<Track> tracks=new ArrayList<>(cursor.getCount());
            while(cursor.moveToNext()){
                Track track=DatabaseUtils.toTrack(cursor);
                tracks.add(track);
            }
            if(!cursor.isClosed()) cursor.close();
            return tracks;
        }
        return null;
    }
    throw new IllegalArgumentException("Id is null");
}
 
Example 3
Project: gogo   File: Login.java   View Source Code Vote up 6 votes
private boolean validateForm() {
    boolean valid = true;

    String email = emailEditText.getText().toString();
    if (TextUtils.isEmpty(email)) {
        emailEditText.setError("Required.");
        valid = false;
    } else {
        emailEditText.setError(null);
    }

    String password = passwordEditText.getText().toString();
    if (TextUtils.isEmpty(password)) {
        passwordEditText.setError("Required.");
        valid = false;
    } else {
        passwordEditText.setError(null);
    }

    return valid;
}
 
Example 4
Project: ucar-weex-core   File: CSSPositionTypeConvert.java   View Source Code Vote up 5 votes
public static CSSPositionType convert(String s) {
  CSSPositionType position = CSSPositionType.RELATIVE;
  if (TextUtils.isEmpty(s) || s.equals("relative") || s.equals("sticky")) {
    position = CSSPositionType.RELATIVE;
  } else if (s.equals("absolute") || s.equals("fixed")) {
    position = CSSPositionType.ABSOLUTE;
  }
  return position;
}
 
Example 5
Project: letv   File: DatabaseUtilsCompat.java   View Source Code Vote up 5 votes
public static String concatenateWhere(String a, String b) {
    if (TextUtils.isEmpty(a)) {
        return b;
    }
    if (TextUtils.isEmpty(b)) {
        return a;
    }
    return "(" + a + ") AND (" + b + ")";
}
 
Example 6
Project: Ghost-Android   File: PostViewActivity.java   View Source Code Vote up 5 votes
private void updatePostSettings() {
    String imageUrl = mPost.getFeatureImage();
    if (!TextUtils.isEmpty(imageUrl)) {
        mPostImageLayoutManager.setViewState(PostImageLayoutManager.ViewState.PROGRESS_BAR);
        String blogUrl = AccountManager.getActiveBlogUrl();
        imageUrl = NetworkUtils.makeAbsoluteUrl(blogUrl, imageUrl);
        getPicasso()
                .load(imageUrl)
                .fit().centerCrop()
                .into(mPostImageLayoutManager.getImageView(), new Callback() {
                    @Override
                    public void onSuccess() {
                        mPostImageLayoutManager.setViewState(PostImageLayoutManager.ViewState.IMAGE);
                    }

                    @Override
                    public void onError() {
                        Toast.makeText(PostViewActivity.this, R.string.post_image_load_error,
                                Toast.LENGTH_SHORT).show();
                        mPostImageLayoutManager.setViewState(PostImageLayoutManager.ViewState.PLACEHOLDER);
                    }
                });
    } else {
        mPostImageLayoutManager.setViewState(PostImageLayoutManager.ViewState.PLACEHOLDER);
    }
    List<String> tagStrs = new ArrayList<>();
    for (Tag tag : mPost.getTags()) {
        tagStrs.add(tag.getName());
    }
    mPostTagsEditText.setTokens(tagStrs);
    mPostExcerptEditText.setText(mPost.getCustomExcerpt());
    mPostFeatureCheckBox.setChecked(mPost.isFeatured());
    mPostPageCheckBox.setChecked(mPost.isPage());
}
 
Example 7
Project: TextReader   File: DownloadBookService.java   View Source Code Vote up 5 votes
@Subscribe(threadMode = ThreadMode.MAIN)
public synchronized void addToDownloadQueue(DownloadQueue queue) {
    if (!TextUtils.isEmpty(queue.bookId)) {
        boolean exists = false;
        // 判断当前书籍缓存任务是否存在
        for (int i = 0; i < downloadQueues.size(); i++) {
            if (downloadQueues.get(i).bookId.equals(queue.bookId)) {
                LogUtils.e("addToDownloadQueue:exists");
                exists = true;
                break;
            }
        }
        if (exists) {
            post(new DownloadMessage(queue.bookId, "当前缓存任务已存在", false));
            return;
        }

        // 添加到下载队列
        downloadQueues.add(queue);
        LogUtils.e("addToDownloadQueue:" + queue.bookId);
        post(new DownloadMessage(queue.bookId, "成功加入缓存队列", false));
    }
    // 从队列顺序取出第一条下载
    if (downloadQueues.size() > 0 && !isBusy) {
        isBusy = true;
        downloadBook(downloadQueues.get(0));
    }
}
 
Example 8
Project: chromium-for-android-56-debug-video   File: CustomTabActivity.java   View Source Code Vote up 5 votes
private void recordClientPackageName() {
    String clientName = CustomTabsConnection.getInstance(getApplication())
            .getClientPackageNameForSession(mSession);
    if (TextUtils.isEmpty(clientName)) clientName = mIntentDataProvider.getClientPackageName();
    final String packageName = clientName;
    if (TextUtils.isEmpty(packageName) || packageName.contains(getPackageName())) return;
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            RapporServiceBridge.sampleString(
                    "CustomTabs.ServiceClient.PackageName", packageName);
        }
    });
}
 
Example 9
Project: chromium-for-android-56-debug-video   File: AccountManagementFragment.java   View Source Code Vote up 5 votes
public void update() {
    final Context context = getActivity();
    if (context == null) return;

    if (getPreferenceScreen() != null) getPreferenceScreen().removeAll();

    ChromeSigninController signInController = ChromeSigninController.get(context);
    if (!signInController.isSignedIn()) {
        // The AccountManagementFragment can only be shown when the user is signed in. If the
        // user is signed out, exit the fragment.
        getActivity().finish();
        return;
    }

    addPreferencesFromResource(R.xml.account_management_preferences);

    String signedInAccountName =
            ChromeSigninController.get(getActivity()).getSignedInAccountName();
    String fullName = getCachedUserName(signedInAccountName);
    if (TextUtils.isEmpty(fullName)) {
        fullName = ProfileDownloader.getCachedFullName(Profile.getLastUsedProfile());
    }
    if (TextUtils.isEmpty(fullName)) fullName = signedInAccountName;

    getActivity().setTitle(fullName);

    configureSignOutSwitch();
    configureAddAccountPreference();
    configureChildAccountPreferences();
    configureSyncSettings();
    configureGoogleActivityControls();

    updateAccountsList();
}
 
Example 10
Project: popomusic   File: SearchActivity.java   View Source Code Vote up 5 votes
@Override
public void onSearchStateChanged(boolean b) {
    SearchActivity activity = weakActivity.get();
    if (null == activity) return;
    if (TextUtils.isEmpty(activity.mSearchBar.getText().trim())) {
        activity.finish();
    }
}
 
Example 11
Project: ucar-weex-core   File: WXDebugActivity.java   View Source Code Vote up 5 votes
private void handleDecodeInternally(String code) {

        if (!TextUtils.isEmpty(code)) {
            Uri uri = Uri.parse(code);
            if (uri.getQueryParameterNames().contains("bundle")) {
                WXEnvironment.sDynamicMode = uri.getBooleanQueryParameter("debug", false);
                WXEnvironment.sDynamicUrl = uri.getQueryParameter("bundle");
                String tip = WXEnvironment.sDynamicMode ? "Has switched to Dynamic Mode" : "Has switched to Normal Mode";
                Toast.makeText(this, tip, Toast.LENGTH_SHORT).show();
                finish();
                return;
            } else if (uri.getQueryParameterNames().contains("_wx_devtool")) {
                WXEnvironment.sRemoteDebugProxyUrl = uri.getQueryParameter("_wx_devtool");
                WXEnvironment.sDebugServerConnectable = true;
                WXSDKEngine.reload();
                Toast.makeText(this, "devtool", Toast.LENGTH_SHORT).show();
                return;
            } else if (code.contains("_wx_debug")) {
                uri = Uri.parse(code);
                String debug_url = uri.getQueryParameter("_wx_debug");
                WXSDKEngine.switchDebugModel(true, debug_url);
                finish();
            } else {
                Toast.makeText(this, code, Toast.LENGTH_SHORT).show();
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
//                intent.setPackage(getPackageName());
                intent.setData(Uri.parse(code));
                startActivity(intent);
            }
        }
    }
 
Example 12
Project: OSchina_resources_android   File: OtherUserHomeActivity.java   View Source Code Vote up 5 votes
@Override
protected boolean initBundle(Bundle bundle) {
    user = (User) bundle.getSerializable(KEY_BUNDLE);
    if (user == null || (user.getId() <= 0 && TextUtils.isEmpty(user.getName())
            && TextUtils.isEmpty(user.getSuffix()))) {
        Toast.makeText(this, "没有此用户", Toast.LENGTH_SHORT).show();
        return false;
    }
    return super.initBundle(bundle);
}
 
Example 13
Project: GxIconAndroid   File: ExtraUtil.java   View Source Code Vote up 5 votes
@NonNull
public static String purifyIconName(String iconName) {
    if (TextUtils.isEmpty(iconName)) {
        return "";
    }
    if (iconName.matches(".+?_\\d+")) {
        return iconName.substring(0, iconName.lastIndexOf('_'));
    }
    return iconName;
}
 
Example 14
Project: easyShopping   File: WeiXinDonate.java   View Source Code Vote up 5 votes
/**
 * 微信捐赠
 * @param activity activity
 * @param qrSavePath 个人收款二维码,可以通过微信生成
 */
public static void donateViaWeiXin(Activity activity, String qrSavePath) {
    if (activity == null || TextUtils.isEmpty(qrSavePath)) {
        //参数错误
        Log.d(TAG, "参数为null");
        return;
    }
    sendPictureStoredBroadcast(activity, qrSavePath);
    gotoWeChatQrScan(activity);
}
 
Example 15
Project: DeeplinkRouter   File: Mapping.java   View Source Code Vote up 5 votes
public boolean isMatched(String url)
{
    if(TextUtils.isEmpty(url)) return false;

    Uri uri = Uri.parse(url);

    String host = uri.getHost();

    if(!TextUtils.isEmpty(host) && TextUtils.equals(this.host, host))
    {
        if(paramsFilter.isEmpty())
        {
            return true;
        }
        else
        {
            Set<String> queryKeySet = uri.getQueryParameterNames();

            if(queryKeySet.isEmpty()) return false;

            boolean isAllParamsMatched = true;

            for(String paramKey : paramsFilter.keySet())
            {
                isAllParamsMatched = isAllParamsMatched
                        && queryKeySet.contains(paramKey)
                        && TextUtils.equals(paramsFilter.get(paramKey), uri.getQueryParameter(paramKey));
            }

            return isAllParamsMatched;
        }
    }

    return false;
}
 
Example 16
Project: IdealMedia   File: Security.java   View Source Code Vote up 5 votes
/**
 * Verifies that the data was signed with the given signature, and returns
 * the verified purchase. The data is in JSON format and signed
 * with a private key. The data also contains the {@link PurchaseState}
 * and product ID of the purchase.
 * @param base64PublicKey the base64-encoded public key to use for verifying.
 * @param signedData the signed JSON string (signed, not encrypted)
 * @param signature the signature for the data, signed with the private key
 */
public static boolean exverifyPurchase(String base64PublicKey, String signedData, String signature) {
    if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) ||
            TextUtils.isEmpty(signature)) {
        Log.e(TAG, "Purchase verification failed: missing data.");
        return false;
    }

    PublicKey key = Security.generatePublicKey(base64PublicKey);
    return Security.verify(key, signedData, signature);
}
 
Example 17
Project: EvolvingNetLib   File: CCIOUtils.java   View Source Code Vote up 5 votes
/**
 * Create a file, If the file exists is not created.
 *
 * @param filePath file path.
 * @return True: success, or false: failure.
 */
public static boolean createFile(String filePath) {
    if (!TextUtils.isEmpty(filePath)) {
        File file = new File(filePath);
        return createFile(file);
    }
    return false;
}
 
Example 18
Project: QuanMinTV   File: MineFragment.java   View Source Code Vote up 4 votes
/**
 * 支付宝支付业务
 */
public void pay() {
    if (TextUtils.isEmpty(APPID) || TextUtils.isEmpty(RSA2_PRIVATE)) {
        new AlertDialog.Builder(getContext()).setTitle("警告").setMessage("需要配置APPID | RSA_PRIVATE")
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialoginterface, int i) {
                        //
                        getActivity().finish();
                    }
                }).show();
        return;
    }

    /**
     * 这里只是为了方便直接向商户展示支付宝的整个支付流程;所以Demo中加签过程直接放在客户端完成;
     * 真实App里,privateKey等数据严禁放在客户端,加签过程务必要放在服务端完成;
     * 防止商户私密数据泄露,造成不必要的资金损失,及面临各种安全风险;
     *
     * orderInfo的获取必须来自服务端;
     */
    boolean rsa2 = (RSA2_PRIVATE.length() > 0);
    Map<String, String> params = OrderInfoUtil2_0.buildOrderParamMap(APPID, rsa2);
    String orderParam = OrderInfoUtil2_0.buildOrderParam(params);

    String privateKey = rsa2 ? RSA2_PRIVATE : RSA_PRIVATE;
    String sign = OrderInfoUtil2_0.getSign(params, privateKey, rsa2);
    final String orderInfo = orderParam + "&" + sign;
    LogUtil.d(orderInfo);

    Runnable payRunnable = new Runnable() {

        @Override
        public void run() {
            PayTask alipay = new PayTask(getActivity());
            Map<String, String> result = alipay.payV2(orderInfo, true);
            Log.i("msp", result.toString());

            Message msg = new Message();
            msg.what = SDK_PAY_FLAG;
            msg.obj = result;
            mHandler.sendMessage(msg);
        }
    };

    Thread payThread = new Thread(payRunnable);
    payThread.start();
}
 
Example 19
Project: BlockCanaryEx   File: DetailAdapter.java   View Source Code Vote up 4 votes
@Override
public String getItem(int position) {
    if (getItemViewType(position) == TOP_ROW) {
        return null;
    }
    StringBuilder contentBuilder = new StringBuilder();
    switch (position) {
        case POSITION_TIME:
            return contentBuilder.append("time :").append(SEPARATOR).append(SEPARATOR).append(mBlockInfo.getTimeString()).toString();
        case POSITION_ENV:
            return contentBuilder.append("environment :").append(SEPARATOR).append(SEPARATOR).append(mBlockInfo.getEnvInfo()).toString();
        case POSITION_TOP_HEAVY_METHOD:
            return contentBuilder.append("top-heavy-method :").append(SEPARATOR).append(SEPARATOR).append(mBlockInfo.getTopHeavyMethod()).toString();
        case POSITION_TOP_FREQUENT_METHOD:
            if(TextUtils.isEmpty(mBlockInfo.getTopFrequentMethod())) {
                return "top-frequent-method : null";
            }
            return contentBuilder.append("top-frequent-method :").append(SEPARATOR).append(SEPARATOR).append(mBlockInfo.getTopFrequentMethod()).toString();
        case POSITION_VIEW:
            if(TextUtils.isEmpty(mBlockInfo.getViewPerformance()))  {
                if(!ViewPerformanceSampler.isSupported()) {
                    return String.format(Locale.getDefault(), "view-perf : don't support current android version %d", Build.VERSION.SDK_INT);
                }
                return "view-perf : null";
            } else {
                return contentBuilder.append("view-perf :").append(SEPARATOR).append(SEPARATOR).append(mBlockInfo.getViewPerformance()).toString();
            }
        case POSITION_GC:
            if(TextUtils.isEmpty(mBlockInfo.getGcEvent()))  {
                return "gc-event : null";
            } else {
                return contentBuilder.append("gc-event :").append(SEPARATOR).append(SEPARATOR).append(mBlockInfo.getGcEvent()).toString();
            }
        case POSITION_HEAVY_METHOD:
            if(TextUtils.isEmpty(mBlockInfo.getHeavyMethods())) {
                return "heavy-methods : null";
            }
            return contentBuilder.append("heavy-methods :").append(SEPARATOR).append(SEPARATOR).append(mBlockInfo.getHeavyMethods()).toString();
        case POSITION_FREQUENT_METHOD:
        default:
            if(TextUtils.isEmpty(mBlockInfo.getFrequentMethods())) {
                return "frequent-methods : null";
            }
            return contentBuilder.append("frequent-methods :").append(SEPARATOR).append(SEPARATOR).append(mBlockInfo.getFrequentMethods()).toString();
    }
}
 
Example 20
Project: GitHub   File: AxesRenderer.java   View Source Code Vote up 4 votes
private void drawAxisLabelsAndName(Canvas canvas, Axis axis, int position) {
    float labelX, labelY;
    labelX = labelY = 0;
    boolean isAxisVertical = isAxisVertical(position);
    if (LEFT == position || RIGHT == position) {
        labelX = labelBaselineTab[position];
    } else if (TOP == position || BOTTOM == position) {
        labelY = labelBaselineTab[position];
    }

    for (int valueToDrawIndex = 0; valueToDrawIndex < valuesToDrawNumTab[position]; ++valueToDrawIndex) {
        int charsNumber = 0;
        if (axis.isAutoGenerated()) {
            final float value = autoValuesToDrawTab[position][valueToDrawIndex];
            charsNumber = axis.getFormatter().formatValueForAutoGeneratedAxis(labelBuffer, value,
                    autoValuesBufferTab[position].decimals);
        } else {
            AxisValue axisValue = valuesToDrawTab[position][valueToDrawIndex];
            charsNumber = axis.getFormatter().formatValueForManualAxis(labelBuffer, axisValue);
        }

        if (isAxisVertical) {
            labelY = rawValuesTab[position][valueToDrawIndex];
        } else {
            labelX = rawValuesTab[position][valueToDrawIndex];
        }

        if (axis.hasTiltedLabels()) {
            canvas.save();
            canvas.translate(tiltedLabelXTranslation[position], tiltedLabelYTranslation[position]);
            canvas.rotate(-45, labelX, labelY);
            canvas.drawText(labelBuffer, labelBuffer.length - charsNumber, charsNumber, labelX, labelY,
                    labelPaintTab[position]);
            canvas.restore();
        } else {
            canvas.drawText(labelBuffer, labelBuffer.length - charsNumber, charsNumber, labelX, labelY,
                    labelPaintTab[position]);
        }
    }

    // Drawing axis name
    final Rect contentRectMargins = computator.getContentRectMinusAxesMargins();
    if (!TextUtils.isEmpty(axis.getName())) {
        if (isAxisVertical) {
            canvas.save();
            canvas.rotate(-90, contentRectMargins.centerY(), contentRectMargins.centerY());
            canvas.drawText(axis.getName(), contentRectMargins.centerY(), nameBaselineTab[position],
                    namePaintTab[position]);
            canvas.restore();
        } else {
            canvas.drawText(axis.getName(), contentRectMargins.centerX(), nameBaselineTab[position],
                    namePaintTab[position]);
        }
    }
}