bug fixes

This commit is contained in:
X1nto 2020-05-25 18:12:52 +04:00
parent 1798386044
commit b582f75d45
3 changed files with 28 additions and 45 deletions

View File

@ -31,7 +31,7 @@ import java.io.*
open class BaseFragment : Fragment() {
private var disposable: Disposable? = null
private lateinit var packageInstaller: PackageInstaller
private var packageInstaller: PackageInstaller? = activity?.packageManager?.packageInstaller
fun openUrl(Url: String, color: Int) {
val builder = CustomTabsIntent.Builder()
@ -208,7 +208,7 @@ open class BaseFragment : Fragment() {
val installParams = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL)
installParams.setSize(totalSize)
try {
sessionId = packageInstaller.createSession(installParams)
sessionId = packageInstaller?.createSession(installParams)!!
Log.d("AppLog","Success: created install session [$sessionId]")
for ((key, value) in nameSizeMap) {
doWriteSession(sessionId, apkFolderPath + key, value, key)
@ -235,11 +235,11 @@ open class BaseFragment : Fragment() {
var inputStream: InputStream? = null
var out: OutputStream? = null
try {
session = packageInstaller.openSession(sessionId)
session = packageInstaller?.openSession(sessionId)
if (inPathToUse != null) {
inputStream = FileInputStream(inPathToUse)
}
out = session.openWrite(splitName, 0, sizeBytesToUse)
out = session?.openWrite(splitName, 0, sizeBytesToUse)
var total = 0
val buffer = ByteArray(65536)
var c: Int
@ -248,9 +248,11 @@ open class BaseFragment : Fragment() {
if (c == -1)
break
total += c
out.write(buffer, 0, c)
out?.write(buffer, 0, c)
}
if (out != null) {
session?.fsync(out)
}
session.fsync(out)
Log.d("AppLog", "Success: streamed $total bytes")
return PackageInstaller.STATUS_SUCCESS
} catch (e: IOException) {
@ -271,13 +273,13 @@ open class BaseFragment : Fragment() {
var session: PackageInstaller.Session? = null
try {
try {
session = packageInstaller.openSession(sessionId)
session = packageInstaller?.openSession(sessionId)
val callbackIntent = Intent(activity?.applicationContext, SplitInstallerService::class.java)
val pendingIntent = PendingIntent.getService(activity?.applicationContext, 0, callbackIntent, 0)
session.commit(pendingIntent.intentSender)
session.close()
session?.commit(pendingIntent.intentSender)
session?.close()
Log.d("AppLog", "install request sent")
Log.d("AppLog", "doCommitSession: " + packageInstaller.mySessions)
Log.d("AppLog", "doCommitSession: " + packageInstaller?.mySessions)
Log.d("AppLog", "doCommitSession: after session commit ")
} catch (e: IOException) {
e.printStackTrace()
@ -288,20 +290,4 @@ open class BaseFragment : Fragment() {
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
when (requestCode) {
69 -> {
activity?.recreate()
}
420 -> {
activity?.recreate()
}
666 -> {
activity?.recreate()
}
}
}
}

View File

@ -116,4 +116,20 @@ open class Home : BaseFragment() {
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
when (requestCode) {
69 -> {
activity?.recreate()
}
420 -> {
activity?.recreate()
}
666 -> {
activity?.recreate()
}
}
}
}

View File

@ -45,7 +45,6 @@ class HomeFragment : Home() {
val tabLayout = view.findViewById(R.id.tablayout) as TabLayout
viewPager = view.findViewById(R.id.viewpager)
viewPager.adapter = sectionPageAdapter
viewPager.currentItem = 0
TabLayoutMediator(tabLayout, viewPager) { tab, position ->
when (position) {
@ -54,7 +53,6 @@ class HomeFragment : Home() {
2 -> tab.text = "Manager"
}
}.attach()
tabLayout.getTabAt(0)?.select()
}
@ -101,15 +99,6 @@ class HomeFragment : Home() {
}
}
}
/*!microgStatus -> {
microginstallbtn?.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.outline_cloud_download_24,
0,
0,
0
)
}
*/
vancedStatus!! -> {
val vancedVer =
pm.getPackageInfo("com.vanced.android.youtube", 0).versionName
@ -124,14 +113,6 @@ class HomeFragment : Home() {
}
}
}
/*!vancedStatus -> {
vancedinstallbtn?.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.outline_cloud_download_24,
0,
0,
0
)
}*/
}
val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0f, 0.3f)