Commit 25c70ef2fea19fd3f562bd2fd0398dbefea74f9a
Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/newModuleStrike
Conflicts: .idea/inspectionProfiles/Project_Default.xml
Showing
35 changed files
with
891 additions
and
180 deletions
.idea/inspectionProfiles/Project_Default.xml
| 1 | <component name="InspectionProjectProfileManager"> | 1 | <component name="InspectionProjectProfileManager"> |
| 2 | <profile version="1.0"> | 2 | <profile version="1.0"> |
| 3 | <option name="myName" value="Project Default" /> | 3 | <option name="myName" value="Project Default" /> |
| 4 | - <inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true"> | ||
| 5 | - <option name="TOP_LEVEL_CLASS_OPTIONS"> | ||
| 6 | - <value> | ||
| 7 | - <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||
| 8 | - <option name="REQUIRED_TAGS" value="" /> | ||
| 9 | - </value> | ||
| 10 | - </option> | ||
| 11 | - <option name="INNER_CLASS_OPTIONS"> | ||
| 12 | - <value> | ||
| 13 | - <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||
| 14 | - <option name="REQUIRED_TAGS" value="" /> | ||
| 15 | - </value> | ||
| 16 | - </option> | ||
| 17 | - <option name="METHOD_OPTIONS"> | ||
| 18 | - <value> | ||
| 19 | - <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||
| 20 | - <option name="REQUIRED_TAGS" value="@return@param@throws or @exception" /> | ||
| 21 | - </value> | ||
| 22 | - </option> | ||
| 23 | - <option name="FIELD_OPTIONS"> | ||
| 24 | - <value> | ||
| 25 | - <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | ||
| 26 | - <option name="REQUIRED_TAGS" value="" /> | ||
| 27 | - </value> | ||
| 28 | - </option> | ||
| 29 | - <option name="IGNORE_DEPRECATED" value="false" /> | ||
| 30 | - <option name="IGNORE_JAVADOC_PERIOD" value="true" /> | ||
| 31 | - <option name="IGNORE_DUPLICATED_THROWS" value="false" /> | ||
| 32 | - <option name="IGNORE_POINT_TO_ITSELF" value="false" /> | ||
| 33 | - <option name="myAdditionalJavadocTags" value="date" /> | ||
| 34 | - </inspection_tool> | 4 | + <inspection_tool class="AndroidLintLockedOrientationActivity" enabled="false" level="ERROR" enabled_by_default="false" /> |
| 5 | + <inspection_tool class="AndroidLintSourceLockedOrientationActivity" enabled="false" level="ERROR" enabled_by_default="false" /> | ||
| 35 | </profile> | 6 | </profile> |
| 36 | </component> | 7 | </component> |
| 37 | \ No newline at end of file | 8 | \ No newline at end of file |
.idea/misc.xml
| @@ -39,7 +39,7 @@ | @@ -39,7 +39,7 @@ | ||
| 39 | </value> | 39 | </value> |
| 40 | </option> | 40 | </option> |
| 41 | </component> | 41 | </component> |
| 42 | - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK"> | 42 | + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> |
| 43 | <output url="file://$PROJECT_DIR$/build/classes" /> | 43 | <output url="file://$PROJECT_DIR$/build/classes" /> |
| 44 | </component> | 44 | </component> |
| 45 | <component name="ProjectType"> | 45 | <component name="ProjectType"> |
app/strike/src/main/AndroidManifest.xml
| @@ -34,20 +34,20 @@ | @@ -34,20 +34,20 @@ | ||
| 34 | </provider> | 34 | </provider> |
| 35 | <activity | 35 | <activity |
| 36 | android:name="com.cnlive.strike.demo.activity.tiktok.TikTokViewPager2Activity" | 36 | android:name="com.cnlive.strike.demo.activity.tiktok.TikTokViewPager2Activity" |
| 37 | - android:screenOrientation="fullSensor" /> | 37 | + android:screenOrientation="portrait" /> |
| 38 | <activity | 38 | <activity |
| 39 | android:name="com.cnlive.strike.demo.activity.tiktok.TikTokRecycleActivity" | 39 | android:name="com.cnlive.strike.demo.activity.tiktok.TikTokRecycleActivity" |
| 40 | - android:screenOrientation="fullSensor" /> | 40 | + android:screenOrientation="portrait" /> |
| 41 | <activity | 41 | <activity |
| 42 | android:name="com.cnlive.strike.demo.activity.tiktok.DemoTikTokActivity" | 42 | android:name="com.cnlive.strike.demo.activity.tiktok.DemoTikTokActivity" |
| 43 | - android:screenOrientation="fullSensor" /> | 43 | + android:screenOrientation="portrait" /> |
| 44 | <activity | 44 | <activity |
| 45 | android:name="com.cnlive.strike.demo.activity.tiktok.TikTokVerticalViewPagerActivity" | 45 | android:name="com.cnlive.strike.demo.activity.tiktok.TikTokVerticalViewPagerActivity" |
| 46 | - android:screenOrientation="fullSensor" /> | 46 | + android:screenOrientation="portrait"/> |
| 47 | <activity | 47 | <activity |
| 48 | android:name="com.cnlive.strike.demo.activity.ExoPlayerActivity" | 48 | android:name="com.cnlive.strike.demo.activity.ExoPlayerActivity" |
| 49 | android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | 49 | android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" |
| 50 | - android:screenOrientation="fullSensor" /> | 50 | + android:screenOrientation="portrait" /> |
| 51 | <activity android:name="com.cnlive.strike.demo.activity.CNplayerActivity" /> | 51 | <activity android:name="com.cnlive.strike.demo.activity.CNplayerActivity" /> |
| 52 | <activity android:name="com.cnlive.strike.demo.activity.DemoAnimActivity" /> | 52 | <activity android:name="com.cnlive.strike.demo.activity.DemoAnimActivity" /> |
| 53 | <activity | 53 | <activity |
app/strike/src/main/java/com/cnlive/strike/DemoApplication.java
| @@ -101,7 +101,7 @@ public class DemoApplication extends BaseApplication { | @@ -101,7 +101,7 @@ public class DemoApplication extends BaseApplication { | ||
| 101 | // .setPlayerFactory(ThunderMediaPlayerFactory.create()) | 101 | // .setPlayerFactory(ThunderMediaPlayerFactory.create()) |
| 102 | .setPlayerFactory(ExoMediaPlayerFactory.create()) | 102 | .setPlayerFactory(ExoMediaPlayerFactory.create()) |
| 103 | .setRenderViewFactory(TextureRenderViewFactory.create()) | 103 | .setRenderViewFactory(TextureRenderViewFactory.create()) |
| 104 | - .setEnableOrientation(true) | 104 | + .setEnableOrientation(false) |
| 105 | // .setEnableAudioFocus(false) | 105 | // .setEnableAudioFocus(false) |
| 106 | // .setScreenScaleType(VideoView.SCREEN_SCALE_MATCH_PARENT) | 106 | // .setScreenScaleType(VideoView.SCREEN_SCALE_MATCH_PARENT) |
| 107 | // .setAdaptCutout(false) | 107 | // .setAdaptCutout(false) |
app/strike/src/main/java/com/cnlive/strike/demo/activity/ExoPlayerActivity.java
| @@ -18,10 +18,13 @@ import com.google.android.exoplayer2.source.hls.HlsMediaSource; | @@ -18,10 +18,13 @@ import com.google.android.exoplayer2.source.hls.HlsMediaSource; | ||
| 18 | import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; | 18 | import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; |
| 19 | import com.google.android.exoplayer2.util.Util; | 19 | import com.google.android.exoplayer2.util.Util; |
| 20 | import com.google.android.exoplayer2.video.VideoListener; | 20 | import com.google.android.exoplayer2.video.VideoListener; |
| 21 | +import com.libs.video.util.cache.PreloadManager; | ||
| 21 | import com.libs.video.util.cache.ProxyVideoCacheManager; | 22 | import com.libs.video.util.cache.ProxyVideoCacheManager; |
| 22 | import com.libs.video.video.exoplayer.component.DefaultErrorView; | 23 | import com.libs.video.video.exoplayer.component.DefaultErrorView; |
| 23 | import com.libs.video.video.exoplayer.component.DefaultYoukuPrepareView; | 24 | import com.libs.video.video.exoplayer.component.DefaultYoukuPrepareView; |
| 24 | import com.libs.video.video.exoplayer.play.CNVideoView; | 25 | import com.libs.video.video.exoplayer.play.CNVideoView; |
| 26 | +import com.libs.video.video.exoplayer.playerCore.exoplayer.ExoMediaSourceHelper; | ||
| 27 | +import com.libs.video.video.exoplayer.util.PlayCacheUtils; | ||
| 25 | import com.libs.video.video.test.CNLiveVideoView; | 28 | import com.libs.video.video.test.CNLiveVideoView; |
| 26 | import com.libs.video.video.test.VideoPlayer; | 29 | import com.libs.video.video.test.VideoPlayer; |
| 27 | import com.libs.video.video.exoplayer.component.DefaultAdControlView; | 30 | import com.libs.video.video.exoplayer.component.DefaultAdControlView; |
| @@ -44,6 +47,7 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | @@ -44,6 +47,7 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | ||
| 44 | private static final String URL_AD = "https://gslb.miaopai.com/stream/IR3oMYDhrON5huCmf7sHCfnU5YKEkgO2.mp4"; | 47 | private static final String URL_AD = "https://gslb.miaopai.com/stream/IR3oMYDhrON5huCmf7sHCfnU5YKEkgO2.mp4"; |
| 45 | 48 | ||
| 46 | private StandardVideoController mController; | 49 | private StandardVideoController mController; |
| 50 | + private PreloadManager mPreloadManager; | ||
| 47 | 51 | ||
| 48 | @Override | 52 | @Override |
| 49 | protected int getBindLayoutId() { | 53 | protected int getBindLayoutId() { |
| @@ -82,7 +86,6 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | @@ -82,7 +86,6 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | ||
| 82 | player.prepare(hlsMediaSource); | 86 | player.prepare(hlsMediaSource); |
| 83 | 87 | ||
| 84 | 88 | ||
| 85 | - | ||
| 86 | mController = new StandardVideoController(this); | 89 | mController = new StandardVideoController(this); |
| 87 | DefaultAdControlView adControlView = new DefaultAdControlView(this); | 90 | DefaultAdControlView adControlView = new DefaultAdControlView(this); |
| 88 | adControlView.setListener(new DefaultAdControlView.AdControlListener() { | 91 | adControlView.setListener(new DefaultAdControlView.AdControlListener() { |
| @@ -96,15 +99,13 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | @@ -96,15 +99,13 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | ||
| 96 | playVideo(); | 99 | playVideo(); |
| 97 | } | 100 | } |
| 98 | }); | 101 | }); |
| 99 | - DefaultErrorView errorView=new DefaultErrorView(this); | ||
| 100 | - mController.addControlComponent(adControlView,new DefaultYoukuPrepareView(me),errorView); | 102 | + DefaultErrorView errorView = new DefaultErrorView(this); |
| 103 | + mController.addControlComponent(adControlView, new DefaultYoukuPrepareView(me), errorView); | ||
| 101 | //直播 | 104 | //直播 |
| 102 | - HttpProxyCacheServer cacheServer = ProxyVideoCacheManager.getProxy(this); | ||
| 103 | - String proxyUrl = cacheServer.getProxyUrl(URL_AD); | ||
| 104 | - binding.playerView.setUrl(proxyUrl); | ||
| 105 | -// binding.playerView.setUrl("http://ffyl.vods2.cnlive.com/223/vod/2018/1120/223_88c98ab1395f4762b703fbdd9d59d2e5/ff80808166c2a45201672f14a9933131_800.m3u8"); | 105 | +// binding.playerView.setUrl(proxyUrl); |
| 106 | + binding.playerView.setUrl("http://ffyl.vods2.cnlive.com/223/vod/2018/1120/223_88c98ab1395f4762b703fbdd9d59d2e5/ff80808166c2a45201672f14a9933131_800.m3u8", true); | ||
| 106 | binding.playerView.setVideoController(mController); | 107 | binding.playerView.setVideoController(mController); |
| 107 | - binding.playerView.setScreenScaleType(CNVideoView.SCREEN_SCALE_16_9); | 108 | +// binding.playerView.setScreenScaleType(CNVideoView.SCREEN_SCALE_16_9); |
| 108 | binding.playerView.start(); | 109 | binding.playerView.start(); |
| 109 | //监听播放结束 | 110 | //监听播放结束 |
| 110 | // binding.playerView.addOnStateChangeListener(new CNVideoView.SimpleOnStateChangeListener() { | 111 | // binding.playerView.addOnStateChangeListener(new CNVideoView.SimpleOnStateChangeListener() { |
| @@ -154,7 +155,7 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | @@ -154,7 +155,7 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | ||
| 154 | private void playVideo() { | 155 | private void playVideo() { |
| 155 | binding.playerView.release(); | 156 | binding.playerView.release(); |
| 156 | mController.removeAllControlComponent(); | 157 | mController.removeAllControlComponent(); |
| 157 | - mController.addDefaultControlComponent("正片", true); | 158 | + mController.addDefaultControlComponent("正片", false); |
| 158 | //重新设置数据 | 159 | //重新设置数据 |
| 159 | // List<String> list = new ArrayList<>(); | 160 | // List<String> list = new ArrayList<>(); |
| 160 | // list.add("http://sbslive.cnrmobile.com/storage/storage4/76/23/10/14de52115893fb5371b7e064f910ab7b.3gp"); | 161 | // list.add("http://sbslive.cnrmobile.com/storage/storage4/76/23/10/14de52115893fb5371b7e064f910ab7b.3gp"); |
| @@ -162,8 +163,8 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | @@ -162,8 +163,8 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | ||
| 162 | // list.add("http://ffyl.vods2.cnlive.com/223/vod/2018/1120/223_88c98ab1395f4762b703fbdd9d59d2e5/ff80808166c2a45201672f14a9933131_800.m3u8"); | 163 | // list.add("http://ffyl.vods2.cnlive.com/223/vod/2018/1120/223_88c98ab1395f4762b703fbdd9d59d2e5/ff80808166c2a45201672f14a9933131_800.m3u8"); |
| 163 | // list.add("http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8"); | 164 | // list.add("http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8"); |
| 164 | // binding.playerView.setDataSource(list); | 165 | // binding.playerView.setDataSource(list); |
| 165 | - binding.playerView.setUrl("rtmp://tyzg.rtmps2.cnlive.com/live-tyzg-577/577_999"); | ||
| 166 | - | 166 | + binding.playerView.setUrl("https://qq.com-ok-qq.com/20191005/24249_f5e36323/index.m3u8", true); |
| 167 | +// binding.playerView.setUrl("rtmp://tyzg.rtmps2.cnlive.com/live-tyzg-577/577_999"); | ||
| 167 | //开始播放 | 168 | //开始播放 |
| 168 | binding.playerView.start(); | 169 | binding.playerView.start(); |
| 169 | } | 170 | } |
| @@ -187,4 +188,6 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | @@ -187,4 +188,6 @@ public class ExoPlayerActivity extends BaseActivity implements VideoListener, Pl | ||
| 187 | // }); | 188 | // }); |
| 188 | } | 189 | } |
| 189 | 190 | ||
| 191 | + | ||
| 192 | + | ||
| 190 | } | 193 | } |
app/strike/src/main/java/com/cnlive/strike/imgutil/UgcActivity.java
| @@ -4,6 +4,7 @@ import android.content.Intent; | @@ -4,6 +4,7 @@ import android.content.Intent; | ||
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | 5 | ||
| 6 | import com.cnlive.cloud.R; | 6 | import com.cnlive.cloud.R; |
| 7 | +import com.cnlive.core.company_verfication.ui.activity.FillInCompanyDataActivity; | ||
| 7 | import com.cnlive.core.people_verfication.activity.TakeIdentityPictureActivity; | 8 | import com.cnlive.core.people_verfication.activity.TakeIdentityPictureActivity; |
| 8 | 9 | ||
| 9 | import androidx.appcompat.app.AppCompatActivity; | 10 | import androidx.appcompat.app.AppCompatActivity; |
| @@ -15,5 +16,6 @@ public class UgcActivity extends AppCompatActivity { | @@ -15,5 +16,6 @@ public class UgcActivity extends AppCompatActivity { | ||
| 15 | super.onCreate(savedInstanceState); | 16 | super.onCreate(savedInstanceState); |
| 16 | setContentView(R.layout.activity_ugc); | 17 | setContentView(R.layout.activity_ugc); |
| 17 | findViewById(R.id.people_denty).setOnClickListener(view -> startActivity(new Intent(this, TakeIdentityPictureActivity.class))); | 18 | findViewById(R.id.people_denty).setOnClickListener(view -> startActivity(new Intent(this, TakeIdentityPictureActivity.class))); |
| 19 | + findViewById(R.id.company_denty).setOnClickListener(view -> startActivity(new Intent(this, FillInCompanyDataActivity.class))); | ||
| 18 | } | 20 | } |
| 19 | } | 21 | } |
app/strike/src/main/res/layout/activity_ugc.xml
| @@ -4,12 +4,20 @@ | @@ -4,12 +4,20 @@ | ||
| 4 | xmlns:tools="http://schemas.android.com/tools" | 4 | xmlns:tools="http://schemas.android.com/tools" |
| 5 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
| 6 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
| 7 | + android:orientation="vertical" | ||
| 7 | tools:context="com.cnlive.strike.imgutil.UgcActivity"> | 8 | tools:context="com.cnlive.strike.imgutil.UgcActivity"> |
| 8 | 9 | ||
| 9 | <Button | 10 | <Button |
| 10 | android:id="@+id/people_denty" | 11 | android:id="@+id/people_denty" |
| 11 | - android:layout_width="wrap_content" | 12 | + android:layout_width="match_parent" |
| 12 | android:layout_height="wrap_content" | 13 | android:layout_height="wrap_content" |
| 13 | - android:text="个人认证" | ||
| 14 | - /> | 14 | + android:layout_margin="@dimen/dp_10" |
| 15 | + android:text="个人认证" /> | ||
| 16 | + | ||
| 17 | + <Button | ||
| 18 | + android:id="@+id/company_denty" | ||
| 19 | + android:layout_width="match_parent" | ||
| 20 | + android:layout_height="wrap_content" | ||
| 21 | + android:layout_margin="@dimen/dp_10" | ||
| 22 | + android:text="机构认证" /> | ||
| 15 | </LinearLayout> | 23 | </LinearLayout> |
cloud/video/src/main/java/com/danikula/videocache/StorageUtils.java
| @@ -37,7 +37,7 @@ public final class StorageUtils { | @@ -37,7 +37,7 @@ public final class StorageUtils { | ||
| 37 | * <i>("/Android/data/[app_package_name]/cache")</i> (if card is mounted and app has appropriate permission) or | 37 | * <i>("/Android/data/[app_package_name]/cache")</i> (if card is mounted and app has appropriate permission) or |
| 38 | * on device's file system depending incoming parameters. | 38 | * on device's file system depending incoming parameters. |
| 39 | * | 39 | * |
| 40 | - * @param context Application context | 40 | + * @param context Application context |
| 41 | * @return Cache {@link File directory}.<br /> | 41 | * @return Cache {@link File directory}.<br /> |
| 42 | * <b>NOTE:</b> Can be null in some unpredictable cases (if SD card is unmounted and | 42 | * <b>NOTE:</b> Can be null in some unpredictable cases (if SD card is unmounted and |
| 43 | * {@link Context#getCacheDir() Context.getCacheDir()} returns null). | 43 | * {@link Context#getCacheDir() Context.getCacheDir()} returns null). |
| @@ -58,6 +58,26 @@ public final class StorageUtils { | @@ -58,6 +58,26 @@ public final class StorageUtils { | ||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | /** | 60 | /** |
| 61 | + * 获取缓存路径 | ||
| 62 | + * | ||
| 63 | + * @param context | ||
| 64 | + * @return | ||
| 65 | + */ | ||
| 66 | + public static String getCacheDirectoryPath(Context context) { | ||
| 67 | + String appCacheDir = null; | ||
| 68 | + if (MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { | ||
| 69 | + appCacheDir = context.getExternalCacheDir().getAbsolutePath(); | ||
| 70 | + } | ||
| 71 | + if (appCacheDir == null) { | ||
| 72 | + appCacheDir = context.getCacheDir().getAbsolutePath(); | ||
| 73 | + } | ||
| 74 | + if (appCacheDir == null) { | ||
| 75 | + appCacheDir = "/data/data/" + context.getPackageName() + "/cache/"; | ||
| 76 | + } | ||
| 77 | + return appCacheDir; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + /** | ||
| 61 | * delete directory | 81 | * delete directory |
| 62 | */ | 82 | */ |
| 63 | public static boolean deleteFiles(File root) { | 83 | public static boolean deleteFiles(File root) { |
cloud/video/src/main/java/com/libs/video/util/cache/ProxyVideoCacheManager.java
| @@ -20,7 +20,7 @@ public class ProxyVideoCacheManager { | @@ -20,7 +20,7 @@ public class ProxyVideoCacheManager { | ||
| 20 | 20 | ||
| 21 | private static HttpProxyCacheServer newProxy(Context context) { | 21 | private static HttpProxyCacheServer newProxy(Context context) { |
| 22 | return new HttpProxyCacheServer.Builder(context) | 22 | return new HttpProxyCacheServer.Builder(context) |
| 23 | - .maxCacheSize(512 * 1024 * 1024) // 512MB for cache | 23 | + .maxCacheSize(1024 * 1024 * 1024) // 512MB for cache |
| 24 | //缓存路径,不设置默认在sd_card/Android/data/[app_package_name]/cache中 | 24 | //缓存路径,不设置默认在sd_card/Android/data/[app_package_name]/cache中 |
| 25 | // .cacheDirectory() | 25 | // .cacheDirectory() |
| 26 | .build(); | 26 | .build(); |
cloud/video/src/main/java/com/libs/video/video/exoplayer/PlayErrorException.java
| @@ -5,8 +5,6 @@ import android.text.TextUtils; | @@ -5,8 +5,6 @@ import android.text.TextUtils; | ||
| 5 | 5 | ||
| 6 | import androidx.annotation.IntDef; | 6 | import androidx.annotation.IntDef; |
| 7 | 7 | ||
| 8 | -import com.cnlive.core.libs.base.util.StatusBarConfig; | ||
| 9 | - | ||
| 10 | import java.lang.annotation.Retention; | 8 | import java.lang.annotation.Retention; |
| 11 | import java.lang.annotation.RetentionPolicy; | 9 | import java.lang.annotation.RetentionPolicy; |
| 12 | 10 | ||
| @@ -19,26 +17,20 @@ public class PlayErrorException extends Exception { | @@ -19,26 +17,20 @@ public class PlayErrorException extends Exception { | ||
| 19 | public static final int TYPE_OUT_OF_MEMORY = 2;//内存溢出 | 17 | public static final int TYPE_OUT_OF_MEMORY = 2;//内存溢出 |
| 20 | public static final int TYPE_UNEXPECTED_ERROR = 3;//未知错误 | 18 | public static final int TYPE_UNEXPECTED_ERROR = 3;//未知错误 |
| 21 | public static final int TYPE_RENDERER_ERROR = 4;//渲染异常 | 19 | public static final int TYPE_RENDERER_ERROR = 4;//渲染异常 |
| 22 | - public static final int TYPE_MediaPlayer_IOException = 5; | ||
| 23 | - public static final int TYPE_MediaPlayer_IllegalArgumentException = 6; | ||
| 24 | - public static final int TYPE_MediaPlayer_SecurityException = 7; | ||
| 25 | - public static final int TYPE_MediaPlayer_IllegalStateException = 8; | ||
| 26 | - public static final int TYPE_MediaPlayer_unknownException = 9; | ||
| 27 | - public static final int TYPE_MediaPlayer_ON_ERROR = 10; | ||
| 28 | - | ||
| 29 | - | 20 | + public static final int TYPE_IllegalArgumentException = 5; |
| 21 | + public static final int TYPE_SecurityException = 6; | ||
| 22 | + public static final int TYPE_IllegalStateException = 7; | ||
| 23 | + public static final int TYPE_TIMED_OUT_ERROR = 9;//播放超时错误 | ||
| 24 | + public static final int TYPE_MEDIA_UNSUPPORTED_ERROR = 10;//不支持的媒体类型 | ||
| 25 | + public static final int TYPE_MEDIA_SERVER_DIED_ERROR = 11;//媒体服务器挂机(应用必须释放对象,然后开启新的实例) | ||
| 26 | + public static final int TYPE_OTHER_ERROR = 12;//其他错误 | ||
| 30 | private int errorType;//错误类型 | 27 | private int errorType;//错误类型 |
| 31 | private String errorMsg;//错误信息 | 28 | private String errorMsg;//错误信息 |
| 32 | 29 | ||
| 33 | 30 | ||
| 34 | - private MediaPlayer mediaPlayer; | ||
| 35 | - private int mediaPlayer_what; | ||
| 36 | - private int mediaPlayer_extra; | ||
| 37 | - | ||
| 38 | - | ||
| 39 | @IntDef({TYPE_NETWORK_ERROR, TYPE_SOURCE_ERROR, TYPE_OUT_OF_MEMORY, TYPE_UNEXPECTED_ERROR, TYPE_RENDERER_ERROR, | 31 | @IntDef({TYPE_NETWORK_ERROR, TYPE_SOURCE_ERROR, TYPE_OUT_OF_MEMORY, TYPE_UNEXPECTED_ERROR, TYPE_RENDERER_ERROR, |
| 40 | - TYPE_MediaPlayer_IOException, TYPE_MediaPlayer_IllegalArgumentException, TYPE_MediaPlayer_SecurityException, | ||
| 41 | - TYPE_MediaPlayer_IllegalStateException, TYPE_MediaPlayer_unknownException, TYPE_MediaPlayer_ON_ERROR}) | 32 | + TYPE_IllegalArgumentException, TYPE_SecurityException, TYPE_IllegalStateException, |
| 33 | + TYPE_TIMED_OUT_ERROR,TYPE_MEDIA_UNSUPPORTED_ERROR,TYPE_MEDIA_SERVER_DIED_ERROR,TYPE_OTHER_ERROR}) | ||
| 42 | @Retention(RetentionPolicy.SOURCE) | 34 | @Retention(RetentionPolicy.SOURCE) |
| 43 | public @interface Type { | 35 | public @interface Type { |
| 44 | } | 36 | } |
| @@ -70,27 +62,4 @@ public class PlayErrorException extends Exception { | @@ -70,27 +62,4 @@ public class PlayErrorException extends Exception { | ||
| 70 | this.errorMsg = errorMsg; | 62 | this.errorMsg = errorMsg; |
| 71 | } | 63 | } |
| 72 | 64 | ||
| 73 | - public MediaPlayer getMediaPlayer() { | ||
| 74 | - return mediaPlayer; | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - public void setMediaPlayer(MediaPlayer mediaPlayer) { | ||
| 78 | - this.mediaPlayer = mediaPlayer; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - public int getMediaPlayer_what() { | ||
| 82 | - return mediaPlayer_what; | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | - public void setMediaPlayer_what(int mediaPlayer_what) { | ||
| 86 | - this.mediaPlayer_what = mediaPlayer_what; | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - public int getMediaPlayer_extra() { | ||
| 90 | - return mediaPlayer_extra; | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - public void setMediaPlayer_extra(int mediaPlayer_extra) { | ||
| 94 | - this.mediaPlayer_extra = mediaPlayer_extra; | ||
| 95 | - } | ||
| 96 | } | 65 | } |
cloud/video/src/main/java/com/libs/video/video/exoplayer/component/DebugInfoView.java
| @@ -13,7 +13,7 @@ import android.widget.TextView; | @@ -13,7 +13,7 @@ import android.widget.TextView; | ||
| 13 | import com.libs.video.video.exoplayer.PlayErrorException; | 13 | import com.libs.video.video.exoplayer.PlayErrorException; |
| 14 | import com.libs.video.video.exoplayer.controller.ControlWrapper; | 14 | import com.libs.video.video.exoplayer.controller.ControlWrapper; |
| 15 | import com.libs.video.video.exoplayer.controller.IControlComponent; | 15 | import com.libs.video.video.exoplayer.controller.IControlComponent; |
| 16 | -import com.libs.video.video.exoplayer.play.AndroidMediaPlayerFactory; | 16 | +import com.libs.video.video.exoplayer.playerCore.mediaplayer.AndroidMediaPlayerFactory; |
| 17 | import com.libs.video.video.exoplayer.playerCore.exoplayer.ExoMediaPlayerFactory; | 17 | import com.libs.video.video.exoplayer.playerCore.exoplayer.ExoMediaPlayerFactory; |
| 18 | import com.libs.video.video.exoplayer.util.PlayerUtils; | 18 | import com.libs.video.video.exoplayer.util.PlayerUtils; |
| 19 | 19 |
cloud/video/src/main/java/com/libs/video/video/exoplayer/controller/MediaPlayerControl.java
| @@ -9,7 +9,6 @@ import com.libs.video.video.exoplayer.play.AbstractPlayer; | @@ -9,7 +9,6 @@ import com.libs.video.video.exoplayer.play.AbstractPlayer; | ||
| 9 | */ | 9 | */ |
| 10 | public interface MediaPlayerControl { | 10 | public interface MediaPlayerControl { |
| 11 | 11 | ||
| 12 | -// int getMediaCount(); | ||
| 13 | 12 | ||
| 14 | void start(); | 13 | void start(); |
| 15 | 14 |
cloud/video/src/main/java/com/libs/video/video/exoplayer/play/AbstractPlayer.java
| 1 | package com.libs.video.video.exoplayer.play; | 1 | package com.libs.video.video.exoplayer.play; |
| 2 | 2 | ||
| 3 | +import android.content.Context; | ||
| 3 | import android.content.res.AssetFileDescriptor; | 4 | import android.content.res.AssetFileDescriptor; |
| 4 | import android.view.Surface; | 5 | import android.view.Surface; |
| 5 | import android.view.SurfaceHolder; | 6 | import android.view.SurfaceHolder; |
| @@ -53,11 +54,29 @@ public abstract class AbstractPlayer { | @@ -53,11 +54,29 @@ public abstract class AbstractPlayer { | ||
| 53 | */ | 54 | */ |
| 54 | public abstract void setDataSource(String path, Map<String, String> headers); | 55 | public abstract void setDataSource(String path, Map<String, String> headers); |
| 55 | 56 | ||
| 57 | + | ||
| 58 | + public abstract void setDataSource(String path, Map<String, String> headers, boolean isCache); | ||
| 59 | + | ||
| 56 | /** | 60 | /** |
| 57 | * 用于播放raw和asset里面的视频文件 | 61 | * 用于播放raw和asset里面的视频文件 |
| 58 | */ | 62 | */ |
| 59 | public abstract void setDataSource(AssetFileDescriptor fd); | 63 | public abstract void setDataSource(AssetFileDescriptor fd); |
| 60 | 64 | ||
| 65 | +// /** | ||
| 66 | +// * 清除全部视频缓存 | ||
| 67 | +// * | ||
| 68 | +// * @param context | ||
| 69 | +// */ | ||
| 70 | +// public abstract void clearAllCache(Context context); | ||
| 71 | +// | ||
| 72 | +// /** | ||
| 73 | +// * 根据url清除指定视频缓存 | ||
| 74 | +// * | ||
| 75 | +// * @param context | ||
| 76 | +// * @param url | ||
| 77 | +// */ | ||
| 78 | +// public abstract void clearDefaultCache(Context context, String url); | ||
| 79 | + | ||
| 61 | /** | 80 | /** |
| 62 | * 播放 | 81 | * 播放 |
| 63 | */ | 82 | */ |
cloud/video/src/main/java/com/libs/video/video/exoplayer/play/CNVideoView.java
| @@ -128,6 +128,8 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | @@ -128,6 +128,8 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | ||
| 128 | */ | 128 | */ |
| 129 | private int mPlayerBackgroundColor; | 129 | private int mPlayerBackgroundColor; |
| 130 | 130 | ||
| 131 | + private boolean isCache;//是否边缓存边播放 | ||
| 132 | + | ||
| 131 | // private List<String> dataSource; | 133 | // private List<String> dataSource; |
| 132 | // private int curentPlayIndex; | 134 | // private int curentPlayIndex; |
| 133 | 135 | ||
| @@ -237,7 +239,7 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | @@ -237,7 +239,7 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | ||
| 237 | if (mProgressManager != null) { | 239 | if (mProgressManager != null) { |
| 238 | mCurrentPosition = mProgressManager.getSavedProgress(mUrl); | 240 | mCurrentPosition = mProgressManager.getSavedProgress(mUrl); |
| 239 | } | 241 | } |
| 240 | - initPlayer(); | 242 | + initPlayer(); |
| 241 | //添加渲染视图 | 243 | //添加渲染视图 |
| 242 | addDisplay(); | 244 | addDisplay(); |
| 243 | startPrepare(false); | 245 | startPrepare(false); |
| @@ -272,7 +274,7 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | @@ -272,7 +274,7 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | ||
| 272 | * 初始化播放器 | 274 | * 初始化播放器 |
| 273 | */ | 275 | */ |
| 274 | protected void initPlayer() { | 276 | protected void initPlayer() { |
| 275 | - if (null==mMediaPlayer){ | 277 | + if (null == mMediaPlayer) { |
| 276 | //初始化播放器 | 278 | //初始化播放器 |
| 277 | mMediaPlayer = mPlayerFactory.createPlayer(getContext()); | 279 | mMediaPlayer = mPlayerFactory.createPlayer(getContext()); |
| 278 | } | 280 | } |
| @@ -341,7 +343,7 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | @@ -341,7 +343,7 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | ||
| 341 | mMediaPlayer.setDataSource(mAssetFileDescriptor); | 343 | mMediaPlayer.setDataSource(mAssetFileDescriptor); |
| 342 | return true; | 344 | return true; |
| 343 | } else if (!TextUtils.isEmpty(mUrl)) { | 345 | } else if (!TextUtils.isEmpty(mUrl)) { |
| 344 | - mMediaPlayer.setDataSource(mUrl, mHeaders); | 346 | + mMediaPlayer.setDataSource(mUrl, mHeaders, isCache); |
| 345 | return true; | 347 | return true; |
| 346 | } | 348 | } |
| 347 | return false; | 349 | return false; |
| @@ -657,13 +659,24 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | @@ -657,13 +659,24 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | ||
| 657 | /** | 659 | /** |
| 658 | * 设置视频地址 | 660 | * 设置视频地址 |
| 659 | */ | 661 | */ |
| 660 | - public void setUrl(String url) { | 662 | + public void setUrl(String url, boolean isCache) { |
| 663 | + this.isCache = isCache; | ||
| 661 | // dataSource.clear(); | 664 | // dataSource.clear(); |
| 662 | // dataSource.add(url); | 665 | // dataSource.add(url); |
| 663 | // curentPlayIndex = 0; | 666 | // curentPlayIndex = 0; |
| 664 | setUrl(url, null); | 667 | setUrl(url, null); |
| 665 | } | 668 | } |
| 666 | 669 | ||
| 670 | + /** | ||
| 671 | + * 设置视频地址 | ||
| 672 | + */ | ||
| 673 | + public void setUrl(String url) { | ||
| 674 | + this.isCache = false; | ||
| 675 | +// dataSource.clear(); | ||
| 676 | +// dataSource.add(url); | ||
| 677 | +// curentPlayIndex = 0; | ||
| 678 | + setUrl(url, null); | ||
| 679 | + } | ||
| 667 | // public void setDataSource(List<String> url) { | 680 | // public void setDataSource(List<String> url) { |
| 668 | // dataSource.clear(); | 681 | // dataSource.clear(); |
| 669 | // dataSource.addAll(url); | 682 | // dataSource.addAll(url); |
| @@ -944,14 +957,14 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | @@ -944,14 +957,14 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | ||
| 944 | * 设置控制器,传null表示移除控制器 | 957 | * 设置控制器,传null表示移除控制器 |
| 945 | */ | 958 | */ |
| 946 | public void setVideoController(@Nullable BaseVideoController mediaController) { | 959 | public void setVideoController(@Nullable BaseVideoController mediaController) { |
| 947 | - if (null==mMediaPlayer){ | 960 | + if (null == mMediaPlayer) { |
| 948 | //初始化播放器 | 961 | //初始化播放器 |
| 949 | mMediaPlayer = mPlayerFactory.createPlayer(getContext()); | 962 | mMediaPlayer = mPlayerFactory.createPlayer(getContext()); |
| 950 | } | 963 | } |
| 951 | mPlayerContainer.removeView(mVideoController); | 964 | mPlayerContainer.removeView(mVideoController); |
| 952 | mVideoController = mediaController; | 965 | mVideoController = mediaController; |
| 953 | if (mediaController != null) { | 966 | if (mediaController != null) { |
| 954 | - mediaController.setMediaPlayer(this,mMediaPlayer); | 967 | + mediaController.setMediaPlayer(this, mMediaPlayer); |
| 955 | LayoutParams params = new LayoutParams( | 968 | LayoutParams params = new LayoutParams( |
| 956 | ViewGroup.LayoutParams.MATCH_PARENT, | 969 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 957 | ViewGroup.LayoutParams.MATCH_PARENT); | 970 | ViewGroup.LayoutParams.MATCH_PARENT); |
| @@ -1150,8 +1163,9 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | @@ -1150,8 +1163,9 @@ public class CNVideoView<P extends AbstractPlayer> extends FrameLayout | ||
| 1150 | /** | 1163 | /** |
| 1151 | * 视频缩放类型 | 1164 | * 视频缩放类型 |
| 1152 | */ | 1165 | */ |
| 1153 | - @IntDef({SCREEN_SCALE_DEFAULT,SCREEN_SCALE_16_9,SCREEN_SCALE_4_3,SCREEN_SCALE_MATCH_PARENT,SCREEN_SCALE_ORIGINAL,SCREEN_SCALE_CENTER_CROP}) | 1166 | + @IntDef({SCREEN_SCALE_DEFAULT, SCREEN_SCALE_16_9, SCREEN_SCALE_4_3, SCREEN_SCALE_MATCH_PARENT, SCREEN_SCALE_ORIGINAL, SCREEN_SCALE_CENTER_CROP}) |
| 1154 | @Retention(RetentionPolicy.SOURCE) | 1167 | @Retention(RetentionPolicy.SOURCE) |
| 1155 | public @interface screenScalType { | 1168 | public @interface screenScalType { |
| 1156 | } | 1169 | } |
| 1170 | + | ||
| 1157 | } | 1171 | } |
cloud/video/src/main/java/com/libs/video/video/exoplayer/play/VideoViewConfig.java
| @@ -2,6 +2,7 @@ package com.libs.video.video.exoplayer.play; | @@ -2,6 +2,7 @@ package com.libs.video.video.exoplayer.play; | ||
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | +import com.libs.video.video.exoplayer.playerCore.mediaplayer.AndroidMediaPlayerFactory; | ||
| 5 | import com.libs.video.video.exoplayer.render.RenderViewFactory; | 6 | import com.libs.video.video.exoplayer.render.RenderViewFactory; |
| 6 | import com.libs.video.video.exoplayer.render.texture.TextureRenderViewFactory; | 7 | import com.libs.video.video.exoplayer.render.texture.TextureRenderViewFactory; |
| 7 | 8 |
cloud/video/src/main/java/com/libs/video/video/exoplayer/playerCore/exoplayer/ExoMediaPlayer.java
| @@ -31,6 +31,7 @@ import com.google.android.exoplayer2.video.VideoListener; | @@ -31,6 +31,7 @@ import com.google.android.exoplayer2.video.VideoListener; | ||
| 31 | import com.libs.video.video.exoplayer.PlayErrorException; | 31 | import com.libs.video.video.exoplayer.PlayErrorException; |
| 32 | import com.libs.video.video.exoplayer.play.AbstractPlayer; | 32 | import com.libs.video.video.exoplayer.play.AbstractPlayer; |
| 33 | import com.libs.video.video.exoplayer.play.VideoViewManager; | 33 | import com.libs.video.video.exoplayer.play.VideoViewManager; |
| 34 | +import com.libs.video.video.exoplayer.util.PlayCacheUtils; | ||
| 34 | 35 | ||
| 35 | import java.util.Map; | 36 | import java.util.Map; |
| 36 | 37 | ||
| @@ -80,7 +81,6 @@ public class ExoMediaPlayer extends AbstractPlayer implements VideoListener, Pla | @@ -80,7 +81,6 @@ public class ExoMediaPlayer extends AbstractPlayer implements VideoListener, Pla | ||
| 80 | Clock.DEFAULT) | 81 | Clock.DEFAULT) |
| 81 | .build(); | 82 | .build(); |
| 82 | setOptions(); | 83 | setOptions(); |
| 83 | - | ||
| 84 | //播放器日志 | 84 | //播放器日志 |
| 85 | if (VideoViewManager.getConfig().mIsEnableLog && mTrackSelector instanceof MappingTrackSelector) { | 85 | if (VideoViewManager.getConfig().mIsEnableLog && mTrackSelector instanceof MappingTrackSelector) { |
| 86 | exoPlayer.addAnalyticsListener(new EventLogger((MappingTrackSelector) mTrackSelector, "ExoPlayer")); | 86 | exoPlayer.addAnalyticsListener(new EventLogger((MappingTrackSelector) mTrackSelector, "ExoPlayer")); |
| @@ -114,10 +114,16 @@ public class ExoMediaPlayer extends AbstractPlayer implements VideoListener, Pla | @@ -114,10 +114,16 @@ public class ExoMediaPlayer extends AbstractPlayer implements VideoListener, Pla | ||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | @Override | 116 | @Override |
| 117 | + public void setDataSource(String path, Map<String, String> headers, boolean isCache) { | ||
| 118 | + mMediaSource = mMediaSourceHelper.getMediaSource(path, headers,isCache); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + @Override | ||
| 117 | public void setDataSource(AssetFileDescriptor fd) { | 122 | public void setDataSource(AssetFileDescriptor fd) { |
| 118 | //no support | 123 | //no support |
| 119 | } | 124 | } |
| 120 | 125 | ||
| 126 | + | ||
| 121 | @Override | 127 | @Override |
| 122 | public void start() { | 128 | public void start() { |
| 123 | if (exoPlayer == null) | 129 | if (exoPlayer == null) |
cloud/video/src/main/java/com/libs/video/video/exoplayer/playerCore/exoplayer/ExoMediaSourceHelper.java
| @@ -4,6 +4,7 @@ import android.content.Context; | @@ -4,6 +4,7 @@ import android.content.Context; | ||
| 4 | import android.net.Uri; | 4 | import android.net.Uri; |
| 5 | import android.text.TextUtils; | 5 | import android.text.TextUtils; |
| 6 | 6 | ||
| 7 | +import com.danikula.videocache.StorageUtils; | ||
| 7 | import com.google.android.exoplayer2.C; | 8 | import com.google.android.exoplayer2.C; |
| 8 | import com.google.android.exoplayer2.database.ExoDatabaseProvider; | 9 | import com.google.android.exoplayer2.database.ExoDatabaseProvider; |
| 9 | import com.google.android.exoplayer2.ext.rtmp.RtmpDataSourceFactory; | 10 | import com.google.android.exoplayer2.ext.rtmp.RtmpDataSourceFactory; |
| @@ -36,6 +37,8 @@ public final class ExoMediaSourceHelper { | @@ -36,6 +37,8 @@ public final class ExoMediaSourceHelper { | ||
| 36 | private Context mAppContext; | 37 | private Context mAppContext; |
| 37 | private HttpDataSource.Factory mHttpDataSourceFactory; | 38 | private HttpDataSource.Factory mHttpDataSourceFactory; |
| 38 | private Cache mCache; | 39 | private Cache mCache; |
| 40 | + private final int CACHE_SIZE = 1024;//缓存大小1G | ||
| 41 | + public static final String CACHE_DIR = "exo-video-cache"; | ||
| 39 | 42 | ||
| 40 | private ExoMediaSourceHelper(Context context) { | 43 | private ExoMediaSourceHelper(Context context) { |
| 41 | mAppContext = context.getApplicationContext(); | 44 | mAppContext = context.getApplicationContext(); |
| @@ -117,11 +120,15 @@ public final class ExoMediaSourceHelper { | @@ -117,11 +120,15 @@ public final class ExoMediaSourceHelper { | ||
| 117 | CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR); | 120 | CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR); |
| 118 | } | 121 | } |
| 119 | 122 | ||
| 120 | - private Cache newCache() { | ||
| 121 | - return new SimpleCache( | ||
| 122 | - new File(mAppContext.getExternalCacheDir(), "exo-video-cache"),//缓存目录 | ||
| 123 | - new LeastRecentlyUsedCacheEvictor(512 * 1024 * 1024),//缓存大小,默认512M,使用LRU算法实现 | ||
| 124 | - new ExoDatabaseProvider(mAppContext)); | 123 | + public Cache newCache() { |
| 124 | + if (null == mCache) { | ||
| 125 | + return new SimpleCache( | ||
| 126 | + new File(StorageUtils.getCacheDirectoryPath(mAppContext), CACHE_DIR),//缓存目录 | ||
| 127 | + new LeastRecentlyUsedCacheEvictor(CACHE_SIZE * 1024 * 1024),//缓存大小,默认512M,使用LRU算法实现 | ||
| 128 | + new ExoDatabaseProvider(mAppContext)); | ||
| 129 | + } else { | ||
| 130 | + return mCache; | ||
| 131 | + } | ||
| 125 | } | 132 | } |
| 126 | 133 | ||
| 127 | /** | 134 | /** |
cloud/video/src/main/java/com/libs/video/video/exoplayer/play/AndroidMediaPlayer.java renamed to cloud/video/src/main/java/com/libs/video/video/exoplayer/playerCore/mediaplayer/AndroidMediaPlayer.java
| 1 | -package com.libs.video.video.exoplayer.play; | 1 | +package com.libs.video.video.exoplayer.playerCore.mediaplayer; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.content.res.AssetFileDescriptor; | 4 | import android.content.res.AssetFileDescriptor; |
| @@ -6,10 +6,16 @@ import android.media.AudioManager; | @@ -6,10 +6,16 @@ import android.media.AudioManager; | ||
| 6 | import android.media.MediaPlayer; | 6 | import android.media.MediaPlayer; |
| 7 | import android.net.Uri; | 7 | import android.net.Uri; |
| 8 | import android.os.Build; | 8 | import android.os.Build; |
| 9 | +import android.text.TextUtils; | ||
| 9 | import android.view.Surface; | 10 | import android.view.Surface; |
| 10 | import android.view.SurfaceHolder; | 11 | import android.view.SurfaceHolder; |
| 11 | 12 | ||
| 13 | +import com.danikula.videocache.HttpProxyCacheServer; | ||
| 14 | +import com.danikula.videocache.StorageUtils; | ||
| 15 | +import com.libs.video.util.cache.ProxyVideoCacheManager; | ||
| 12 | import com.libs.video.video.exoplayer.PlayErrorException; | 16 | import com.libs.video.video.exoplayer.PlayErrorException; |
| 17 | +import com.libs.video.video.exoplayer.play.AbstractPlayer; | ||
| 18 | +import com.libs.video.video.exoplayer.util.PlayCacheUtils; | ||
| 13 | 19 | ||
| 14 | import java.io.IOException; | 20 | import java.io.IOException; |
| 15 | import java.util.Map; | 21 | import java.util.Map; |
| @@ -48,6 +54,20 @@ public class AndroidMediaPlayer extends AbstractPlayer { | @@ -48,6 +54,20 @@ public class AndroidMediaPlayer extends AbstractPlayer { | ||
| 48 | } | 54 | } |
| 49 | 55 | ||
| 50 | @Override | 56 | @Override |
| 57 | + public void setDataSource(String path, Map<String, String> headers, boolean isCache) { | ||
| 58 | + try { | ||
| 59 | + if (isCache) { | ||
| 60 | + mMediaPlayer.setDataSource(mAppContext, Uri.parse(PlayCacheUtils.getCachePath(mAppContext,path)), headers); | ||
| 61 | + } else { | ||
| 62 | + //不缓存 | ||
| 63 | + mMediaPlayer.setDataSource(mAppContext, Uri.parse(path), headers); | ||
| 64 | + } | ||
| 65 | + } catch (IOException e) { | ||
| 66 | + e.printStackTrace(); | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 51 | public void setDataSource(AssetFileDescriptor fd) { | 71 | public void setDataSource(AssetFileDescriptor fd) { |
| 52 | try { | 72 | try { |
| 53 | mMediaPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength()); | 73 | mMediaPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength()); |
| @@ -56,6 +76,7 @@ public class AndroidMediaPlayer extends AbstractPlayer { | @@ -56,6 +76,7 @@ public class AndroidMediaPlayer extends AbstractPlayer { | ||
| 56 | } | 76 | } |
| 57 | } | 77 | } |
| 58 | 78 | ||
| 79 | + | ||
| 59 | /** | 80 | /** |
| 60 | * 获取当前异常 | 81 | * 获取当前异常 |
| 61 | * | 82 | * |
| @@ -64,15 +85,16 @@ public class AndroidMediaPlayer extends AbstractPlayer { | @@ -64,15 +85,16 @@ public class AndroidMediaPlayer extends AbstractPlayer { | ||
| 64 | private void getException(Exception e) { | 85 | private void getException(Exception e) { |
| 65 | PlayErrorException errorException = null; | 86 | PlayErrorException errorException = null; |
| 66 | if (e instanceof IOException) { | 87 | if (e instanceof IOException) { |
| 67 | - errorException = new PlayErrorException(PlayErrorException.TYPE_MediaPlayer_IOException, e.getMessage()); | 88 | + //资源错误 |
| 89 | + errorException = new PlayErrorException(PlayErrorException.TYPE_SOURCE_ERROR, e.getMessage()); | ||
| 68 | } else if (e instanceof IllegalArgumentException) { | 90 | } else if (e instanceof IllegalArgumentException) { |
| 69 | - errorException = new PlayErrorException(PlayErrorException.TYPE_MediaPlayer_IllegalArgumentException, e.getMessage()); | 91 | + errorException = new PlayErrorException(PlayErrorException.TYPE_IllegalArgumentException, e.getMessage()); |
| 70 | } else if (e instanceof SecurityException) { | 92 | } else if (e instanceof SecurityException) { |
| 71 | - errorException = new PlayErrorException(PlayErrorException.TYPE_MediaPlayer_SecurityException, e.getMessage()); | 93 | + errorException = new PlayErrorException(PlayErrorException.TYPE_SecurityException, e.getMessage()); |
| 72 | } else if (e instanceof IllegalStateException) { | 94 | } else if (e instanceof IllegalStateException) { |
| 73 | - errorException = new PlayErrorException(PlayErrorException.TYPE_MediaPlayer_IllegalStateException, e.getMessage()); | 95 | + errorException = new PlayErrorException(PlayErrorException.TYPE_IllegalStateException, e.getMessage()); |
| 74 | } else { | 96 | } else { |
| 75 | - errorException = new PlayErrorException(PlayErrorException.TYPE_MediaPlayer_unknownException, e.getMessage()); | 97 | + errorException = new PlayErrorException(PlayErrorException.TYPE_UNEXPECTED_ERROR, e.getMessage()); |
| 76 | } | 98 | } |
| 77 | mPlayerEventListener.onError(errorException); | 99 | mPlayerEventListener.onError(errorException); |
| 78 | } | 100 | } |
| @@ -132,7 +154,7 @@ public class AndroidMediaPlayer extends AbstractPlayer { | @@ -132,7 +154,7 @@ public class AndroidMediaPlayer extends AbstractPlayer { | ||
| 132 | try { | 154 | try { |
| 133 | mMediaPlayer.seekTo((int) time); | 155 | mMediaPlayer.seekTo((int) time); |
| 134 | } catch (IllegalStateException e) { | 156 | } catch (IllegalStateException e) { |
| 135 | - mPlayerEventListener.onError(new PlayErrorException(PlayErrorException.TYPE_MediaPlayer_IllegalStateException, e.getMessage())); | 157 | + mPlayerEventListener.onError(new PlayErrorException(PlayErrorException.TYPE_IllegalStateException, e.getMessage())); |
| 136 | 158 | ||
| 137 | } | 159 | } |
| 138 | } | 160 | } |
| @@ -226,10 +248,28 @@ public class AndroidMediaPlayer extends AbstractPlayer { | @@ -226,10 +248,28 @@ public class AndroidMediaPlayer extends AbstractPlayer { | ||
| 226 | @Override | 248 | @Override |
| 227 | public boolean onError(MediaPlayer mp, int what, int extra) { | 249 | public boolean onError(MediaPlayer mp, int what, int extra) { |
| 228 | PlayErrorException errorException = new PlayErrorException(); | 250 | PlayErrorException errorException = new PlayErrorException(); |
| 229 | - errorException.setErrorType(PlayErrorException.TYPE_MediaPlayer_ON_ERROR); | ||
| 230 | - errorException.setMediaPlayer(mp); | ||
| 231 | - errorException.setMediaPlayer_what(what); | ||
| 232 | - errorException.setMediaPlayer_extra(extra); | 251 | + switch (what) { |
| 252 | + //播放超时错误 | ||
| 253 | + case MediaPlayer.MEDIA_ERROR_TIMED_OUT: | ||
| 254 | + errorException.setErrorType(PlayErrorException.TYPE_TIMED_OUT_ERROR); | ||
| 255 | + errorException.setErrorMsg("播放超时错误"); | ||
| 256 | + break; | ||
| 257 | + //不支持的媒体类型 | ||
| 258 | + case MediaPlayer.MEDIA_ERROR_UNSUPPORTED: | ||
| 259 | + errorException.setErrorType(PlayErrorException.TYPE_MEDIA_UNSUPPORTED_ERROR); | ||
| 260 | + errorException.setErrorMsg("不支持的媒体类型"); | ||
| 261 | + break; | ||
| 262 | + //媒体服务器挂机(应用必须释放对象,然后开启新的实例) | ||
| 263 | + case MediaPlayer.MEDIA_ERROR_SERVER_DIED: | ||
| 264 | + errorException.setErrorType(PlayErrorException.TYPE_MEDIA_SERVER_DIED_ERROR); | ||
| 265 | + errorException.setErrorMsg("媒体服务器挂机(应用必须释放对象,然后开启新的实例)"); | ||
| 266 | + break; | ||
| 267 | + default: | ||
| 268 | + errorException.setErrorType(PlayErrorException.TYPE_OTHER_ERROR); | ||
| 269 | + errorException.setErrorMsg("其他错误:" + what); | ||
| 270 | + break; | ||
| 271 | + } | ||
| 272 | + | ||
| 233 | mPlayerEventListener.onError(errorException); | 273 | mPlayerEventListener.onError(errorException); |
| 234 | return true; | 274 | return true; |
| 235 | } | 275 | } |
cloud/video/src/main/java/com/libs/video/video/exoplayer/play/AndroidMediaPlayerFactory.java renamed to cloud/video/src/main/java/com/libs/video/video/exoplayer/playerCore/mediaplayer/AndroidMediaPlayerFactory.java
| 1 | -package com.libs.video.video.exoplayer.play; | 1 | +package com.libs.video.video.exoplayer.playerCore.mediaplayer; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | 4 | ||
| 5 | +import com.libs.video.video.exoplayer.play.PlayerFactory; | ||
| 6 | + | ||
| 5 | public class AndroidMediaPlayerFactory extends PlayerFactory<AndroidMediaPlayer> { | 7 | public class AndroidMediaPlayerFactory extends PlayerFactory<AndroidMediaPlayer> { |
| 6 | 8 | ||
| 7 | public static AndroidMediaPlayerFactory create() { | 9 | public static AndroidMediaPlayerFactory create() { |
cloud/video/src/main/java/com/libs/video/video/exoplayer/util/PlayCacheUtils.java
0 → 100644
| 1 | +package com.libs.video.video.exoplayer.util; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.text.TextUtils; | ||
| 5 | + | ||
| 6 | +import com.danikula.videocache.HttpProxyCacheServer; | ||
| 7 | +import com.danikula.videocache.StorageUtils; | ||
| 8 | +import com.libs.video.util.cache.ProxyVideoCacheManager; | ||
| 9 | +import com.libs.video.video.exoplayer.playerCore.exoplayer.ExoMediaPlayerFactory; | ||
| 10 | +import com.libs.video.video.exoplayer.playerCore.exoplayer.ExoMediaSourceHelper; | ||
| 11 | +import com.libs.video.video.exoplayer.playerCore.mediaplayer.AndroidMediaPlayerFactory; | ||
| 12 | + | ||
| 13 | +import java.io.File; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * 播放缓存工具 | ||
| 17 | + */ | ||
| 18 | +public class PlayCacheUtils { | ||
| 19 | + public static String getCachePath(Context mAppContext, String path) { | ||
| 20 | + String result = ""; | ||
| 21 | + if (null == mAppContext || TextUtils.isEmpty(path)) { | ||
| 22 | + return result; | ||
| 23 | + } | ||
| 24 | + if (path.contains("m3u8")) { | ||
| 25 | + result = path; | ||
| 26 | + } else if (null != mAppContext && !TextUtils.isDigitsOnly(path) && !path.contains(StorageUtils.getCacheDirectoryPath(mAppContext))) { | ||
| 27 | + HttpProxyCacheServer cacheServer = ProxyVideoCacheManager.getProxy(mAppContext); | ||
| 28 | + if (!cacheServer.isCached(path)) { | ||
| 29 | + String proxyUrl = cacheServer.getProxyUrl(path); | ||
| 30 | + result = proxyUrl; | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + return result; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 目前exoplayer是全部删除 | ||
| 38 | + * | ||
| 39 | + * @param context | ||
| 40 | + * @param url | ||
| 41 | + */ | ||
| 42 | + public void clearDefaultCache(Context context, String url) { | ||
| 43 | + //获取当前播放核心 | ||
| 44 | + Object object = PlayerFactoryUtils.getCurrentPlayerFactory(); | ||
| 45 | + if (null != object) { | ||
| 46 | + if (object instanceof ExoMediaPlayerFactory) { | ||
| 47 | + File file = new File(StorageUtils.getCacheDirectoryPath(context), ExoMediaSourceHelper.CACHE_DIR);//缓存目录 | ||
| 48 | + if (null == file) { | ||
| 49 | + return; | ||
| 50 | + } | ||
| 51 | + if (file.exists()) { | ||
| 52 | + deleteFile(file); | ||
| 53 | + } | ||
| 54 | + } else if (object instanceof AndroidMediaPlayerFactory) { | ||
| 55 | + ProxyVideoCacheManager.clearDefaultCache(context, url); | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public static void clearAllCache(Context context) { | ||
| 61 | + //获取当前播放核心 | ||
| 62 | +// Object object = PlayerFactoryUtils.getCurrentPlayerFactory(); | ||
| 63 | +// if (null != object) { | ||
| 64 | +// if (object instanceof ExoMediaPlayerFactory) { | ||
| 65 | + File file = new File(StorageUtils.getCacheDirectoryPath(context), ExoMediaSourceHelper.CACHE_DIR);//缓存目录 | ||
| 66 | + if (null == file) { | ||
| 67 | + return; | ||
| 68 | + } | ||
| 69 | + if (file.exists()) { | ||
| 70 | + deleteFile(file); | ||
| 71 | + } | ||
| 72 | +// } else if (object instanceof AndroidMediaPlayerFactory) { | ||
| 73 | + ProxyVideoCacheManager.clearAllCache(context); | ||
| 74 | +// } | ||
| 75 | +// } | ||
| 76 | + | ||
| 77 | + | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * 删除文件 | ||
| 82 | + * | ||
| 83 | + * @param file | ||
| 84 | + */ | ||
| 85 | + private static void deleteFile(File file) { | ||
| 86 | + if (file.exists()) { // 判断文件是否存在 | ||
| 87 | + if (file.isFile()) { // 判断是否是文件 | ||
| 88 | + file.delete(); // delete()方法 你应该知道 是删除的意思; | ||
| 89 | + } else if (file.isDirectory()) { // 否则如果它是一个目录 | ||
| 90 | + File files[] = file.listFiles(); // 声明目录下所有的文件 files[]; | ||
| 91 | + for (File file1 : files) { // 遍历目录下所有的文件 | ||
| 92 | + deleteFile(file1); // 把每个文件 用这个方法进行迭代 | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + file.delete(); | ||
| 96 | + } else { | ||
| 97 | + | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | +} |
core/base/src/main/java/com/cnlive/core/libs/base/frame/activity/BaseActivity.java
| @@ -116,7 +116,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -116,7 +116,7 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 116 | 116 | ||
| 117 | 117 | ||
| 118 | @Override | 118 | @Override |
| 119 | - public void onCreate(@Nullable Bundle savedInstanceState) { | 119 | + protected void onCreate(@Nullable Bundle savedInstanceState) { |
| 120 | super.onCreate(savedInstanceState); | 120 | super.onCreate(savedInstanceState); |
| 121 | if (0 != getBindLayoutId()) { | 121 | if (0 != getBindLayoutId()) { |
| 122 | baseBinding = DataBindingUtil.setContentView(this, getBindLayoutId()); | 122 | baseBinding = DataBindingUtil.setContentView(this, getBindLayoutId()); |
core/dentity_verfication/src/main/AndroidManifest.xml
| @@ -12,13 +12,14 @@ | @@ -12,13 +12,14 @@ | ||
| 12 | <uses-feature android:name="android.hardware.camera.autofocus" /> | 12 | <uses-feature android:name="android.hardware.camera.autofocus" /> |
| 13 | 13 | ||
| 14 | <application> | 14 | <application> |
| 15 | - <activity android:name=".activity.TakeIdentityPictureActivity"></activity> | 15 | + <activity android:name="com.cnlive.core.company_verfication.ui.activity.FillInCompanyDataActivity"></activity> |
| 16 | + <activity android:name=".activity.TakeIdentityPictureActivity" /> | ||
| 16 | <activity | 17 | <activity |
| 17 | android:name="com.cnlive.core.ocr.ui.camera.CameraActivity" | 18 | android:name="com.cnlive.core.ocr.ui.camera.CameraActivity" |
| 18 | android:configChanges="screenSize|orientation" | 19 | android:configChanges="screenSize|orientation" |
| 19 | - android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" | ||
| 20 | android:launchMode="singleTop" | 20 | android:launchMode="singleTop" |
| 21 | - android:screenOrientation="portrait"/> | 21 | + android:screenOrientation="portrait" |
| 22 | + android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" /> | ||
| 22 | </application> | 23 | </application> |
| 23 | 24 | ||
| 24 | </manifest> | 25 | </manifest> |
| 25 | \ No newline at end of file | 26 | \ No newline at end of file |
core/dentity_verfication/src/main/java/com/cnlive/core/company_verfication/ui/activity/FillInCompanyDataActivity.java
0 → 100644
| 1 | +package com.cnlive.core.company_verfication.ui.activity; | ||
| 2 | + | ||
| 3 | +import androidx.annotation.Nullable; | ||
| 4 | +import androidx.appcompat.app.AppCompatActivity; | ||
| 5 | +import androidx.databinding.ViewDataBinding; | ||
| 6 | +import androidx.recyclerview.widget.LinearLayoutManager; | ||
| 7 | + | ||
| 8 | +import android.os.Bundle; | ||
| 9 | +import android.os.PersistableBundle; | ||
| 10 | + | ||
| 11 | +import com.cnlive.core.company_verfication.ui.adapter.CompanyDataAdapter; | ||
| 12 | +import com.cnlive.core.libs.base.frame.activity.BaseActivity; | ||
| 13 | +import com.cnlive.core.people_verfication.R; | ||
| 14 | +import com.cnlive.core.people_verfication.databinding.FragmentFillInCompanyDataBinding; | ||
| 15 | + | ||
| 16 | +import java.util.ArrayList; | ||
| 17 | +import java.util.List; | ||
| 18 | + | ||
| 19 | +public class FillInCompanyDataActivity extends BaseActivity { | ||
| 20 | + private List<String> data = new ArrayList<>(); | ||
| 21 | + private FragmentFillInCompanyDataBinding binding; | ||
| 22 | + private CompanyDataAdapter adapter; | ||
| 23 | + @Override | ||
| 24 | + protected int getBindLayoutId() { | ||
| 25 | + return R.layout.fragment_fill_in_company_data; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + protected void initBindingLayoutData(ViewDataBinding baseBinding) { | ||
| 30 | + super.initBindingLayoutData(baseBinding); | ||
| 31 | + binding= (FragmentFillInCompanyDataBinding) baseBinding; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + protected void initView() { | ||
| 36 | + data.add("测试"); | ||
| 37 | + adapter=new CompanyDataAdapter(me,data); | ||
| 38 | + binding.recyclerView.setLayoutManager(new LinearLayoutManager(me)); | ||
| 39 | + binding.recyclerView.setAdapter(adapter); | ||
| 40 | + } | ||
| 41 | +} |
core/dentity_verfication/src/main/java/com/cnlive/core/company_verfication/ui/adapter/CompanyDataAdapter.java
0 → 100644
| 1 | +package com.cnlive.core.company_verfication.ui.adapter; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.view.LayoutInflater; | ||
| 5 | +import android.view.View; | ||
| 6 | +import android.view.ViewGroup; | ||
| 7 | +import android.widget.TextView; | ||
| 8 | + | ||
| 9 | +import androidx.annotation.NonNull; | ||
| 10 | +import androidx.databinding.DataBindingUtil; | ||
| 11 | +import androidx.recyclerview.widget.RecyclerView; | ||
| 12 | + | ||
| 13 | +import com.cnlive.core.people_verfication.R; | ||
| 14 | +import com.cnlive.core.people_verfication.databinding.ItemCompanyDateBinding; | ||
| 15 | + | ||
| 16 | +import java.util.List; | ||
| 17 | + | ||
| 18 | +public class CompanyDataAdapter extends RecyclerView.Adapter { | ||
| 19 | + private Context context; | ||
| 20 | + private List<String> data; | ||
| 21 | + | ||
| 22 | + public CompanyDataAdapter(Context context, List<String> data) { | ||
| 23 | + this.context = context; | ||
| 24 | + this.data = data; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @NonNull | ||
| 28 | + @Override | ||
| 29 | + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
| 30 | + LayoutInflater inflater = LayoutInflater.from(context); | ||
| 31 | + ItemCompanyDateBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_company_date, parent, false); | ||
| 32 | + return new MyViewHolder(binding); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | ||
| 37 | + ItemCompanyDateBinding binding = ((MyViewHolder) holder).binding; | ||
| 38 | + binding.includeAccountChild.llRoot.getBaselineAlignedChildIndex(); | ||
| 39 | + binding.includeAccountChild.tvDelete.setVisibility(View.GONE); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public int getItemCount() { | ||
| 44 | + return data.size(); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + private class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { | ||
| 48 | + private ItemCompanyDateBinding binding; | ||
| 49 | + | ||
| 50 | + public MyViewHolder(@NonNull ItemCompanyDateBinding binding) { | ||
| 51 | + super(binding.getRoot()); | ||
| 52 | + this.binding = binding; | ||
| 53 | + binding.btnAddChildCircle.setOnClickListener(this); | ||
| 54 | + binding.btnAddChildAccount.setOnClickListener(this); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public void onClick(View v) { | ||
| 60 | + //添加圈子 | ||
| 61 | + if (v.getId() == R.id.btn_addChildCircle) { | ||
| 62 | + View child = LayoutInflater.from(context).inflate(R.layout.item_company_date_include_circle_child, null); | ||
| 63 | + binding.includeCircleChild.llRoot.addView(child); | ||
| 64 | + } | ||
| 65 | + //添加群组 | ||
| 66 | + else if (v.getId() == R.id.btn_addChildAccount) { | ||
| 67 | + View child = LayoutInflater.from(context).inflate(R.layout.item_company_date_include_account_child, null); | ||
| 68 | + int index=binding.includeAccountChild.llRoot.getChildCount() - 1; | ||
| 69 | + binding.includeAccountChild.llRoot.addView(child, index); | ||
| 70 | + TextView textView = child.findViewById(R.id.tv_delete); | ||
| 71 | + textView.setVisibility(View.VISIBLE); | ||
| 72 | + textView.setOnClickListener(this); | ||
| 73 | + textView.setTag(child); | ||
| 74 | +// textView.setOnClickListener(new View.OnClickListener() { | ||
| 75 | +// @Override | ||
| 76 | +// public void onClick(View v) { | ||
| 77 | +// binding.includeAccountChild.llRoot.removeView(child); | ||
| 78 | +// } | ||
| 79 | +// }); | ||
| 80 | + } else if (v.getId() == R.id.tv_delete) { | ||
| 81 | + if (null!=v&&null!=v.getTag()){ | ||
| 82 | + View child= (View) v.getTag(); | ||
| 83 | + //获取当前子类 | ||
| 84 | + binding.includeAccountChild.llRoot.removeView(child); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | +} |
core/dentity_verfication/src/main/java/com/cnlive/core/people_verfication/activity/TakeIdentityPictureActivity.java
| @@ -8,6 +8,7 @@ import android.text.TextUtils; | @@ -8,6 +8,7 @@ import android.text.TextUtils; | ||
| 8 | 8 | ||
| 9 | import com.baidu.ocr.sdk.model.IDCardParams; | 9 | import com.baidu.ocr.sdk.model.IDCardParams; |
| 10 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; | 10 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 11 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 11 | import com.cnlive.core.libs.base.util.FileUtils; | 12 | import com.cnlive.core.libs.base.util.FileUtils; |
| 12 | import com.cnlive.core.ocr.ui.camera.CameraActivity; | 13 | import com.cnlive.core.ocr.ui.camera.CameraActivity; |
| 13 | import com.cnlive.core.people_verfication.R; | 14 | import com.cnlive.core.people_verfication.R; |
| @@ -15,8 +16,12 @@ import com.cnlive.core.people_verfication.databinding.ActivityTakePictureBinding | @@ -15,8 +16,12 @@ import com.cnlive.core.people_verfication.databinding.ActivityTakePictureBinding | ||
| 15 | import com.cnlive.core.people_verfication.presenter.TakeIdentityPicturePresenter; | 16 | import com.cnlive.core.people_verfication.presenter.TakeIdentityPicturePresenter; |
| 16 | import com.cnlive.core.people_verfication.view.ICertificatePhohosView; | 17 | import com.cnlive.core.people_verfication.view.ICertificatePhohosView; |
| 17 | import com.cnlive.core.people_verfication.view.TakeIdentityPictureView; | 18 | import com.cnlive.core.people_verfication.view.TakeIdentityPictureView; |
| 19 | +import com.cnlive.media.picker.PickerConfig; | ||
| 20 | +import com.cnlive.media.picker.entity.Media; | ||
| 18 | import com.cnlive.media.picker.utils.PermissionChecker; | 21 | import com.cnlive.media.picker.utils.PermissionChecker; |
| 19 | 22 | ||
| 23 | +import java.util.ArrayList; | ||
| 24 | + | ||
| 20 | import androidx.annotation.NonNull; | 25 | import androidx.annotation.NonNull; |
| 21 | import androidx.databinding.ViewDataBinding; | 26 | import androidx.databinding.ViewDataBinding; |
| 22 | 27 | ||
| @@ -32,6 +37,7 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | @@ -32,6 +37,7 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | ||
| 32 | private int preViewClickId = 0; | 37 | private int preViewClickId = 0; |
| 33 | private static int CAMERA_WRITE_FR_PERMISSION = 1001; | 38 | private static int CAMERA_WRITE_FR_PERMISSION = 1001; |
| 34 | private static int CAMERA_WRITE_BA_PERMISSION = 1002; | 39 | private static int CAMERA_WRITE_BA_PERMISSION = 1002; |
| 40 | + private static int CAMERA_WRITE_PI_PERMISSION = 1003; | ||
| 35 | 41 | ||
| 36 | @Override | 42 | @Override |
| 37 | protected int getBindLayoutId() { | 43 | protected int getBindLayoutId() { |
| @@ -63,21 +69,23 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | @@ -63,21 +69,23 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | ||
| 63 | preViewClickTime = curClickTime; | 69 | preViewClickTime = curClickTime; |
| 64 | preViewClickId = id; | 70 | preViewClickId = id; |
| 65 | if (id == R.id.certificate_front) { | 71 | if (id == R.id.certificate_front) { |
| 66 | - if(hasCampermission(CAMERA_WRITE_FR_PERMISSION)){//权限判断 | 72 | + if (hasCampermission(CAMERA_WRITE_FR_PERMISSION)) {//权限判断 |
| 67 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_FRONT); | 73 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_FRONT); |
| 68 | } | 74 | } |
| 69 | } else if (id == R.id.certificate_back) { | 75 | } else if (id == R.id.certificate_back) { |
| 70 | - if(hasCampermission(CAMERA_WRITE_BA_PERMISSION)){//权限判断 | 76 | + if (hasCampermission(CAMERA_WRITE_BA_PERMISSION)) {//权限判断 |
| 71 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_BACK); | 77 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_BACK); |
| 72 | } | 78 | } |
| 73 | } else if (id == R.id.take_picture) { | 79 | } else if (id == R.id.take_picture) { |
| 74 | - | 80 | + if (hasCampermission(CAMERA_WRITE_PI_PERMISSION)) { |
| 81 | + getMvpView().showDialog(); | ||
| 82 | + } | ||
| 75 | } | 83 | } |
| 76 | } | 84 | } |
| 77 | 85 | ||
| 78 | - private boolean hasCampermission(int typeNum){ | 86 | + private boolean hasCampermission(int typeNum) { |
| 79 | boolean hasPermission = PermissionChecker.checkPermissions(this | 87 | boolean hasPermission = PermissionChecker.checkPermissions(this |
| 80 | - , new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE} | 88 | + , new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE} |
| 81 | , typeNum, R.string.dialog_imagepicker_permission_camera_nerver_ask_message); | 89 | , typeNum, R.string.dialog_imagepicker_permission_camera_nerver_ask_message); |
| 82 | return hasPermission; | 90 | return hasPermission; |
| 83 | } | 91 | } |
| @@ -86,13 +94,17 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | @@ -86,13 +94,17 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | ||
| 86 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 94 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
| 87 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 95 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| 88 | if (requestCode == CAMERA_WRITE_FR_PERMISSION) { | 96 | if (requestCode == CAMERA_WRITE_FR_PERMISSION) { |
| 89 | - if (PermissionChecker.onRequestPermissionsResult(this,requestCode, permissions, grantResults, false, R.string.dialog_imagepicker_permission_sdcard_message)[0]) { | 97 | + if (PermissionChecker.onRequestPermissionsResult(this, requestCode, permissions, grantResults, false, R.string.dialog_imagepicker_permission_sdcard_message)[0]) { |
| 90 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_FRONT); | 98 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_FRONT); |
| 91 | } | 99 | } |
| 92 | - }else if(requestCode == CAMERA_WRITE_BA_PERMISSION){ | ||
| 93 | - if (PermissionChecker.onRequestPermissionsResult(this,requestCode, permissions, grantResults, false, R.string.dialog_imagepicker_permission_sdcard_message)[0]) { | 100 | + } else if (requestCode == CAMERA_WRITE_BA_PERMISSION) { |
| 101 | + if (PermissionChecker.onRequestPermissionsResult(this, requestCode, permissions, grantResults, false, R.string.dialog_imagepicker_permission_sdcard_message)[0]) { | ||
| 94 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_BACK); | 102 | getMvpView().takeIdCardPictures(this, ICertificatePhohosView.ID_CARD_SIDE_BACK); |
| 95 | } | 103 | } |
| 104 | + } else if (requestCode == CAMERA_WRITE_PI_PERMISSION) { | ||
| 105 | + if (PermissionChecker.onRequestPermissionsResult(this, requestCode, permissions, grantResults, false, R.string.dialog_imagepicker_permission_sdcard_message)[0]) { | ||
| 106 | + getMvpView().showDialog(); | ||
| 107 | + } | ||
| 96 | } | 108 | } |
| 97 | } | 109 | } |
| 98 | 110 | ||
| @@ -107,14 +119,25 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | @@ -107,14 +119,25 @@ public class TakeIdentityPictureActivity extends BaseActivity<TakeIdentityPictur | ||
| 107 | String frontFilePath = FileUtils.getSaveFile(getApplicationContext(), ICertificatePhohosView.PIC_FRONT).getAbsolutePath(); | 119 | String frontFilePath = FileUtils.getSaveFile(getApplicationContext(), ICertificatePhohosView.PIC_FRONT).getAbsolutePath(); |
| 108 | if (getMvpView() == null) return; | 120 | if (getMvpView() == null) return; |
| 109 | getMvpView().recIDCard(IDCardParams.ID_CARD_SIDE_FRONT, frontFilePath); | 121 | getMvpView().recIDCard(IDCardParams.ID_CARD_SIDE_FRONT, frontFilePath); |
| 110 | - | ||
| 111 | } else if (CameraActivity.CONTENT_TYPE_ID_CARD_BACK.equals(contentType)) { | 122 | } else if (CameraActivity.CONTENT_TYPE_ID_CARD_BACK.equals(contentType)) { |
| 112 | String backFilePath = FileUtils.getSaveFile(getApplicationContext(), ICertificatePhohosView.PIC_BACK).getAbsolutePath(); | 123 | String backFilePath = FileUtils.getSaveFile(getApplicationContext(), ICertificatePhohosView.PIC_BACK).getAbsolutePath(); |
| 113 | if (getMvpView() == null) return; | 124 | if (getMvpView() == null) return; |
| 114 | getMvpView().recIDCard(IDCardParams.ID_CARD_SIDE_BACK, backFilePath); | 125 | getMvpView().recIDCard(IDCardParams.ID_CARD_SIDE_BACK, backFilePath); |
| 126 | + }else if(CameraActivity.CONTENT_TYPE_GENERAL.endsWith(contentType)){ | ||
| 127 | + String filePath = FileUtils.getSaveFile(getApplicationContext(), ICertificatePhohosView.PIC_GENERAL).getAbsolutePath(); | ||
| 128 | + if (getMvpView() == null) return; | ||
| 129 | + if (!TextUtils.isEmpty(filePath))getMvpView().hasFace(filePath); | ||
| 115 | } | 130 | } |
| 116 | } | 131 | } |
| 117 | } | 132 | } |
| 133 | + }else if (requestCode == 200 && resultCode == PickerConfig.DEFAULT_RESULT_CODE) { | ||
| 134 | + ArrayList<Media> select = data.getParcelableArrayListExtra(PickerConfig.EXTRA_RESULT); | ||
| 135 | + if (select != null && select.size() > 0) { | ||
| 136 | + String path = select.get(0).path; | ||
| 137 | + if (!TextUtils.isEmpty(path))getMvpView().hasFace(path); | ||
| 138 | + } else { | ||
| 139 | + AlertUtil.showDeftToast(this, "请选择图片"); | ||
| 140 | + } | ||
| 118 | } | 141 | } |
| 119 | } | 142 | } |
| 120 | 143 |
core/dentity_verfication/src/main/java/com/cnlive/core/people_verfication/view/ICertificatePhohosView.java
| @@ -10,6 +10,8 @@ public interface ICertificatePhohosView extends MvpView { | @@ -10,6 +10,8 @@ public interface ICertificatePhohosView extends MvpView { | ||
| 10 | int REQUEST_CODE_CAMERA = 102; | 10 | int REQUEST_CODE_CAMERA = 102; |
| 11 | int ID_CARD_SIDE_FRONT = 1; | 11 | int ID_CARD_SIDE_FRONT = 1; |
| 12 | int ID_CARD_SIDE_BACK = 2; | 12 | int ID_CARD_SIDE_BACK = 2; |
| 13 | + int ID_CAMERA_GENETAL = 3; | ||
| 13 | String PIC_FRONT = "pic_front"; | 14 | String PIC_FRONT = "pic_front"; |
| 14 | String PIC_BACK = "pic_back"; | 15 | String PIC_BACK = "pic_back"; |
| 16 | + String PIC_GENERAL = "pic_general"; | ||
| 15 | } | 17 | } |
core/dentity_verfication/src/main/java/com/cnlive/core/people_verfication/view/TakeIdentityPictureView.java
| 1 | package com.cnlive.core.people_verfication.view; | 1 | package com.cnlive.core.people_verfication.view; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | +import android.app.Dialog; | ||
| 4 | import android.content.Context; | 5 | import android.content.Context; |
| 5 | import android.content.Intent; | 6 | import android.content.Intent; |
| 6 | import android.graphics.Bitmap; | 7 | import android.graphics.Bitmap; |
| 7 | import android.graphics.BitmapFactory; | 8 | import android.graphics.BitmapFactory; |
| 8 | import android.hardware.Camera; | 9 | import android.hardware.Camera; |
| 10 | + | ||
| 11 | +import com.cnlive.media.picker.ImagePicker; | ||
| 12 | +import com.cnlive.media.picker.PickerConfig; | ||
| 13 | + | ||
| 14 | +import android.media.FaceDetector; | ||
| 9 | import android.os.Environment; | 15 | import android.os.Environment; |
| 10 | import android.os.Handler; | 16 | import android.os.Handler; |
| 11 | import android.os.Looper; | 17 | import android.os.Looper; |
| 12 | import android.text.TextUtils; | 18 | import android.text.TextUtils; |
| 19 | +import android.view.Gravity; | ||
| 20 | +import android.view.View; | ||
| 21 | +import android.view.ViewGroup; | ||
| 22 | +import android.view.Window; | ||
| 13 | import android.widget.ImageView; | 23 | import android.widget.ImageView; |
| 14 | 24 | ||
| 15 | import com.baidu.ocr.sdk.OCR; | 25 | import com.baidu.ocr.sdk.OCR; |
| @@ -30,17 +40,16 @@ import com.cnlive.core.ocr.ui.camera.CameraActivity; | @@ -30,17 +40,16 @@ import com.cnlive.core.ocr.ui.camera.CameraActivity; | ||
| 30 | import com.cnlive.core.ocr.ui.util.ImageUtil; | 40 | import com.cnlive.core.ocr.ui.util.ImageUtil; |
| 31 | import com.cnlive.core.people_verfication.R; | 41 | import com.cnlive.core.people_verfication.R; |
| 32 | import com.cnlive.core.people_verfication.activity.TakeIdentityPictureActivity; | 42 | import com.cnlive.core.people_verfication.activity.TakeIdentityPictureActivity; |
| 43 | +import com.cnlive.media.picker.utils.ImagePickerComUtils; | ||
| 33 | 44 | ||
| 34 | -import java.io.ByteArrayOutputStream; | ||
| 35 | import java.io.File; | 45 | import java.io.File; |
| 36 | -import java.io.FileNotFoundException; | ||
| 37 | -import java.io.FileOutputStream; | ||
| 38 | -import java.io.IOException; | ||
| 39 | import java.text.SimpleDateFormat; | 46 | import java.text.SimpleDateFormat; |
| 40 | import java.util.Date; | 47 | import java.util.Date; |
| 41 | 48 | ||
| 49 | + | ||
| 42 | import static com.cnlive.core.people_verfication.view.ICertificatePhohosView.PIC_BACK; | 50 | import static com.cnlive.core.people_verfication.view.ICertificatePhohosView.PIC_BACK; |
| 43 | import static com.cnlive.core.people_verfication.view.ICertificatePhohosView.PIC_FRONT; | 51 | import static com.cnlive.core.people_verfication.view.ICertificatePhohosView.PIC_FRONT; |
| 52 | +import static com.cnlive.core.people_verfication.view.ICertificatePhohosView.PIC_GENERAL; | ||
| 44 | 53 | ||
| 45 | public class TakeIdentityPictureView extends BaseView { | 54 | public class TakeIdentityPictureView extends BaseView { |
| 46 | 55 | ||
| @@ -51,6 +60,7 @@ public class TakeIdentityPictureView extends BaseView { | @@ -51,6 +60,7 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 51 | private boolean isBackEffective = false; | 60 | private boolean isBackEffective = false; |
| 52 | private String idCardNo; | 61 | private String idCardNo; |
| 53 | private String realName; | 62 | private String realName; |
| 63 | + private Dialog dialog; | ||
| 54 | 64 | ||
| 55 | public TakeIdentityPictureView(TakeIdentityPictureActivity activity) { | 65 | public TakeIdentityPictureView(TakeIdentityPictureActivity activity) { |
| 56 | this.activity = activity; | 66 | this.activity = activity; |
| @@ -64,14 +74,9 @@ public class TakeIdentityPictureView extends BaseView { | @@ -64,14 +74,9 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 64 | activity.finish(); | 74 | activity.finish(); |
| 65 | } | 75 | } |
| 66 | 76 | ||
| 67 | - /** | ||
| 68 | - * 拍摄 | ||
| 69 | - * | ||
| 70 | - * @param idCardSide | ||
| 71 | - */ | ||
| 72 | public void takeIdCardPictures(Context context, final int idCardSide) { | 77 | public void takeIdCardPictures(Context context, final int idCardSide) { |
| 73 | long curClickTime = System.currentTimeMillis(); | 78 | long curClickTime = System.currentTimeMillis(); |
| 74 | - if (preViewClickTime > 0 && curClickTime - preViewClickTime <= 2000 ) { | 79 | + if (preViewClickTime > 0 && curClickTime - preViewClickTime <= 2000) { |
| 75 | return; | 80 | return; |
| 76 | } | 81 | } |
| 77 | preViewClickTime = curClickTime; | 82 | preViewClickTime = curClickTime; |
| @@ -83,6 +88,8 @@ public class TakeIdentityPictureView extends BaseView { | @@ -83,6 +88,8 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 83 | takePhoto(PIC_FRONT, CameraActivity.CONTENT_TYPE_ID_CARD_FRONT); | 88 | takePhoto(PIC_FRONT, CameraActivity.CONTENT_TYPE_ID_CARD_FRONT); |
| 84 | } else if (idCardSide == ICertificatePhohosView.ID_CARD_SIDE_BACK) { | 89 | } else if (idCardSide == ICertificatePhohosView.ID_CARD_SIDE_BACK) { |
| 85 | takePhoto(PIC_BACK, CameraActivity.CONTENT_TYPE_ID_CARD_BACK); | 90 | takePhoto(PIC_BACK, CameraActivity.CONTENT_TYPE_ID_CARD_BACK); |
| 91 | + } else if (idCardSide == ICertificatePhohosView.ID_CAMERA_GENETAL) { | ||
| 92 | + takePhoto(PIC_GENERAL, CameraActivity.CONTENT_TYPE_GENERAL); | ||
| 86 | } | 93 | } |
| 87 | } | 94 | } |
| 88 | 95 | ||
| @@ -130,7 +137,7 @@ public class TakeIdentityPictureView extends BaseView { | @@ -130,7 +137,7 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 130 | camera.release(); | 137 | camera.release(); |
| 131 | } catch (Throwable e) { | 138 | } catch (Throwable e) { |
| 132 | e.printStackTrace(); | 139 | e.printStackTrace(); |
| 133 | - AlertUtil.showDeftToast(getContext(),"没有相机权限,相机开启失败"); | 140 | + AlertUtil.showDeftToast(getContext(), "没有相机权限,相机开启失败"); |
| 134 | return; | 141 | return; |
| 135 | } | 142 | } |
| 136 | } | 143 | } |
| @@ -198,7 +205,7 @@ public class TakeIdentityPictureView extends BaseView { | @@ -198,7 +205,7 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 198 | frontBitmap = bitmap; | 205 | frontBitmap = bitmap; |
| 199 | showIdCard(idCardSide, frontBitmap, activity.binding.certificateFront); | 206 | showIdCard(idCardSide, frontBitmap, activity.binding.certificateFront); |
| 200 | activity.binding.certificateFront.setImageBitmap(bitmap); | 207 | activity.binding.certificateFront.setImageBitmap(bitmap); |
| 201 | - if(isBackEffective){ | 208 | + if (isBackEffective) { |
| 202 | // activity.binding.submit.setClickable(true); | 209 | // activity.binding.submit.setClickable(true); |
| 203 | // activity.binding.submit.setTextColor(activity.getResources().getColor(R.color.white)); | 210 | // activity.binding.submit.setTextColor(activity.getResources().getColor(R.color.white)); |
| 204 | // activity.binding.submit.setBackground(getContext().getResources().getDrawable(R.drawable.bg_apply_btn)); | 211 | // activity.binding.submit.setBackground(getContext().getResources().getDrawable(R.drawable.bg_apply_btn)); |
| @@ -208,20 +215,20 @@ public class TakeIdentityPictureView extends BaseView { | @@ -208,20 +215,20 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 208 | if (idCardSide.equals(IDCardParams.ID_CARD_SIDE_BACK)) { | 215 | if (idCardSide.equals(IDCardParams.ID_CARD_SIDE_BACK)) { |
| 209 | backBitmap = bitmap; | 216 | backBitmap = bitmap; |
| 210 | isBackEffective = true; | 217 | isBackEffective = true; |
| 211 | - if(TextUtils.isEmpty(idCardResult.getIssueAuthority().toString().trim()) || | ||
| 212 | - TextUtils.isEmpty(idCardResult.getSignDate().toString().trim())){ | 218 | + if (TextUtils.isEmpty(idCardResult.getIssueAuthority().toString().trim()) || |
| 219 | + TextUtils.isEmpty(idCardResult.getSignDate().toString().trim())) { | ||
| 213 | // activity.binding.submit.setClickable(false); | 220 | // activity.binding.submit.setClickable(false); |
| 214 | AlertUtil.showDeftToast(getContext(), "身份证信息读取失败,请重新拍摄"); | 221 | AlertUtil.showDeftToast(getContext(), "身份证信息读取失败,请重新拍摄"); |
| 215 | return; | 222 | return; |
| 216 | } | 223 | } |
| 217 | - try{ | 224 | + try { |
| 218 | Integer.parseInt(idCardResult.getExpiryDate().toString().trim()); | 225 | Integer.parseInt(idCardResult.getExpiryDate().toString().trim()); |
| 219 | - if(idCardResult.getExpiryDate() != null && Integer.parseInt(idCardResult.getExpiryDate().toString().trim()) < getCurrentTime()){ | 226 | + if (idCardResult.getExpiryDate() != null && Integer.parseInt(idCardResult.getExpiryDate().toString().trim()) < getCurrentTime()) { |
| 220 | // activity.binding.submit.setClickable(false); | 227 | // activity.binding.submit.setClickable(false); |
| 221 | AlertUtil.showDeftToast(getContext(), "身份证有效期失效"); | 228 | AlertUtil.showDeftToast(getContext(), "身份证有效期失效"); |
| 222 | return; | 229 | return; |
| 223 | } | 230 | } |
| 224 | - }catch (Exception e){ | 231 | + } catch (Exception e) { |
| 225 | e.printStackTrace(); | 232 | e.printStackTrace(); |
| 226 | } | 233 | } |
| 227 | 234 | ||
| @@ -234,7 +241,7 @@ public class TakeIdentityPictureView extends BaseView { | @@ -234,7 +241,7 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 234 | // activity.binding.submit.setBackground(getContext().getResources().getDrawable(R.drawable.bg_apply_btn)); | 241 | // activity.binding.submit.setBackground(getContext().getResources().getDrawable(R.drawable.bg_apply_btn)); |
| 235 | } | 242 | } |
| 236 | } | 243 | } |
| 237 | - }else { | 244 | + } else { |
| 238 | // activity.binding.submit.setClickable(false); | 245 | // activity.binding.submit.setClickable(false); |
| 239 | AlertUtil.showDeftToast(getContext(), "身份证信息读取失败,请重新拍摄"); | 246 | AlertUtil.showDeftToast(getContext(), "身份证信息读取失败,请重新拍摄"); |
| 240 | } | 247 | } |
| @@ -259,34 +266,71 @@ public class TakeIdentityPictureView extends BaseView { | @@ -259,34 +266,71 @@ public class TakeIdentityPictureView extends BaseView { | ||
| 259 | return Integer.parseInt(date); | 266 | return Integer.parseInt(date); |
| 260 | } | 267 | } |
| 261 | 268 | ||
| 262 | - public File compressImage(Bitmap bitmap, String filename) { | ||
| 263 | - ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
| 264 | - bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中 | ||
| 265 | - int options = 100; | ||
| 266 | - while (baos.toByteArray().length / 1024 > 500) { //循环判断如果压缩后图片是否大于500kb,大于继续压缩 | ||
| 267 | - baos.reset();//重置baos即清空baos | ||
| 268 | - options -= 10;//每次都减少10 | ||
| 269 | - bitmap.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中 | ||
| 270 | - long length = baos.toByteArray().length; | 269 | + public void showDialog() { |
| 270 | + if (dialog == null) { | ||
| 271 | + dialog = new Dialog(activity, R.style.DialogStyle); | ||
| 272 | + View view = View.inflate(activity, R.layout.dialog_takimg, null); | ||
| 273 | + dialog.setContentView(view); | ||
| 274 | + Window window = dialog.getWindow(); | ||
| 275 | + window.setGravity(Gravity.BOTTOM); | ||
| 276 | + window.setWindowAnimations(R.style.dialogStyle); | ||
| 277 | + window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); | ||
| 278 | + dialog.show(); | ||
| 279 | + } else { | ||
| 280 | + dialog.show(); | ||
| 271 | } | 281 | } |
| 272 | - File file = new File(Environment.getExternalStorageDirectory() + "/aegis/file"); | ||
| 273 | - if (!file.exists()) { | ||
| 274 | - file.mkdirs(); | 282 | + dialog.findViewById(R.id.take_photo).setOnClickListener(view -> { |
| 283 | + dialog.dismiss(); | ||
| 284 | + takeIdCardPictures(activity, ICertificatePhohosView.ID_CAMERA_GENETAL); | ||
| 285 | + }); | ||
| 286 | + dialog.findViewById(R.id.get_img).setOnClickListener(view -> { | ||
| 287 | + dialog.dismiss(); | ||
| 288 | + showAum(); | ||
| 289 | + }); | ||
| 290 | + dialog.findViewById(R.id.cancle).setOnClickListener(view -> dialog.dismiss()); | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + /** | ||
| 294 | + * 打开相册 | ||
| 295 | + */ | ||
| 296 | + public void showAum() { | ||
| 297 | + if (!ImagePickerComUtils.isSdExist()) { | ||
| 298 | + AlertUtil.showDeftToast(getContext(), "SD卡不存在"); | ||
| 299 | + return; | ||
| 275 | } | 300 | } |
| 276 | - file = new File(Environment.getExternalStorageDirectory() + "/aegis/file/", filename + ".png"); | ||
| 277 | - try { | ||
| 278 | - FileOutputStream fos = new FileOutputStream(file); | ||
| 279 | - try { | ||
| 280 | - fos.write(baos.toByteArray()); | ||
| 281 | - fos.flush(); | ||
| 282 | - fos.close(); | ||
| 283 | - } catch (IOException e) { | ||
| 284 | - e.printStackTrace(); | 301 | + new ImagePicker.Builder() |
| 302 | + .maxNum(1) | ||
| 303 | + .maxImageSize(20 * 1024 * 1024) | ||
| 304 | + .setSelectGif(false) | ||
| 305 | + //是否需要相机 | ||
| 306 | +// .needCamera(true) | ||
| 307 | + .selectMode(PickerConfig.PICKER_IMAGE) | ||
| 308 | + .cachePath(Environment.getExternalStorageDirectory() + "/strike/file/") | ||
| 309 | + .isSinglePick(true) | ||
| 310 | + .doCrop(1, 1, 300, 300) | ||
| 311 | + .builder() | ||
| 312 | + .start(activity, 200, PickerConfig.DEFAULT_RESULT_CODE); | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + /** | ||
| 316 | + * 检测是否有人脸 | ||
| 317 | + * @param path | ||
| 318 | + */ | ||
| 319 | + public void hasFace(String path){ | ||
| 320 | + int numberOfFace = 12; | ||
| 321 | + FaceDetector myFaceDetect; | ||
| 322 | + Bitmap bitmap = BitmapFactory.decodeFile(path); | ||
| 323 | + Bitmap bitmap565 = bitmap.copy(Bitmap.Config.RGB_565, true); | ||
| 324 | + int imageWidth = bitmap565.getWidth(); | ||
| 325 | + int imageHeight = bitmap565.getHeight(); | ||
| 326 | + FaceDetector.Face[] myFace = new FaceDetector.Face[numberOfFace]; | ||
| 327 | + myFaceDetect = new FaceDetector(imageWidth, imageHeight, numberOfFace); | ||
| 328 | + int numberOfFaceDetected = myFaceDetect.findFaces(bitmap565, myFace); | ||
| 329 | + AlertUtil.showDeftToast(getContext(), "检测到"+numberOfFaceDetected+"个人脸"); | ||
| 330 | + if(numberOfFaceDetected == 1) { | ||
| 331 | + GlideUtil.init(activity, path).error(R.drawable.take_photo).into(activity.binding.takePicture); | ||
| 332 | + }else if(new File(path).exists()){ | ||
| 333 | + new File(path).delete(); | ||
| 285 | } | 334 | } |
| 286 | - } catch (FileNotFoundException e) { | ||
| 287 | - e.printStackTrace(); | ||
| 288 | - } | ||
| 289 | -// recycleBitmap(bitmap); | ||
| 290 | - return file; | ||
| 291 | } | 335 | } |
| 292 | } | 336 | } |
core/dentity_verfication/src/main/res/layout/dialog_takimg.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="match_parent" | ||
| 5 | + android:background="@color/white" | ||
| 6 | + android:orientation="vertical"> | ||
| 7 | + | ||
| 8 | + <LinearLayout | ||
| 9 | + android:id="@+id/take_photo" | ||
| 10 | + android:layout_width="match_parent" | ||
| 11 | + android:layout_height="wrap_content" | ||
| 12 | + android:orientation="vertical"> | ||
| 13 | + | ||
| 14 | + <TextView | ||
| 15 | + android:layout_width="match_parent" | ||
| 16 | + android:layout_height="wrap_content" | ||
| 17 | + android:gravity="center_horizontal" | ||
| 18 | + android:padding="15dp" | ||
| 19 | + android:text="@string/tak_picture" | ||
| 20 | + android:textColor="#333333" | ||
| 21 | + android:textSize="15sp" /> | ||
| 22 | + | ||
| 23 | + <View | ||
| 24 | + android:layout_width="match_parent" | ||
| 25 | + android:layout_height="1dp" | ||
| 26 | + android:background="#f2f3f4" /> | ||
| 27 | + </LinearLayout> | ||
| 28 | + | ||
| 29 | + <LinearLayout | ||
| 30 | + android:id="@+id/get_img" | ||
| 31 | + android:layout_width="match_parent" | ||
| 32 | + android:layout_height="wrap_content" | ||
| 33 | + android:orientation="vertical"> | ||
| 34 | + | ||
| 35 | + <TextView | ||
| 36 | + android:layout_width="match_parent" | ||
| 37 | + android:layout_height="wrap_content" | ||
| 38 | + android:gravity="center_horizontal" | ||
| 39 | + android:padding="15dp" | ||
| 40 | + android:text="@string/to_picture" | ||
| 41 | + android:textColor="#333333" | ||
| 42 | + android:textSize="15sp" /> | ||
| 43 | + | ||
| 44 | + <View | ||
| 45 | + android:layout_width="match_parent" | ||
| 46 | + android:layout_height="1dp" | ||
| 47 | + android:background="#f2f3f4" /> | ||
| 48 | + </LinearLayout> | ||
| 49 | + | ||
| 50 | + <LinearLayout | ||
| 51 | + android:id="@+id/cancle" | ||
| 52 | + android:layout_width="match_parent" | ||
| 53 | + android:layout_height="wrap_content" | ||
| 54 | + android:orientation="vertical"> | ||
| 55 | + | ||
| 56 | + <View | ||
| 57 | + android:layout_width="match_parent" | ||
| 58 | + android:layout_height="10dp" | ||
| 59 | + android:background="#f2f3f4" /> | ||
| 60 | + | ||
| 61 | + <TextView | ||
| 62 | + android:layout_width="match_parent" | ||
| 63 | + android:layout_height="wrap_content" | ||
| 64 | + android:gravity="center_horizontal" | ||
| 65 | + android:padding="15dp" | ||
| 66 | + android:text="@string/cancle" | ||
| 67 | + android:textColor="#333333" | ||
| 68 | + android:textSize="15sp" /> | ||
| 69 | + </LinearLayout> | ||
| 70 | +</LinearLayout> | ||
| 0 | \ No newline at end of file | 71 | \ No newline at end of file |
core/dentity_verfication/src/main/res/layout/fragment_fill_in_company_data.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout> | ||
| 3 | + | ||
| 4 | + <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 5 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 6 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 7 | + android:layout_width="match_parent" | ||
| 8 | + android:layout_height="match_parent" | ||
| 9 | + tools:context="com.cnlive.core.company_verfication.ui.activity.FillInCompanyDataActivity"> | ||
| 10 | + | ||
| 11 | + <androidx.recyclerview.widget.RecyclerView | ||
| 12 | + android:id="@+id/recyclerView" | ||
| 13 | + android:layout_width="match_parent" | ||
| 14 | + android:layout_height="match_parent" /> | ||
| 15 | + </androidx.constraintlayout.widget.ConstraintLayout> | ||
| 16 | +</layout> |
core/dentity_verfication/src/main/res/layout/item_company_date.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout> | ||
| 3 | + | ||
| 4 | + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 5 | + android:id="@+id/ll_root" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:layout_height="wrap_content" | ||
| 8 | + android:orientation="vertical"> | ||
| 9 | + | ||
| 10 | + <LinearLayout | ||
| 11 | + android:layout_width="match_parent" | ||
| 12 | + android:layout_height="wrap_content" | ||
| 13 | + android:layout_marginLeft="10dp" | ||
| 14 | + android:layout_marginRight="10dp" | ||
| 15 | + android:gravity="center_vertical" | ||
| 16 | + android:minHeight="40dp" | ||
| 17 | + android:orientation="horizontal"> | ||
| 18 | + | ||
| 19 | + <TextView | ||
| 20 | + android:layout_width="wrap_content" | ||
| 21 | + android:layout_height="wrap_content" | ||
| 22 | + android:text="所属机构(主账号)" /> | ||
| 23 | + | ||
| 24 | + <EditText | ||
| 25 | + android:layout_width="match_parent" | ||
| 26 | + android:layout_height="wrap_content" | ||
| 27 | + android:hint="请选择属于您的机构" /> | ||
| 28 | + | ||
| 29 | + </LinearLayout> | ||
| 30 | + | ||
| 31 | + <View | ||
| 32 | + android:layout_width="match_parent" | ||
| 33 | + android:layout_height="1dp" | ||
| 34 | + android:layout_margin="10dp" | ||
| 35 | + android:background="@color/my_dialog_line" /> | ||
| 36 | + | ||
| 37 | + <include | ||
| 38 | + android:id="@+id/include_circle_child" | ||
| 39 | + layout="@layout/item_company_date_include_circle_child" /> | ||
| 40 | + | ||
| 41 | + <RelativeLayout | ||
| 42 | + android:layout_width="match_parent" | ||
| 43 | + android:layout_height="wrap_content"> | ||
| 44 | + | ||
| 45 | + <TextView | ||
| 46 | + android:id="@+id/tv_add_circle_tip" | ||
| 47 | + android:layout_width="wrap_content" | ||
| 48 | + android:layout_height="wrap_content" | ||
| 49 | + android:layout_centerHorizontal="true" | ||
| 50 | + android:layout_centerVertical="true" | ||
| 51 | + android:layout_marginRight="10dp" | ||
| 52 | + android:text="如您有多个圈子,可点击添加" /> | ||
| 53 | + | ||
| 54 | + <Button | ||
| 55 | + android:id="@+id/btn_addChildCircle" | ||
| 56 | + android:layout_width="wrap_content" | ||
| 57 | + android:layout_height="wrap_content" | ||
| 58 | + android:layout_centerVertical="true" | ||
| 59 | + android:layout_toRightOf="@id/tv_add_circle_tip" | ||
| 60 | + android:text="添加圈子" /> | ||
| 61 | + </RelativeLayout> | ||
| 62 | + | ||
| 63 | + <include | ||
| 64 | + android:id="@+id/include_account_child" | ||
| 65 | + layout="@layout/item_company_date_include_account_child" /> | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + <RelativeLayout | ||
| 69 | + android:layout_width="match_parent" | ||
| 70 | + android:layout_height="wrap_content"> | ||
| 71 | + | ||
| 72 | + <TextView | ||
| 73 | + android:id="@+id/tv_add_account_tip" | ||
| 74 | + android:layout_width="wrap_content" | ||
| 75 | + android:layout_height="wrap_content" | ||
| 76 | + android:layout_centerHorizontal="true" | ||
| 77 | + android:layout_centerVertical="true" | ||
| 78 | + android:layout_marginRight="10dp" | ||
| 79 | + android:text="如您有多个圈子,可点击添加" /> | ||
| 80 | + | ||
| 81 | + <Button | ||
| 82 | + android:id="@+id/btn_addChildAccount" | ||
| 83 | + android:layout_width="wrap_content" | ||
| 84 | + android:layout_height="wrap_content" | ||
| 85 | + android:layout_centerVertical="true" | ||
| 86 | + android:layout_toRightOf="@id/tv_add_account_tip" | ||
| 87 | + android:text="添加子账号" /> | ||
| 88 | + </RelativeLayout> | ||
| 89 | + </LinearLayout> | ||
| 90 | +</layout> | ||
| 0 | \ No newline at end of file | 91 | \ No newline at end of file |
core/dentity_verfication/src/main/res/layout/item_company_date_include_account_child.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout> | ||
| 3 | + | ||
| 4 | + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 5 | + android:id="@+id/ll_root" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:layout_height="wrap_content" | ||
| 8 | + android:orientation="vertical"> | ||
| 9 | + | ||
| 10 | + <LinearLayout | ||
| 11 | + android:layout_width="match_parent" | ||
| 12 | + android:layout_height="wrap_content" | ||
| 13 | + android:gravity="center"> | ||
| 14 | + | ||
| 15 | + <LinearLayout | ||
| 16 | + android:layout_width="0dp" | ||
| 17 | + android:layout_height="wrap_content" | ||
| 18 | + android:layout_weight="1" | ||
| 19 | + android:orientation="vertical"> | ||
| 20 | + | ||
| 21 | + <LinearLayout | ||
| 22 | + android:layout_width="match_parent" | ||
| 23 | + android:layout_height="wrap_content" | ||
| 24 | + android:layout_marginLeft="10dp" | ||
| 25 | + android:layout_marginRight="10dp" | ||
| 26 | + android:gravity="center_vertical" | ||
| 27 | + android:minHeight="40dp" | ||
| 28 | + android:orientation="horizontal"> | ||
| 29 | + | ||
| 30 | + <TextView | ||
| 31 | + android:layout_width="wrap_content" | ||
| 32 | + android:layout_height="wrap_content" | ||
| 33 | + android:text="相关账号(子账号)" /> | ||
| 34 | + | ||
| 35 | + <EditText | ||
| 36 | + android:layout_width="match_parent" | ||
| 37 | + android:layout_height="wrap_content" | ||
| 38 | + android:hint="请选择机构子账号" | ||
| 39 | + android:textSize="15sp" /> | ||
| 40 | + | ||
| 41 | + </LinearLayout> | ||
| 42 | + | ||
| 43 | + <!-- --> | ||
| 44 | + <LinearLayout | ||
| 45 | + android:layout_width="match_parent" | ||
| 46 | + android:layout_height="wrap_content" | ||
| 47 | + android:layout_marginLeft="10dp" | ||
| 48 | + android:layout_marginRight="10dp" | ||
| 49 | + android:gravity="center_vertical" | ||
| 50 | + android:minHeight="40dp" | ||
| 51 | + android:orientation="horizontal"> | ||
| 52 | + | ||
| 53 | + <TextView | ||
| 54 | + android:layout_width="wrap_content" | ||
| 55 | + android:layout_height="wrap_content" | ||
| 56 | + android:text="相关群组(子群组)" /> | ||
| 57 | + | ||
| 58 | + <EditText | ||
| 59 | + android:layout_width="match_parent" | ||
| 60 | + android:layout_height="wrap_content" | ||
| 61 | + android:hint="请选择子账号群组" | ||
| 62 | + android:textSize="15sp" /> | ||
| 63 | + | ||
| 64 | + </LinearLayout> | ||
| 65 | + </LinearLayout> | ||
| 66 | + <!-- 删除--> | ||
| 67 | + <TextView | ||
| 68 | + android:id="@+id/tv_delete" | ||
| 69 | + android:layout_width="wrap_content" | ||
| 70 | + android:layout_height="wrap_content" | ||
| 71 | + android:layout_margin="10dp" | ||
| 72 | + android:text="删除" | ||
| 73 | + android:visibility="gone" /> | ||
| 74 | + </LinearLayout> | ||
| 75 | + | ||
| 76 | + | ||
| 77 | + <View | ||
| 78 | + android:layout_width="match_parent" | ||
| 79 | + android:layout_height="1dp" | ||
| 80 | + android:layout_marginTop="10dp" | ||
| 81 | + android:background="@color/my_dialog_line" /> | ||
| 82 | + </LinearLayout> | ||
| 83 | +</layout> | ||
| 0 | \ No newline at end of file | 84 | \ No newline at end of file |
core/dentity_verfication/src/main/res/layout/item_company_date_include_circle_child.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout> | ||
| 3 | + | ||
| 4 | + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 5 | + android:id="@+id/ll_root" | ||
| 6 | + android:layout_width="match_parent" | ||
| 7 | + android:layout_height="wrap_content" | ||
| 8 | + android:orientation="vertical"> | ||
| 9 | + | ||
| 10 | + <LinearLayout | ||
| 11 | + android:layout_width="match_parent" | ||
| 12 | + android:layout_height="wrap_content" | ||
| 13 | + android:layout_marginLeft="10dp" | ||
| 14 | + android:layout_marginRight="10dp" | ||
| 15 | + android:gravity="center_vertical" | ||
| 16 | + android:minHeight="40dp" | ||
| 17 | + android:orientation="horizontal"> | ||
| 18 | + | ||
| 19 | + <TextView | ||
| 20 | + android:layout_width="wrap_content" | ||
| 21 | + android:layout_height="wrap_content" | ||
| 22 | + android:text="您的圈子(子账号)" /> | ||
| 23 | + | ||
| 24 | + <EditText | ||
| 25 | + android:layout_width="match_parent" | ||
| 26 | + android:layout_height="wrap_content" | ||
| 27 | + android:hint="请选择您的圈子" | ||
| 28 | + android:textSize="15sp" /> | ||
| 29 | + | ||
| 30 | + </LinearLayout> | ||
| 31 | + | ||
| 32 | + <!-- --> | ||
| 33 | + <LinearLayout | ||
| 34 | + android:layout_width="match_parent" | ||
| 35 | + android:layout_height="wrap_content" | ||
| 36 | + android:layout_marginLeft="10dp" | ||
| 37 | + android:layout_marginRight="10dp" | ||
| 38 | + android:gravity="center_vertical" | ||
| 39 | + android:minHeight="40dp" | ||
| 40 | + android:orientation="horizontal"> | ||
| 41 | + | ||
| 42 | + <TextView | ||
| 43 | + android:layout_width="wrap_content" | ||
| 44 | + android:layout_height="wrap_content" | ||
| 45 | + android:text="圈子群组(子群组)" /> | ||
| 46 | + | ||
| 47 | + <EditText | ||
| 48 | + android:layout_width="match_parent" | ||
| 49 | + android:layout_height="wrap_content" | ||
| 50 | + android:hint="请选择圈子群组" | ||
| 51 | + android:textSize="15sp" /> | ||
| 52 | + | ||
| 53 | + </LinearLayout> | ||
| 54 | + | ||
| 55 | + <View | ||
| 56 | + android:layout_width="match_parent" | ||
| 57 | + android:layout_height="1dp" | ||
| 58 | + android:layout_marginTop="10dp" | ||
| 59 | + android:background="@color/my_dialog_line" /> | ||
| 60 | + </LinearLayout> | ||
| 61 | +</layout> | ||
| 0 | \ No newline at end of file | 62 | \ No newline at end of file |
core/dentity_verfication/src/main/res/values/strings.xml
| @@ -13,4 +13,7 @@ | @@ -13,4 +13,7 @@ | ||
| 13 | 13 | ||
| 14 | <string name="init_baidu_faile">初始化失败</string> | 14 | <string name="init_baidu_faile">初始化失败</string> |
| 15 | <string name="only_for_verified">仅用于实名认证</string> | 15 | <string name="only_for_verified">仅用于实名认证</string> |
| 16 | + <string name="tak_picture">拍摄</string> | ||
| 17 | + <string name="to_picture">从手机相册选择</string> | ||
| 18 | + <string name="cancle">取消</string> | ||
| 16 | </resources> | 19 | </resources> |
core/dentity_verfication/src/main/res/values/styles.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<resources> | ||
| 3 | + <style name="DialogStyle" parent="@android:style/Theme.Dialog"> | ||
| 4 | + <item name="android:windowFrame">@null</item> | ||
| 5 | + <item name="android:windowIsFloating">true</item> | ||
| 6 | + <item name="android:windowIsTranslucent">true</item> | ||
| 7 | + <item name="android:windowNoTitle">true</item> | ||
| 8 | + <item name="android:windowBackground">@android:color/transparent</item> | ||
| 9 | + <item name="android:backgroundDimEnabled">true</item> | ||
| 10 | + <item name="android:backgroundDimAmount">0.6</item> | ||
| 11 | + <item name="android:windowCloseOnTouchOutside">true</item> | ||
| 12 | + </style> | ||
| 13 | + | ||
| 14 | + <style name="dialogStyle" parent="android:Animation"> | ||
| 15 | + <item name="android:windowEnterAnimation">@anim/anim_enter</item> | ||
| 16 | + <item name="android:windowExitAnimation">@anim/anim_exit</item> | ||
| 17 | + </style> | ||
| 18 | +</resources> | ||
| 0 | \ No newline at end of file | 19 | \ No newline at end of file |
core/imageload/src/main/java/com/cnlive/core/ui/view/PreViewImageView.java
| @@ -27,6 +27,7 @@ import com.cnlive.core.imageload.preview.router.PreviewRouters; | @@ -27,6 +27,7 @@ import com.cnlive.core.imageload.preview.router.PreviewRouters; | ||
| 27 | import com.cnlive.core.imageload.preview.widget.CustomTipDialog; | 27 | import com.cnlive.core.imageload.preview.widget.CustomTipDialog; |
| 28 | import com.cnlive.core.imageload.preview.widget.DownloadUtil; | 28 | import com.cnlive.core.imageload.preview.widget.DownloadUtil; |
| 29 | import com.cnlive.core.imageload.util.DownLoadImageService; | 29 | import com.cnlive.core.imageload.util.DownLoadImageService; |
| 30 | +import com.cnlive.core.imagepreview.listener.OnDragStatusListener; | ||
| 30 | import com.cnlive.core.imagepreview.listener.OnItemLongPressListener; | 31 | import com.cnlive.core.imagepreview.listener.OnItemLongPressListener; |
| 31 | import com.cnlive.core.libs.base.frame.view.BaseView; | 32 | import com.cnlive.core.libs.base.frame.view.BaseView; |
| 32 | import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener; | 33 | import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener; |
| @@ -84,8 +85,6 @@ public class PreViewImageView extends BaseView { | @@ -84,8 +85,6 @@ public class PreViewImageView extends BaseView { | ||
| 84 | if (TextUtils.isEmpty(activity.type)) { | 85 | if (TextUtils.isEmpty(activity.type)) { |
| 85 | showError(); | 86 | showError(); |
| 86 | } | 87 | } |
| 87 | - | ||
| 88 | - | ||
| 89 | if (activity.type.equals("1")) { | 88 | if (activity.type.equals("1")) { |
| 90 | preViewImgList = activity.data.getPicInfoList(); | 89 | preViewImgList = activity.data.getPicInfoList(); |
| 91 | if (preViewImgList.size() == 1) { | 90 | if (preViewImgList.size() == 1) { |
| @@ -111,6 +110,14 @@ public class PreViewImageView extends BaseView { | @@ -111,6 +110,14 @@ public class PreViewImageView extends BaseView { | ||
| 111 | activity.binding.imagePre.overlayStatusBar(false) | 110 | activity.binding.imagePre.overlayStatusBar(false) |
| 112 | .imageData(activity.picList) | 111 | .imageData(activity.picList) |
| 113 | .playExitAnim(false); | 112 | .playExitAnim(false); |
| 113 | + activity.binding.imagePre.setOnDragStatusListener(new OnDragStatusListener() { | ||
| 114 | + @Override | ||
| 115 | + public void onDragStatusChanged(int status) { | ||
| 116 | + if(status == 8){ | ||
| 117 | + activity.finish(); | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | + }); | ||
| 114 | activity.binding.imagePre.watch(activity.position); | 121 | activity.binding.imagePre.watch(activity.position); |
| 115 | activity.binding.imagePre.setOnItemLongPressListener(new OnItemLongPressListener() { | 122 | activity.binding.imagePre.setOnItemLongPressListener(new OnItemLongPressListener() { |
| 116 | @Override | 123 | @Override |