|
@@ -3,7 +3,9 @@ package com.sheep.gamegroup.view.fragment;
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
import android.support.design.widget.TabLayout;
|
|
import android.support.design.widget.TabLayout;
|
|
|
|
|
+import android.support.v4.app.Fragment;
|
|
|
import android.support.v4.view.ViewPager;
|
|
import android.support.v4.view.ViewPager;
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
@@ -14,6 +16,7 @@ import com.sheep.gamegroup.event.BigEvent;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.TaskAuditEntity;
|
|
import com.sheep.gamegroup.model.entity.TaskAuditEntity;
|
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
|
|
|
+import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.gamegroup.view.adapter.TitleFragmentListAdapter;
|
|
import com.sheep.gamegroup.view.adapter.TitleFragmentListAdapter;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
@@ -55,6 +58,30 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
public static final String[] tabNames = {"审核中", "任务成功", "任务失败"};
|
|
public static final String[] tabNames = {"审核中", "任务成功", "任务失败"};
|
|
|
private TitleFragmentListAdapter mAdapter;
|
|
private TitleFragmentListAdapter mAdapter;
|
|
|
|
|
|
|
|
|
|
+ public static FgtMainAudit newInstance(int index) {
|
|
|
|
|
+ FgtMainAudit fgtMainAudit = new FgtMainAudit();
|
|
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
|
|
+ DataUtil.putObject(bundle, index);
|
|
|
|
|
+ fgtMainAudit.setArguments(bundle);
|
|
|
|
|
+ return fgtMainAudit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public FgtMainAudit() {
|
|
|
|
|
+ }
|
|
|
|
|
+ private Integer curPosition = 0;
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
|
|
|
+ View rootView = super.onCreateView(inflater, container, savedInstanceState);
|
|
|
|
|
+ Bundle bundle = getArguments();
|
|
|
|
|
+ if (bundle != null) {
|
|
|
|
|
+ Integer position = DataUtil.getObject(bundle, Integer.class);
|
|
|
|
|
+ if(position != null){
|
|
|
|
|
+ curPosition = position;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return rootView;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public int getLayoutId() {
|
|
public int getLayoutId() {
|
|
|
return R.layout.act_audit_layout;
|
|
return R.layout.act_audit_layout;
|
|
@@ -75,6 +102,7 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
ViewUtil.showOrienteeringDetails(activity);
|
|
ViewUtil.showOrienteeringDetails(activity);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ initView();
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -106,7 +134,6 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void new_tab() {
|
|
private void new_tab() {
|
|
|
-// indicator.newTab();
|
|
|
|
|
pager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(indicator));
|
|
pager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(indicator));
|
|
|
indicator.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager));
|
|
indicator.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager));
|
|
|
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
@@ -117,17 +144,7 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onPageSelected(int i) {
|
|
public void onPageSelected(int i) {
|
|
|
-// MY_MONEY_TAB.onEvent("tab_name", tabNames[2]);
|
|
|
|
|
-// for(int d=0;d<indicator.getTabCount();d++){
|
|
|
|
|
-// TabLayout.Tab tab=indicator.getTabAt(i);
|
|
|
|
|
-// if(i == d){
|
|
|
|
|
-//
|
|
|
|
|
-// ((TextView) tab.getCustomView().findViewById(R.id.tv_text)).setTextColor(Color.parseColor("#34a6e7"));
|
|
|
|
|
-// }else {
|
|
|
|
|
-//
|
|
|
|
|
-// ((TextView) tab.getCustomView().findViewById(R.id.tv_text)).setTextColor(Color.parseColor("#333333"));
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ curPosition = i;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -139,28 +156,23 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
|
|
|
|
|
indicator.setupWithViewPager(pager);
|
|
indicator.setupWithViewPager(pager);
|
|
|
CommonUtil.getInstance().reflex(indicator, activity);
|
|
CommonUtil.getInstance().reflex(indicator, activity);
|
|
|
-// for (int i = 0; i < indicator.getTabCount(); i++) {
|
|
|
|
|
-// indicator.getTabAt(i).setCustomView(mAdapter.getTabView(i));
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
- /* TabLayout.Tab tab=indicator.getTabAt(2);
|
|
|
|
|
-
|
|
|
|
|
- tab.getCustomView().findViewById(R.id.iv_img).setVisibility(View.VISIBLE);*/
|
|
|
|
|
-
|
|
|
|
|
|
|
+ pager.setCurrentItem(curPosition);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void initViewOnVisibleToUser() {
|
|
|
|
|
|
|
+ public static final int POSITION_ING = 0;
|
|
|
|
|
+ public static final int POSITION_SUCCESS = 1;
|
|
|
|
|
+ public static final int POSITION_FAIL = 2;
|
|
|
|
|
+ protected void initView() {
|
|
|
mAdapter = new TitleFragmentListAdapter(getChildFragmentManager());
|
|
mAdapter = new TitleFragmentListAdapter(getChildFragmentManager());
|
|
|
- mAdapter.add(FgtAudit.newInstance(1), tabNames[0]);
|
|
|
|
|
- mAdapter.add(FgtAudit.newInstance(2), tabNames[1]);
|
|
|
|
|
- mAdapter.add(FgtAudit.newInstance(3), tabNames[2]);
|
|
|
|
|
|
|
+ mAdapter.add(FgtAudit.newInstance(POSITION_ING + 1), tabNames[POSITION_ING]);
|
|
|
|
|
+ mAdapter.add(FgtAudit.newInstance(POSITION_SUCCESS + 1), tabNames[POSITION_SUCCESS]);
|
|
|
|
|
+ mAdapter.add(FgtAudit.newInstance(POSITION_FAIL + 1), tabNames[POSITION_FAIL]);
|
|
|
pager.setAdapter(mAdapter);
|
|
pager.setAdapter(mAdapter);
|
|
|
new_tab();
|
|
new_tab();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void initDataOnVisibleToUser() {
|
|
|
|
|
|
|
+ public void onResume() {
|
|
|
|
|
+ super.onResume();
|
|
|
try {
|
|
try {
|
|
|
initData();
|
|
initData();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -169,21 +181,6 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private boolean isFirstOnResume = true;//第一次onResume
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onResume() {
|
|
|
|
|
- super.onResume();
|
|
|
|
|
- if(!isFirstOnResume) {
|
|
|
|
|
- try {
|
|
|
|
|
- initData();
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- G.showToast(e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- isFirstOnResume = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public void setCurrentItem(int item, boolean smoothScroll) {
|
|
public void setCurrentItem(int item, boolean smoothScroll) {
|
|
|
if(pager != null)
|
|
if(pager != null)
|
|
|
pager.setCurrentItem(item, smoothScroll);
|
|
pager.setCurrentItem(item, smoothScroll);
|