Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmedbadereldin committed Aug 11, 2020
1 parent 6e2ba23 commit 85b3d88
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,57 @@ dependencies {
```

* In YourActivity
```
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Open VideoTrimmerActivity
if (requestCode == REQUEST_TAKE_GALLERY_VIDEO) { //recive
if (resultCode == RESULT_OK) {
Uri selectedImageUri = data.getData();
// MEDIA GALLERY
String path = getPath(selectedImageUri);
Uri uriFile = Uri.fromFile(new File(path));
String fileExtension = MimeTypeMap.getFileExtensionFromUrl(uriFile.toString());
Log.d(TAG, "onActivityResult: " + fileExtension);
if (fileExtension.equalsIgnoreCase("MP4")) {
File file = new File(path);
if (file.exists()) {
startActivityForResult(new Intent(YourActivity.this, VideoTrimmerActivity.class).putExtra("EXTRA_PATH", path), VIDEO_TRIM);
overridePendingTransition(0, 0);
} else {
Toast.makeText(NewPostActivity.this, "Please select proper video", Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(this, getString(R.string.file_format) + " ," + fileExtension, Toast.LENGTH_SHORT).show();
}
}
}
// ForResult from VideoTrimmerActivity
if (requestCode == VIDEO_TRIM) {
if (resultCode == RESULT_OK) {
if (data != null) {
String videoPath = data.getExtras().getString("INTENT_VIDEO_FILE");
File file = new File(videoPath);
Log.d(TAG, "onActivityResult: " + file.length());
pathPostImg = videoPath;
Glide.with(this)
.load(pathPostImg)
.into(postImg);
postImgLY.setVisibility(View.VISIBLE);
}
}
}
}
```

## Requirements ##

- Android 4.1+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ private void initViews() {
cancelImgBtn = findViewById(R.id.cancelImgBtn);
}


private void setSharedInentData(Intent sharedInentData) {

String receivedAction = sharedInentData.getAction();
Expand Down Expand Up @@ -169,7 +168,6 @@ private void loadImage(Uri filepath) {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == REQUEST_TAKE_GALLERY_VIDEO) {
if (resultCode == RESULT_OK) {
Uri selectedImageUri = data.getData();
Expand Down

0 comments on commit 85b3d88

Please sign in to comment.