android.text.TextUtils Java Examples

The following examples show how to use android.text.TextUtils. 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: EventTracker.java    From Anecdote with Apache License 2.0 7 votes vote down vote up
/**
 * Track fragment view, should be called in onResume
 *
 * @param fragment   the fragment name to track
 * @param screenName the additional name if any
 * @param subName    sub view name
 */
public static void trackFragmentView(Fragment fragment, @Nullable String screenName, @Nullable String subName) {
    if (!isEventEnable()) return;

    String name;

    if (TextUtils.isEmpty(screenName)) {
        name = fragment.getClass().getSimpleName();
    } else {
        name = screenName;
    }

    if (TextUtils.isEmpty(name)) {
        name = "ERROR";
    }

    String detail = subName;
    if (TextUtils.isEmpty(detail)) {
        detail = "Fragment";
    }

    sEvent.sendView(name, detail);
}
 
Example #2
Source File: AppApplicationMgr.java    From AndroidWallet with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 是否有权限
 *
 * @param context
 * @param permission
 * @return
 */
public static boolean hasPermission(Context context, String permission) {
    if (context != null && !TextUtils.isEmpty(permission)) {
        try {
            PackageManager packageManager = context.getPackageManager();
            if (packageManager != null) {
                if (PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(permission, context
                        .getPackageName())) {
                    return true;
                }
                Log.d("AppUtils", "Have you  declared permission " + permission + " in AndroidManifest.xml ?");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    return false;
}
 
Example #3
Source File: UVCCamera.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
public static List<Size> getSupportedSize(final int type, final String supportedSize) {
	final List<Size> result = new ArrayList<Size>();
	if (!TextUtils.isEmpty(supportedSize))
	try {
		final JSONObject json = new JSONObject(supportedSize);
		final JSONArray formats = json.getJSONArray("formats");
		final int format_nums = formats.length();
		for (int i = 0; i < format_nums; i++) {
			final JSONObject format = formats.getJSONObject(i);
			final int format_type = format.getInt("type");
			if ((format_type == type) || (type == -1)) {
				addSize(format, format_type, 0, result);
			}
		}
	} catch (final JSONException e) {
	}
	return result;
}
 
Example #4
Source File: DeviceAdapter.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void bind(@NonNull final BluetoothDevice device) {
	final boolean ready = service.isReady(device);

	String name = device.getName();
	if (TextUtils.isEmpty(name))
		name = nameView.getResources().getString(R.string.proximity_default_device_name);
	nameView.setText(name);
	addressView.setText(device.getAddress());

	final boolean on = service.isImmediateAlertOn(device);
	actionButton.setImageResource(on ? R.drawable.ic_stat_notify_proximity_silent : R.drawable.ic_stat_notify_proximity_find);
	actionButton.setVisibility(ready ? View.VISIBLE : View.GONE);
	progress.setVisibility(ready ? View.GONE : View.VISIBLE);

	final Integer batteryValue = service.getBatteryLevel(device);
	if (batteryValue != null) {
		batteryView.getCompoundDrawables()[0 /*left*/].setLevel(batteryValue);
		batteryView.setVisibility(View.VISIBLE);
		batteryView.setText(batteryView.getResources().getString(R.string.battery, batteryValue));
		batteryView.setAlpha(ready ? 1.0f : 0.5f);
	} else {
		batteryView.setVisibility(View.GONE);
	}
}
 
Example #5
Source File: RepoProvider.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method decides what repo a URL belongs to by iteratively removing path fragments and
 * checking if it belongs to a repo or not. It will match the most specific repository which
 * could serve the file at the given URL.
 * <p>
 * For any given HTTP resource requested by F-Droid, it should belong to a repository.
 * Whether that resource is an index.jar, an icon, or a .apk file, they all belong to a
 * repository. Therefore, that repository must exist in the database. The way to find out
 * which repository a particular URL came from requires some consideration:
 * <li>Repositories can exist at particular paths on a server (e.g. /fdroid/repo)
 * <li>Individual files can exist at a more specific path on the repo (e.g.
 * /fdroid/repo/icons/org.fdroid.fdroid.png)</li>
 * <p>
 * So for a given URL "/fdroid/repo/icons/org.fdroid.fdroid.png" we don't actually know
 * whether it is for the file "org.fdroid.fdroid.png" at repository "/fdroid/repo/icons" or
 * the file "icons/org.fdroid.fdroid.png" at the repository at "/fdroid/repo".
 */
@Nullable
public static Repo findByUrl(Context context, Uri uri, String[] projection) {
    Uri withoutQuery = uri.buildUpon().query(null).build();
    Repo repo = findByAddress(context, withoutQuery.toString(), projection);

    // Take a copy of this, because the result of getPathSegments() is an AbstractList
    // which doesn't support the remove() operation.
    List<String> pathSegments = new ArrayList<>(withoutQuery.getPathSegments());

    boolean haveTriedWithoutPath = false;
    while (repo == null && !haveTriedWithoutPath) {
        if (pathSegments.isEmpty()) {
            haveTriedWithoutPath = true;
        } else {
            pathSegments.remove(pathSegments.size() - 1);
            withoutQuery = withoutQuery.buildUpon().path(TextUtils.join("/", pathSegments)).build();
        }
        repo = findByAddress(context, withoutQuery.toString(), projection);
    }
    return repo;
}
 
Example #6
Source File: NavigatorUtils.java    From Navigator with Apache License 2.0 6 votes vote down vote up
/**
 * @param tag             point to return
 * @param container       id container
 * @param fragmentManager variable contain fragment stack
 * @return true if is possible return to tag param
 */
public boolean canGoBackToSpecificPoint(String tag, int container, FragmentManager fragmentManager) {
    if (TextUtils.isEmpty(tag)) {
        return (fragmentManager.getBackStackEntryCount() > 1);
    } else {
        List<FragmentManager.BackStackEntry> fragmentList = fragmentList();
        Fragment fragment = fragmentManager.findFragmentById(container);
        if (fragment != null && tag.equalsIgnoreCase(fragment.getTag())) {
            return false;
        }
        for (int i = 0; i < fragmentList.size(); i++) {
            if (tag.equalsIgnoreCase(fragmentList.get(i).getName())) {
                return true;
            }
        }
        return false;
    }
}
 
Example #7
Source File: LikeMePresenter.java    From umeng_community_android with MIT License 6 votes vote down vote up
@Override
public void loadDataFromServer() {

    mCommunitySDK.fetchLikedRecords(CommConfig.getConfig().loginedUser.id,
            new SimpleFetchListener<LikeMeResponse>() {

                @Override
                public void onStart() {
                    mFeedView.onRefreshStart();
                }

                @Override
                public void onComplete(LikeMeResponse response) {
                    if(NetworkUtils.handleResponseAll(response) ){
                        mFeedView.onRefreshEnd();
                        return ;
                    }
                    if ( TextUtils.isEmpty(mNextPageUrl) && mUpdateNextPageUrl.get() ) {
                        mNextPageUrl = response.nextPageUrl;
                        mUpdateNextPageUrl.set(false);
                    }
                    addFeedItemsToHeader(response.result);
                    mFeedView.onRefreshEnd();
                }
            });
}
 
Example #8
Source File: OnekeyShareThemeImpl.java    From fingerpoetry-android with Apache License 2.0 6 votes vote down vote up
final ShareParams shareDataToShareParams(Platform plat) {
	if (plat == null || shareParamsMap == null) {
		toast("ssdk_oks_share_failed");
		return null;
	}

	try {
		String imagePath = R.forceCast(shareParamsMap.get("imagePath"));
		Bitmap viewToShare = R.forceCast(shareParamsMap.get("viewToShare"));
		if (TextUtils.isEmpty(imagePath) && viewToShare != null && !viewToShare.isRecycled()) {
			String path = R.getCachePath(plat.getContext(), "screenshot");
			File ss = new File(path, String.valueOf(System.currentTimeMillis()) + ".jpg");
			FileOutputStream fos = new FileOutputStream(ss);
			viewToShare.compress(CompressFormat.JPEG, 100, fos);
			fos.flush();
			fos.close();
			shareParamsMap.put("imagePath", ss.getAbsolutePath());
		}
	} catch (Throwable t) {
		t.printStackTrace();
		toast("ssdk_oks_share_failed");
		return null;
	}

	return new ShareParams(shareParamsMap);
}
 
Example #9
Source File: NotificationStatusBarReceiver.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null || TextUtils.isEmpty(intent.getAction())) {
        return;
    }
    String extra = intent.getStringExtra(EXTRA);
    if (TextUtils.equals(extra, MusicPlayAction.TYPE_NEXT)) {
        PlayService.startCommand(context, MusicPlayAction.TYPE_NEXT);
        AppLogUtils.e("NotifiyStatusBarReceiver"+"下一首");
    } else if (TextUtils.equals(extra, MusicPlayAction.TYPE_START_PAUSE)) {
        if(BaseAppHelper.get().getPlayService()!=null){
            boolean playing = BaseAppHelper.get().getPlayService().isPlaying();
            if(playing){
                AppLogUtils.e("NotifiyStatusBarReceiver"+"暂停");
            }else {
                AppLogUtils.e("NotifiyStatusBarReceiver"+"播放");
            }
            PlayService.startCommand(context, MusicPlayAction.TYPE_START_PAUSE);
        }

    }else if(TextUtils.equals(extra, MusicPlayAction.TYPE_PRE)){
        PlayService.startCommand(context, MusicPlayAction.TYPE_PRE);
        AppLogUtils.e("NotifiyStatusBarReceiver"+"上一首");
    }
}
 
Example #10
Source File: InstallerFactory.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns an instance of an appropriate installer.
 * Either DefaultInstaller, PrivilegedInstaller, or in the special
 * case to install the "F-Droid Privileged Extension" ExtensionInstaller.
 *
 * @param context current {@link Context}
 * @param apk     to be installed, always required.
 * @return instance of an Installer
 */
public static Installer create(Context context, @NonNull Apk apk) {
    if (TextUtils.isEmpty(apk.packageName)) {
        throw new IllegalArgumentException("Apk.packageName must not be empty: " + apk);
    }

    Installer installer;
    if (!apk.isApk()) {
        Utils.debugLog(TAG, "Using FileInstaller for non-apk file");
        installer = new FileInstaller(context, apk);
    } else if (PrivilegedInstaller.isDefault(context)) {
        Utils.debugLog(TAG, "privileged extension correctly installed -> PrivilegedInstaller");
        installer = new PrivilegedInstaller(context, apk);
    } else {
        installer = new DefaultInstaller(context, apk);
    }

    return installer;
}
 
Example #11
Source File: WeexUiTestCaseTcInputType.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * get tc list by text
 * @param byText
 * @return
 * @throws InterruptedException
 */
public ArrayList<View> getTestCaseListViewByText(String byText) throws InterruptedException {
    Log.e("TestScript_Guide", "byText ==" + byText);

    if(TextUtils.isEmpty(byText)){
        return null;
    }
    ArrayList<View> outViews = new ArrayList<View>();

    mViewGroup.findViewsWithText(outViews, byText, View.FIND_VIEWS_WITH_TEXT);

    for (View view :  outViews){
        String viewText = ((WXTextView)view).getText().toString();
        Log.e(TAG, "viewText ==" + viewText);


    }
    return outViews;
}
 
Example #12
Source File: MovieEntity.java    From GracefulMovies with Apache License 2.0 6 votes vote down vote up
public List<String> getTypeList() {
    if (typeList == null && !TextUtils.isEmpty(type)) {
        typeList = new ArrayList<>();
        if (type.contains("/")) {
            String[] split = type.trim().split("/");
            typeList = Arrays.asList(split);
        } else {
            typeList.add(type);
        }
    }
    return typeList;
}
 
Example #13
Source File: XulSelect.java    From starcor.xul with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void setPriorityLevel(int priorityLevel, int baseLevel) {
	int complexLevel = 0;
	complexLevel += TextUtils.isEmpty(_id) ? 0 : 1;
	complexLevel += TextUtils.isEmpty(_class) ? 0 : 1;
	complexLevel += TextUtils.isEmpty(_type) ? 0 : 1;
	complexLevel += (_state <= 0) ? 0 : 1;
	complexLevel *= 0x10000;
	if (_state == XulView.STATE_DISABLED) {
		complexLevel += 0x8000;
	}
	priorityLevel = complexLevel + priorityLevel;

	for (int i = 0; i < _prop.size(); i++) {
		XulProp prop = _prop.get(i);
		prop.setPriority(priorityLevel + baseLevel);
	}
}
 
Example #14
Source File: ExtraUtil.java    From NanoIconPack with Apache License 2.0 6 votes vote down vote up
public static void shareText(Context context, String content, String hint) {
    if (context == null || TextUtils.isEmpty(content)) {
        return;
    }

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, content);
    try {
        if (TextUtils.isEmpty(hint)) {
            context.startActivity(intent);
        } else {
            context.startActivity(Intent.createChooser(intent, hint));
        }
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}
 
Example #15
Source File: FileItem.java    From apkextractor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 如果为documentFile实例,则会返回以“external/”开头的片段;如果为File实例,则返回正常的完整路径
 */
public String getPath(){
    if(documentFile!=null){
        String uriPath= documentFile.getUri().getPath();
        if(uriPath==null)return "";
        int index=uriPath.lastIndexOf(":")+1;
        if(index<=uriPath.length())return "external/"+uriPath.substring(index);
    }
    if(file!=null)return file.getAbsolutePath();
    if(context!=null&&contentUri!=null){
        if(ContentResolver.SCHEME_FILE.equalsIgnoreCase(contentUri.getScheme())){
            return contentUri.getPath();
        }
        String path=EnvironmentUtil.getFilePathFromContentUri(context,contentUri);
        if(!TextUtils.isEmpty(path))return path;
        return contentUri.toString();
    }
    return "";
}
 
Example #16
Source File: HlsMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private static Map<String, DrmInitData> deriveOverridingDrmInitData(
    List<DrmInitData> sessionKeyDrmInitData) {
  ArrayList<DrmInitData> mutableSessionKeyDrmInitData = new ArrayList<>(sessionKeyDrmInitData);
  HashMap<String, DrmInitData> drmInitDataBySchemeType = new HashMap<>();
  for (int i = 0; i < mutableSessionKeyDrmInitData.size(); i++) {
    DrmInitData drmInitData = sessionKeyDrmInitData.get(i);
    String scheme = drmInitData.schemeType;
    // Merge any subsequent drmInitData instances that have the same scheme type. This is valid
    // due to the assumptions documented on HlsMediaSource.Builder.setUseSessionKeys, and is
    // necessary to get data for different CDNs (e.g. Widevine and PlayReady) into a single
    // drmInitData.
    int j = i + 1;
    while (j < mutableSessionKeyDrmInitData.size()) {
      DrmInitData nextDrmInitData = mutableSessionKeyDrmInitData.get(j);
      if (TextUtils.equals(nextDrmInitData.schemeType, scheme)) {
        drmInitData = drmInitData.merge(nextDrmInitData);
        mutableSessionKeyDrmInitData.remove(j);
      } else {
        j++;
      }
    }
    drmInitDataBySchemeType.put(scheme, drmInitData);
  }
  return drmInitDataBySchemeType;
}
 
Example #17
Source File: BaseLanguageSelectActivity.java    From android-unispeech with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mLayoutInflater.inflate(R.layout.item_language, null);
        convertView.setTag(new ViewHolder(convertView));
    }

    SupportedSttLanguage language = getItem(position);

    ViewHolder viewHolder = (ViewHolder) convertView.getTag();
    viewHolder.language.setText(language.getLabel());
    if (!TextUtils.isEmpty(language.getSpecifier())) {
        viewHolder.specifier.setText("(" +language.getSpecifier() + ")");
        viewHolder.specifier.setVisibility(View.VISIBLE);
    } else {
        viewHolder.specifier.setVisibility(View.GONE);
    }

    return convertView;
}
 
Example #18
Source File: MainAdapter.java    From screenAdaptation with Apache License 2.0 6 votes vote down vote up
@Override
public RecyclerView.ViewHolder getView(RecyclerView.ViewHolder holder, final int position) {
    BaseHolder mHolder = (BaseHolder) holder;
    String title = getItem(position).getTitle();
    mHolder.mTitleView.setText(!TextUtils.isEmpty(title) ? title : "");
    mHolder.mTitleView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int type = getItem(position).getType();
            switch (type) {
                case Type.MAIN_TRI:
                    TriActivity.launch(mContext);
                    break;
                case Type.MAIN_FIVE:
                    FiveActivity.launch(mContext);
                    break;
            }
        }
    });
    return holder;
}
 
Example #19
Source File: ResourceUtils.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
public static int getDefaultKeyboardHeight(final Resources res) {
    final DisplayMetrics dm = res.getDisplayMetrics();
    final String keyboardHeightInDp = getDeviceOverrideValue(
            res, R.array.keyboard_heights, null /* defaultValue */);
    final float keyboardHeight;
    if (TextUtils.isEmpty(keyboardHeightInDp)) {
        keyboardHeight = res.getDimension(R.dimen.config_default_keyboard_height);
    } else {
        keyboardHeight = Float.parseFloat(keyboardHeightInDp) * dm.density;
    }
    final float maxKeyboardHeight = res.getFraction(
            R.fraction.config_max_keyboard_height, dm.heightPixels, dm.heightPixels);
    float minKeyboardHeight = res.getFraction(
            R.fraction.config_min_keyboard_height, dm.heightPixels, dm.heightPixels);
    if (minKeyboardHeight < 0.0f) {
        // Specified fraction was negative, so it should be calculated against display
        // width.
        minKeyboardHeight = -res.getFraction(
                R.fraction.config_min_keyboard_height, dm.widthPixels, dm.widthPixels);
    }
    // Keyboard height will not exceed maxKeyboardHeight and will not be less than
    // minKeyboardHeight.
    return (int)Math.max(Math.min(keyboardHeight, maxKeyboardHeight), minKeyboardHeight);
}
 
Example #20
Source File: MainPresenter.java    From a with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void addBookUrl(String bookUrls) {
    bookUrls=bookUrls.trim();
    if (TextUtils.isEmpty(bookUrls)) return;

    String[] urls=bookUrls.split("\\n");

    Observable.fromArray(urls)
            .flatMap(this::addBookUrlO)
            .compose(RxUtils::toSimpleSingle)
            .subscribe(new MyObserver<BookShelfBean>() {
                @Override
                public void onNext(BookShelfBean bookShelfBean) {
                    getBook(bookShelfBean);
                }

                @Override
                public void onError(Throwable e) {
                    mView.toast(e.getMessage());
                }
            });
}
 
Example #21
Source File: UCApiManager.java    From netanalysis-sdk-android with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    sharedPreferences = context.getSharedPreferences("umqa-sdk", Context.MODE_PRIVATE);
    uuid = sharedPreferences.getString(KEY_SP_UUID, null);
    if (TextUtils.isEmpty(uuid)) {
        uuid = UUID.randomUUID().toString().toUpperCase();
        sharedPreferences.edit().putString(KEY_SP_UUID, uuid).apply();
    }
}
 
Example #22
Source File: RegisterActivity.java    From MyHearts with Apache License 2.0 5 votes vote down vote up
private String getMCC() {
    TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    // 返回当前手机注册的网络运营商所在国家的MCC+MNC. 如果没注册到网络就为空.
    String networkOperator = tm.getNetworkOperator();
    if (!TextUtils.isEmpty(networkOperator)) {
        return networkOperator;
    }

    // 返回SIM卡运营商所在国家的MCC+MNC. 5位或6位. 如果没有SIM卡返回空
    return tm.getSimOperator();
}
 
Example #23
Source File: Utils.java    From Leisure with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void getRawHtmlFromUrl(String url, Callback callback) {
    if (callback == null || TextUtils.isEmpty(url)) {
        return ;
    }
    Request.Builder builder = new Request.Builder();
    builder.url(url);
    Request request = builder.build();
    HttpUtil.enqueue(request, callback);
}
 
Example #24
Source File: AppChooserPreference.java    From BetterWeather with Apache License 2.0 5 votes vote down vote up
public static Intent getIntentValue(String value, Intent defaultIntent) {
    try {
        if (TextUtils.isEmpty(value)) {
            return defaultIntent;
        }

        return Intent.parseUri(value, Intent.URI_INTENT_SCHEME);
    } catch (URISyntaxException e) {
        return defaultIntent;
    }
}
 
Example #25
Source File: CreateFileFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());

    final View view = dialogInflater.inflate(R.layout.dialog_create_dir, null, false);
    final EditText text1 = (EditText) view.findViewById(android.R.id.text1);
    Utils.tintWidget(text1);

    String title = getArguments().getString(EXTRA_DISPLAY_NAME);
    if(!TextUtils.isEmpty(title)) {
        text1.setText(title);
        text1.setSelection(title.length());
    }
    builder.setTitle(R.string.menu_create_file);
    builder.setView(view);

    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String displayName = text1.getText().toString();
            final String mimeType = getArguments().getString(EXTRA_MIME_TYPE);
            String extension = FileUtils.getExtFromFilename(displayName);
            final DocumentsActivity activity = (DocumentsActivity) getActivity();
            final DocumentInfo cwd = activity.getCurrentDirectory();
            new CreateFileTask(activity, cwd,
                    TextUtils.isEmpty(extension) ? mimeType : extension, displayName).executeOnExecutor(
                    ProviderExecutor.forAuthority(cwd.authority));
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);

    return builder.create();
}
 
Example #26
Source File: SimChangeReceiver.java    From MobileGuard with MIT License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    // check all services when system startup
    ServiceManagerEngine.checkAndAutoStart(context);

    // check the service is on
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    boolean phoneSafe = sp.getBoolean(Constant.KEY_CB_PHONE_SAFE, false);
    boolean bindSim = sp.getBoolean(Constant.KEY_CB_BIND_SIM, false);
    // haven't start bind sim or phone safe service
    if(!bindSim || !phoneSafe) {
        return;
    }
    // get old sim info
    String oldSimInfo = ConfigUtils.getString(context, Constant.KEY_SIM_INFO, "");
    // get current sim info
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String currentSimInfo = manager.getSimSerialNumber();
    // the two sim info equal
    if(currentSimInfo.equals(oldSimInfo)) {
        return;
    }
    // send alarm info to safe phone number
    String safePhone = ConfigUtils.getString(context, Constant.KEY_SAFE_PHONE, "");
    if(TextUtils.isEmpty(safePhone)) {
        Log.e(TAG, "safe phone is empty");
        return;
    }
    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(safePhone, null, context.getString(R.string.tips_sim_changed), null, null);
    System.out.println("success send a sms to " + safePhone + ":\n" + context.getString(R.string.tips_sim_changed));
}
 
Example #27
Source File: HttpTask.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void getLogon(IWebviewListener iLetvBrideg) {
    String ssoToken = LemallPlatform.getInstance().getSsoToken();
    Context context = LemallPlatform.getInstance().getContext();
    if (TextUtils.isEmpty(ssoToken)) {
        EALogger.i(CommonUtils.SDK, "无token");
        return;
    }
    AsyncHttpClient client = new AsyncHttpClient();
    RequestParams params = new RequestParams();
    params.put("SSO_TK", ssoToken);
    params.put("EXPIRE_TYPE", "3");
    EALogger.i("正式登录", "正式登录==SSO_TK=>" + ssoToken);
    client.get(true, Constants.THIRDLOGIN, params, new AnonymousClass1(context, iLetvBrideg));
}
 
Example #28
Source File: DashboardCategory.java    From HeadsUp with GNU General Public License v2.0 5 votes vote down vote up
private DashboardCategory(Parcel in) {
    titleRes = in.readInt();
    title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);

    final int count = in.readInt();

    for (int n = 0; n < count; n++) {
        DashboardTile tile = DashboardTile.CREATOR.createFromParcel(in);
        tiles.add(tile);
    }
}
 
Example #29
Source File: PathUtils.java    From cronet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @return Download directories including the default storage directory on SD card, and a
 * private directory on external SD card.
 */
@SuppressWarnings("unused")
@CalledByNative
public static String[] getAllPrivateDownloadsDirectories() {
    File[] files;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        StrictModeContext unused = null;
        try {
            unused = StrictModeContext.allowDiskWrites();
            files = ContextUtils.getApplicationContext().getExternalFilesDirs(
                    Environment.DIRECTORY_DOWNLOADS);
        } finally {
            if (unused != null) {
                try {
                    unused.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    } else {
        files = new File[] {Environment.getExternalStorageDirectory()};
    }

    ArrayList<String> absolutePaths = new ArrayList<String>();
    for (int i = 0; i < files.length; ++i) {
        if (files[i] == null || TextUtils.isEmpty(files[i].getAbsolutePath())) continue;
        absolutePaths.add(files[i].getAbsolutePath());
    }

    return absolutePaths.toArray(new String[absolutePaths.size()]);
}
 
Example #30
Source File: DownloadInfoChecker.java    From RxHttp with GNU General Public License v3.0 5 votes vote down vote up
public static void checkDirPath(DownloadInfo info){
    if (TextUtils.isEmpty(info.saveDirPath)) {
        info.saveDirPath = RxHttp.getDownloadSetting().getSaveDirPath();
    }
    if (TextUtils.isEmpty(info.saveDirPath)) {
        info.saveDirPath = SDCardUtils.getDownloadCacheDir();
    }
}