Commit 78cc565d by 郑鹏

修复点击更多闪退的bug

parent d3e7306b
...@@ -2,16 +2,13 @@ package cn.dankal.client.ui.home.details; ...@@ -2,16 +2,13 @@ package cn.dankal.client.ui.home.details;
import android.Manifest; import android.Manifest;
import android.content.Intent; import android.content.Intent;
import android.location.LocationManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.chad.library.adapter.base.BaseViewHolder; import com.chad.library.adapter.base.BaseViewHolder;
import com.luck.picture.lib.permissions.RxPermissions;
import com.scwang.smartrefresh.layout.api.RefreshLayout; import com.scwang.smartrefresh.layout.api.RefreshLayout;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -36,13 +33,11 @@ public class RecommendMerchantActivity extends BaseListActivity<RestaurantEntity ...@@ -36,13 +33,11 @@ public class RecommendMerchantActivity extends BaseListActivity<RestaurantEntity
private int page = 1; private int page = 1;
public static final String UUID = "uuid"; public static final String UUID = "uuid";
private Map<String, Object> maps; private Map<String, Object> maps;
private RxPermissions rxPermissions;
@Override @Override
protected void initComponents() { protected void initComponents() {
super.initComponents(); super.initComponents();
addSingleTitleBar(getString(R.string.recommended_merchant)); addSingleTitleBar(getString(R.string.recommended_merchant));
rxPermissions = new RxPermissions(this);
maps = new HashMap<>(); maps = new HashMap<>();
uuid = getIntent().getStringExtra(UUID); uuid = getIntent().getStringExtra(UUID);
...@@ -141,6 +136,6 @@ public class RecommendMerchantActivity extends BaseListActivity<RestaurantEntity ...@@ -141,6 +136,6 @@ public class RecommendMerchantActivity extends BaseListActivity<RestaurantEntity
* @return * @return
*/ */
private boolean checkGPSIsOpen() { private boolean checkGPSIsOpen() {
return rxPermissions.isGranted(Manifest.permission.ACCESS_COARSE_LOCATION); return getRxPermissions().isGranted(Manifest.permission.ACCESS_COARSE_LOCATION);
} }
} }
...@@ -2,6 +2,7 @@ package cn.dankal.client.ui.shop; ...@@ -2,6 +2,7 @@ package cn.dankal.client.ui.shop;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -11,6 +12,11 @@ import android.widget.LinearLayout; ...@@ -11,6 +12,11 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.flyco.tablayout.SlidingTabLayout; import com.flyco.tablayout.SlidingTabLayout;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -39,6 +45,8 @@ public class ShopFragment extends BaseFragment { ...@@ -39,6 +45,8 @@ public class ShopFragment extends BaseFragment {
TextView tvStateBar; TextView tvStateBar;
private List<Fragment> dataList; private List<Fragment> dataList;
private List<String> titles; private List<String> titles;
@BindView(R.id.refreshLayout)
SmartRefreshLayout refreshLayout;
private FragmentAdapter adapter; private FragmentAdapter adapter;
...@@ -51,22 +59,47 @@ public class ShopFragment extends BaseFragment { ...@@ -51,22 +59,47 @@ public class ShopFragment extends BaseFragment {
protected void initComponents() { protected void initComponents() {
dataList = new ArrayList<>(); dataList = new ArrayList<>();
titles = new ArrayList<>(); titles = new ArrayList<>();
adapter = new FragmentAdapter(getFragmentManager(), dataList, titles);
vpShopPager.setAdapter(adapter);
slidingTabs.setViewPager(vpShopPager);
getStateBar();
refreshLayout.setEnableLoadMore(false);
refreshLayout.setRefreshHeader(new ClassicsHeader(getActivity()).setEnableLastTime(false));
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
requestData();
}
});
refreshLayout.autoRefresh();
}
private void requestData() {
MallServiceFactory.getHomeTopList(1, 20).subscribe(new AbstractDialogSubscriber<MallTopDataEntity>(this) { MallServiceFactory.getHomeTopList(1, 20).subscribe(new AbstractDialogSubscriber<MallTopDataEntity>(this) {
@Override @Override
public void onNext(MallTopDataEntity mallTopDataEntity) { public void onNext(MallTopDataEntity mallTopDataEntity) {
for (int i = 0; i < mallTopDataEntity.getStore_type_list().size(); i++) { dataList.clear();
MallTopDataEntity.StoreTypeListBean storeTypeListBean = mallTopDataEntity.getStore_type_list().get(i); titles.clear();
List<MallTopDataEntity.StoreTypeListBean> listBeans = mallTopDataEntity.getStore_type_list();
for (int i = 0; i < listBeans.size(); i++) {
MallTopDataEntity.StoreTypeListBean storeTypeListBean = listBeans.get(i);
dataList.add(getFragment(storeTypeListBean.getUuid(), mallTopDataEntity.getBanner_list())); dataList.add(getFragment(storeTypeListBean.getUuid(), mallTopDataEntity.getBanner_list()));
titles.add(storeTypeListBean.getName()); titles.add(storeTypeListBean.getName());
} }
adapter = new FragmentAdapter(getFragmentManager(), dataList, titles); adapter.notifyDataSetChanged();
vpShopPager.setAdapter(adapter); slidingTabs.notifyDataSetChanged();
slidingTabs.setViewPager(vpShopPager); refreshLayout.finishRefresh();
} }
});
getStateBar(); @Override
public void onError(Throwable e) {
super.onError(e);
refreshLayout.finishRefresh();
}
});
} }
//获取状态栏高度 //获取状态栏高度
......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:tl="http://schemas.android.com/apk/res-auto" xmlns:tl="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<!-- <TextView <!-- <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="modoo order" android:text="modoo order"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/dp_24" />--> android:textSize="@dimen/dp_24" />-->
<ImageView <ImageView
android:layout_width="@dimen/dp_152" android:layout_width="@dimen/dp_152"
android:layout_height="@dimen/dp_16" android:layout_height="@dimen/dp_16"
...@@ -47,37 +47,52 @@ ...@@ -47,37 +47,52 @@
android:id="@+id/iv_mall_search" android:id="@+id/iv_mall_search"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_15"
android:src="@mipmap/ic_home_search" android:src="@mipmap/ic_home_search"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="@dimen/dp_15" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintRight_toRightOf="parent"/>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
<com.flyco.tablayout.SlidingTabLayout <com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/sliding_tabs" android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_24"
android:layout_marginTop="@dimen/dp_17"
android:layout_marginBottom="@dimen/dp_15"
android:background="@color/white"
tl:tl_indicator_color="@color/btn_bg"
tl:tl_indicator_height="@dimen/dp_6"
tl:tl_indicator_width_equal_title="true"
tl:tl_tab_padding="@dimen/dp_8"
tl:tl_tab_space_equal="false"
tl:tl_textSelectColor="@color/color33"
tl:tl_textUnselectColor="#686868"
tl:tl_textsize="17sp"
tl:tl_underline_color="@color/white"
tl:tl_underline_height="0dp" />
<android.support.v4.view.ViewPager
android:id="@+id/vp_shop_pager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent">
android:layout_weight="1" />
<android.support.v7.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.flyco.tablayout.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_24"
android:layout_marginTop="@dimen/dp_17"
android:layout_marginBottom="@dimen/dp_15"
android:background="@color/white"
tl:tl_indicator_color="@color/btn_bg"
tl:tl_indicator_height="@dimen/dp_6"
tl:tl_indicator_width_equal_title="true"
tl:tl_tab_padding="@dimen/dp_8"
tl:tl_tab_space_equal="false"
tl:tl_textSelectColor="@color/color33"
tl:tl_textUnselectColor="#686868"
tl:tl_textsize="17sp"
tl:tl_underline_color="@color/white"
tl:tl_underline_height="0dp" />
<android.support.v4.view.ViewPager
android:id="@+id/vp_shop_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</android.support.v7.widget.LinearLayoutCompat>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout> </LinearLayout>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10" android:layout_marginBottom="@dimen/dp_10"
app:cardCornerRadius="@dimen/dp_10" app:cardCornerRadius="@dimen/dp_10"
app:cardElevation="@dimen/dp_4"> app:cardElevation="@dimen/dp_4">
......
...@@ -105,7 +105,7 @@ dependencies { ...@@ -105,7 +105,7 @@ dependencies {
api 'com.hyman:flowlayout-lib:1.1.2' api 'com.hyman:flowlayout-lib:1.1.2'
api 'org.litepal.android:java:3.0.0' api 'org.litepal.android:java:3.0.0'
api 'com.squareup.retrofit2:converter-gson:2.0.0-beta3' api 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
api 'com.github.anzaizai:EasySwipeMenuLayout:1.1.2' api 'com.github.anzaizai:EasySwipeMenuLayout:1.1.4'
api 'org.greenrobot:eventbus:3.1.1' api 'org.greenrobot:eventbus:3.1.1'
//api 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-25' //api 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-25'
api 'com.google.android.gms:play-services-wallet:16.0.1' api 'com.google.android.gms:play-services-wallet:16.0.1'
......
...@@ -68,6 +68,9 @@ public abstract class BaseActivity extends AppCompatActivity implements BaseView ...@@ -68,6 +68,9 @@ public abstract class BaseActivity extends AppCompatActivity implements BaseView
super.attachBaseContext(MultiLanguage.setLocal(newBase)); super.attachBaseContext(MultiLanguage.setLocal(newBase));
} }
public RxPermissions getRxPermissions() {
return mRxPermissions;
}
/*@Override /*@Override
protected void attachBaseContext(Context newBase) { protected void attachBaseContext(Context newBase) {
......
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