Commit 284aa6af authored by mengcuiguang2's avatar mengcuiguang2

代码优化

parent d68c6994
...@@ -67,7 +67,7 @@ class HomePresenter : BasePresenter<HomeView>() { ...@@ -67,7 +67,7 @@ class HomePresenter : BasePresenter<HomeView>() {
when (code) { when (code) {
200 -> { 200 -> {
view.topTabsSuc(baseResponse.data) view.topTabsSuc(baseResponse.data)
showTurn() // showTurn()
} }
else -> { else -> {
view.showToast(message) view.showToast(message)
......
...@@ -82,7 +82,7 @@ class MyPresenter : BasePresenter<MyView>() { ...@@ -82,7 +82,7 @@ class MyPresenter : BasePresenter<MyView>() {
val code = baseResponse.status val code = baseResponse.status
when (code) { when (code) {
200 -> { 200 -> {
showTurn() // showTurn()
getMyInfo() getMyInfo()
} }
} }
......
...@@ -73,7 +73,7 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView { ...@@ -73,7 +73,7 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
ninePresenter.showTurn() // ninePresenter.showTurn()
} }
override fun onDestroy() { override fun onDestroy() {
...@@ -127,7 +127,7 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView { ...@@ -127,7 +127,7 @@ class NineActivity : BaseActivity(), View.OnClickListener, NineView {
} }
override fun unlockSuc() { override fun unlockSuc() {
ninePresenter.showTurn() // ninePresenter.showTurn()
if (isAdShow) { if (isAdShow) {
if (nineShowBean != null) { if (nineShowBean != null) {
......
...@@ -121,14 +121,14 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener ...@@ -121,14 +121,14 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
hotStyleAdapter.animationEnable = false hotStyleAdapter.animationEnable = false
rv_pic_list.adapter = hotStyleAdapter rv_pic_list.adapter = hotStyleAdapter
val emptyView = val emptyView =
LayoutInflater.from(requireContext()).inflate(R.layout.item_empty_data, null) LayoutInflater.from(requireContext()).inflate(R.layout.item_empty_data, null)
hotStyleAdapter.setEmptyView(emptyView) hotStyleAdapter.setEmptyView(emptyView)
hotStyleAdapter.setOnCustomChildClickListener(object : hotStyleAdapter.setOnCustomChildClickListener(object :
NewHotStyleAdapter.OnCustomChildClickListener { NewHotStyleAdapter.OnCustomChildClickListener {
override fun onCustomChildClick(view: View, vedioBean: VedioBean) { override fun onCustomChildClick(view: View, vedioBean: VedioBean) {
LocalVedioManager.startVedioDetailActivityForType( LocalVedioManager.startVedioDetailActivityForType(
requireActivity(), requireActivity(),
vedioBean vedioBean
) )
} }
}) })
...@@ -169,19 +169,21 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener ...@@ -169,19 +169,21 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
var insertIndex = 3 var insertIndex = 3
val allData = hotStyleAdapter.data val allData = hotStyleAdapter.data
for (i in allData.size - 1 downTo 0) { if (allData != null && allData.size > 0) {
if (allData[i].itemType == MULTI_ITEM_3) { for (i in allData.size - 1 downTo 0) {
insertIndex += 4 if (allData[i].itemType == MULTI_ITEM_3) {
insertIndex += 4
}
}
if (insertIndex >= allData.size) {
insertIndex = allData.size
} }
}
if (insertIndex >= allData.size) {
insertIndex = allData.size
}
if (allData[allData.lastIndex].itemType == MULTI_ITEM_3) return if (allData[allData.lastIndex].itemType == MULTI_ITEM_3) return
val data = VideoMultiItemEntity3(MULTI_ITEM_3, null, adView) val data = VideoMultiItemEntity3(MULTI_ITEM_3, null, adView)
hotStyleAdapter.addData(insertIndex, data) hotStyleAdapter.addData(insertIndex, data)
}
} }
override fun onDestroyView() { override fun onDestroyView() {
......
...@@ -100,7 +100,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -100,7 +100,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
} }
if (!TextUtils.isEmpty(userManager?.userID)) { if (!TextUtils.isEmpty(userManager?.userID)) {
myPresenter.showTurn() // myPresenter.showTurn()
myPresenter.getMyInfo() myPresenter.getMyInfo()
} else { } else {
myPresenter.userLogin() myPresenter.userLogin()
...@@ -209,7 +209,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -209,7 +209,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
//----9宫格逻辑--开始--// //----9宫格逻辑--开始--//
override fun unlockSuc() { override fun unlockSuc() {
myPresenter.showTurn() // myPresenter.showTurn()
if (nineShowBean != null) { if (nineShowBean != null) {
if (nineShowBean!!.need - nineShowBean!!.complete-1>0) { if (nineShowBean!!.need - nineShowBean!!.complete-1>0) {
......
...@@ -28,8 +28,7 @@ public class UIUtils { ...@@ -28,8 +28,7 @@ public class UIUtils {
DisplayMetrics dm = context.getResources().getDisplayMetrics(); DisplayMetrics dm = context.getResources().getDisplayMetrics();
return dm.widthPixels; return dm.widthPixels;
}catch (Exception e){ }catch (Exception e){
DisplayMetrics dm = ForegroundOrBackground.getTopActivity().getResources().getDisplayMetrics(); return 0;
return dm.widthPixels;
} }
} }
...@@ -39,8 +38,7 @@ public class UIUtils { ...@@ -39,8 +38,7 @@ public class UIUtils {
DisplayMetrics dm = context.getResources().getDisplayMetrics(); DisplayMetrics dm = context.getResources().getDisplayMetrics();
return dm.heightPixels; return dm.heightPixels;
}catch (Exception e){ }catch (Exception e){
DisplayMetrics dm = ForegroundOrBackground.getTopActivity().getResources().getDisplayMetrics(); return 0;
return dm.heightPixels;
} }
} }
...@@ -60,8 +58,7 @@ public class UIUtils { ...@@ -60,8 +58,7 @@ public class UIUtils {
final float scale = context.getResources().getDisplayMetrics().density; final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f); return (int) (dpValue * scale + 0.5f);
}catch (Exception e){ }catch (Exception e){
final float scale = ForegroundOrBackground.getTopActivity().getResources().getDisplayMetrics().density; return 0;
return (int) (dpValue * scale + 0.5f);
} }
} }
...@@ -293,8 +290,7 @@ public class UIUtils { ...@@ -293,8 +290,7 @@ public class UIUtils {
final float scale = context.getResources().getDisplayMetrics().density; final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / (scale <= 0 ? 1 : scale) + 0.5f); return (int) (pxValue / (scale <= 0 ? 1 : scale) + 0.5f);
}catch (Exception e){ }catch (Exception e){
final float scale = ForegroundOrBackground.getTopActivity().getResources().getDisplayMetrics().density; return 0;
return (int) (pxValue / (scale <= 0 ? 1 : scale) + 0.5f);
} }
} }
...@@ -304,8 +300,7 @@ public class UIUtils { ...@@ -304,8 +300,7 @@ public class UIUtils {
final float scale = context.getResources().getDisplayMetrics().density; final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dp * scale + 0.5f); return (int) (dp * scale + 0.5f);
}catch (Exception e){ }catch (Exception e){
final float scale = ForegroundOrBackground.getTopActivity().getResources().getDisplayMetrics().density; return 0;
return (int) (dp * scale + 0.5f);
} }
} }
......
...@@ -268,7 +268,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -268,7 +268,7 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
videoPresenter.showTurn() // videoPresenter.showTurn()
if (mVipFlag != UserManager.getInstance().vipFlag && UserManager.getInstance().vipFlag) { if (mVipFlag != UserManager.getInstance().vipFlag && UserManager.getInstance().vipFlag) {
// 重置状态 // 重置状态
......
...@@ -82,7 +82,7 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -82,7 +82,7 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
super_short_video_view.resume() super_short_video_view.resume()
videoPresenter.showTurn() // videoPresenter.showTurn()
if (mVipFlag != UserManager.getInstance().vipFlag && UserManager.getInstance().vipFlag) { if (mVipFlag != UserManager.getInstance().vipFlag && UserManager.getInstance().vipFlag) {
// 重置状态 // 重置状态
......
...@@ -79,7 +79,7 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -79,7 +79,7 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
super.onResume() super.onResume()
new_super_short_video_view.resume() new_super_short_video_view.resume()
videoPresenter.showTurn() // videoPresenter.showTurn()
if (mVipFlag != UserManager.getInstance().vipFlag && UserManager.getInstance().vipFlag) { if (mVipFlag != UserManager.getInstance().vipFlag && UserManager.getInstance().vipFlag) {
// 重置状态 // 重置状态
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment