Skip to content

Commit

Permalink
update name to screenrecordhelper
Browse files Browse the repository at this point in the history
  • Loading branch information
shilin.liu committed Jun 21, 2019
1 parent 0b09b95 commit b5623f0
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 17 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/liushilin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions app/src/main/java/com/nanchen/screenrecorder/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import android.os.Bundle
import android.util.Log
import android.widget.Toast
import com.blankj.utilcode.util.PathUtils
import com.nanchen.screenrecord.ScreenRecorder
import com.nanchen.screenrecordhelper.ScreenRecordHelper
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

private var screenRecorder: ScreenRecorder? = null
private var screenRecordHelper: ScreenRecordHelper? = null
private val afdd: AssetFileDescriptor by lazy { assets.openFd("test.aac") }

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -23,8 +23,8 @@ class MainActivity : AppCompatActivity() {

btnStart.setOnClickListener {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (screenRecorder == null) {
screenRecorder = ScreenRecorder(this, object : ScreenRecorder.OnVideoRecordListener {
if (screenRecordHelper == null) {
screenRecordHelper = ScreenRecordHelper(this, object : ScreenRecordHelper.OnVideoRecordListener {
override fun onBeforeRecord() {
}

Expand All @@ -42,9 +42,9 @@ class MainActivity : AppCompatActivity() {

}, PathUtils.getExternalStoragePath() + "/nanchen")
}
screenRecorder?.apply {
screenRecordHelper?.apply {
if (!isRecording) {
screenRecorder?.startRecord()
screenRecordHelper?.startRecord()
}
}
} else {
Expand All @@ -54,7 +54,7 @@ class MainActivity : AppCompatActivity() {

btnStop.setOnClickListener {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
screenRecorder?.apply {
screenRecordHelper?.apply {
if (isRecording) {
if (mediaPlayer != null) {
stopRecord(mediaPlayer!!.duration.toLong(), 15 * 1000, afdd)
Expand Down Expand Up @@ -98,13 +98,13 @@ class MainActivity : AppCompatActivity() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && data != null) {
screenRecorder?.onActivityResult(requestCode, resultCode, data)
screenRecordHelper?.onActivityResult(requestCode, resultCode, data)
}
}

override fun onDestroy() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
screenRecorder?.clearAll()
screenRecordHelper?.clearAll()
}
afdd.close()
super.onDestroy()
Expand Down
2 changes: 0 additions & 2 deletions screenrecord/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ apply plugin: 'kotlin-android'
android {
compileSdkVersion 28



defaultConfig {
minSdkVersion 14
targetSdkVersion 28
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.nanchen.screenrecord;
package com.nanchen.screenrecordhelper;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
Expand Down
2 changes: 1 addition & 1 deletion screenrecord/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nanchen.screenrecord">
package="com.nanchen.screenrecordhelper">

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.nanchen.screenrecord
package com.nanchen.screenrecordhelper

import android.app.Activity
import android.content.Context
Expand Down Expand Up @@ -30,7 +30,7 @@ import java.nio.ByteBuffer
* Date: 2019/6/21 15:19
*/
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
class ScreenRecorder @JvmOverloads constructor(
class ScreenRecordHelper @JvmOverloads constructor(
private var activity: Activity,
private val listener: OnVideoRecordListener?,
private var savePath: String = Environment.getExternalStorageDirectory().absolutePath + File.separator
Expand Down Expand Up @@ -328,7 +328,7 @@ class ScreenRecorder @JvmOverloads constructor(
companion object {
private const val VIDEO_FRAME_RATE = 30
private const val REQUEST_CODE = 1024
private const val TAG = "ScreenRecorder"
private const val TAG = "ScreenRecordHelper"
}

interface OnVideoRecordListener {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.nanchen.screenrecord;
package com.nanchen.screenrecordhelper;

import org.junit.Test;

Expand Down

0 comments on commit b5623f0

Please sign in to comment.