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
279c854b
Commit
279c854b
authored
Jun 24, 2020
by
Yu-Tung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getsid 拿取空值 ok
parent
d1ec12a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
227 additions
and
251 deletions
+227
-251
MainActivity.java
...a/com/example/audiovisualrecord/ui/main/MainActivity.java
+97
-203
MainContract.java
...a/com/example/audiovisualrecord/ui/main/MainContract.java
+4
-3
MainPresenter.java
.../com/example/audiovisualrecord/ui/main/MainPresenter.java
+126
-45
No files found.
app/src/main/java/com/example/audiovisualrecord/ui/main/MainActivity.java
View file @
279c854b
...
...
@@ -67,7 +67,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
private
String
pathFactoryClass
=
""
;
private
String
pathClass
=
""
;
private
String
pathShootType
=
""
;
private
String
uploadPath
=
"
/
"
;
private
String
uploadPath
=
""
;
// Bundle bag;
String
token
,
imageFilePath
;
...
...
@@ -94,7 +94,7 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
mPresenter
=
new
MainPresenter
(
this
);
mMainData
=
new
MainData
();
mChooseDeviceItemData
=
new
ChooseDeviceItemData
();
mPresenter
.
onGetSid
();
//
mPresenter.onGetSid();
}
@Override
...
...
@@ -215,6 +215,10 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
myBitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
out
);
out
.
flush
();
out
.
close
();
MediaStore
.
Images
.
Media
.
insertImage
(
getContentResolver
(),
myBitmap
,
imgFile
.
getName
(),
"description"
);
sendBroadcast
(
new
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
,
Uri
.
fromFile
(
new
File
(
Environment
.
getExternalStorageDirectory
().
getPath
()))));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -239,8 +243,9 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
Log
.
e
(
"eee"
,
getPath
(
data
.
getData
()));
}
//照片的uri
// mPresenter.onGetSid();
onUploadFile
(
uriList
,
getResourceString
(
R
.
string
.
on_upload_image
));
mPresenter
.
onGetSid
(
uriList
,
getResourceString
(
R
.
string
.
on_upload_image
));
// onUploadFile(uriList, getResourceString(R.string.on_upload_image));
// onUploadFile1();
}
...
...
@@ -257,24 +262,33 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
Log
.
e
(
"gggg"
,
""
+
uriList
.
get
(
i
));
Log
.
e
(
"dddd"
,
""
+
filename
.
get
(
i
));
mPresenter
.
segVideo
(
uriList
.
get
(
i
),
filename
.
get
(
i
));
//
mPresenter.segVideo(uriList.get(i), filename.get(i));
// onUploadFile(uriList, getResourceString(R.string.on_upload_vedio));
}
Log
.
e
(
"aaa"
,
count
+
""
);
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
16
&&
data
.
getClipData
()
==
null
)
{
uriList
.
clear
();
String
path
=
FileUtil
.
getFileAbsolutePath
(
this
,
data
.
getData
());
String
name
=
FileUtil
.
fileName
(
path
);
uriList
.
add
(
path
);
// onUploadFile(uriList, getResourceString(R.string.on_upload_vedio));
ArrayList
segVideoList
=
new
ArrayList
();
segVideoList
=
mPresenter
.
segVideo
(
path
,
name
);
mPresenter
.
segVideo
(
path
,
name
);
for
(
int
i
=
0
;
i
<
segVideoList
.
size
();
i
++)
Log
.
e
(
"aaa"
,
segVideoList
.
get
(
i
).
toString
());
mPresenter
.
onGetSid
(
segVideoList
,
getResourceString
(
R
.
string
.
on_upload_vedio
));
Log
.
e
(
"path"
,
path
);
// TODO here====================
// onUploadFile(compressList, getResourceString(R.string.on_upload_vedio));
// onUploadFile(uriList, getResourceString(R.string.on_upload_vedio));
//影片的uri
}
...
...
@@ -318,20 +332,44 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
public
void
onClick
(
View
v
)
{
switch
(
v
.
getId
())
{
case
R
.
id
.
btnCaptureImage
:
openCameraIntent
();
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
if
(
""
.
equals
(
uploadPath
)){
showDialogCaveatMessage
(
"請選擇路徑"
);
}
else
{
openCameraIntent
();
}
break
;
case
R
.
id
.
btnGetImageFromGallery
:
pickImageFromGallery
();
// onUploadFile1();
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
if
(
""
.
equals
(
uploadPath
)){
showDialogCaveatMessage
(
"請選擇路徑"
);
}
else
{
pickImageFromGallery
();
}
break
;
case
R
.
id
.
btnGetVideoFromGallery
:
pickVideoFromGallery
();
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
if
(
""
.
equals
(
uploadPath
)){
showDialogCaveatMessage
(
"請選擇路徑"
);
}
else
{
pickVideoFromGallery
();
}
break
;
case
R
.
id
.
btnRecordVideo
:
openRecordVideoIntent
();
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
if
(
""
.
equals
(
uploadPath
)){
showDialogCaveatMessage
(
"請選擇路徑"
);
}
else
{
openRecordVideoIntent
();
}
break
;
case
R
.
id
.
tv_company
:
...
...
@@ -376,193 +414,6 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
}
}
//如果能改成用retrofit加rxjava最好,已經嘗試過三天的,可能有缺什麼,不過緊急所以先求功能
private
void
onUploadFile
(
final
ArrayList
<
String
>
uriList
,
String
type
)
{
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
// ongetsid();
showProgressDialog
(
type
);
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
// OkHttpClient client = new OkHttpClient().newBuilder()
// .build();
// MediaType mediaType = MediaType.parse("text/plain");
// MultipartBody.Builder buildernew = new MultipartBody.Builder()
// .setType(MultipartBody.FORM)
// .addFormDataPart("AuthorizedId", "1179cf63-9f4c-4060-a0f3-201f108b20c1")
// .addFormDataPart("CO", "1")
// .addFormDataPart("CONM", "台塑")
// .addFormDataPart("PMFCT", "A3")
// .addFormDataPart("PMFCTNM", "麥寮AN廠")
// .addFormDataPart("EQKD", "PU")
// .addFormDataPart("EQKDNM", "泵浦")
// .addFormDataPart("EQNO", "P-166")
// .addFormDataPart("EQNM", "工業用水泵浦")
// .addFormDataPart("RecordDate", "2020/04/06")
// .addFormDataPart("RecordSubject", "測試")
// .addFormDataPart("UploadEMP", "1")
// .addFormDataPart("UploadNM", "新人")
// .addFormDataPart("UploadDATETM", "");
// for (String path : uriList) {
// File uploadFile = new File(path);
// buildernew.addFormDataPart("", uploadFile.getName(),
// RequestBody.create(MediaType.parse("application/octet-stream"),
// uploadFile));
// }
// RequestBody body = buildernew.build();
//
// Request request = new Request.Builder()
// .url("https://cloud.fpcetg.com.tw/FPC/API/MTN/API_MTN/MTN/Upload")
// .method("POST", body)
// .build();
String
apiname
=
"SYNO.FileStation.Upload"
;
String
method
=
"upload"
;
String
version
=
"2"
;
String
path1
=
uploadPath
;
Boolean
a
=
true
;
Boolean
b
=
false
;
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
()
.
connectTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
build
();
// MediaType mediaType = MediaType.parse("application/octet-stream");
// MediaType mediaType = MediaType.parse("multiparty/form-data");
MediaType
mediaType
=
MediaType
.
parse
(
"image/jpg"
);
MultipartBody
.
Builder
buildernew
=
new
MultipartBody
.
Builder
()
.
setType
(
MultipartBody
.
FORM
)
// .addFormDataPart("api", apiname)
// .addFormDataPart("method", method)
// .addFormDataPart("version", version)
// .addFormDataPart("_sid", sid)
.
addFormDataPart
(
"path"
,
path1
)
.
addFormDataPart
(
"create_parents"
,
a
.
toString
())
.
addFormDataPart
(
"overwrite"
,
a
.
toString
())
.
addFormDataPart
(
"data"
,
""
)
.
addFormDataPart
(
"success"
,
""
);
Log
.
e
(
"test_path"
,
path1
);
Log
.
e
(
"test_create_parents"
,
b
.
toString
());
Log
.
e
(
"test_overwrite"
,
a
.
toString
());
// .addFormDataPart("file", "b525a7db0c5da640_1.jpg",
// RequestBody.create(mediaType,new File("/storage/emulated/0/Watashi AHD V.2/temp_images/b525a7db0c5da640_1.jpg")
// ));
// Log.e("test",""+buildernew.build().parts().get(0));
for
(
String
path
:
uriList
)
{
File
uploadFile
=
new
File
(
path
);
// RequestBody fileBody = RequestBody.create(mediaType,uploadFile);
buildernew
.
addFormDataPart
(
"file"
,
uploadFile
.
getName
(),
RequestBody
.
create
(
MediaType
.
parse
(
"multiparty/form-data"
),
path
));
// RequestBody.create(MediaType.parse("application/octet-stream"), path));
Log
.
e
(
"test_filename"
,
uploadFile
.
getName
());
Log
.
e
(
"path"
,
path
);
Log
.
e
(
"test_file"
,
uploadFile
.
getAbsolutePath
());
}
RequestBody
body
=
buildernew
.
build
();
// buildernew.build();
Request
request
=
new
Request
.
Builder
()
.
url
(
"https://fpcrtpms.synology.me:5001/webapi/entry.cgi?api="
+
apiname
+
"&method="
+
method
+
"&version="
+
version
+
"&_sid="
+
sidData
)
// .url("https://fpcrtpms.synology.me:5001/webapi/entry.cgi")
.
method
(
"POST"
,
body
)
// .header("api",apiname)
// .header("method",method)
// .header("version",version)
// .header("_sid",sid)
// .addHeader("Content-Type", "text/xml; charset=utf-8")
// .post(buildernew.build())
.
build
();
Log
.
e
(
"test_url"
,
request
.
url
().
toString
());
try
{
Response
response
=
client
.
newCall
(
request
).
execute
();
Log
.
e
(
"response"
,
response
.
body
().
string
());
dismissProgressDialog
();
// Log.e("isSuccess",json.get("IsSuccess").toString());
mPresenter
.
onLogoutSid
(
sidData
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
dismissProgressDialog
();
// showDialogCaveatMessage("上傳失敗");
Log
.
e
(
"error"
,
""
+
e
.
getMessage
());
}
}
}).
start
();
}
private
void
onUploadFile1
()
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
()
.
build
();
MediaType
mediaType
=
MediaType
.
parse
(
"text/plain"
);
RequestBody
body
=
new
MultipartBody
.
Builder
().
setType
(
MultipartBody
.
FORM
)
.
addFormDataPart
(
"path"
,
"/仁武氯乙烯廠製造一課/1_SOP導讀"
)
.
addFormDataPart
(
"create_parents"
,
"false"
)
.
addFormDataPart
(
"overwrite"
,
"true"
)
.
addFormDataPart
(
"file"
,
"/C:/Users/PCKing/Pictures/356154.jpg"
,
RequestBody
.
create
(
MediaType
.
parse
(
"application/octet-stream"
),
new
File
(
"/C:/Users/PCKing/Pictures/356154.jpg"
)))
.
build
();
Request
request
=
new
Request
.
Builder
()
.
url
(
"https://fpcrtpms.synology.me:5001/webapi/entry.cgi?api=SYNO.FileStation.Upload&method=upload&version=2&_sid="
)
.
method
(
"POST"
,
body
)
.
build
();
try
{
Response
response
=
client
.
newCall
(
request
).
execute
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
// Call call = client.newCall(request);
// call.enqueue(new Callback() {
// @Override
// public void onFailure(@NotNull Call call, @NotNull IOException e) {
// Log.e("error", "" + e.getMessage());
// }
//
// @Override
// public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
// Log.e("response", response.body().string());
// }
// });
try
{
Response
response
=
client
.
newCall
(
request
).
execute
();
Log
.
e
(
"response"
,
response
.
body
().
string
());
mPresenter
.
onLogoutSid
(
sidData
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
Log
.
e
(
"error"
,
""
+
e
.
getMessage
());
}
}
}).
start
();
}
private
void
ongetsid
(){
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
()
.
build
();
Request
request
=
new
Request
.
Builder
()
.
url
(
"https://webapp.fpcitc.com.tw/SOP/api/FileUpload/GetLogin"
)
.
method
(
"GET"
,
null
)
.
addHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded"
)
.
build
();
try
{
Response
response
=
client
.
newCall
(
request
).
execute
();
Log
.
e
(
"response"
,
response
.
body
().
string
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}).
start
();
}
@Override
public
void
setCOData
(
List
<
COResponse
>
adapterData
)
{
dialogString
.
clear
();
...
...
@@ -613,10 +464,55 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
showItemDialog
(
dialogString
,
onShootTypeCategoryDialogItemClick
);
}
//如果能改成用retrofit加rxjava最好,已經嘗試過三天的,可能有缺什麼,不過緊急所以先求功能
@Override
public
void
setSIDData
(
String
sid
)
{
sidData
=
sid
;
public
void
onUploadFile
(
final
ArrayList
<
String
>
uriList
,
String
type
,
final
String
sid
)
{
uploadPath
=
mPresenter
.
onJudgmentPath
(
pathCompany
,
pathFactoryArea
,
pathFactoryClass
,
pathClass
,
pathShootType
);
showProgressDialog
(
type
);
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
String
path1
=
uploadPath
;
OkHttpClient
client
=
new
OkHttpClient
().
newBuilder
()
.
connectTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
60
,
TimeUnit
.
SECONDS
)
.
build
();
MultipartBody
.
Builder
buildernew
=
new
MultipartBody
.
Builder
()
.
setType
(
MultipartBody
.
FORM
)
.
addFormDataPart
(
"_sid"
,
sid
)
.
addFormDataPart
(
"path"
,
path1
);
for
(
String
path
:
uriList
)
{
File
uploadFile
=
new
File
(
path
);
buildernew
.
addFormDataPart
(
"file"
,
uploadFile
.
getName
(),
RequestBody
.
create
(
MediaType
.
parse
(
"multiparty/form-data"
),
path
));
}
RequestBody
body
=
buildernew
.
build
();
Request
request
=
new
Request
.
Builder
()
.
addHeader
(
"Accept"
,
"*/*"
)
.
url
(
"https://webapp.fpcitc.com.tw/SOP/api/FileUpload/fileUpload"
)
.
method
(
"POST"
,
body
)
.
build
();
Log
.
e
(
"test_url"
,
request
.
url
().
toString
());
try
{
Response
response
=
client
.
newCall
(
request
).
execute
();
Log
.
e
(
"response"
,
response
.
body
().
string
());
dismissProgressDialog
();
// Log.e("isSuccess",json.get("IsSuccess").toString());
mPresenter
.
onLogoutSid
(
sidData
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
dismissProgressDialog
();
// showDialogCaveatMessage("上傳失敗");
Log
.
e
(
"error"
,
""
+
e
.
getMessage
());
}
}
}).
start
();
}
private
DialogInterface
.
OnClickListener
onCompanyDialogItemClick
=
new
DialogInterface
.
OnClickListener
()
{
...
...
@@ -636,7 +532,6 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
tvFactory
.
setText
(
mMainData
.
getmMNTFCTDataList
().
get
(
which
).
getmPZNM
());
pathFactoryArea
=
mMainData
.
getmMNTFCTDataList
().
get
(
which
).
getmPZNM
();
mChooseDeviceItemData
.
setFactoryAreaName
(
mMainData
.
getmMNTFCTDataList
().
get
(
which
).
getmPZNM
());
// mChooseDeviceItemData.setMaintenancePlantCompanyId(mMainData.getmMNTFCTDataList().get(which).getmPZ());
mChooseDeviceItemData
.
setFactoryAreaId
(
mMainData
.
getmMNTFCTDataList
().
get
(
which
).
getmPZ
());
}
...
...
@@ -659,7 +554,6 @@ public class MainActivity extends BaseActivity implements MainContract.View, Vie
tvClass
.
setText
(
mMainData
.
getmEQKDDataList
().
get
(
which
).
getmShift
());
pathClass
=
mMainData
.
getmEQKDDataList
().
get
(
which
).
getmShift
();
mChooseDeviceItemData
.
setDeviceCategory
(
mMainData
.
getmEQKDDataList
().
get
(
which
).
getmShift
());
// mChooseDeviceItemData.setDeviceCategryId(mMainData.getmEQKDDataList().get(which).getmEQKD());
}
};
...
...
app/src/main/java/com/example/audiovisualrecord/ui/main/MainContract.java
View file @
279c854b
...
...
@@ -9,6 +9,7 @@ import com.example.audiovisualrecord.utils.api.searcheqkd.EQKDResponse;
import
com.example.audiovisualrecord.utils.api.searchmntfct.MNTFCTResponse
;
import
com.example.audiovisualrecord.utils.api.searchpmfct.PMFCTResponse
;
import
java.util.ArrayList
;
import
java.util.List
;
public
interface
MainContract
{
...
...
@@ -18,7 +19,7 @@ public interface MainContract {
void
setDPNMData
(
List
<
PMFCTResponse
>
adapterData
);
void
setEQKDData
(
List
<
EQKDResponse
>
adapterData
);
void
setTYPEData
(
List
<
TYPEResponse
>
adapterData
);
void
setSIDData
(
String
sid
);
void
onUploadFile
(
ArrayList
<
String
>
uriList
,
String
type
,
String
sid
);
}
interface
Presenter
<
V
extends
MainContract
.
View
>
{
...
...
@@ -27,9 +28,9 @@ public interface MainContract {
void
onGetPZData
();
void
onGetDPData
(
String
CO
,
String
PZ
);
void
onGetSHIFTData
(
String
CO
,
String
PMFCT
);
void
segVideo
(
String
path
,
String
name
);
ArrayList
<
String
>
segVideo
(
String
path
,
String
name
);
void
onGetTYPEData
(
String
CO
,
String
PMFCT
);
void
onGetSid
();
void
onGetSid
(
ArrayList
<
String
>
uriList
,
String
type
);
void
onLogoutSid
(
String
sid
);
String
onJudgmentPath
(
String
pathCompany
,
String
pathFactoryArea
,
String
pathFactoryClass
,
String
pathClass
,
String
pathShootType
);
...
...
app/src/main/java/com/example/audiovisualrecord/ui/main/MainPresenter.java
View file @
279c854b
...
...
@@ -8,6 +8,7 @@ import com.arthenica.mobileffmpeg.Config;
import
com.arthenica.mobileffmpeg.FFmpeg
;
import
com.arthenica.mobileffmpeg.FFprobe
;
import
com.example.audiovisualrecord.R
;
import
com.example.audiovisualrecord.utils.api.ApiService
;
import
com.example.audiovisualrecord.utils.api.HttpMethods
;
import
com.example.audiovisualrecord.utils.api.apidata.CORequest.CORequest
;
...
...
@@ -44,13 +45,11 @@ public class MainPresenter<V extends MainContract.View> implements MainContract.
private
String
KEY_SEARCH_TYPE
=
"145ce81d-7bae-4848-a38a-e0e738385681"
;
private
String
USER_ID
=
"N000158385"
;
private
String
pathCompany
=
""
;
private
String
pathFactoryArea
=
""
;
private
String
pathFactoryClass
=
""
;
private
String
pathClass
=
""
;
private
String
pathShootType
=
""
;
// private String pathCompany = "";
// private String pathFactoryArea = "";
// private String pathFactoryClass = "";
// private String pathClass = "";
// private String pathShootType = "";
private
V
view
;
private
String
LOGIN_AUTHORIZED_ID
=
"acd9be92-46bf-4185-8721-5b60c67f0742"
;
private
ApiService
api
;
...
...
@@ -61,6 +60,7 @@ public class MainPresenter<V extends MainContract.View> implements MainContract.
this
.
view
=
view
;
api
=
HttpMethods
.
getInstance
().
getApi
();
compositeDisposable
=
new
CompositeDisposable
();
}
@Override
...
...
@@ -215,7 +215,7 @@ public class MainPresenter<V extends MainContract.View> implements MainContract.
}
@Override
public
void
onGetSid
()
{
public
void
onGetSid
(
final
ArrayList
<
String
>
uriList
,
final
String
type
)
{
// TYPERequest mTypeRequest = new TYPERequest(KEY_SEARCH_TYPE,USER_ID,CO, PMFCT);
String
url
=
view
.
getResourceString
(
R
.
string
.
api_on_getSID
);
compositeDisposable
.
add
(
api
.
getSID
(
url
)
...
...
@@ -224,7 +224,8 @@ public class MainPresenter<V extends MainContract.View> implements MainContract.
.
subscribeWith
(
new
DisposableObserver
<
SIDDataList
>()
{
@Override
public
void
onNext
(
SIDDataList
mSIDDataList
)
{
view
.
setSIDData
(
mSIDDataList
.
getsIdDataList
().
getSid
());
view
.
onUploadFile
(
uriList
,
type
,
mSIDDataList
.
getsIdDataList
().
getSid
());
Log
.
e
(
"sss"
,
mSIDDataList
.
getSuccess
());
}
...
...
@@ -271,9 +272,116 @@ public class MainPresenter<V extends MainContract.View> implements MainContract.
}
@Override
public
void
segVideo
(
final
String
path
,
final
String
name
)
{
public
ArrayList
<
String
>
segVideo
(
final
String
path
,
final
String
name
)
{
view
.
showProgressDialog
(
"影片分割中"
);
final
ArrayList
<
String
>
segVideoList
=
new
ArrayList
<>();
// Runnable runnable = new Runnable() {
// @Override
// public void run() {
// File video = new File(path);
// int sizeLimit = 50 * 1024 * 1024;
// Log.e("size", video.length() + "");
//// Log.e("path2", );
// int duration = (int) (FFprobe.getMediaInformation(path).getDuration() / 1000); //影片秒數
// int startTime = 0;
// int segTime = 30; //分割秒數
// int loop = 0;
// if (duration % segTime != 0) {
// loop = duration / segTime + 1;
// } else {
// loop = duration / segTime;
// }
// if (video.length() > sizeLimit) {
// for (int i = 0; i < loop; i++) {
//
// int rc = FFmpeg.execute("-ss " + startTime + " -i " + path + " -t " + segTime + " " + Environment.getExternalStorageDirectory().toString() + "/seg_" + i +"_"+ name);
// segVideoList.add(Environment.getExternalStorageDirectory().toString() + "/seg_" + i +"_"+ name);
//
//
// if (rc == RETURN_CODE_SUCCESS) {
// Log.i(Config.TAG, "Command execution completed successfully.");
// } else if (rc == RETURN_CODE_CANCEL) {
// Log.i(Config.TAG, "Command execution cancelled by user.");
// } else {
//
// Log.i(Config.TAG, String.format("Command execution failed with rc=%d and the output below.", rc));
// Config.printLastCommandOutput(Log.INFO);
// }
// startTime += segTime;
// }
// view.dismissProgressDialog();
//
// } else {
// //沒超過
// segVideoList.add(path);
// view.dismissProgressDialog();
// }
// }
//
// };
// Thread thread = new Thread(runnable);
// view.showProgressDialog("影片分割中");
// thread.start();
// try {
// thread.join();
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// Thread a = new Thread(new Runnable(){
// @Override
// public void run() {
// File video = new File(path);
// int sizeLimit = 50 * 1024 * 1024;
// Log.e("size", video.length() + "");
//// Log.e("path2", );
// int duration = (int) (FFprobe.getMediaInformation(path).getDuration() / 1000); //影片秒數
// int startTime = 0;
// int segTime = 30; //分割秒數
// int loop = 0;
// if (duration % segTime != 0) {
// loop = duration / segTime + 1;
// } else {
// loop = duration / segTime;
// }
// if (video.length() > sizeLimit) {
// for (int i = 0; i < loop; i++) {
//
// int rc = FFmpeg.execute("-ss " + startTime + " -i " + path + " -t " + segTime + " " + Environment.getExternalStorageDirectory().toString() + "/seg_" + i +"_"+ name);
// segVideoList.add(Environment.getExternalStorageDirectory().toString() + "/seg_" + i +"_"+ name);
//
//
// if (rc == RETURN_CODE_SUCCESS) {
// Log.i(Config.TAG, "Command execution completed successfully.");
// } else if (rc == RETURN_CODE_CANCEL) {
// Log.i(Config.TAG, "Command execution cancelled by user.");
// } else {
//
// Log.i(Config.TAG, String.format("Command execution failed with rc=%d and the output below.", rc));
// Config.printLastCommandOutput(Log.INFO);
// }
// startTime += segTime;
// }
// view.dismissProgressDialog();
//
// } else {
// //沒超過
// segVideoList.add(path);
// view.dismissProgressDialog();
// }
// }
// }, "Thread-a");
// a.run();
// a.start();
//
// try {
// a.join();
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
new
Thread
(
new
Runnable
()
{
@Override
...
...
@@ -294,8 +402,8 @@ public class MainPresenter<V extends MainContract.View> implements MainContract.
if
(
video
.
length
()
>
sizeLimit
)
{
for
(
int
i
=
0
;
i
<
loop
;
i
++)
{
int
rc
=
FFmpeg
.
execute
(
"-ss "
+
startTime
+
" -i "
+
path
+
" -t "
+
segTime
+
" "
+
Environment
.
getExternalStorageDirectory
().
toString
()
+
"/seg_"
+
i
+
name
);
int
rc
=
FFmpeg
.
execute
(
"-ss "
+
startTime
+
" -i "
+
path
+
" -t "
+
segTime
+
" "
+
Environment
.
getExternalStorageDirectory
().
toString
()
+
"/seg_"
+
i
+
"_"
+
name
);
segVideoList
.
add
(
Environment
.
getExternalStorageDirectory
().
toString
()
+
"/seg_"
+
i
+
"_"
+
name
);
if
(
rc
==
RETURN_CODE_SUCCESS
)
{
Log
.
i
(
Config
.
TAG
,
"Command execution completed successfully."
);
...
...
@@ -308,16 +416,20 @@ public class MainPresenter<V extends MainContract.View> implements MainContract.
}
startTime
+=
segTime
;
}
view
.
dismissProgressDialog
();
view
.
dismissProgressDialog
();
}
else
{
//沒超過
segVideoList
.
add
(
path
);
view
.
dismissProgressDialog
();
}
}
}).
start
();
Log
.
e
(
"asd"
,
segVideoList
.
size
()+
""
);
return
segVideoList
;
}
@Override
...
...
@@ -339,35 +451,4 @@ public class MainPresenter<V extends MainContract.View> implements MainContract.
return
path
;
}
// @Override
// public void onGetDisposableToken(String DeviceId) {
// String authorizedId ="fec40e7e-48c2-4226-81ca-5044b72a8e1f";
// String url = getView().getResourceString(R.string.api_on_DisposableToken);
// DisposableTokenRequest mDisposableTokenRequest=new DisposableTokenRequest(authorizedId,mLoginPreferencesProvider.getToken(),DeviceId);
// getCompositeDisposable().add(getApiService().onDisposableToken(url, mDisposableTokenRequest)
// .subscribeOn(getSchedulerProvider().io())
// .observeOn(getSchedulerProvider().ui())
// .subscribeWith(new DisposableObserver<DisposableTokenResponse>() {
// @Override
// public void onNext(DisposableTokenResponse disposableTokenResponse) {
// Log.e("wwwww","getmResult:"+disposableTokenResponse.getmResult());
// Log.e("wwwww","getmErrMsg:"+disposableTokenResponse.getmErrMsg());
// Log.e("wwwww","getmDisposableToken:"+disposableTokenResponse.getmDisposableToken());
//
// }
//
// @Override
// public void onError(Throwable e) {
//
// }
//
// @Override
// public void onComplete() {
//
// }
// })
// );
// }
}
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