AskPresenter.java
2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Copyright (c) 2016 wugian
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.xgimi.gimicinema.presenter;
import android.content.Context;
import android.util.Log;
import com.gimi.common.cinema.utils.ShellUtils;
import com.xgimi.gimicinema.BuildConfig;
import com.xgimi.gimicinema.model.IOtherModel;
import com.xgimi.gimicinema.model.ISambaModel;
import com.xgimi.gimicinema.model.OtherModelImpl;
import com.xgimi.gimicinema.model.SambaModelImpl;
import com.xgimi.gimicinema.mview.IAskView;
import java.util.ArrayList;
/**
* Created by wugian on 2016/10/10
*/
public class AskPresenter implements SambaModelImpl.OnSambaMountListener,
OtherModelImpl.OnScanOtherMovieListener, OtherModelImpl.OnScanMultiMovieListener {
private ISambaModel sambaModel;
private IOtherModel otherModel;
private IAskView askView;
public AskPresenter(IAskView askView) {
this.sambaModel = new SambaModelImpl();
this.otherModel = new OtherModelImpl();
this.askView = askView;
}
public void load(Context context) {
Log.d("lovely", "╟ service mount");
if (!BuildConfig.MACHINE_TYPE.equals("himedia")) {
Log.d("lovely", "╟ service mount if");
sambaModel.mountSamba(context, this);
} else {
ShellUtils.execCommand(new String[]{"su", "start adbd"}, false);
Log.d("lovely", "╟ service mount else");
}
}
public void playMovie(Context context, String path) {
otherModel.scanOtherMovies(context, path, this);
}
@Override
public void onSambaMountSuccess() {
}
@Override
public void onSambaMountFailure(int code, String wrongMsg) {
}
public void umountSamba() {
Log.d("lovely", "╟ service umount");
// sambaModel.umountSamba();
}
@Override
public void onScanOtherMovieSuccess(ArrayList<String> result) {
if (result.size() <= 1) {
askView.playPath();
} else if (result.size() > 1) {
askView.playPath(result, 0);
}
}
public void playMultiMovie(Context contexts, String[] movie_urls, int position) {
otherModel.scanMultiMovies(contexts, movie_urls, position, this);
}
@Override
public void onScanMultiMovieSuccess(ArrayList<String> result, int position) {
askView.playPath(result, position);
}
@Override
public void onScanMultiMovieFailure(String msg) {
askView.showMsg(msg);
}
}