Java Code Examples for android.text.TextUtils#isEmpty()
The following examples show how to use
android.text.TextUtils#isEmpty() .
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 File: MacAddressUtils.java From CacheEmulatorChecker with Apache License 2.0 | 6 votes |
public static String getConnectedWifiMacAddress(Application context) { String connectedWifiMacAddress = null; WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); List<ScanResult> wifiList; if (wifiManager != null) { wifiList = wifiManager.getScanResults(); WifiInfo info = wifiManager.getConnectionInfo(); if (wifiList != null && info != null) { for (int i = 0; i < wifiList.size(); i++) { ScanResult result = wifiList.get(i); if (!TextUtils.isEmpty(info.getBSSID()) && info.getBSSID().equals(result.BSSID)) { connectedWifiMacAddress = result.BSSID; } } } } return connectedWifiMacAddress; }
Example 2
Source File: MultiPointController.java From letv with Apache License 2.0 | 6 votes |
public boolean play(Device device, String path) { if (device == null) { return false; } Service service = device.getService("urn:schemas-upnp-org:service:AVTransport:1"); if (service == null) { return false; } Action action = service.getAction("SetAVTransportURI"); if (action == null) { return false; } Action playAction = service.getAction("Play"); if (playAction == null || TextUtils.isEmpty(path)) { return false; } action.setArgumentValue("InstanceID", 0); action.setArgumentValue(AVTransport.CURRENTURI, path); action.setArgumentValue(AVTransport.CURRENTURIMETADATA, 0); if (!action.postControlAction()) { return false; } playAction.setArgumentValue("InstanceID", 0); playAction.setArgumentValue(AVTransport.SPEED, "1"); return playAction.postControlAction(); }
Example 3
Source File: VideoServiceQueryChainModel.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 6 votes |
private Map<String, String> createBody(Map<String, String> params) { Map<String, String> bodyParams = new HashMap<>(); bodyParams.put("commonParam", LVCommonParamPlugin.getCommonParamJson()); Platform platform = getPlatform(); if (platform != null) { PlatformInfo info = platform.getPlatformInfo(); if (info != null) { String videoId = info.getVideoId(); if (!TextUtils.isEmpty(videoId)) { bodyParams.put("videoId", videoId); } } } if (params != null) { bodyParams.putAll(params); } HashMap<String, String> dataParams = new HashMap<>(); dataParams.put("data", VenvyAesUtil.encrypt(AppSecret.getAppSecret(getPlatform()), AppSecret.getAppSecret(getPlatform()), new JSONObject(bodyParams).toString())); return dataParams; }
Example 4
Source File: PlayMusicManager.java From PlayMusicExporter with MIT License | 6 votes |
/** * Gets the full path to the artwork * @param artworkPath The artwork path * @return The full path to the artwork */ public String getArtworkPath(String artworkPath) { // Artwork path is empty if (TextUtils.isEmpty(artworkPath)) return null; String path; // DS 2017-05-06: Changed the path to the newest version if (!artworkPath.startsWith("artwork/")) artworkPath = "artwork/" + artworkPath; // Search in the public data for (String publicData : mPathPublicData) { path = publicData + "/files/" + artworkPath; if (FileTools.fileExists(path)) return path; } // Private artwork path path = getPrivateFilesPath() + "/" + artworkPath; // Don't check if the file exists, this will freeze the UI thread // if (SuperUserTools.fileExists(path)) return path; return path; }
Example 5
Source File: HttpTask.java From letv with Apache License 2.0 | 6 votes |
protected void sendResponseMessage(HttpResponse response) { super.sendResponseMessage(response); Header[] headers = response.getHeaders("Set-Cookie"); if (headers != null && headers.length > 0) { CookieSyncManager.createInstance(this.val$context).sync(); CookieManager instance = CookieManager.getInstance(); instance.setAcceptCookie(true); instance.removeSessionCookie(); String mm = ""; for (Header header : headers) { String[] split = header.toString().split("Set-Cookie:"); EALogger.i("正式登录", "split[1]===>" + split[1]); instance.setCookie(Constants.THIRDLOGIN, split[1]); int index = split[1].indexOf(";"); if (TextUtils.isEmpty(mm)) { mm = split[1].substring(index + 1); EALogger.i("正式登录", "mm===>" + mm); } } EALogger.i("正式登录", "split[1222]===>COOKIE_DEVICE_ID=" + LemallPlatform.getInstance().uuid + ";" + mm); instance.setCookie(Constants.THIRDLOGIN, "COOKIE_DEVICE_ID=" + LemallPlatform.getInstance().uuid + ";" + mm); instance.setCookie(Constants.THIRDLOGIN, "COOKIE_APP_ID=" + LemallPlatform.getInstance().getmAppInfo().getId() + ";" + mm); CookieSyncManager.getInstance().sync(); this.val$iLetvBrideg.reLoadWebUrl(); } }
Example 6
Source File: ModifyAdvIntervalFragment.java From Android-nRF-Beacon with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Called when OK button has been pressed. */ @Override public void onClick(final View view) { final String idValue = mAdvIntervalView.getText().toString(); boolean valid = true; int interval = 0; if (TextUtils.isEmpty(idValue)) valid = false; try { interval = Integer.parseInt(idValue); } catch (final NumberFormatException e) { valid = false; } if (interval < 100 || interval > 10240) valid = false; if (valid) { final UpdateFragment parentFragment = (UpdateFragment) getParentFragment(); parentFragment.writeNewAdvInterval(interval); dismiss(); } else { mAdvIntervalView.setError(getText(R.string.update_dialog_adv_interval_error)); mAdvIntervalView.requestFocus(); } }
Example 7
Source File: LikePresenter.java From umeng_community_android with MIT License | 6 votes |
/** * 用户点赞操作</br> * * @param feedId 该条feed的id */ public void postLike(final String feedId) { SimpleFetchListener<SimpleResponse> listener = new SimpleFetchListener<SimpleResponse>() { @Override public void onComplete(SimpleResponse response) { if (NetworkUtils.handleResponseComm(response)) { return; } if (!TextUtils.isEmpty(response.id)) { likeSuccess(feedId, response.id); } else if (ErrorCode.LIKED_CODE == response.errCode) { mFeedItem.isLiked = true; if (mLikeViewInterface != null) { mLikeViewInterface.like(true); mLikeViewInterface.updateLikeView(""); } } } }; mCommunitySDK.postLike(feedId, listener); }
Example 8
Source File: BaseService.java From libcommon with Apache License 2.0 | 5 votes |
/** * 指定したNotificationChannelを破棄する * @param channelId */ @SuppressLint("NewApi") protected void releaseNotificationChannel(@Nullable final String channelId) { if (!TextUtils.isEmpty(channelId) && BuildCheck.isOreo()) { final NotificationManager manager = ContextUtils.requireSystemService(this, NotificationManager.class); try { manager.deleteNotificationChannel(channelId); } catch (final Exception e) { Log.w(TAG, e); } } }
Example 9
Source File: ContextUtils.java From Stringlate with MIT License | 5 votes |
/** * Get an {@link Locale} out of a android language code * The {@code androidLC} may be in any of the forms: de, en, de-rAt */ public Locale getLocaleByAndroidCode(String androidLC) { if (!TextUtils.isEmpty(androidLC)) { return androidLC.contains("-r") ? new Locale(androidLC.substring(0, 2), androidLC.substring(4, 6)) // de-rAt : new Locale(androidLC); // de } return Resources.getSystem().getConfiguration().locale; }
Example 10
Source File: ByWebView.java From ByWebView with Apache License 2.0 | 5 votes |
public void loadUrl(String url) { if (!TextUtils.isEmpty(url) && url.endsWith("mp4") && Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) { mWebView.loadData(ByWebTools.getVideoHtmlBody(url), "text/html", "UTF-8"); } else { mWebView.loadUrl(url); } mProgressBar.show(); }
Example 11
Source File: BookshelfHelp.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
public static int guessChapterNum(String name) { if (TextUtils.isEmpty(name) || name.matches("第.*?卷.*?第.*[章节回]")) return -1; Matcher matcher = chapterNamePattern.matcher(name); if (matcher.find()) { return StringUtils.stringToInt(matcher.group(2)); } return -1; }
Example 12
Source File: NodesCloudFragment.java From guanggoo-android with Apache License 2.0 | 5 votes |
@Override public String getTitle() { if (TextUtils.isEmpty(mTitle)) { return getString(R.string.nodes_list); } else { return mTitle; } }
Example 13
Source File: AttachmentDownloadJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private SignalServiceAttachmentPointer createAttachmentPointer(Attachment attachment) throws InvalidPartException { if (TextUtils.isEmpty(attachment.getLocation())) { throw new InvalidPartException("empty content id"); } if (TextUtils.isEmpty(attachment.getKey())) { throw new InvalidPartException("empty encrypted key"); } try { final SignalServiceAttachmentRemoteId remoteId = SignalServiceAttachmentRemoteId.from(attachment.getLocation()); final byte[] key = Base64.decode(attachment.getKey()); if (attachment.getDigest() != null) { Log.i(TAG, "Downloading attachment with digest: " + Hex.toString(attachment.getDigest())); } else { Log.i(TAG, "Downloading attachment with no digest..."); } return new SignalServiceAttachmentPointer(attachment.getCdnNumber(), remoteId, null, key, Optional.of(Util.toIntExact(attachment.getSize())), Optional.absent(), 0, 0, Optional.fromNullable(attachment.getDigest()), Optional.fromNullable(attachment.getFileName()), attachment.isVoiceNote(), Optional.absent(), Optional.fromNullable(attachment.getBlurHash()).transform(BlurHash::getHash), attachment.getUploadTimestamp()); } catch (IOException | ArithmeticException e) { Log.w(TAG, e); throw new InvalidPartException(e); } }
Example 14
Source File: l.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public static String[] a(JSONObject jsonobject) { String as[] = { null, null, null, null, null }; if (jsonobject == null || "http://apilocate.amap.com/mobile/binary".length() == 0) { as[0] = "false"; } else { try { String s = jsonobject.getString("key"); String s1 = jsonobject.getString("X-INFO"); String s2 = jsonobject.getString("X-BIZ"); String s3 = jsonobject.getString("User-Agent"); if (!TextUtils.isEmpty(s) && !TextUtils.isEmpty(s1) && !TextUtils.isEmpty(s3)) { as[0] = "true"; as[1] = s; as[2] = s1; as[3] = s2; as[4] = s3; } } catch (JSONException jsonexception) { } if (as[0] == null || !as[0].equals("true")) { as[0] = "true"; return as; } } return as; }
Example 15
Source File: RichMessageActionProcessor.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void openWebLink(String formData, String formAction) { Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(formData)) { bundle.putString(AlRichMessage.KM_FORM_DATA, formData); } if (!TextUtils.isEmpty(formAction)) { bundle.putString(AlRichMessage.KM_FORM_ACTION, formAction); } if (richMessageListener != null) { richMessageListener.onAction(null, AlRichMessage.OPEN_WEB_VIEW_ACTIVITY, null, bundle, null); } }
Example 16
Source File: CustomTabsHelper.java From android-browser-helper with Apache License 2.0 | 4 votes |
/** * Goes through all apps that handle VIEW intents and have a warmup service. Picks * the one chosen by the user if there is one, otherwise makes a best effort to return a * valid package name. * * This is <strong>not</strong> threadsafe. * * @param context {@link Context} to use for accessing {@link PackageManager}. * @return The package name recommended to use for connecting to custom tabs related components. */ public static String getPackageNameToUse(Context context) { if (sPackageNameToUse != null) return sPackageNameToUse; PackageManager pm = context.getPackageManager(); // Get default VIEW intent handler. Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); ResolveInfo defaultViewHandlerInfo = pm.resolveActivity(activityIntent, 0); String defaultViewHandlerPackageName = null; if (defaultViewHandlerInfo != null) { defaultViewHandlerPackageName = defaultViewHandlerInfo.activityInfo.packageName; } // Get all apps that can handle VIEW intents. List<ResolveInfo> resolvedActivityList = pm.queryIntentActivities(activityIntent, 0); List<String> packagesSupportingCustomTabs = new ArrayList<>(); for (ResolveInfo info : resolvedActivityList) { Intent serviceIntent = new Intent(); serviceIntent.setAction(ACTION_CUSTOM_TABS_CONNECTION); serviceIntent.setPackage(info.activityInfo.packageName); if (pm.resolveService(serviceIntent, 0) != null) { packagesSupportingCustomTabs.add(info.activityInfo.packageName); } } // Now packagesSupportingCustomTabs contains all apps that can handle both VIEW intents // and service calls. if (packagesSupportingCustomTabs.isEmpty()) { sPackageNameToUse = null; } else if (packagesSupportingCustomTabs.size() == 1) { sPackageNameToUse = packagesSupportingCustomTabs.get(0); } else if (!TextUtils.isEmpty(defaultViewHandlerPackageName) && !hasSpecializedHandlerIntents(context, activityIntent) && packagesSupportingCustomTabs.contains(defaultViewHandlerPackageName)) { sPackageNameToUse = defaultViewHandlerPackageName; } else if (packagesSupportingCustomTabs.contains(STABLE_PACKAGE)) { sPackageNameToUse = STABLE_PACKAGE; } else if (packagesSupportingCustomTabs.contains(BETA_PACKAGE)) { sPackageNameToUse = BETA_PACKAGE; } else if (packagesSupportingCustomTabs.contains(DEV_PACKAGE)) { sPackageNameToUse = DEV_PACKAGE; } else if (packagesSupportingCustomTabs.contains(LOCAL_PACKAGE)) { sPackageNameToUse = LOCAL_PACKAGE; } return sPackageNameToUse; }
Example 17
Source File: InMobiAdapter.java From googleads-mobile-android-mediation with Apache License 2.0 | 4 votes |
@Override public void requestNativeAd(final Context context, final MediationNativeListener listener, Bundle serverParameters, final NativeMediationAdRequest mediationAdRequest, final Bundle mediationExtras) { mNativeMedAdReq = mediationAdRequest; final long placement = InMobiAdapterUtils.getPlacementId(serverParameters); mNativeListener = listener; if (!mNativeMedAdReq.isUnifiedNativeAdRequested() && !mNativeMedAdReq.isAppInstallAdRequested()) { Log.e(TAG, "Failed to request InMobi native ad: " + "Unified Native Ad or App install Ad should be requested."); mNativeListener.onAdFailedToLoad(this, AdRequest.ERROR_CODE_INVALID_REQUEST); return; } String accountID = serverParameters.getString(InMobiAdapterUtils.KEY_ACCOUNT_ID); if (TextUtils.isEmpty(accountID)) { Log.w(TAG, "Failed to initialize InMobi SDK: Missing or invalid Account ID."); listener.onAdFailedToLoad(InMobiAdapter.this, AdRequest.ERROR_CODE_INTERNAL_ERROR); return; } InMobiInitializer.getInstance().init(context, accountID, new Listener() { @Override public void onInitializeSuccess() { createAndLoadNativeAd(context, placement, mNativeMedAdReq, mediationExtras); } @Override public void onInitializeError(@NonNull Error error) { Log.w(TAG, error.getMessage()); if (mNativeListener != null) { mNativeListener.onAdFailedToLoad(InMobiAdapter.this, AdRequest.ERROR_CODE_INTERNAL_ERROR); } } }); }
Example 18
Source File: WXEmbed.java From ucar-weex-core with Apache License 2.0 | 4 votes |
@Override public void reload() { if (!TextUtils.isEmpty(src)) { loadContent(); } }
Example 19
Source File: ADBUtils.java From DevUtils with Apache License 2.0 | 4 votes |
/** * 获取对应包名应用启动的 Activity * <pre> * android.intent.category.LAUNCHER (android.intent.action.MAIN) * </pre> * @param packageName 应用包名 * @return package.xx.Activity.className */ public static String getActivityToLauncher(final String packageName) { if (StringUtils.isSpace(packageName)) return null; String cmd = "dumpsys package %s"; // 执行 shell ShellUtils.CommandResult result = ShellUtils.execCmd(String.format(cmd, packageName), true); if (result.isSuccess3()) { String mainStr = "android.intent.action.MAIN:"; int start = result.successMsg.indexOf(mainStr); // 防止都为 null if (start != -1) { try { // 进行裁剪字符串 String subData = result.successMsg.substring(start + mainStr.length()); // 进行拆分 String[] arrays = subData.split(NEW_LINE_STR); for (String str : arrays) { if (!TextUtils.isEmpty(str)) { // 存在包名才处理 if (str.indexOf(packageName) != -1) { String[] splitArys = str.split(REGEX_SPACE); for (String strData : splitArys) { if (!TextUtils.isEmpty(strData)) { // 属于 packageName/ 前缀的 if (strData.indexOf(packageName + "/") != -1) { // 防止属于 packageName/.xx.Main_Activity if (strData.indexOf("/.") != -1) { // packageName/.xx.Main_Activity // packageName/packageName.xx.Main_Activity strData = strData.replace("/", "/" + packageName); } return strData; } } } } } } } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "getActivityToLauncher " + packageName); } } } return null; }
Example 20
Source File: DragBubbleView.java From AndroidAnimationExercise with Apache License 2.0 | 4 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawColor(Color.GRAY); //画拖拽气泡 if (mState != STATE_DISMISS) { canvas.drawCircle(mBubbleCenterX, mBubbleCenterY, mBubbleRadius, mBubblePaint); } if (mState == STATE_DRAG && d < maxD - maxD / 4) { //画黏连小圆 canvas.drawCircle(mCircleCenterX, mCircleCenterY, mCircleRadius, mBubblePaint); //计算控制点坐标,为两圆圆心连线的中点 mControlX = (mBubbleCenterX + mCircleCenterX) / 2; mControlY = (mBubbleCenterY + mCircleCenterY) / 2; //计算两条二阶贝塞尔曲线的起点和终点 float sin = (mBubbleCenterY - mCircleCenterY) / d; float cos = (mBubbleCenterX - mCircleCenterX) / d; mCircleStartX = mCircleCenterX - mCircleRadius * sin; mCircleStartY = mCircleCenterY + mCircleRadius * cos; mCircleEndX = mCircleCenterX + mCircleRadius * sin; mCircleEndY = mCircleCenterY - mCircleRadius * cos; mBubbleEndX = mBubbleCenterX - mBubbleRadius * sin; mBubbleEndY = mBubbleCenterY + mBubbleRadius * cos; mBubbleStartX = mBubbleCenterX + mBubbleRadius * sin; mBubbleStartY = mBubbleCenterY - mBubbleRadius * cos; //画二阶贝赛尔曲线 mBezierPath.reset(); mBezierPath.moveTo(mCircleStartX, mCircleStartY); mBezierPath.quadTo(mControlX, mControlY, mBubbleEndX, mBubbleEndY); mBezierPath.lineTo(mBubbleStartX, mBubbleStartY); mBezierPath.quadTo(mControlX, mControlY, mCircleEndX, mCircleEndY); mBezierPath.close(); canvas.drawPath(mBezierPath, mBubblePaint); } //画消息个数的文本 if (mState != STATE_DISMISS && !TextUtils.isEmpty(mText)) { mTextPaint.getTextBounds(mText, 0, mText.length(), mTextRect); canvas.drawText(mText, mBubbleCenterX - mTextRect.width() / 2, mBubbleCenterY + mTextRect.height() / 2, mTextPaint); } if (mIsExplosionAnimStart && mCurExplosionIndex < mExplosionDrawables.length) { //设置气泡爆炸图片的位置 mExplosionRect.set((int) (mBubbleCenterX - mBubbleRadius), (int) (mBubbleCenterY - mBubbleRadius) , (int) (mBubbleCenterX + mBubbleRadius), (int) (mBubbleCenterY + mBubbleRadius)); //根据当前进行到爆炸气泡的位置index来绘制爆炸气泡bitmap canvas.drawBitmap(mExplosionBitmaps[mCurExplosionIndex], null, mExplosionRect, mExplosionPaint); } }