Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
AndiovisualRecord
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yu_Tung
AndiovisualRecord
Commits
f5decb73
Commit
f5decb73
authored
Sep 17, 2020
by
Yu_Tung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改MideaStore出現已經刪除的影片
parent
1f7eb234
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
39 deletions
+61
-39
misc.xml
.idea/misc.xml
+1
-1
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
LoginPresenter.java
...om/example/audiovisualrecord/ui/login/LoginPresenter.java
+1
-1
MainActivity.java
...a/com/example/audiovisualrecord/ui/main/MainActivity.java
+56
-35
login.xml
app/src/main/res/layout/login.xml
+2
-2
No files found.
.idea/misc.xml
View file @
f5decb73
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
7
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
8
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
...
...
app/src/main/AndroidManifest.xml
View file @
f5decb73
...
...
@@ -32,6 +32,7 @@
<activity
android:name=
".ui.main.MainActivity"
android:screenOrientation=
"portrait"
/>
<provider
android:name=
"androidx.core.content.FileProvider"
android:authorities=
"${applicationId}.provider"
...
...
app/src/main/java/com/example/audiovisualrecord/ui/login/LoginPresenter.java
View file @
f5decb73
...
...
@@ -33,7 +33,7 @@ public class LoginPresenter<V extends LoginContract.View> implements LoginContra
@Override
public
void
onLogin
(
String
account
,
String
password
)
{
String
url
=
view
.
getResourceString
(
R
.
string
.
api_on_Login
);
// LoginRequest mLoginRequest = new LoginRequest(LOGIN_AUTHORIZED_ID, "N000
158385", "781122222
");
// LoginRequest mLoginRequest = new LoginRequest(LOGIN_AUTHORIZED_ID, "N000
042089", "566345
");
LoginRequest
mLoginRequest
=
new
LoginRequest
(
LOGIN_AUTHORIZED_ID
,
account
,
password
);
compositeDisposable
.
add
(
api
.
onLogin
(
url
,
mLoginRequest
)
.
subscribeOn
(
schedulerProviderImp
.
io
())
...
...
app/src/main/java/com/example/audiovisualrecord/ui/main/MainActivity.java
View file @
f5decb73
...
...
@@ -14,11 +14,12 @@ import android.content.pm.PackageManager;
import
android.content.pm.ResolveInfo
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.media.MediaScannerConnection
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.os.Handler
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
...
...
@@ -46,6 +47,7 @@ import org.json.JSONObject;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
...
...
@@ -268,8 +270,8 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
);
String
formattedDate
=
df
.
format
(
c
);
fileName
=
"IMG_"
+
formattedDate
+
".jpg"
;
imageFilePhth
=
path
+
"/"
+
fileName
;
fileName
=
"IMG_"
+
formattedDate
+
".jpg"
;
imageFilePhth
=
path
+
"/"
+
fileName
;
// fileName = System.currentTimeMillis() + "";
Log
.
e
(
"filepath"
,
imageFilePhth
);
File
file1
=
new
File
(
imageFilePhth
);
...
...
@@ -284,7 +286,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
// MediaStore.Images.Media.insertImage(this.getContentResolver(), bitmap, "", "");
//要改掉下面那行
// this.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file1.getAbsolutePath())));
changeFileNameCheckDialog
(
imageFilePhth
,
fileName
);
changeFileNameCheckDialog
(
imageFilePhth
,
fileName
);
// context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
}
catch
(
Exception
e
)
{
...
...
@@ -344,8 +346,11 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
videoFilePath
=
MagicFileChooser
.
getAbsolutePathFromUri
(
this
,
videoUri
);
File
file
=
new
File
(
videoFilePath
);
String
name
=
(
file
.
getName
());
changeFileNameCheckDialog
(
videoFilePath
,
name
);
changeFileNameCheckDialog
(
videoFilePath
,
name
);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Files.move(videoFilePath,Environment.getDataDirectory().toString(),REPLACE)
// }
}
...
...
@@ -364,6 +369,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
mPresenter
.
onGetSid
(
uriList
,
getResourceString
(
R
.
string
.
on_upload_image
));
}
if
(
requestCode
==
PICK_VIDEO_FROM_GALLERY_REQUEST_CODE
&&
resultCode
==
RESULT_OK
)
{
ArrayList
<
String
>
uriList
=
new
ArrayList
<
String
>();
...
...
@@ -393,8 +399,8 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
ArrayList
<
String
>
VideoList
=
new
ArrayList
<>();
VideoList
.
add
(
path
);
Log
.
e
(
"Listsize"
,
VideoList
.
size
()+
""
);
Log
.
e
(
"List"
,
VideoList
.
get
(
0
));
Log
.
e
(
"Listsize"
,
VideoList
.
size
()
+
""
);
Log
.
e
(
"List"
,
VideoList
.
get
(
0
));
mPresenter
.
onGetSid
(
VideoList
,
getResourceString
(
R
.
string
.
on_upload_vedio
));
// TODO here====================
//影片的uri
...
...
@@ -497,7 +503,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
if
(
mChooseDeviceItemData
.
getProductionPlantId
().
equals
(
""
))
{
showDialogCaveatMessage
(
getResourceString
(
R
.
string
.
add_device_no_production_plant_error
));
}
mPresenter
.
onGetSHIFTData
(
mChooseDeviceItemData
.
getCompanyId
(),
mChooseDeviceItemData
.
getProductionPlantId
(),
mChooseDeviceItemData
.
getFactoryClassCode
());
mPresenter
.
onGetSHIFTData
(
mChooseDeviceItemData
.
getCompanyId
(),
mChooseDeviceItemData
.
getProductionPlantId
(),
mChooseDeviceItemData
.
getFactoryClassCode
());
break
;
case
R
.
id
.
tv_shoottype
:
...
...
@@ -574,14 +580,14 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
@Override
public
void
onUploadFile
(
final
ArrayList
<
String
>
uriList
,
String
type
,
final
String
sid
)
{
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
Log
.
e
(
"path"
,
uploadPath
);
Log
.
e
(
"path"
,
uploadPath
);
dismissProgressDialog
();
showProgressDialog
(
type
);
for
(
String
path
:
uriList
)
{
updateMedia
(
path
,
this
);
updateMedia
(
path
,
this
);
}
new
Thread
(
new
Runnable
()
{
...
...
@@ -718,7 +724,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
};
//廣播更新媒體庫
private
static
void
updateMedia
(
String
path
,
Context
context
)
{
private
static
void
updateMedia
(
String
path
,
Context
context
)
{
File
file
=
new
File
(
path
);
Intent
intent
=
new
Intent
();
intent
.
setAction
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
);
...
...
@@ -733,7 +739,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
//取得自訂版面
LayoutInflater
inflater
=
LayoutInflater
.
from
(
MainActivity
.
this
);
final
View
v
=
inflater
.
inflate
(
R
.
layout
.
dialog_changefilename
,
null
);
final
View
v
=
inflater
.
inflate
(
R
.
layout
.
dialog_changefilename
,
null
);
builder
.
setTitle
(
"請問要將檔名修改成:"
);
builder
.
setView
(
v
);
builder
.
setCancelable
(
false
);
...
...
@@ -743,41 +749,41 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
EditText
editChangeName
=
v
.
findViewById
(
R
.
id
.
etChangeName
);
changeFileName
=
editChangeName
.
getText
().
toString
();
// Log.e("euu",changeFileName);
if
(
changeFileName
.
length
()
<=
0
){
Toast
.
makeText
(
MainActivity
.
this
,
"請輸入要更改的檔名"
,
Toast
.
LENGTH_SHORT
).
show
();
changeFileNameCheckDialog
(
path
,
name
);
}
else
if
(
changeFileName
.
length
()>
0
){
updateChangeFileName
(
changeFileName
,
path
,
name
);
if
(
changeFileName
.
length
()
<=
0
)
{
Toast
.
makeText
(
MainActivity
.
this
,
"請輸入要更改的檔名"
,
Toast
.
LENGTH_SHORT
).
show
();
changeFileNameCheckDialog
(
path
,
name
);
}
else
if
(
changeFileName
.
length
()
>
0
)
{
updateChangeFileName
(
changeFileName
,
path
,
name
);
}
}
}).
setNegativeButton
(
"取消"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
//廣播圖片or影片
updateMedia
(
path
,
MainActivity
.
this
);
updateMedia
(
path
,
MainActivity
.
this
);
}
});
builder
.
create
();
builder
.
show
();
}
private
void
updateChangeFileName
(
String
changeFileName
,
final
String
path
,
String
originFileName
)
{
if
(
originFileName
.
contains
(
".jpg"
)){
Log
.
e
(
"type"
,
"jpg"
);
File
newFile
=
new
File
(
path
.
replace
(
originFileName
,
changeFileName
)+
".jpg"
);
private
void
updateChangeFileName
(
final
String
changeFileName
,
final
String
path
,
String
originFileName
)
{
if
(
originFileName
.
contains
(
".jpg"
))
{
Log
.
e
(
"type"
,
"jpg"
);
File
newFile
=
new
File
(
path
.
replace
(
originFileName
,
changeFileName
)
+
".jpg"
);
File
originFile
=
new
File
(
path
);
originFile
.
renameTo
(
newFile
);
updateMedia
(
newFile
.
getAbsolutePath
(),
this
);
}
else
if
(
originFileName
.
contains
(
".mp4"
)){
Log
.
e
(
"type"
,
"mp4"
);
File
newFile
=
new
File
(
path
.
replace
(
originFileName
,
changeFileName
)+
".mp4"
);
File
originFile
=
new
File
(
path
);
updateMedia
(
newFile
.
getAbsolutePath
(),
this
);
}
else
if
(
originFileName
.
contains
(
".mp4"
))
{
Log
.
e
(
"type"
,
"mp4"
);
final
File
newFile
=
new
File
(
path
.
replace
(
originFileName
,
changeFileName
)
+
".mp4"
);
final
File
originFile
=
new
File
(
path
);
originFile
.
renameTo
(
newFile
);
updateMedia
(
newFile
.
getAbsolutePath
(),
this
);
//
updateMedia(newFile.getAbsolutePath(),this);
//
跑太快畫面來不及更新
//
跑太快畫面來不及更新
showProgressDialog
(
"影片改名中"
);
showProgressDialog
(
"影片改名中"
);
showProgressDialog
(
"影片改名中"
);
...
...
@@ -787,16 +793,31 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
@Override
public
void
run
()
{
try
{
Thread
.
sleep
(
3000
);
updateMedia
(
new
File
(
path
).
getAbsolutePath
(),
MainActivity
.
this
);
//把舊檔案更新掉,不然媒體庫會有一個額外且不能用的檔案
dismissProgressDialog
();
refreshVideoMediastore
(
path
,
newFile
);
Thread
.
sleep
(
5000
);
dismissProgressDialog
();
//updateMedia(new File(path).getAbsolutePath(),this); //把舊檔案更新掉,不然媒體庫會有一個額外且不能用的檔案
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
Log
.
e
(
"error"
,
e
.
getMessage
());
}
}
}).
start
();
// updateMedia(new File(path).getAbsolutePath(),this); //把舊檔案更新掉,不然媒體庫會有一個額外且不能用的檔案
}
}
private
void
refreshVideoMediastore
(
String
path
,
File
after
)
{
MainActivity
.
this
.
getContentResolver
().
delete
(
MediaStore
.
Video
.
Media
.
EXTERNAL_CONTENT_URI
,
MediaStore
.
Video
.
Media
.
DATA
+
"=?"
,
new
String
[]{
path
});
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
);
intent
.
setData
(
Uri
.
fromFile
(
after
));
MainActivity
.
this
.
sendBroadcast
(
intent
);
}
}
app/src/main/res/layout/login.xml
View file @
f5decb73
...
...
@@ -39,7 +39,7 @@
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:hint=
"@string/login_account_hint"
android:text=
"N000042089"
android:textColorHint=
"@color/white"
android:paddingStart=
"100dp"
app:layout_constraintWidth_percent=
"0.9"
...
...
@@ -56,7 +56,7 @@
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:hint=
"@string/login_password_hint"
android:text=
"566345"
android:inputType=
"textPassword"
android:textColorHint=
"@color/white"
android:paddingStart=
"100dp"
...
...
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