diff --git a/.gitignore b/.gitignore index f545b32..ec84ae2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ /captures .externalNativeBuild /.idea/ +src/main/java/cf/android666/wanandroid/utils/Logger.kt +src/main/res/drawable/inputbox_bg.xml diff --git a/app/build.gradle b/app/build.gradle index b4704ce..c94bab0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,12 +32,12 @@ android { minSdkVersion 21 targetSdkVersion 28 versionCode Integer.parseInt(releaseTime()) - versionName "1.1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - ndk { - //腾讯bugly 设置支持的SO库架构 - abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a' - } + versionName "1.2.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" +// ndk { +// //腾讯bugly 设置支持的SO库架构 +// abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a' +// } } buildTypes { release { @@ -53,7 +53,7 @@ android { } productFlavors { - beta { + WanAndroid { buildConfigField "String", "BUGLY_APP_KEY", "\"$BUGLY_APP_KEY\"" } } @@ -68,34 +68,41 @@ android { //解决flavor Dimensions问题 http://blog.csdn.net/syif88/article/details/75009663 flavorDimensions "versionCode" + + //格式化输出文件名称 + applicationVariants.all { variant -> + variant.outputs.all { + outputFileName = "${variant.flavorName}-v${variant.versionName}-${variant.buildType.name}-${releaseTime()}.apk" + } + } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' - implementation 'com.android.support:design:28.0.0' - implementation 'com.android.support:cardview-v7:28.0.0' - implementation 'com.android.support:preference-v7:28.0.0' - implementation 'com.android.support:preference-v14:28.0.0' - implementation 'com.google.code.gson:gson:2.8.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.cardview:cardview:1.0.0' + implementation 'androidx.preference:preference:1.1.0' + implementation 'androidx.legacy:legacy-preference-v14:1.0.0' + implementation 'com.google.code.gson:gson:2.8.5' //高版本对fragment有影响 implementation 'com.github.bumptech.glide:glide:4.0.0' //打印日志 - implementation 'com.orhanobut:logger:2.1.1' + implementation 'com.orhanobut:logger:2.2.0' //网络相关 implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' implementation 'io.reactivex.rxjava2:rxjava:2.1.10' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0' implementation 'com.squareup.retrofit2:retrofit:2.3.0' - implementation 'com.squareup.retrofit2:converter-gson:2.1.0' + implementation 'com.squareup.retrofit2:converter-gson:2.3.0' //解析返回数据 implementation 'com.github.pinguo-zhouwei:MZBannerView:v2.0.0' - implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0' + implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0' //事件处理 implementation 'org.greenrobot:eventbus:3.1.1' //友盟sdk @@ -105,7 +112,7 @@ dependencies { //腾讯bugly implementation 'com.tencent.bugly:crashreport_upgrade:1.3.6' - implementation 'com.tencent.bugly:nativecrashreport:3.6.0.1' +// implementation 'com.tencent.bugly:nativecrashreport:3.6.0.1' //内存泄漏分析 debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4' diff --git a/app/src/androidTest/java/cf/android666/wanandroid/ExampleInstrumentedTest.kt b/app/src/androidTest/java/cf/android666/wanandroid/ExampleInstrumentedTest.kt index b5cbd4b..f9ac0e9 100644 --- a/app/src/androidTest/java/cf/android666/wanandroid/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/cf/android666/wanandroid/ExampleInstrumentedTest.kt @@ -1,13 +1,11 @@ package cf.android666.wanandroid -import android.support.test.InstrumentationRegistry -import android.support.test.runner.AndroidJUnit4 - +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith -import org.junit.Assert.* - /** * Instrumented test, which will execute on an Android device. * diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 684260a..4b59dec 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,7 +86,7 @@ android:configChanges="keyboardHidden|orientation|screenSize|locale" android:theme="@android:style/Theme.Translucent" /> diff --git a/app/src/main/java/cf/android666/wanandroid/MainActivity.kt b/app/src/main/java/cf/android666/wanandroid/MainActivity.kt index 6f2f4b1..b6cd86e 100644 --- a/app/src/main/java/cf/android666/wanandroid/MainActivity.kt +++ b/app/src/main/java/cf/android666/wanandroid/MainActivity.kt @@ -3,9 +3,8 @@ package cf.android666.wanandroid import android.app.SearchManager import android.content.Context import android.os.Bundle -import android.support.v4.view.ViewPager -import android.support.v7.widget.SearchView import android.view.Menu +import androidx.appcompat.widget.SearchView import cf.android666.wanandroid.adapter.MFragmentViewPagerAdapter import cf.android666.wanandroid.base.BaseActivity import cf.android666.wanandroid.base.BaseFragment @@ -15,6 +14,7 @@ import cf.android666.wanandroid.fragment.IndexFragment import cf.android666.wanandroid.utils.SharePreference import cf.android666.wanandroid.utils.SuperUtil import kotlinx.android.synthetic.main.activity_main.* + class MainActivity : BaseActivity() { @@ -26,7 +26,7 @@ class MainActivity : BaseActivity() { setSupportActionBar(toolbar) if (SharePreference.getV(SharePreference.IS_AUTO_UPDATE, false)) { - SuperUtil.update(this,false) + SuperUtil.update(this, false) } val fragments = arrayListOf() @@ -39,7 +39,7 @@ class MainActivity : BaseActivity() { val bottomNavIds = arrayListOf(R.id.index, R.id.discover, R.id.about) - viewpager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + viewpager.addOnPageChangeListener(object : androidx.viewpager.widget.ViewPager.OnPageChangeListener { override fun onPageScrollStateChanged(state: Int) { } @@ -55,17 +55,17 @@ class MainActivity : BaseActivity() { when (it.itemId) { R.id.index -> { // viewpager.currentItem = 0 - viewpager.setCurrentItem(0,false) + viewpager.setCurrentItem(0, false) return@setOnNavigationItemSelectedListener true } R.id.discover -> { // viewpager.currentItem = 1 - viewpager.setCurrentItem(1,false) + viewpager.setCurrentItem(1, false) return@setOnNavigationItemSelectedListener true } R.id.about -> { // viewpager.currentItem = 2 - viewpager.setCurrentItem(2,false) + viewpager.setCurrentItem(2, false) return@setOnNavigationItemSelectedListener true } else -> return@setOnNavigationItemSelectedListener false diff --git a/app/src/main/java/cf/android666/wanandroid/activity/SearchActivity.kt b/app/src/main/java/cf/android666/wanandroid/activity/SearchActivity.kt index a3a7676..a6fb0d3 100644 --- a/app/src/main/java/cf/android666/wanandroid/activity/SearchActivity.kt +++ b/app/src/main/java/cf/android666/wanandroid/activity/SearchActivity.kt @@ -4,16 +4,16 @@ import android.app.SearchManager import android.content.Context import android.content.Intent import android.os.Bundle -import android.support.v7.widget.LinearLayoutManager -import android.support.v7.widget.SearchView import android.view.Menu import android.widget.Toast +import androidx.appcompat.widget.SearchView +import androidx.recyclerview.widget.LinearLayoutManager import cf.android666.mylibrary.view.SwitchStateLayout import cf.android666.wanandroid.R import cf.android666.wanandroid.adapter.PostArticleAdapter +import cf.android666.wanandroid.api.cookie.CookieTools import cf.android666.wanandroid.base.BaseActivity import cf.android666.wanandroid.bean.BaseArticlesBean -import cf.android666.wanandroid.api.cookie.CookieTools import cf.android666.wanandroid.utils.SuperUtil import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers @@ -100,7 +100,7 @@ class SearchActivity : BaseActivity() { currentPage = it.data.curPage - recycler_view.adapter.notifyDataSetChanged() + recycler_view.adapter?.notifyDataSetChanged() }, { switch_state.showView(SwitchStateLayout.VIEW_ERROR) }, { diff --git a/app/src/main/java/cf/android666/wanandroid/adapter/DiscoverProjectsAdapter.kt b/app/src/main/java/cf/android666/wanandroid/adapter/DiscoverProjectsAdapter.kt index c28af70..9fc269b 100644 --- a/app/src/main/java/cf/android666/wanandroid/adapter/DiscoverProjectsAdapter.kt +++ b/app/src/main/java/cf/android666/wanandroid/adapter/DiscoverProjectsAdapter.kt @@ -1,9 +1,9 @@ package cf.android666.wanandroid.adapter -import android.support.v7.widget.RecyclerView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView import cf.android666.wanandroid.R import cf.android666.wanandroid.bean.BaseArticlesBean import cf.android666.wanandroid.fragment.DiscoverProjectsFragment @@ -22,7 +22,7 @@ class DiscoverProjectsAdapter(private val context: DiscoverProjectsFragment, private val imgBtnListener: ((view: View) -> Unit)) : RecyclerView.Adapter() { - override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): MViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MViewHolder { var view = LayoutInflater.from(parent!!.context) .inflate(R.layout.item_discover_projects, parent, false) @@ -36,7 +36,7 @@ class DiscoverProjectsAdapter(private val context: DiscoverProjectsFragment, } - override fun onBindViewHolder(holder: MViewHolder?, position: Int) { + override fun onBindViewHolder(holder: MViewHolder, position: Int) { holder!!.itemView.title.text = data[position].title @@ -66,7 +66,7 @@ class DiscoverProjectsAdapter(private val context: DiscoverProjectsFragment, } - class MViewHolder(view: View) : RecyclerView.ViewHolder(view) { + class MViewHolder(view: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(view) { init { diff --git a/app/src/main/java/cf/android666/wanandroid/adapter/MFragmentViewPagerAdapter.kt b/app/src/main/java/cf/android666/wanandroid/adapter/MFragmentViewPagerAdapter.kt index 3e7c3b6..66d18a0 100644 --- a/app/src/main/java/cf/android666/wanandroid/adapter/MFragmentViewPagerAdapter.kt +++ b/app/src/main/java/cf/android666/wanandroid/adapter/MFragmentViewPagerAdapter.kt @@ -1,18 +1,15 @@ package cf.android666.wanandroid.adapter -import android.support.v4.app.Fragment -import android.support.v4.app.FragmentManager -import android.support.v4.app.FragmentPagerAdapter import cf.android666.wanandroid.base.BaseFragment /** * Created by jixiaoyong on 2018/2/25. */ -class MFragmentViewPagerAdapter(fragmentManager:FragmentManager, +class MFragmentViewPagerAdapter(fragmentManager: androidx.fragment.app.FragmentManager, private val fragments:ArrayList) - : FragmentPagerAdapter(fragmentManager) { + : androidx.fragment.app.FragmentPagerAdapter(fragmentManager) { - override fun getItem(position: Int): Fragment { + override fun getItem(position: Int): androidx.fragment.app.Fragment { return fragments[position] } diff --git a/app/src/main/java/cf/android666/wanandroid/adapter/PostArticleAdapter.kt b/app/src/main/java/cf/android666/wanandroid/adapter/PostArticleAdapter.kt index 5d0c39b..12367f5 100644 --- a/app/src/main/java/cf/android666/wanandroid/adapter/PostArticleAdapter.kt +++ b/app/src/main/java/cf/android666/wanandroid/adapter/PostArticleAdapter.kt @@ -1,6 +1,5 @@ package cf.android666.wanandroid.adapter -import android.support.v7.widget.RecyclerView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -15,10 +14,10 @@ class PostArticleAdapter(private val data: ArrayList, private val isImageButtonSelect: Boolean, private val itemListener: ((url: String) -> Unit), private val imgBtnListener: ((view: View, position: Int) -> Unit)) - : RecyclerView.Adapter() { + : androidx.recyclerview.widget.RecyclerView.Adapter() { - override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): MViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MViewHolder { var view = LayoutInflater.from(parent!!.context) .inflate(R.layout.item_index_post, parent, false) @@ -31,7 +30,7 @@ class PostArticleAdapter(private val data: ArrayList, return data.size } - override fun onBindViewHolder(holder: MViewHolder?, position: Int) { + override fun onBindViewHolder(holder: MViewHolder, position: Int) { holder!!.itemView.title.text = data[position].title @@ -64,5 +63,5 @@ class PostArticleAdapter(private val data: ArrayList, } - class MViewHolder(view: View) : RecyclerView.ViewHolder(view) + class MViewHolder(view: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(view) } \ No newline at end of file diff --git a/app/src/main/java/cf/android666/wanandroid/api/WanAndroidService.kt b/app/src/main/java/cf/android666/wanandroid/api/WanAndroidService.kt index 843a652..5df24bf 100644 --- a/app/src/main/java/cf/android666/wanandroid/api/WanAndroidService.kt +++ b/app/src/main/java/cf/android666/wanandroid/api/WanAndroidService.kt @@ -1,10 +1,7 @@ package cf.android666.wanandroid.api -import android.text.Editable import cf.android666.wanandroid.bean.* import io.reactivex.Observable -import okhttp3.Cookie -import retrofit2.Call import retrofit2.http.* /** @@ -14,7 +11,7 @@ import retrofit2.http.* interface WanAndroidService{ companion object { - const val BASE_URL = "http://www.wanandroid.com/" + const val BASE_URL = "https://www.wanandroid.com/" } @GET("tree/json") diff --git a/app/src/main/java/cf/android666/wanandroid/base/BaseActivity.kt b/app/src/main/java/cf/android666/wanandroid/base/BaseActivity.kt index f8a8634..923580a 100644 --- a/app/src/main/java/cf/android666/wanandroid/base/BaseActivity.kt +++ b/app/src/main/java/cf/android666/wanandroid/base/BaseActivity.kt @@ -1,12 +1,10 @@ package cf.android666.wanandroid.base import android.os.Bundle -import android.support.v7.app.AppCompatActivity +import androidx.appcompat.app.AppCompatActivity import cf.android666.wanandroid.R import cf.android666.wanandroid.utils.EventInterface import cf.android666.wanandroid.utils.SharePreference -import com.squareup.leakcanary.LeakCanary - import com.umeng.analytics.MobclickAgent import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe diff --git a/app/src/main/java/cf/android666/wanandroid/base/BaseFragment.kt b/app/src/main/java/cf/android666/wanandroid/base/BaseFragment.kt index fccff57..40ff2db 100644 --- a/app/src/main/java/cf/android666/wanandroid/base/BaseFragment.kt +++ b/app/src/main/java/cf/android666/wanandroid/base/BaseFragment.kt @@ -1,7 +1,6 @@ package cf.android666.wanandroid.base import android.os.Bundle -import android.support.v4.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -9,7 +8,7 @@ import android.view.ViewGroup /** * Created by jixiaoyong on 2018/2/25. */ -abstract class BaseFragment : Fragment() { +abstract class BaseFragment : androidx.fragment.app.Fragment() { protected abstract var layoutId: Int @@ -20,7 +19,7 @@ abstract class BaseFragment : Fragment() { // 在viewpager中 // 在自身/相邻fragment显示的时候就已经执行了, // 在自身/相邻fragment由都不可见(会执行onDestroyView)转可见时执行onCreateView - override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { //复用view if (mView == null) { diff --git a/app/src/main/java/cf/android666/wanandroid/fragment/AboutFragment.kt b/app/src/main/java/cf/android666/wanandroid/fragment/AboutFragment.kt index bd8ef14..3471102 100644 --- a/app/src/main/java/cf/android666/wanandroid/fragment/AboutFragment.kt +++ b/app/src/main/java/cf/android666/wanandroid/fragment/AboutFragment.kt @@ -1,27 +1,24 @@ package cf.android666.wanandroid.fragment import android.app.AlertDialog +import android.content.Intent import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup import android.widget.Toast import cf.android666.wanandroid.R -import cf.android666.wanandroid.base.BaseFragment -import cf.android666.wanandroid.utils.SharePreference -import kotlinx.android.synthetic.main.fragment_about.view.* -import android.content.Intent import cf.android666.wanandroid.`interface`.RefreshUiInterface import cf.android666.wanandroid.activity.LoginActivity import cf.android666.wanandroid.activity.SettingActivity +import cf.android666.wanandroid.base.BaseFragment import cf.android666.wanandroid.utils.EventFactory import cf.android666.wanandroid.utils.EventInterface +import cf.android666.wanandroid.utils.SharePreference +import kotlinx.android.synthetic.main.fragment_about.view.* import org.greenrobot.eventbus.EventBus /** * Created by jixiaoyong on 2018/2/25. */ -class AboutFragment : BaseFragment() ,RefreshUiInterface{ +class AboutFragment : BaseFragment(), RefreshUiInterface { override fun lazyLoadData() { @@ -49,7 +46,7 @@ class AboutFragment : BaseFragment() ,RefreshUiInterface{ } else { mView!!.user_icon.setOnClickListener { - context.startActivity(Intent(activity, LoginActivity::class.java)) + requireContext().startActivity(Intent(activity, LoginActivity::class.java)) } @@ -67,7 +64,7 @@ class AboutFragment : BaseFragment() ,RefreshUiInterface{ } mView!!.more_tv.setOnClickListener { - context.startActivity(Intent(activity, SettingActivity::class.java)) + requireContext().startActivity(Intent(activity, SettingActivity::class.java)) } } @@ -79,7 +76,7 @@ class AboutFragment : BaseFragment() ,RefreshUiInterface{ when (eventInterface) { - is EventFactory.LoginState ->{ + is EventFactory.LoginState -> { updateUserName() @@ -101,7 +98,7 @@ class AboutFragment : BaseFragment() ,RefreshUiInterface{ dialog.dismiss() - EventBus.getDefault().postSticky(EventFactory.LoginState(false,"")) + EventBus.getDefault().postSticky(EventFactory.LoginState(false, "")) Toast.makeText(context, "注销成功", Toast.LENGTH_SHORT).show() @@ -119,15 +116,15 @@ class AboutFragment : BaseFragment() ,RefreshUiInterface{ //todo 在切换activity的时候做个动画掩饰,可以参考酷软 - val intent = activity.intent + val intent = requireActivity().intent - activity.overridePendingTransition(0, 0)//不设置进入退出动画 + requireActivity().overridePendingTransition(0, 0)//不设置进入退出动画 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) - activity.finish() + requireActivity().finish() - activity.overridePendingTransition(0, 0) + requireActivity().overridePendingTransition(0, 0) startActivity(intent) } diff --git a/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverFragment.kt b/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverFragment.kt index 3be177c..48449f1 100644 --- a/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverFragment.kt +++ b/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverFragment.kt @@ -1,9 +1,6 @@ package cf.android666.wanandroid.fragment import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup import cf.android666.wanandroid.R import cf.android666.wanandroid.adapter.MFragmentViewPagerAdapter import cf.android666.wanandroid.base.BaseFragment diff --git a/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverNaviFragment.kt b/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverNaviFragment.kt index 6a510f7..e902176 100644 --- a/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverNaviFragment.kt +++ b/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverNaviFragment.kt @@ -1,15 +1,12 @@ package cf.android666.wanandroid.fragment import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup import cf.android666.mylibrary.view.SwitchStateLayout import cf.android666.wanandroid.R import cf.android666.wanandroid.adapter.DiscoverNaviAdapter +import cf.android666.wanandroid.api.cookie.CookieTools import cf.android666.wanandroid.base.BaseFragment import cf.android666.wanandroid.bean.DiscoverNaviBean -import cf.android666.wanandroid.api.cookie.CookieTools import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers import kotlinx.android.synthetic.main.fragment_discover_tree.view.* @@ -43,7 +40,7 @@ class DiscoverNaviFragment : BaseFragment() { mData.addAll(it.data) - mView!!.expandable_layout.setAdapter(DiscoverNaviAdapter(context, mData)) + mView!!.expandable_layout.setAdapter(DiscoverNaviAdapter(requireContext(), mData)) }, { mView!!.switch_state.showView(SwitchStateLayout.VIEW_ERROR) }, { diff --git a/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverProjectsFragment.kt b/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverProjectsFragment.kt index 87a8edd..094cb19 100644 --- a/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverProjectsFragment.kt +++ b/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverProjectsFragment.kt @@ -1,26 +1,26 @@ package cf.android666.wanandroid.fragment import android.os.Bundle -import android.support.design.widget.TabLayout -import android.support.v7.widget.StaggeredGridLayoutManager +import androidx.recyclerview.widget.StaggeredGridLayoutManager import cf.android666.mylibrary.view.SwitchStateLayout import cf.android666.wanandroid.R import cf.android666.wanandroid.activity.ContentActivity import cf.android666.wanandroid.adapter.DiscoverProjectsAdapter +import cf.android666.wanandroid.api.cookie.CookieTools import cf.android666.wanandroid.base.BaseFragment import cf.android666.wanandroid.bean.BaseArticlesBean import cf.android666.wanandroid.bean.DiscoverProjectTreeBean -import cf.android666.wanandroid.api.cookie.CookieTools import cf.android666.wanandroid.utils.SuperUtil +import com.google.android.material.tabs.TabLayout import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers import kotlinx.android.synthetic.main.fragment_discover_projects.view.* -import java.util.ArrayList +import java.util.* /** * Created by jixiaoyong on 2018/2/25. */ -class DiscoverProjectsFragment() : BaseFragment() { +class DiscoverProjectsFragment : BaseFragment() { private var mData = ArrayList() @@ -73,7 +73,7 @@ class DiscoverProjectsFragment() : BaseFragment() { mView!!.recycler_view.adapter = DiscoverProjectsAdapter(this, mData, { - SuperUtil.startActivity(context, ContentActivity::class.java, it) + SuperUtil.startActivity(requireContext(), ContentActivity::class.java, it) }, { @@ -133,7 +133,7 @@ class DiscoverProjectsFragment() : BaseFragment() { .getProjectItems(page, cid) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe ({ + .subscribe({ when (page) { @@ -149,7 +149,7 @@ class DiscoverProjectsFragment() : BaseFragment() { currentPage = it.data.curPage - view!!.recycler_view.adapter.notifyDataSetChanged() + view!!.recycler_view.adapter?.notifyDataSetChanged() view!!.swipe_refresh.isRefreshing = false diff --git a/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverTreeFragment.kt b/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverTreeFragment.kt index 85c84fe..73738f3 100644 --- a/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverTreeFragment.kt +++ b/app/src/main/java/cf/android666/wanandroid/fragment/DiscoverTreeFragment.kt @@ -1,15 +1,12 @@ package cf.android666.wanandroid.fragment import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup import cf.android666.mylibrary.view.SwitchStateLayout import cf.android666.wanandroid.R import cf.android666.wanandroid.adapter.DiscoverTreeAdapter +import cf.android666.wanandroid.api.cookie.CookieTools import cf.android666.wanandroid.base.BaseFragment import cf.android666.wanandroid.bean.DiscoverTreeBean -import cf.android666.wanandroid.api.cookie.CookieTools import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers import kotlinx.android.synthetic.main.fragment_discover_tree.view.* @@ -23,7 +20,7 @@ class DiscoverTreeFragment : BaseFragment() { override fun onCreateViewState(savedInstanceState: Bundle?) { mView!!.switch_state.showView(SwitchStateLayout.VIEW_EMPTY) - mView!!.expandable_layout.setAdapter(DiscoverTreeAdapter(context, mData)) + mView!!.expandable_layout.setAdapter(DiscoverTreeAdapter(requireContext(), mData)) } override fun lazyLoadData() { @@ -39,7 +36,7 @@ class DiscoverTreeFragment : BaseFragment() { mData.addAll(it.data) - mView!!.expandable_layout.setAdapter(DiscoverTreeAdapter(context, mData)) + mView!!.expandable_layout.setAdapter(DiscoverTreeAdapter(requireContext(), mData)) }, { mView!!.switch_state.showView(SwitchStateLayout.VIEW_ERROR) }, { diff --git a/app/src/main/java/cf/android666/wanandroid/fragment/IndexFavoriteFragment.kt b/app/src/main/java/cf/android666/wanandroid/fragment/IndexFavoriteFragment.kt index 1a29f74..bacf3d4 100644 --- a/app/src/main/java/cf/android666/wanandroid/fragment/IndexFavoriteFragment.kt +++ b/app/src/main/java/cf/android666/wanandroid/fragment/IndexFavoriteFragment.kt @@ -1,19 +1,21 @@ package cf.android666.wanandroid.fragment import android.os.Bundle -import android.support.v7.widget.LinearLayoutManager import android.view.View import android.widget.Toast +import androidx.recyclerview.widget.LinearLayoutManager import cf.android666.mylibrary.view.SwitchStateLayout import cf.android666.wanandroid.R import cf.android666.wanandroid.`interface`.RefreshUiInterface import cf.android666.wanandroid.activity.ContentActivity import cf.android666.wanandroid.adapter.PostArticleAdapter +import cf.android666.wanandroid.api.cookie.CookieTools import cf.android666.wanandroid.base.BaseFragment import cf.android666.wanandroid.bean.BaseArticlesBean -import cf.android666.wanandroid.api.cookie.CookieTools -import cf.android666.wanandroid.utils.* -import com.orhanobut.logger.Logger +import cf.android666.wanandroid.utils.EventFactory +import cf.android666.wanandroid.utils.EventInterface +import cf.android666.wanandroid.utils.SharePreference +import cf.android666.wanandroid.utils.SuperUtil import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers import kotlinx.android.synthetic.main.fragment_index_favorite.* @@ -83,14 +85,14 @@ class IndexFavoriteFragment : BaseFragment(), RefreshUiInterface { } - mView!!.recycler_view.layoutManager = LinearLayoutManager(context, - LinearLayoutManager.VERTICAL, false) + mView!!.recycler_view.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context, + androidx.recyclerview.widget.LinearLayoutManager.VERTICAL, false) mView!!.recycler_view.adapter = PostArticleAdapter(mData, true, { - SuperUtil.startActivity(context, ContentActivity::class.java, it) + SuperUtil.startActivity(requireContext(), ContentActivity::class.java, it) }, { it, position -> @@ -100,7 +102,7 @@ class IndexFavoriteFragment : BaseFragment(), RefreshUiInterface { mData.removeAt(position) - mView!!.recycler_view.adapter.notifyDataSetChanged() + mView!!.recycler_view.adapter?.notifyDataSetChanged() }) diff --git a/app/src/main/java/cf/android666/wanandroid/fragment/IndexFragment.kt b/app/src/main/java/cf/android666/wanandroid/fragment/IndexFragment.kt index ca878cc..30c840a 100644 --- a/app/src/main/java/cf/android666/wanandroid/fragment/IndexFragment.kt +++ b/app/src/main/java/cf/android666/wanandroid/fragment/IndexFragment.kt @@ -1,16 +1,9 @@ package cf.android666.wanandroid.fragment import android.os.Bundle -import android.support.design.widget.TabItem -import android.support.design.widget.TabLayout -import android.support.v4.view.ViewPager -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup import cf.android666.wanandroid.R import cf.android666.wanandroid.adapter.MFragmentViewPagerAdapter import cf.android666.wanandroid.base.BaseFragment -import kotlinx.android.synthetic.main.fragment_index.* import kotlinx.android.synthetic.main.fragment_index.view.* /** diff --git a/app/src/main/java/cf/android666/wanandroid/fragment/IndexPostFragment.kt b/app/src/main/java/cf/android666/wanandroid/fragment/IndexPostFragment.kt index 3c2e950..8205389 100644 --- a/app/src/main/java/cf/android666/wanandroid/fragment/IndexPostFragment.kt +++ b/app/src/main/java/cf/android666/wanandroid/fragment/IndexPostFragment.kt @@ -1,27 +1,24 @@ package cf.android666.wanandroid.fragment import android.os.Bundle -import android.support.v4.widget.NestedScrollView -import android.support.v7.widget.LinearLayoutManager -import android.support.v7.widget.RecyclerView -import android.view.View import android.widget.Toast +import androidx.core.widget.NestedScrollView +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import cf.android666.mylibrary.view.SwitchStateLayout import cf.android666.wanandroid.R import cf.android666.wanandroid.`interface`.RefreshUiInterface import cf.android666.wanandroid.activity.ContentActivity import cf.android666.wanandroid.adapter.PostArticleAdapter +import cf.android666.wanandroid.api.cookie.CookieTools import cf.android666.wanandroid.base.BaseFragment import cf.android666.wanandroid.bean.BaseArticlesBean -import cf.android666.wanandroid.api.cookie.CookieTools import cf.android666.wanandroid.utils.* -import com.orhanobut.logger.AndroidLogAdapter -import com.orhanobut.logger.Logger +import com.zhouwei.mzbanner.MZBannerView import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers -import kotlinx.android.synthetic.main.fragment_index_post.view.* -import com.zhouwei.mzbanner.MZBannerView import kotlinx.android.synthetic.main.fragment_index_post.* +import kotlinx.android.synthetic.main.fragment_index_post.view.* import org.greenrobot.eventbus.EventBus /** @@ -57,12 +54,12 @@ class IndexPostFragment : BaseFragment(), RefreshUiInterface { mView!!.switch_state.showView(SwitchStateLayout.VIEW_LOADING) - mView!!.recycler_view.layoutManager = LinearLayoutManager(context, - LinearLayoutManager.VERTICAL, false) + mView!!.recycler_view.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context, + androidx.recyclerview.widget.LinearLayoutManager.VERTICAL, false) mView!!.recycler_view.adapter = PostArticleAdapter(mData, false, { - SuperUtil.startActivity(context, ContentActivity::class.java, it) + SuperUtil.startActivity(requireContext(), ContentActivity::class.java, it) }, { view, position -> @@ -94,7 +91,7 @@ class IndexPostFragment : BaseFragment(), RefreshUiInterface { if ((scrollY - oldScrollY) > 0 && (scrollY + v!!.measuredHeight) == mView!!.switch_state.measuredHeight - && recyclerView.scrollState == RecyclerView.SCROLL_STATE_IDLE) { + && recyclerView.scrollState == androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE) { Toast.makeText(context,"更新数据中...",Toast.LENGTH_SHORT).show() downloadData(++currentPage) @@ -205,7 +202,7 @@ class IndexPostFragment : BaseFragment(), RefreshUiInterface { if (view != null) { - view!!.recycler_view.adapter.notifyDataSetChanged() + view!!.recycler_view.adapter?.notifyDataSetChanged() childCount = recycler_view.childCount } diff --git a/app/src/main/java/cf/android666/wanandroid/fragment/SettingsFragment.kt b/app/src/main/java/cf/android666/wanandroid/fragment/SettingsFragment.kt index 10bd386..ce88db0 100644 --- a/app/src/main/java/cf/android666/wanandroid/fragment/SettingsFragment.kt +++ b/app/src/main/java/cf/android666/wanandroid/fragment/SettingsFragment.kt @@ -1,8 +1,10 @@ package cf.android666.wanandroid.fragment import android.os.Bundle -import android.support.v7.preference.* -import android.widget.Switch +import androidx.preference.Preference +import androidx.preference.PreferenceCategory +import androidx.preference.PreferenceFragmentCompat +import androidx.preference.SwitchPreferenceCompat import cf.android666.wanandroid.R import cf.android666.wanandroid.activity.ContentActivity import cf.android666.wanandroid.utils.SharePreference @@ -18,7 +20,7 @@ class SettingsFragment:PreferenceFragmentCompat(){ addPreferencesFromResource(R.xml.settings) - var version = context.packageManager.getPackageInfo(context.packageName,0).versionName + var version = requireContext().packageManager.getPackageInfo(requireContext().packageName, 0).versionName (preferenceScreen.getPreference(0) as PreferenceCategory).getPreference(1).summary = version @@ -30,20 +32,23 @@ class SettingsFragment:PreferenceFragmentCompat(){ "update"-> { if ((preference as SwitchPreferenceCompat).isChecked) { - SuperUtil.update(context,true) + SuperUtil.update(requireContext(), true) } SharePreference.saveKV(SharePreference.IS_AUTO_UPDATE,preference.isChecked) } - "version"-> {SuperUtil.toast(context, + "version" -> { + SuperUtil.toast(requireContext(), "当前版本是${preference.summary}")} - "project_url"-> {SuperUtil.startActivity(context,ContentActivity::class.java + "project_url" -> { + SuperUtil.startActivity(requireContext(), ContentActivity::class.java ,preference.summary.toString())} - "author_url"-> {SuperUtil.startActivity(context,ContentActivity::class.java + "author_url" -> { + SuperUtil.startActivity(requireContext(), ContentActivity::class.java ,preference.summary.toString())} "about_summary"-> {} } diff --git a/app/src/main/java/cf/android666/wanandroid/utils/Logger.kt b/app/src/main/java/cf/android666/wanandroid/utils/Logger.kt new file mode 100644 index 0000000..7561a64 --- /dev/null +++ b/app/src/main/java/cf/android666/wanandroid/utils/Logger.kt @@ -0,0 +1,41 @@ +package cf.android666.wanandroid.utils + +import android.util.Log + +/** + * author: jixiaoyong + * email: jixiaoyong1995@gmail.com + * website: www.jixiaoyong.github.io + * date: 2019/1/19 + * description: todo + */ + +object Logger { + + @JvmStatic + var isLog = true + + @JvmStatic + fun generateTag(): String { + val stack = Thread.currentThread().stackTrace[3] + return "${stack.className}.${stack.methodName}(Line:${stack.lineNumber})" + } + + fun d(any: Any) { + if (isLog) { + Log.d(generateTag(), any.toString()) + } + } + + fun e(any: Any) { + if (isLog) { + Log.e(generateTag(), any.toString()) + } + } + + fun i(any: Any) { + if (isLog) { + Log.i(generateTag(), any.toString()) + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/inputbox_bg.xml b/app/src/main/res/drawable/inputbox_bg.xml new file mode 100644 index 0000000..cca2aba --- /dev/null +++ b/app/src/main/res/drawable/inputbox_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_content.xml b/app/src/main/res/layout/activity_content.xml index 42ad21a..66d3944 100644 --- a/app/src/main/res/layout/activity_content.xml +++ b/app/src/main/res/layout/activity_content.xml @@ -5,14 +5,14 @@ android:layout_height="match_parent" android:orientation="vertical"> - - + - - - + - - - + - - - + - - + - - + - - - + - - + - - - - - + - diff --git a/app/src/main/res/layout/fragment_discover_projects.xml b/app/src/main/res/layout/fragment_discover_projects.xml index 2afda92..2b57b6d 100644 --- a/app/src/main/res/layout/fragment_discover_projects.xml +++ b/app/src/main/res/layout/fragment_discover_projects.xml @@ -1,5 +1,5 @@ - - - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_index.xml b/app/src/main/res/layout/fragment_index.xml index 7447091..89bdf82 100644 --- a/app/src/main/res/layout/fragment_index.xml +++ b/app/src/main/res/layout/fragment_index.xml @@ -5,28 +5,28 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - + - diff --git a/app/src/main/res/layout/fragment_index_favorite.xml b/app/src/main/res/layout/fragment_index_favorite.xml index e082457..7ee50ab 100644 --- a/app/src/main/res/layout/fragment_index_favorite.xml +++ b/app/src/main/res/layout/fragment_index_favorite.xml @@ -1,5 +1,5 @@ - @@ -19,4 +19,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_index_post.xml b/app/src/main/res/layout/fragment_index_post.xml index 949dbb9..171f8a1 100644 --- a/app/src/main/res/layout/fragment_index_post.xml +++ b/app/src/main/res/layout/fragment_index_post.xml @@ -1,11 +1,11 @@ - - @@ -48,7 +48,7 @@ - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/item_discover_projects.xml b/app/src/main/res/layout/item_discover_projects.xml index e7c8af5..07474a1 100644 --- a/app/src/main/res/layout/item_discover_projects.xml +++ b/app/src/main/res/layout/item_discover_projects.xml @@ -1,5 +1,5 @@ - - + diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 8d8a8d5..86224a6 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -7,7 +7,7 @@ android:icon="@drawable/ic_search_black_24dp" android:title="Search" app:showAsAction="always|collapseActionView" - app:actionViewClass="android.support.v7.widget.SearchView" + app:actionViewClass="androidx.appcompat.widget.SearchView" /> diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index 3a84f84..df24e90 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -1,8 +1,8 @@ - - + - + - + - + - \ No newline at end of file + \ No newline at end of file diff --git a/build.gradle b/build.gradle index ee71e3c..b6a3be0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,23 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.51' - ext.kotlin_version_plugin = '1.3.11' + ext { + kotlin_version = '1.3.50' + } repositories { - maven {url'http://maven.aliyun.com/nexus/content/groups/public/'} google() jcenter() + maven { url 'http://maven.aliyun.com/nexus/content/groups/public' } + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + maven { url 'https://maven.aliyun.com/repository/jcenter' } + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'https://jitpack.io' }//for MZBannerView,PersistentCookieJar } dependencies { - classpath 'com.android.tools.build:gradle:3.3.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version_plugin" + classpath 'com.android.tools.build:gradle:3.5.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -20,9 +25,13 @@ buildscript { allprojects { repositories { - maven {url'http://maven.aliyun.com/nexus/content/groups/public/'} google() jcenter() + maven { url 'http://maven.aliyun.com/nexus/content/groups/public' } + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + maven { url 'https://maven.aliyun.com/repository/jcenter' } + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'https://jitpack.io' } } } diff --git a/gradle.properties b/gradle.properties index e48029f..29a54c0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,6 +21,8 @@ org.gradle.parallel=true org.gradle.daemon=true # \u5F00\u542Fkotlin\u7684\u589E\u91CF\u7F16\u8BD1 kotlin.incremental=true +android.useAndroidX=true +android.enableJetifier=true # \u53C2\u8003\u6587\u7AE0 # \u4E00\u4E9B\u5173\u4E8E\u52A0\u901FGradle\u6784\u5EFA\u7684\u4E2A\u4EBA\u7ECF\u9A8C - \u6280\u672F\u5C0F\u9ED1\u5C4B diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a3680ca..1ccf188 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Jan 19 16:27:42 CST 2019 +#Sat Nov 02 14:48:46 CST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/mylibrary/build.gradle b/mylibrary/build.gradle index a5fa734..c798c14 100644 --- a/mylibrary/build.gradle +++ b/mylibrary/build.gradle @@ -11,7 +11,7 @@ android { versionCode 2 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -37,12 +37,12 @@ android { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'androidx.appcompat:appcompat:1.0.0' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.1' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.android.support:recyclerview-v7:26.1.0' + implementation 'androidx.recyclerview:recyclerview:1.0.0' } repositories { mavenCentral() diff --git a/mylibrary/src/androidTest/java/cf/android666/mylibrary/ExampleInstrumentedTest.java b/mylibrary/src/androidTest/java/cf/android666/mylibrary/ExampleInstrumentedTest.java index f986fd2..6178046 100644 --- a/mylibrary/src/androidTest/java/cf/android666/mylibrary/ExampleInstrumentedTest.java +++ b/mylibrary/src/androidTest/java/cf/android666/mylibrary/ExampleInstrumentedTest.java @@ -1,13 +1,14 @@ package cf.android666.mylibrary; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * Instrumented test, which will execute on an Android device. diff --git a/mylibrary/src/main/java/cf/android666/mylibrary/view/AutoRefreshRecyclerView.kt b/mylibrary/src/main/java/cf/android666/mylibrary/view/AutoRefreshRecyclerView.kt index 1e09860..064d488 100644 --- a/mylibrary/src/main/java/cf/android666/mylibrary/view/AutoRefreshRecyclerView.kt +++ b/mylibrary/src/main/java/cf/android666/mylibrary/view/AutoRefreshRecyclerView.kt @@ -1,12 +1,10 @@ package cf.android666.wanandroid.view import android.content.Context -import android.support.v7.widget.LinearLayoutManager -import android.support.v7.widget.RecyclerView -import android.support.v7.widget.StaggeredGridLayoutManager import android.util.AttributeSet import android.util.Log import android.view.MotionEvent +import androidx.recyclerview.widget.RecyclerView /** * Created by jixiaoyong on 2018/3/13. @@ -45,11 +43,11 @@ class AutoRefreshRecyclerView(context: Context, attributeSet: AttributeSet?, def when(layoutManager){ - is LinearLayoutManager -> - lastPosition = (layoutManager as LinearLayoutManager).findLastVisibleItemPosition() + is androidx.recyclerview.widget.LinearLayoutManager -> + lastPosition = (layoutManager as androidx.recyclerview.widget.LinearLayoutManager).findLastVisibleItemPosition() - is StaggeredGridLayoutManager -> - lastPosition = (layoutManager as StaggeredGridLayoutManager).findLastVisibleItemPositions(IntArray(2))[1] + is androidx.recyclerview.widget.StaggeredGridLayoutManager -> + lastPosition = (layoutManager as androidx.recyclerview.widget.StaggeredGridLayoutManager).findLastVisibleItemPositions(IntArray(2))[1] } diff --git a/mylibrary/src/main/java/cf/android666/mylibrary/view/SwitchStateLayout.kt b/mylibrary/src/main/java/cf/android666/mylibrary/view/SwitchStateLayout.kt index 70b6566..1b6ab14 100644 --- a/mylibrary/src/main/java/cf/android666/mylibrary/view/SwitchStateLayout.kt +++ b/mylibrary/src/main/java/cf/android666/mylibrary/view/SwitchStateLayout.kt @@ -2,11 +2,11 @@ package cf.android666.mylibrary.view import android.content.Context import android.os.Build -import android.support.annotation.RequiresApi import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import android.widget.FrameLayout +import androidx.annotation.RequiresApi import cf.android666.mylibrary.R import java.util.*