new network library test
This commit is contained in:
parent
7ee2414f0e
commit
91503cf66c
|
@ -70,15 +70,15 @@
|
|||
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/classes" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/out" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/out" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/out" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/ap_generated_sources/debugUnitTest/out" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
|
|
32
app/app.iml
32
app/app.iml
File diff suppressed because one or more lines are too long
|
@ -61,7 +61,6 @@ dependencies {
|
|||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.activity:activity-ktx:1.1.0'
|
||||
implementation 'androidx.core:core-ktx:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.1.0'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.2.4'
|
||||
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
|
@ -72,8 +71,10 @@ dependencies {
|
|||
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.1.0'
|
||||
implementation 'com.github.ssseasonnn.RxDownload:rxdownload4:1.0.9'
|
||||
implementation 'com.github.100rabhkr:GetJSON:1.0'
|
||||
implementation 'com.github.pwittchen:reactivenetwork-rx2:3.0.8'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
|
|
|
@ -71,7 +71,7 @@ open class BaseFragment : Fragment() {
|
|||
Toast.makeText(requireContext(), throwable.toString(), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun downloadEn() {
|
||||
val url = "https://x1nto.github.io/VancedFiles/Splits/Language/split_config.en.apk"
|
||||
|
@ -81,19 +81,19 @@ open class BaseFragment : Fragment() {
|
|||
task.delete()
|
||||
|
||||
disposable = task
|
||||
.download()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeBy(
|
||||
onNext = {
|
||||
},
|
||||
onComplete = {
|
||||
},
|
||||
onError = { throwable ->
|
||||
Toast.makeText(requireContext(), throwable.toString(), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
.download()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeBy(
|
||||
onNext = {
|
||||
},
|
||||
onComplete = {
|
||||
},
|
||||
onError = { throwable ->
|
||||
Toast.makeText(requireContext(), throwable.toString(), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -67,7 +67,7 @@ open class Home : BaseFragment() {
|
|||
}
|
||||
|
||||
vancedinstallbtn.setOnClickListener {
|
||||
view.findNavController().navigate(R.id.toInstallThemeFragment)
|
||||
view.findNavController().navigate(R.id.toInstallVariantFragment)
|
||||
}
|
||||
|
||||
microginstallbtn.setOnClickListener {
|
||||
|
|
|
@ -15,11 +15,10 @@ open class ThemeInstall : BaseFragment() {
|
|||
val loadBar = view.findViewById<ProgressBar>(R.id.vantheme_progress)
|
||||
val themeGroup = view.findViewById<RadioGroup>(R.id.theme_radiogroup)
|
||||
|
||||
|
||||
nextButton.setOnClickListener {
|
||||
val selectedThemeId = themeGroup.checkedRadioButtonId
|
||||
val selectedButton = view.findViewById<RadioButton>(selectedThemeId)
|
||||
downloadSplit("theme", selectedButton.tag.toString(), false, loadBar, R.id.toInstallVariantFragment)
|
||||
downloadSplit("theme", selectedButton.tag.toString(), false, loadBar, R.id.toInstallLanguageFragment)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ open class VariantInstall : BaseFragment() {
|
|||
else -> "armeabi_v7a"
|
||||
}
|
||||
|
||||
downloadSplit("arch", arch, false, loadBar, R.id.toInstallLanguageFragment)
|
||||
downloadSplit("arch", arch, false, loadBar, R.id.toInstallThemeFragment)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ import android.widget.TextView
|
|||
import androidx.core.animation.addListener
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.dezlum.codelabs.getjson.GetJson
|
||||
import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
|
@ -20,11 +21,15 @@ import com.google.gson.JsonObject
|
|||
import com.vanced.manager.R
|
||||
import com.vanced.manager.adapter.SectionPageAdapter
|
||||
import com.vanced.manager.core.fragments.Home
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
class HomeFragment : Home() {
|
||||
|
||||
private lateinit var sectionPageAdapter: SectionPageAdapter
|
||||
private lateinit var viewPager: ViewPager2
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
|
@ -38,11 +43,13 @@ class HomeFragment : Home() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
||||
connectionStatus()
|
||||
checkNetwork()
|
||||
//connectionStatus()
|
||||
//checkNetwork()
|
||||
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
checkNetwork()
|
||||
|
||||
sectionPageAdapter = SectionPageAdapter(this)
|
||||
val tabLayout = view.findViewById(R.id.tablayout) as TabLayout
|
||||
viewPager = view.findViewById(R.id.viewpager)
|
||||
|
@ -58,12 +65,49 @@ class HomeFragment : Home() {
|
|||
|
||||
}
|
||||
|
||||
private fun checkNetwork() {
|
||||
val networkErrorLayout = view?.findViewById<MaterialCardView>(R.id.home_network_wrapper)
|
||||
|
||||
disposable = ReactiveNetwork.observeInternetConnectivity()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { isConnectedToInternet ->
|
||||
if (isConnectedToInternet) {
|
||||
if (networkErrorLayout?.visibility != View.GONE) {
|
||||
val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0f, 0.3f)
|
||||
val oa3 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, -1f)
|
||||
|
||||
oa2.start()
|
||||
oa3.apply {
|
||||
oa3.addListener(onEnd = {
|
||||
networkErrorLayout?.visibility = View.GONE
|
||||
})
|
||||
start()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (networkErrorLayout?.visibility != View.VISIBLE) {
|
||||
val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", -1f, 0.3f)
|
||||
val oa3 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, 0f)
|
||||
|
||||
oa2.apply {
|
||||
oa2.addListener(onStart = {
|
||||
networkErrorLayout?.visibility = View.VISIBLE
|
||||
})
|
||||
start()
|
||||
}
|
||||
oa3.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.toolbar_menu, menu)
|
||||
super .onCreateOptionsMenu(menu, inflater)
|
||||
}
|
||||
|
||||
private fun checkNetwork() {
|
||||
/*private fun checkNetwork() {
|
||||
if (!GetJson().isConnected(requireContext())) {
|
||||
|
||||
netUnavailable()
|
||||
|
@ -142,6 +186,7 @@ class HomeFragment : Home() {
|
|||
} catch (e: Exception) {}
|
||||
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:text="Català"
|
||||
android:tag="ca"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
app:popExitAnim="@animator/fragment_exit_pop" />
|
||||
|
||||
<action
|
||||
android:id="@+id/toInstallThemeFragment"
|
||||
app:destination="@id/install_theme_fragment"
|
||||
android:id="@+id/toInstallVariantFragment"
|
||||
app:destination="@id/install_variant_fragment"
|
||||
app:enterAnim="@animator/fragment_enter_right"
|
||||
app:exitAnim="@animator/fragment_exit_left"
|
||||
app:popEnterAnim="@animator/fragment_enter_left"
|
||||
|
@ -72,8 +72,8 @@
|
|||
tools:layout="@layout/fragment_vanced_theme_selection">
|
||||
|
||||
<action
|
||||
android:id="@+id/toInstallVariantFragment"
|
||||
app:destination="@id/install_variant_fragment"
|
||||
android:id="@+id/toInstallLanguageFragment"
|
||||
app:destination="@id/install_language_fragment"
|
||||
app:enterAnim="@animator/fragment_enter_right"
|
||||
app:exitAnim="@animator/fragment_exit_left"
|
||||
app:popEnterAnim="@animator/fragment_enter_left"
|
||||
|
@ -88,8 +88,8 @@
|
|||
tools:layout="@layout/fragment_vanced_variant_selection">
|
||||
|
||||
<action
|
||||
android:id="@+id/toInstallLanguageFragment"
|
||||
app:destination="@id/install_language_fragment"
|
||||
android:id="@+id/toInstallThemeFragment"
|
||||
app:destination="@id/install_theme_fragment"
|
||||
app:enterAnim="@animator/fragment_enter_right"
|
||||
app:exitAnim="@animator/fragment_exit_left"
|
||||
app:popEnterAnim="@animator/fragment_enter_left"
|
||||
|
|
Loading…
Reference in New Issue