-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lei Xu
committed
Dec 14, 2021
1 parent
4384d01
commit 31b21d5
Showing
20 changed files
with
1,241 additions
and
1,332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,11 @@ android { | |
jniLibs.srcDirs = ['libs'] | ||
} | ||
} | ||
|
||
buildFeatures { | ||
viewBinding true | ||
} | ||
|
||
} | ||
|
||
repositories { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
package com.worldtech.camera2video; | ||
package com.worldtech.camera2video | ||
|
||
import android.app.Application; | ||
import android.content.Context; | ||
import android.annotation.SuppressLint | ||
import android.app.Application | ||
import android.content.Context | ||
|
||
public class App extends Application { | ||
|
||
public static Context context; | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
context = getApplicationContext(); | ||
class App : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
context = applicationContext | ||
} | ||
|
||
} | ||
companion object { | ||
@SuppressLint("StaticFieldLeak") | ||
@JvmField | ||
var context: Context? = null | ||
} | ||
} |
10 changes: 7 additions & 3 deletions
10
app/src/main/java/com/worldtech/camera2video/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 40 additions & 48 deletions
88
app/src/main/java/com/worldtech/camera2video/activity/RecordVideoActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,49 @@ | ||
package com.worldtech.camera2video.activity; | ||
|
||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.widget.ImageView; | ||
|
||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentActivity; | ||
|
||
import com.worldtech.camera2video.R; | ||
import com.worldtech.camera2video.fragment.RecordVideo2Fragment; | ||
import com.worldtech.camera2video.fragment.RecordVideoFragment; | ||
|
||
|
||
public class RecordVideoActivity extends FragmentActivity { | ||
|
||
private ImageView cancel; | ||
private Fragment videoFragment; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_record_video); | ||
|
||
|
||
cancel = findViewById(R.id.cancel); | ||
cancel.setOnClickListener(v -> { | ||
finishFragment(); | ||
}); | ||
videoFragment = getRecordVideoFragment(); | ||
getSupportFragmentManager().beginTransaction() | ||
.replace(R.id.fl_container,videoFragment ,"RecordVideoFragment") | ||
.addToBackStack(null) | ||
.commit(); | ||
package com.worldtech.camera2video.activity | ||
|
||
import android.os.Build | ||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentActivity | ||
import com.worldtech.camera2video.R | ||
import com.worldtech.camera2video.databinding.ActivityRecordVideoBinding | ||
import com.worldtech.camera2video.fragment.RecordVideo2Fragment | ||
import com.worldtech.camera2video.fragment.RecordVideoFragment | ||
|
||
class RecordVideoActivity : FragmentActivity() { | ||
|
||
private lateinit var currentBinding: ActivityRecordVideoBinding | ||
private var videoFragment: Fragment? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
currentBinding = ActivityRecordVideoBinding.inflate(layoutInflater) | ||
setContentView(currentBinding.root) | ||
|
||
currentBinding.cancel.setOnClickListener(View.OnClickListener { v: View? -> finishFragment() }) | ||
videoFragment = recordVideoFragment | ||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.fl_container, videoFragment!!, "RecordVideoFragment") | ||
.addToBackStack(null) | ||
.commit() | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
finishFragment(); | ||
override fun onBackPressed() { | ||
finishFragment() | ||
} | ||
|
||
public Fragment getRecordVideoFragment(){ | ||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { | ||
return new RecordVideoFragment(); | ||
private val recordVideoFragment: Fragment | ||
get() = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { | ||
RecordVideoFragment() | ||
} else { | ||
return new RecordVideo2Fragment(); | ||
RecordVideo2Fragment() | ||
} | ||
} | ||
public void finishFragment(){ | ||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){ | ||
|
||
private fun finishFragment() { | ||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { | ||
// ((RecordVideoFragment)videoFragment).exit(); | ||
}else { | ||
finish(); | ||
} else { | ||
finish() | ||
} | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.