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: LikeMePresenter.java    From umeng_community_android with MIT License 10 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 #2
Source File: DeviceAdapter.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 8 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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #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: 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 #14
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();
    }
}
 
Example #15
Source File: JumpingBeans.java    From BookLoadingView with Apache License 2.0 5 votes vote down vote up
private static boolean endsWithThreeEllipsisDots(@NonNull CharSequence text) {
    if (text.length() < THREE_DOTS_ELLIPSIS_LENGTH) {
        // TODO we should try to normalize "invalid" ellipsis (e.g., ".." or "....")
        return false;
    }
    return TextUtils.equals(text.subSequence(text.length() - THREE_DOTS_ELLIPSIS_LENGTH, text.length()), THREE_DOTS_ELLIPSIS);
}
 
Example #16
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 #17
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 #18
Source File: AddCookiesInterceptor.java    From AndroidWallet with GNU General Public License v3.0 5 votes vote down vote up
private String getCookie(String url, String domain) {
    SharedPreferences sp = Utils.getContext().getSharedPreferences(COOKIE_PREF, Context.MODE_PRIVATE);
    if (!TextUtils.isEmpty(url) && sp.contains(url) && !TextUtils.isEmpty(sp.getString(url, ""))) {
        return sp.getString(url, "");
    }
    if (!TextUtils.isEmpty(domain) && sp.contains(domain) && !TextUtils.isEmpty(sp.getString(domain, ""))) {
        return sp.getString(domain, "");
    }

    return null;
}
 
Example #19
Source File: JarLoader.java    From letv with Apache License 2.0 5 votes vote down vote up
@SuppressLint({"NewApi"})
public static Class loadClass(Context context, String jarName, String packageName, String className) {
    String dexInternalPath = JarUtil.getJarInFolderName(context, jarName);
    String optimizedDexOutputPath = JarUtil.getJarOutFolderName(context);
    if (!TextUtils.isEmpty(dexInternalPath)) {
        try {
            JarClassLoader cl;
            if (dexLoaders.containsKey(packageName)) {
                cl = (JarClassLoader) dexLoaders.get(packageName);
            } else {
                cl = new JarClassLoader(packageName, dexInternalPath, optimizedDexOutputPath, context.getApplicationInfo().nativeLibraryDir, context.getClassLoader());
                dexLoaders.put(packageName, cl);
            }
            return cl.loadClass(packageName + "." + className);
        } catch (Exception e) {
            JLog.i("clf", "!!!!!!! loadClass--" + packageName + " e is " + e.getMessage());
            return null;
        }
    } else if (mReloadNum >= 1) {
        return null;
    } else {
        mReloadNum++;
        JLog.i("plugin", "JarUtil.updatePlugin 333333333333333333");
        JarUtil.updatePlugin(context, 0, false);
        return loadClass(context, jarName, packageName, className);
    }
}
 
Example #20
Source File: CreateWebSiteSuccessActivity.java    From Android-Application-ZJB with Apache License 2.0 5 votes vote down vote up
private void initView(List<WebSite> webSites) {
    WebSite webSite = webSites.get(0);
    String teachAgeData = webSite.getCoachingDate();
    Coach coach = LoginManager.getInstance().getCoach();
    String school = webSite.getDrivingSchool();
    String teachAge;

    //头像
    ViewUtils.showCirCleAvatar(mAvatarIv, webSite.getHeadimgurl(), (int) PixelUtil.dp2px(60));
    mNickNameTv.setText(webSite.getNickname());

    // 判断教龄
    if (!TextUtils.isEmpty(teachAgeData) && !"0001-01-01".equals(teachAgeData)) {
        teachAge = getString(R.string.teach_age_s, TimeUtil.getAge(teachAgeData));
    } else {
        teachAge = getString(R.string.teach_age_s, 0);
    }
    mTeachAgeTv.setText(teachAge);
    if (!TextUtils.isEmpty(school)) {
        mSchoolTv.setText(school);
        mSameSchoolTv.setVisibility(school.equals(coach.getDrivingSchool()) ? View.VISIBLE : View.GONE);
    } else {
        mSchoolTv.setVisibility(View.GONE);
        mSameSchoolTv.setVisibility(View.GONE);
    }

    mGridLayout.setData(webSite.getPictures());
}
 
Example #21
Source File: SaleNHAssetActivity.java    From AndroidWallet with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onHandleEvent(EventBusCarrier busCarrier) {
    if (TextUtils.equals(EventTypeGlobal.DIALOG_DISMISS_TYPE, busCarrier.getEventType())) {
        dialog.dismiss();
    } else if (TextUtils.equals(EventTypeGlobal.SHOW_SALE_NH_ASSET_PASSWORD_VERIFY_DIALOG, busCarrier.getEventType())) {
        dialog.dismiss();
        SaleNHAssetParamsModel saleAssetParamsModel = (SaleNHAssetParamsModel) busCarrier.getObject();
        showSaleAssetPasswordVerifyDialog(saleAssetParamsModel);
    }
}
 
Example #22
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 #23
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 #24
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 #25
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 #26
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 #27
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 #28
Source File: SignalPinReminderDialog.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void verifyPin(@Nullable String pin, @NonNull Callback callback) {
  if (pin == null) return;
  if (TextUtils.isEmpty(pin)) return;

  if (pin.length() < KbsConstants.MINIMUM_PIN_LENGTH) return;

  if (PinHashing.verifyLocalPinHash(localPinHash, pin)) {
    callback.onPinCorrect(pin);
  } else {
    callback.onPinWrong();
  }
}
 
Example #29
Source File: WhorlView.java    From WhorlView with Apache License 2.0 5 votes vote down vote up
public WhorlView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //默认外层最慢270度/s
    final int defaultCircleSpeed = 270;
    final float defaultSweepAngle = 90f;
    final float defaultStrokeWidth = 5f;
    final String defaultColors = "#F44336_#4CAF50_#5677fc";
    if (attrs != null) {
        final TypedArray typedArray = context.obtainStyledAttributes(
                attrs, R.styleable.whorlview_style);
        String colors = typedArray.getString(R.styleable.whorlview_style_whorlview_circle_colors);
        if (TextUtils.isEmpty(colors)) {
            colors = defaultColors;
        }
        parseStringToLayerColors(colors);
        mCircleSpeed = typedArray.getInt(R.styleable.whorlview_style_whorlview_circle_speed, defaultCircleSpeed);
        int index = typedArray.getInt(R.styleable.whorlview_style_whorlview_parallax, 0);
        setParallax(index);
        mSweepAngle = typedArray.getFloat(R.styleable.whorlview_style_whorlview_sweepAngle, defaultSweepAngle);
        if (mSweepAngle <= 0 || mSweepAngle >= 360) {
            throw new IllegalArgumentException("sweep angle out of bound");
        }
        mStrokeWidth = typedArray.getFloat(R.styleable.whorlview_style_whorlview_strokeWidth, defaultStrokeWidth);
        typedArray.recycle();
    } else {
        parseStringToLayerColors(defaultColors);
        mCircleSpeed = defaultCircleSpeed;
        mParallaxSpeed = PARALLAX_MEDIUM;
        mSweepAngle = defaultSweepAngle;
        mStrokeWidth = defaultStrokeWidth;
    }
}
 
Example #30
Source File: AddRecruitActivity.java    From Social with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    StatService.onResume(this);//统计activity页面
    if(!TextUtils.isEmpty(pathImage)){

        imageItem.ensureCapacity(imageItem.size()+1);

        Bitmap addbmp=BitmapFactory.decodeFile(pathImage);
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("itemImage", addbmp);
        imageItem.add(gridviewClickItemPosition, map);

        simpleAdapter = new SimpleAdapter(this, imageItem, R.layout.griditem_addpic, new String[] { "itemImage"}, new int[] { R.id.imageView1});
        simpleAdapter.setViewBinder(new SimpleAdapter.ViewBinder() {
            @Override
            public boolean setViewValue(View view, Object data,
                                        String textRepresentation) {
                // TODO Auto-generated method stub
                if(view instanceof ImageView && data instanceof Bitmap){
                    ImageView i = (ImageView)view;
                    i.setImageBitmap((Bitmap) data);
                    return true;
                }
                return false;
            }
        });
        gridView1.setAdapter(simpleAdapter);
        simpleAdapter.notifyDataSetChanged();
        //刷新后释放防止手机休眠后自动添加
        pathImage = null;
    }
}