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