Exemplo n.º 1
0
  public Bitmap loadImage(String path) throws OutOfMemoryError {
    Bitmap bitsat;

    try {
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inPreferredConfig = Bitmap.Config.ARGB_8888;
      options.inJustDecodeBounds = true;
      Bitmap b = BitmapFactory.decodeFile(path, options);

      options.inSampleSize = Futils.calculateInSampleSize(options, px, px);

      // Decode bitmap with inSampleSize set
      options.inJustDecodeBounds = false;

      Bitmap bit;
      if (path.startsWith("smb:/")) bit = BitmapFactory.decodeStream(new SmbFileInputStream(path));
      else bit = BitmapFactory.decodeFile(path, options);

      bitsat =
          bit; // decodeFile(path);//.createScaledBitmap(bits,imageViewReference.get().getHeight(),imageViewReference.get().getWidth(),true);
    } catch (Exception e) {
      Drawable img = ContextCompat.getDrawable(mContext, R.drawable.ic_doc_image);
      Bitmap img1 = ((BitmapDrawable) img).getBitmap();
      bitsat = img1;
    }
    return bitsat;
  }
Exemplo n.º 2
0
 public Layoutelements(
     BitmapDrawable imageId,
     String title,
     String desc,
     String permissions,
     String symlink,
     String size,
     long longSize,
     boolean header,
     String date,
     boolean isDirectory) {
   this.imageId = imageId;
   this.title = title;
   this.desc = desc;
   this.permissions = permissions.trim();
   this.symlink = symlink.trim();
   this.size = size;
   this.header = header;
   this.longSize = longSize;
   this.isDirectory = isDirectory;
   if (!date.trim().equals("")) {
     this.date = Long.parseLong(date);
     this.date1 = Futils.getdate(this.date, "MMM dd, yyyy", "16");
   }
 }
Exemplo n.º 3
0
  private void requestGplusPermission() {
    final String[] PERMISSIONS = {Manifest.permission.GET_ACCOUNTS, Manifest.permission.INTERNET};
    if (ActivityCompat.shouldShowRequestPermissionRationale(
            getActivity(), Manifest.permission.GET_ACCOUNTS)
        || ActivityCompat.shouldShowRequestPermissionRationale(
            getActivity(), Manifest.permission.INTERNET)) {
      // Provide an additional rationale to the user if the permission was not granted
      // and the user would benefit from additional context for the use of the permission.
      // For example, if the request has been denied previously.

      String fab_skin = (BaseActivity.accentSkin);
      final MaterialDialog materialDialog =
          Futils.showBasicDialog(
              getActivity(),
              fab_skin,
              theme,
              new String[] {
                getResources().getString(R.string.grantgplus),
                getResources().getString(R.string.grantper),
                getResources().getString(R.string.grant),
                getResources().getString(R.string.cancel),
                null
              });
      materialDialog
          .getActionButton(DialogAction.POSITIVE)
          .setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  ActivityCompat.requestPermissions(getActivity(), PERMISSIONS, 66);
                  materialDialog.dismiss();
                }
              });
      materialDialog
          .getActionButton(DialogAction.NEGATIVE)
          .setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  getActivity().finish();
                }
              });
      materialDialog.setCancelable(false);
      materialDialog.show();

    } else {
      // Contact permissions have not been granted yet. Request them directly.
      ActivityCompat.requestPermissions(getActivity(), PERMISSIONS, 66);
    }
  }