Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Skidn disease App
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Skin disease
Skidn disease App
Commits
ca4e7ca5
Commit
ca4e7ca5
authored
Oct 16, 2021
by
Kavindu Randika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixing
parent
fda9d09d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
63 deletions
+56
-63
app/.gitignore
app/.gitignore
+1
-1
app/src/main/java/com/project/skidn_disease_app/CameraFragment.java
...in/java/com/project/skidn_disease_app/CameraFragment.java
+55
-62
No files found.
app/.gitignore
View file @
ca4e7ca5
/build
\ No newline at end of file
build
\ No newline at end of file
app/src/main/java/com/project/skidn_disease_app/CameraFragment.java
View file @
ca4e7ca5
...
...
@@ -7,6 +7,7 @@ import android.content.ContentValues;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.graphics.Bitmap
;
import
android.media.MediaScannerConnection
;
import
android.net.Uri
;
...
...
@@ -17,6 +18,7 @@ import androidx.annotation.NonNull;
import
androidx.annotation.Nullable
;
import
androidx.core.app.ActivityCompat
;
import
androidx.core.content.ContextCompat
;
import
androidx.core.graphics.PathUtils
;
import
androidx.fragment.app.Fragment
;
import
android.os.Environment
;
...
...
@@ -247,38 +249,38 @@ public class CameraFragment extends Fragment {
System
.
out
.
println
(
jsonObject
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
e
.
printStackTrace
();
}
}
},
new
Response
.
ErrorListener
()
{
@Override
public
void
onErrorResponse
(
VolleyError
error
)
{
Toast
.
makeText
(
getContext
(),
"No internet connection"
,
Toast
.
LENGTH_LONG
).
show
();
System
.
out
.
println
(
"error"
);
System
.
out
.
println
(
error
.
toString
());
System
.
out
.
println
(
"error"
);
}
})
}
},
new
Response
.
ErrorListener
()
{
@Override
public
void
onErrorResponse
(
VolleyError
error
)
{
Toast
.
makeText
(
getContext
(),
"No internet connection"
,
Toast
.
LENGTH_LONG
).
show
();
System
.
out
.
println
(
"error"
);
System
.
out
.
println
(
error
.
toString
());
System
.
out
.
println
(
"error"
);
}
})
{
protected
Map
<
String
,
String
>
getParams
()
{
Map
<
String
,
String
>
params
=
new
Hashtable
<>();
params
.
put
(
"req_file"
,
image
);
return
params
;
}
};
{
int
socketTimeout
=
30000
;
stringRequest
.
setRetryPolicy
(
new
DefaultRetryPolicy
(
5000
,
DefaultRetryPolicy
.
DEFAULT_MAX_RETRIES
,
DefaultRetryPolicy
.
DEFAULT_BACKOFF_MULT
));
}
};
{
int
socketTimeout
=
30000
;
stringRequest
.
setRetryPolicy
(
new
DefaultRetryPolicy
(
5000
,
DefaultRetryPolicy
.
DEFAULT_MAX_RETRIES
,
DefaultRetryPolicy
.
DEFAULT_BACKOFF_MULT
));
// RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
// stringRequest.setRetryPolicy(policy);
RequestQueue
requestQueue
=
Volley
.
newRequestQueue
(
getContext
());
requestQueue
.
add
(
stringRequest
);
RequestQueue
requestQueue
=
Volley
.
newRequestQueue
(
getContext
());
requestQueue
.
add
(
stringRequest
);
}
}
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
...
...
@@ -316,9 +318,9 @@ public class CameraFragment extends Fragment {
@Override
public
void
onClick
(
View
v
)
{
// System.out.println("print");
String
image
=
getStringImage
(
bitmapimg
);
//
String image = getStringImage(bitmapimg);
// System.out.println(image);
System
.
out
.
println
(
currentPhotoPath
);
System
.
out
.
println
(
"image path"
+
currentPhotoPath
);
try
{
uploadImage
(
currentPhotoPath
);
}
catch
(
InterruptedException
e
)
{
...
...
@@ -495,14 +497,20 @@ public class CameraFragment extends Fragment {
if
(
requestCode
==
GALLERY_REQUEST_CODE
){
if
(
resultCode
==
Activity
.
RESULT_OK
){
Uri
contentUri
=
data
.
getData
();
File
file_temp
=
new
File
(
contentUri
.
getPath
());
String
path
=
getRealPathFromURI
(
getContext
(),
contentUri
);
System
.
out
.
println
(
"1 file_path"
+
path
);
currentPhotoPath
=
path
;
try
{
bitmapimg
=
MediaStore
.
Images
.
Media
.
getBitmap
(
getContext
().
getContentResolver
(),
contentUri
);
}
catch
(
IOException
fileNotFoundException
){
System
.
out
.
println
(
fileNotFoundException
.
getMessage
().
toString
());
}
String
timeStamp
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
).
format
(
new
Date
());
String
imageFileName
=
"JPEG_"
+
timeStamp
+
"."
+
getFileExt
(
contentUri
);
Log
.
d
(
"tag"
,
"onActivityResult: Gallery Image Uri: "
+
imageFileName
);
try
{
uploadImage
(
contentUri
.
getPath
());
}
catch
(
InterruptedException
|
IOException
e
)
{
e
.
printStackTrace
();
}
selectedImage
.
setImageURI
(
contentUri
);
}
...
...
@@ -511,6 +519,23 @@ public class CameraFragment extends Fragment {
}
public
String
getRealPathFromURI
(
Context
context
,
Uri
contentUri
)
{
Cursor
cursor
=
null
;
try
{
String
[]
proj
=
{
MediaStore
.
Images
.
Media
.
DATA
};
cursor
=
context
.
getContentResolver
().
query
(
contentUri
,
proj
,
null
,
null
,
null
);
int
column_index
=
cursor
.
getColumnIndexOrThrow
(
MediaStore
.
Images
.
Media
.
DATA
);
cursor
.
moveToFirst
();
return
cursor
.
getString
(
column_index
);
}
finally
{
if
(
cursor
!=
null
)
{
cursor
.
close
();
}
}
}
private
String
getFileExt
(
Uri
contentUri
)
{
ContentResolver
c
=
getContext
().
getContentResolver
();
MimeTypeMap
mime
=
MimeTypeMap
.
getSingleton
();
...
...
@@ -536,39 +561,7 @@ public class CameraFragment extends Fragment {
private
void
dispatchTakePictureIntent
()
throws
IOException
{
// String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
// String imageFileName = "JPEG_" + timeStamp + "_.jpg";
// File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
// String path = storageDir + "/CameraImages/example.jpg";
// currentPhotoPath = path;
// File file = new File(path);
// Uri outputFileUri = Uri.fromFile( file );
// Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
// intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
// startActivityForResult( intent, CAMERA_REQUEST_CODE );
// startActivityForResult( intent, CAPTURE_IMAGE );
Intent
takePictureIntent
=
new
Intent
(
MediaStore
.
ACTION_IMAGE_CAPTURE
);
startActivityForResult
(
takePictureIntent
,
CAMERA_REQUEST_CODE
);
// Ensure that there's a camera activity to handle the intent
// if (takePictureIntent.resolveActivity(getContext().getPackageManager()) != null) {
// // Create the File where the photo should go
// File photoFile = null;
// try {
// photoFile = createImageFile();
// } catch (IOException ex) {
//
// }
// // Continue only if the File was successfully created
// if (photoFile != null) {
// Uri photoURI = FileProvider.getUriForFile(getContext(),
// "com.project.skindn_disease_app.fileprovider",
// photoFile);
// takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
// startActivityForResult(takePictureIntent, CAMERA_REQUEST_CODE);
// }
// startActivityForResult(takePictureIntent, CAMERA_REQUEST_CODE);
// }
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment