fix: 修改记录频繁请求的问题
This commit is contained in:
parent
2126781230
commit
11289fb08a
@ -232,14 +232,13 @@ public class HomeActivity extends BaseActivity {
|
||||
EventBus.getDefault().post(obtain);
|
||||
} else if (tab.getPosition() == 1) {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
||||
obtain.obj = true;
|
||||
obtain.what = Constant.SWITCH_RECORFER_ITEM; // 发送消息给Recorder界面,根据子tab的选项请求数据
|
||||
EventBus.getDefault().post(obtain);
|
||||
|
||||
Message obtain1 = Message.obtain();
|
||||
obtain1.what = Constant.HAS_SUBMIT_ITEM;
|
||||
obtain1.obj = true;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
// Message obtain1 = Message.obtain();
|
||||
// obtain1.what = Constant.HAS_SUBMIT_ITEM;
|
||||
// obtain1.obj = true;
|
||||
// EventBus.getDefault().post(obtain1);
|
||||
} else if (tab.getPosition() == 3) {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.HOME_MINE;
|
||||
|
@ -149,6 +149,7 @@ public class Constant {
|
||||
public static final int EVENT_MESSAGE = 55;//提示消息
|
||||
public static final int CAPACITY_EVALUATION=59;//能力测试的返回
|
||||
public static final int CHARGING_STATION_DISABLE=60;//能力测试的返回
|
||||
public static final int SWITCH_RECORFER_ITEM=61;//记录界面请求数据提醒
|
||||
public static final String INTENT_POI_VIDEO_TYPE = "poi_video_type";
|
||||
public static int NUMBER = 200; //任务个数
|
||||
public static int LIMIT_TYPE = -1; //权限类型,普通任务-0,专属任务-1
|
||||
|
@ -106,9 +106,9 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (((HomeActivity)getActivity()).getCurrentTabSelected() == 1) {
|
||||
initRequest();
|
||||
}
|
||||
// if (((HomeActivity)getActivity()).getCurrentTabSelected() == 1) {
|
||||
// initRequest();
|
||||
// }
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -7,6 +7,7 @@ import android.os.Message;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
@ -18,6 +19,7 @@ import com.navinfo.outdoor.base.BaseFragment;
|
||||
import com.navinfo.outdoor.util.NoSlideViewPager;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -29,6 +31,7 @@ import java.util.Objects;
|
||||
public class RecordFragment extends BaseFragment {
|
||||
|
||||
private final String[] names = {"待提交", "已提交"};
|
||||
private TabLayout tabRecord;
|
||||
|
||||
public static RecordFragment newInstance(Bundle bundle) {
|
||||
RecordFragment fragment = new RecordFragment();
|
||||
@ -44,7 +47,7 @@ public class RecordFragment extends BaseFragment {
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
TabLayout tabRecord = findViewById(R.id.tab_record);
|
||||
tabRecord = findViewById(R.id.tab_record);
|
||||
NoSlideViewPager vpRecord = findViewById(R.id.vp_record);
|
||||
ArrayList<Fragment> fragments = new ArrayList<>();
|
||||
// 待提交
|
||||
@ -105,9 +108,37 @@ public class RecordFragment extends BaseFragment {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (!EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEvent(Message data) {
|
||||
if (data.what == Constant.SWITCH_RECORFER_ITEM) {
|
||||
if (tabRecord.getSelectedTabPosition() == 0) {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
||||
obtain.obj = true;
|
||||
EventBus.getDefault().post(obtain);
|
||||
} else {
|
||||
Message obtain1 = Message.obtain();
|
||||
obtain1.what = Constant.HAS_SUBMIT_ITEM;
|
||||
obtain1.obj = true;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user