android.annotation.SuppressLint Java Examples

The following examples show how to use android.annotation.SuppressLint. 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: RNAGSMapView.java    From react-native-arcgis-mapview with MIT License 7 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
public void setUpMap() {
    mapView.setMap(new ArcGISMap(Basemap.Type.STREETS_VECTOR, 34.057, -117.196, 17));
    mapView.setOnTouchListener(new OnSingleTouchListener(getContext(),mapView));
    routeGraphicsOverlay = new GraphicsOverlay();
    mapView.getGraphicsOverlays().add(routeGraphicsOverlay);
    mapView.getMap().addDoneLoadingListener(() -> {
        ArcGISRuntimeException e = mapView.getMap().getLoadError();
        Boolean success = e != null;
        String errorMessage = !success ? "" : e.getMessage();
        WritableMap map = Arguments.createMap();
        map.putBoolean("success",success);
        map.putString("errorMessage",errorMessage);

        emitEvent("onMapDidLoad",map);
    });
}
 
Example #2
Source File: AnalyzeRule.java    From a with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 替换JS
 */
@SuppressLint("DefaultLocale")
private String replaceJs(String ruleStr) throws Exception {
    if (ruleStr.contains("{{") && ruleStr.contains("}}")) {
        Object jsEval;
        StringBuffer sb = new StringBuffer(ruleStr.length());
        Matcher expMatcher = EXP_PATTERN.matcher(ruleStr);
        while (expMatcher.find()) {
            jsEval = evalJS(expMatcher.group(1), object);
            if (jsEval instanceof String) {
                expMatcher.appendReplacement(sb, (String) jsEval);
            } else if (jsEval instanceof Double && ((Double) jsEval) % 1.0 == 0) {
                expMatcher.appendReplacement(sb, String.format("%.0f", (Double) jsEval));
            } else {
                expMatcher.appendReplacement(sb, String.valueOf(jsEval));
            }
        }
        expMatcher.appendTail(sb);
        ruleStr = sb.toString();
    }
    return ruleStr;
}
 
Example #3
Source File: MediaPreviewActivity.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("CodeBlock2Expr")
@SuppressLint("InlinedApi")
private void saveToDisk() {
  MediaItem mediaItem = getCurrentMediaItem();

  if (mediaItem != null) {
    SaveAttachmentTask.showWarningDialog(this, (dialogInterface, i) -> {
      Permissions.with(this)
                 .request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE)
                 .ifNecessary()
                 .withPermanentDenialDialog(getString(R.string.MediaPreviewActivity_signal_needs_the_storage_permission_in_order_to_write_to_external_storage_but_it_has_been_permanently_denied))
                 .onAnyDenied(() -> Toast.makeText(this, R.string.MediaPreviewActivity_unable_to_write_to_external_storage_without_permission, Toast.LENGTH_LONG).show())
                 .onAllGranted(() -> {
                   SaveAttachmentTask saveTask = new SaveAttachmentTask(MediaPreviewActivity.this);
                   long saveDate = (mediaItem.date > 0) ? mediaItem.date : System.currentTimeMillis();
                   saveTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Attachment(mediaItem.uri, mediaItem.type, saveDate, null));
                 })
                 .execute();
    });
  }
}
 
Example #4
Source File: SimpleBookListDetailActivity.java    From a with GNU General Public License v3.0 6 votes vote down vote up
private MyObserver<List<RecommendBookBean>> getImportObserver() {
    return new MyObserver<List<RecommendBookBean>>() {
        @SuppressLint("DefaultLocale")
        @Override
        public void onNext(List<RecommendBookBean> bookSourceBeans) {
            if (bookSourceBeans.size() > 0) {
                adapter.replaceAll(bookSourceBeans);
               // mView.refreshBookList(bookSourceBeans.get(0).getList());
                // mView.showSnackBar(String.format("导入成功%d个书源", bookSourceBeans.size()), Snackbar.LENGTH_SHORT);
                // mView.setResult(RESULT_OK);
            } else {
                //mView.showSnackBar("格式不对", Snackbar.LENGTH_SHORT);
            }
        }

        @Override
        public void onError(Throwable e) {
            //mView.showSnackBar(e.getMessage(), Snackbar.LENGTH_SHORT);
        }
    };
}
 
Example #5
Source File: Registration.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
public void showEnterCodeDialog() {

        LayoutInflater inflater = ((Activity)context).getLayoutInflater();
        @SuppressLint("InflateParams") final View inputView = inflater.inflate(R.layout.edit_text_for_dialog, null, false);
        final EditText editText = inputView.findViewById(R.id.etForDialog);
        editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);

        AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.CustomAlertDialogTheme);
        builder .setTitle(R.string.enter_code)
                .setPositiveButton(R.string.ok, (dialog, which) -> {
                    new PrefManager(context).setStrPref("registrationCode",editText.getText().toString().trim());

                    wrongRegistrationCode = false;

                    TopFragment topFragment = (TopFragment) ((MainActivity)context).getSupportFragmentManager().findFragmentByTag("topFragmentTAG");
                    if (topFragment!=null) {
                        topFragment.checkNewVer();
                        MainActivity.modernDialog = ((MainActivity)context).modernProgressDialog();
                    }
                    dialog.dismiss();
                })
                .setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss())
                .setCancelable(false)
                .setView(inputView);
        builder.show();
    }
 
Example #6
Source File: Wear.java    From ZadakNotification with MIT License 6 votes vote down vote up
@SuppressLint("ResourceType")
public Wear button(@DrawableRes int icon, String title, PendingIntent pendingIntent) {
    if (icon < 0) {
        throw new IllegalArgumentException("Resource ID Should Not Be Less Than Or Equal To Zero!");
    }

    if (title == null) {
        throw new IllegalStateException("Title Must Not Be Null!");
    }
    if (pendingIntent == null) {
        throw new IllegalArgumentException("PendingIntent Must Not Be Null.");
    }

    this.wearableExtender.addAction(new NotificationCompat.Action(icon, title, pendingIntent));
    return this;
}
 
Example #7
Source File: MainFragment.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("SetTextI18n")
@Override
public void setDNSCryptLogViewText() {
    if (getActivity() != null && tvDNSCryptLog == null && svDNSCryptLog == null && !orientationLandscape) {
        tvDNSCryptLog = getActivity().findViewById(R.id.tvDNSCryptLog);
        svDNSCryptLog = getActivity().findViewById(R.id.svDNSCryptLog);

        if (svDNSCryptLog != null) {
            svDNSCryptLog.getViewTreeObserver().addOnScrollChangedListener(this);
        }
    }

    if (tvDNSCryptLog != null && svDNSCryptLog != null) {
        tvDNSCryptLog.setText(getText(R.string.tvDNSDefaultLog) + " " + DNSCryptVersion);
        tvDNSCryptLog.setGravity(Gravity.CENTER);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.CENTER;
        svDNSCryptLog.setLayoutParams(params);
    }
}
 
Example #8
Source File: CoverImageView.java    From a with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (width >= 10 && height > 10) {
        @SuppressLint("DrawAllocation")
        Path path = new Path();
        //四个圆角
        path.moveTo(10, 0);
        path.lineTo(width - 10, 0);
        path.quadTo(width, 0, width, 10);
        path.lineTo(width, height - 10);
        path.quadTo(width, height, width - 10, height);
        path.lineTo(10, height);
        path.quadTo(0, height, 0, height - 10);
        path.lineTo(0, 10);
        path.quadTo(0, 0, 10, 0);

        canvas.clipPath(path);
    }
    super.onDraw(canvas);
}
 
Example #9
Source File: HttpBean.java    From HttpInfo with Apache License 2.0 6 votes vote down vote up
@SuppressLint("DefaultLocale")
@Override
protected JSONObject toJSONObject() {
    try {
        jsonObject.put(isChina() ? HttpData.ERROR_CN : HttpData.ERROR, error);
        jsonObject.put(isChina() ? HttpData.ADDRESS_CN : HttpData.ADDRESS, address);
        jsonObject.put(isChina() ? HttpData.TIME_CN : HttpData.TIME, time + "ms");
        jsonObject.put(isChina() ? HttpData.TOTALTIME_CN : HttpData.TOTALTIME, totalTime + "ms");
        jsonObject.put(isChina() ? HttpData.SPEED_CN : HttpData.SPEED, speed + "kbps");
        jsonObject.put(isChina() ? HttpData.RESPONSECODE_CN : HttpData.RESPONSECODE, responseCode);
        jsonObject.put(isChina() ? HttpData.SIZE_CN : HttpData.SIZE, String.format("%.1fKB", new BigDecimal(size)));
        jsonObject.put(isChina() ? HttpData.HEADER_SERVER_CN : HttpData.HEADER_SERVER, headerServer);
        jsonObject.put(isChina() ? HttpData.CHECK_HEADER_SERVER_CN : HttpData.CHECK_HEADER_SERVER, checkHeaderServer);
        jsonObject.put(isChina() ? HttpData.ISJUMP_CN : HttpData.ISJUMP, isJump);
        jsonObject.put(isChina() ? HttpData.HEADER_CN : HttpData.HEADER, new JSONArray(header));
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return super.toJSONObject();
}
 
Example #10
Source File: TcpSocketModule.java    From react-native-tcp-socket with MIT License 6 votes vote down vote up
@SuppressLint("StaticFieldLeak")
@SuppressWarnings("unused")
@ReactMethod
public void listen(final Integer cId, final ReadableMap options) {
    new GuardedAsyncTask<Void, Void>(mReactContext.getExceptionHandler()) {
        @Override
        protected void doInBackgroundGuarded(Void... params) {
            try {
                TcpSocketServer server = new TcpSocketServer(socketClients, TcpSocketModule.this, cId, options);
                socketClients.put(cId, server);
                int port = options.getInt("port");
                String host = options.getString("host");
                onConnect(cId, host, port);
            } catch (Exception uhe) {
                onError(cId, uhe.getMessage());
            }
        }
    }.executeOnExecutor(executorService);
}
 
Example #11
Source File: MyMainActivity.java    From a with GNU General Public License v3.0 6 votes vote down vote up
private View tab_icon(String name, Integer iconID) {
    @SuppressLint("InflateParams")
    View tabView = LayoutInflater.from(this).inflate(R.layout.tab_view_icon_right, null);
    TextView tv = tabView.findViewById(R.id.tabtext);
    //tv.setHeight(14);
    tv.setText(name);
    tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//加粗
    ImageView im = tabView.findViewById(R.id.tabicon);
    if (iconID != null) {
        im.setVisibility(View.VISIBLE);
        im.setImageResource(iconID);
    } else {
        im.setVisibility(View.GONE);
    }
    return tabView;
}
 
Example #12
Source File: StorageUtils.java    From XMiTools with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Set file world readable
 */
@SuppressLint("SetWorldReadable")
public static void setFileWorldReadable(File file, int parentDepth) {
    if (!file.exists()) {
        return;
    }

    for (int i = 0; i < parentDepth; i++) {
        file.setReadable(true, false);
        file.setExecutable(true, false);
        file = file.getParentFile();
        if (file == null) {
            break;
        }
    }
}
 
Example #13
Source File: ExfriendManager.java    From QNotified with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("MissingPermission")
public void doNotifyDelFlAndSave(Object[] ptr) {
    dirtySerializedFlag = true;
    fileData.putLong("lastUpdateFl", lastUpdateTimeSec);
    //log("Friendlist updated @" + lastUpdateTimeSec);
    saveConfigure();
    try {
        if (isNotifyWhenDeleted() && ((int) ptr[0]) > 0) {
            Intent inner = new Intent(getApplication(), ExfriendListActivity.class);
            inner.putExtra(ACTIVITY_PROXY_ACTION, ACTION_EXFRIEND_LIST);
            Intent wrapper = new Intent();
            wrapper.setClassName(getApplication().getPackageName(), ActProxyMgr.STUB_ACTIVITY);
            wrapper.putExtra(ActProxyMgr.ACTIVITY_PROXY_INTENT, inner);
            PendingIntent pi = PendingIntent.getActivity(getApplication(), 0, wrapper, 0);
            NotificationManager nm = (NotificationManager) Utils.getApplication().getSystemService(Context.NOTIFICATION_SERVICE);
            Notification n = createNotiComp(nm, (String) ptr[1], (String) ptr[2], (String) ptr[3], new long[]{100, 200, 200, 100}, pi);
            nm.notify(ID_EX_NOTIFY, n);
            setRedDot();
        }
    } catch (Exception e) {
        log(e);
    }
}
 
Example #14
Source File: WelcomeActivity.java    From AndroidWallet with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("CheckResult")
@Override
public void initData() {
    try {
        Intent intent = getIntent();
        BaseInvokeModel baseInvokeModel = new BaseInvokeModel();
        baseInvokeModel.setPackageName(intent.getStringExtra("packageName"));
        baseInvokeModel.setClassName(intent.getStringExtra("className"));
        baseInvokeModel.setAppName(intent.getStringExtra("appName"));
        baseInvokeModel.setAction(intent.getStringExtra("action"));
        Uri uri = intent.getData();
        if (uri != null) {
            baseInvokeModel.setParam(uri.getQueryParameter("param"));
        }
        Bundle bundle = new Bundle();
        bundle.putSerializable(IntentKeyGlobal.INVOKE_SENDER_INFO, baseInvokeModel);
        ARouter.getInstance().build(RouterActivityPath.ACTIVITY_MAIN_PATH).with(bundle).navigation();
        finish();
    } catch (Exception e) {
        ARouter.getInstance().build(RouterActivityPath.ACTIVITY_MAIN_PATH).navigation();
        finish();
    }
}
 
Example #15
Source File: FimiMediaPlayer.java    From FimiX8-RE with MIT License 6 votes vote down vote up
@SuppressLint({"Wakelock"})
public void setWakeMode(Context context, int mode) {
    boolean washeld = false;
    if (this.mWakeLock != null) {
        if (this.mWakeLock.isHeld()) {
            washeld = true;
            this.mWakeLock.release();
        }
        this.mWakeLock = null;
    }
    this.mWakeLock = ((PowerManager) context.getSystemService("power")).newWakeLock(NTLMConstants.FLAG_NEGOTIATE_128_BIT_ENCRYPTION | mode, FimiMediaPlayer.class.getName());
    this.mWakeLock.setReferenceCounted(false);
    if (washeld) {
        this.mWakeLock.acquire();
    }
}
 
Example #16
Source File: CameraController.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void startPreview(final CameraSession session) {
    if (session == null) {
        return;
    }
    threadPool.execute(new Runnable() {
        @SuppressLint("NewApi")
        @Override
        public void run() {
            Camera camera = session.cameraInfo.camera;
            try {
                if (camera == null) {
                    camera = session.cameraInfo.camera = Camera.open(session.cameraInfo.cameraId);
                }
                camera.startPreview();
            } catch (Exception e) {
                session.cameraInfo.camera = null;
                if (camera != null) {
                    camera.release();
                }
                FileLog.e(e);
            }
        }
    });
}
 
Example #17
Source File: ConversationItemSwipeCallback.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
private void setTouchListener(@NonNull RecyclerView recyclerView,
                              @NonNull RecyclerView.ViewHolder viewHolder,
                              float dx)
{
  recyclerView.setOnTouchListener((v, event) -> {
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        shouldTriggerSwipeFeedback = true;
        break;
      case MotionEvent.ACTION_UP:
        handleTouchActionUp(recyclerView, viewHolder, dx);
      case MotionEvent.ACTION_CANCEL:
        swipeBack = true;
        shouldTriggerSwipeFeedback = false;
        resetProgressIfAnimationsDisabled(viewHolder);
        break;
    }
    return false;
  });
}
 
Example #18
Source File: MainFragment.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("SetTextI18n")
@Override
public void setTorLogViewText() {
    if (getActivity() != null && tvTorLog == null && svTorLog == null && !orientationLandscape) {
        tvTorLog = getActivity().findViewById(R.id.tvTorLog);
        svTorLog = getActivity().findViewById(R.id.svTorLog);

        if (svTorLog != null) {
            svTorLog.getViewTreeObserver().addOnScrollChangedListener(this);
        }
    }

    if (tvTorLog != null && svTorLog != null) {
        tvTorLog.setText(getText(R.string.tvTorDefaultLog) + " " + TorVersion);
        tvTorLog.setGravity(Gravity.CENTER);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.CENTER;
        svTorLog.setLayoutParams(params);
    }
}
 
Example #19
Source File: KeyCachingService.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("StaticFieldLeak")
private void handleClearKey() {
  Log.i(TAG, "handleClearKey");

  pendingAlarm = false;

  if (ApplicationMigrations.isUpdate(this)) {
    Log.w(TAG, "Cannot clear key during update.");
    return;
  }

  KeyCachingService.locking = true;

  sendPackageBroadcast(CLEAR_KEY_EVENT);

  new AsyncTask<Void, Void, Void>() {
    @Override
    protected Void doInBackground(Void... params) {
      ApplicationDependencies.getMessageNotifier().clearNotifications(KeyCachingService.this, true);
      return null;
    }
  }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #20
Source File: RestoreBackupFragment.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("StaticFieldLeak")
private void initializeBackupDetection(@NonNull View view) {
  searchForBackup(backup -> {
    Context context = getContext();
    if (context == null) {
      Log.i(TAG, "No context on fragment, must have navigated away.");
      return;
    }

    if (backup == null) {
      Log.i(TAG, "Skipping backup detection. No backup found, or permission revoked since.");
      Navigation.findNavController(view)
                .navigate(RestoreBackupFragmentDirections.actionNoBackupFound());
    } else {
      restoreBackupSize.setText(getString(R.string.RegistrationActivity_backup_size_s, Util.getPrettyFileSize(backup.getSize())));
      restoreBackupTime.setText(getString(R.string.RegistrationActivity_backup_timestamp_s, DateUtils.getExtendedRelativeTimeSpanString(requireContext(), Locale.getDefault(), backup.getTimestamp())));

      restoreButton.setOnClickListener((v) -> handleRestore(v.getContext(), backup));
    }
  });
}
 
Example #21
Source File: NetWork.java    From HttpInfo with Apache License 2.0 6 votes vote down vote up
public static boolean isNetworkAvailable(Context context) {
    try {
        ConnectivityManager mgr = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (mgr == null) {
            return false;
        }
        @SuppressLint("MissingPermission") @SuppressWarnings("deprecation") NetworkInfo[] info = mgr.getAllNetworkInfo();
        if (info != null) {
            for (NetworkInfo anInfo : info) {
                if (anInfo.getState() == NetworkInfo.State.CONNECTED) {
                    return true;
                }
            }
        }
    } catch (Exception e) {
        //ignore

    }
    return false;
}
 
Example #22
Source File: NoEmptyInfoWindowMarkerManager.java    From animation-samples with Apache License 2.0 5 votes vote down vote up
@Override
public View getInfoWindow(Marker marker) {
    if (TextUtils.isEmpty(marker.getTitle())) {
        // Highly sophisticated check to see if we're dealing with a cluster.
        // Clusters should not not have an InfoWindow of its own as they don't lead
        // to a specific street view.
        return null;
    }
    @SuppressLint("InflateParams")
    TextView title = (TextView) mLayoutInflater.inflate(R.layout.map_info_window, null);
    title.setText(marker.getTitle());
    return title;
}
 
Example #23
Source File: ConversationItemFooter.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("StaticFieldLeak")
private void presentTimer(@NonNull final MessageRecord messageRecord) {
  if (messageRecord.getExpiresIn() > 0 && !messageRecord.isPending()) {
    this.timerView.setVisibility(View.VISIBLE);
    this.timerView.setPercentComplete(0);

    if (messageRecord.getExpireStarted() > 0) {
      this.timerView.setExpirationTime(messageRecord.getExpireStarted(),
                                       messageRecord.getExpiresIn());
      this.timerView.startAnimation();

      if (messageRecord.getExpireStarted() + messageRecord.getExpiresIn() <= System.currentTimeMillis()) {
        ApplicationContext.getInstance(getContext()).getExpiringMessageManager().checkSchedule();
      }
    } else if (!messageRecord.isOutgoing() && !messageRecord.isMediaPending()) {
      new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
          ExpiringMessageManager expirationManager = ApplicationContext.getInstance(getContext()).getExpiringMessageManager();
          long                   id                = messageRecord.getId();
          boolean                mms               = messageRecord.isMms();

          if (mms) DatabaseFactory.getMmsDatabase(getContext()).markExpireStarted(id);
          else     DatabaseFactory.getSmsDatabase(getContext()).markExpireStarted(id);

          expirationManager.scheduleDeletion(id, mms, messageRecord.getExpiresIn());
          return null;
        }
      }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
  } else {
    this.timerView.setVisibility(View.GONE);
  }
}
 
Example #24
Source File: CordovaActivity.java    From BigDataPlatform with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
    // Capture requestCode here so that it is captured in the setActivityResultCallback() case.
    cordovaInterface.setActivityResultRequestCode(requestCode);
    super.startActivityForResult(intent, requestCode, options);
}
 
Example #25
Source File: MainActivity.java    From g4proxy with Apache License 2.0 5 votes vote down vote up
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    TextView textView = findViewById(R.id.text);
    String clientKey = Settings.System.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
    textView.setText("clientId: " + clientKey);
    startService(new Intent(this, HttpProxyService.class));

}
 
Example #26
Source File: LruResourceCache.java    From giffun with Apache License 2.0 5 votes vote down vote up
@SuppressLint("InlinedApi")
@Override
public void trimMemory(int level) {
    if (level >= android.content.ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
        // Nearing middle of list of cached background apps
        // Evict our entire bitmap cache
        clearMemory();
    } else if (level >= android.content.ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) {
        // Entering list of cached background apps
        // Evict oldest half of our bitmap cache
        trimToSize(getCurrentSize() / 2);
    }
}
 
Example #27
Source File: ChmodCommand.java    From InviZible with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("SetWorldReadable")
static void dirChmod(String path, boolean executableDir) {
    File dir = new File(path);

    if (!dir.isDirectory()) {
        throw new IllegalStateException("dirChmod dir not exist or not dir " + path);
    }

    if (!dir.setReadable(true, false)
            || !dir.setWritable(true)
            || !dir.setExecutable(true, false)) {
        throw new IllegalStateException("DirChmod chmod dir fault " + path);
    }

    File[] files = dir.listFiles();

    if (files == null) {
        return;
    }

    for (File file: files) {

        if (file.isDirectory()) {

            dirChmod(file.getAbsolutePath(), executableDir);

        } else if (file.isFile()) {

            if (executableDir) {
                executableFileChmod(file.getAbsolutePath());
            } else {
                regularFileChmod(file.getAbsolutePath());
            }
        }

    }


}
 
Example #28
Source File: BasePreferenceFragment.java    From mhzs with MIT License 5 votes vote down vote up
/**
 * 设置Pref为可读
 */
@SuppressWarnings({"deprecation", "ResultOfMethodCallIgnored"})
@SuppressLint({"SetWorldReadable", "WorldReadableFiles"})
protected void setWorldReadable() {
    if (FileUtils.getDefaultPrefFile(getActivity())
            .exists()) {
        for (File file : new File[]{FileUtils.getDataDir(getActivity()), FileUtils.getPrefDir(getActivity()), FileUtils.getDefaultPrefFile(getActivity())}) {
            file.setReadable(true, false);
            file.setExecutable(true, false);
        }
    }
}
 
Example #29
Source File: StatusBarUtil.java    From Yuan-WanAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 判断是否为MIUI6以上
 */
public static boolean isMIUI6Later() {
    try {
        @SuppressLint("PrivateApi")
        Class<?> clz = Class.forName("android.os.SystemProperties");
        Method mtd = clz.getMethod("get", String.class);
        String val = (String) mtd.invoke(null, "ro.miui.ui.version.name");
        val = val.replaceAll("[vV]", "");
        int version = Integer.parseInt(val);
        return version >= 6;
    } catch (Exception e) {
        return false;
    }
}
 
Example #30
Source File: DeviceUtils.java    From Android-utils with Apache License 2.0 5 votes vote down vote up
@SuppressLint("HardwareIds")
@RequiresPermission(READ_PHONE_STATE)
public static String getIMEI() {
    TelephonyManager tm =
            (TelephonyManager) UtilsApp.getApp().getSystemService(Context.TELEPHONY_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        //noinspection ConstantConditions
        return tm.getImei();
    }
    //noinspection ConstantConditions
    return tm.getDeviceId();
}