|
@@ -1,36 +1,27 @@
|
|
|
package com.sheep.gamegroup.view.fragment;
|
|
package com.sheep.gamegroup.view.fragment;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
|
|
+import android.graphics.Typeface;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
import android.support.design.widget.TabLayout;
|
|
import android.support.design.widget.TabLayout;
|
|
|
import android.support.v4.view.ViewPager;
|
|
import android.support.v4.view.ViewPager;
|
|
|
-import android.util.Log;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
|
-import android.view.WindowManager;
|
|
|
|
|
-import android.widget.ImageView;
|
|
|
|
|
-import android.widget.LinearLayout;
|
|
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
-
|
|
|
|
|
import com.sheep.gamegroup.event.BigEvent;
|
|
import com.sheep.gamegroup.event.BigEvent;
|
|
|
-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.DataUtil;
|
|
|
-import com.sheep.gamegroup.util.ViewUtil;
|
|
|
|
|
import com.sheep.gamegroup.view.activity.ActMain;
|
|
import com.sheep.gamegroup.view.activity.ActMain;
|
|
|
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;
|
|
|
import com.sheep.jiuyan.samllsheep.base.BaseFragment;
|
|
import com.sheep.jiuyan.samllsheep.base.BaseFragment;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
-
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
-
|
|
|
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
|
-import rx.functions.Action1;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Created by ljy on 2018/8/20.
|
|
* Created by ljy on 2018/8/20.
|
|
@@ -49,7 +40,7 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
ViewPager pager;
|
|
ViewPager pager;
|
|
|
private Activity activity;
|
|
private Activity activity;
|
|
|
|
|
|
|
|
-// public static final String[] tabNames = {"审核中", "任务成功", "任务失败"};
|
|
|
|
|
|
|
+ // public static final String[] tabNames = {"审核中", "任务成功", "任务失败"};
|
|
|
private TitleFragmentListAdapter mAdapter;
|
|
private TitleFragmentListAdapter mAdapter;
|
|
|
|
|
|
|
|
public static FgtMainAudit newInstance(int index) {
|
|
public static FgtMainAudit newInstance(int index) {
|
|
@@ -61,14 +52,17 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public FgtMainAudit() {
|
|
public FgtMainAudit() {
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
private Integer curPosition = 0;
|
|
private Integer curPosition = 0;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
|
Bundle bundle = getArguments();
|
|
Bundle bundle = getArguments();
|
|
|
if (bundle != null) {
|
|
if (bundle != null) {
|
|
|
Integer position = DataUtil.getObject(bundle, Integer.class);
|
|
Integer position = DataUtil.getObject(bundle, Integer.class);
|
|
|
- if(position != null){
|
|
|
|
|
|
|
+ if (position != null) {
|
|
|
curPosition = position;
|
|
curPosition = position;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -88,7 +82,7 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
- if(activity instanceof ActMain){
|
|
|
|
|
|
|
+ if (activity instanceof ActMain) {
|
|
|
TitleBarUtils.getInstance()
|
|
TitleBarUtils.getInstance()
|
|
|
.setTitle(getActivity(), "审核中心")
|
|
.setTitle(getActivity(), "审核中心")
|
|
|
.setTitleListen(getActivity(), 0, null);
|
|
.setTitleListen(getActivity(), 0, null);
|
|
@@ -103,33 +97,57 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
|
|
|
|
|
public void initData() {
|
|
public void initData() {
|
|
|
|
|
|
|
|
- CommonUtil.getInstance().staticAudit(new Action1<BaseMessage>() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void call(BaseMessage o) {
|
|
|
|
|
- try {
|
|
|
|
|
- TaskAuditEntity taskAuditEntity = o.getData(TaskAuditEntity.class);
|
|
|
|
|
- if (taskAuditEntity != null) {
|
|
|
|
|
- String audit_total_audit = String.format(activity.getResources().getString(R.string.audit_total_audit), taskAuditEntity.getAudit_count());
|
|
|
|
|
- String audit_total_complete = String.format(activity.getResources().getString(R.string.audit_total_complete), taskAuditEntity.getFinish_count());
|
|
|
|
|
- String audit_total_money = String.format(activity.getResources().getString(R.string.audit_total_money), taskAuditEntity.getFinish_cash());
|
|
|
|
|
- String audit_total_welfare = String.format(activity.getResources().getString(R.string.audit_total_welfare), taskAuditEntity.getWelfare_award());
|
|
|
|
|
-
|
|
|
|
|
- if (numberTv == null)
|
|
|
|
|
- return;
|
|
|
|
|
- numberTv.setText(audit_total_audit + "");
|
|
|
|
|
- auditTotalCompleteTv.setText(audit_total_complete + "");
|
|
|
|
|
- auditTotalMoneyTv.setText(audit_total_money + "");
|
|
|
|
|
- }
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
|
+ CommonUtil.getInstance().staticAudit(o -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ TaskAuditEntity taskAuditEntity = o.getData(TaskAuditEntity.class);
|
|
|
|
|
+ if (taskAuditEntity != null) {
|
|
|
|
|
+ String audit_total_audit = taskAuditEntity.getAudit_count();
|
|
|
|
|
+ String audit_total_complete = String.format(activity.getResources().getString(R.string.audit_total_complete), taskAuditEntity.getFinish_count());
|
|
|
|
|
+ String audit_total_money = String.format(activity.getResources().getString(R.string.audit_total_money), taskAuditEntity.getFinish_cash());
|
|
|
|
|
+ String audit_total_welfare = String.format(activity.getResources().getString(R.string.audit_total_welfare), taskAuditEntity.getWelfare_award());
|
|
|
|
|
+
|
|
|
|
|
+ if (numberTv == null)
|
|
|
|
|
+ return;
|
|
|
|
|
+ numberTv.setText(audit_total_audit + "");
|
|
|
|
|
+ auditTotalCompleteTv.setText(audit_total_complete + "");
|
|
|
|
|
+ auditTotalMoneyTv.setText(audit_total_money + "");
|
|
|
}
|
|
}
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void new_tab() {
|
|
private void new_tab() {
|
|
|
pager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(indicator));
|
|
pager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(indicator));
|
|
|
- indicator.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager));
|
|
|
|
|
|
|
+ //indicator.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager));
|
|
|
|
|
+ indicator.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onTabSelected(TabLayout.Tab tab) {
|
|
|
|
|
+ View view = tab.getCustomView();
|
|
|
|
|
+ if (null == view) {
|
|
|
|
|
+ tab.setCustomView(R.layout.custom_tab_layout_text);
|
|
|
|
|
+ }
|
|
|
|
|
+ TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
|
|
|
|
|
+ textView.setTextColor(indicator.getTabTextColors());
|
|
|
|
|
+ textView.setTypeface(Typeface.DEFAULT_BOLD);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onTabUnselected(TabLayout.Tab tab) {
|
|
|
|
|
+ View view = tab.getCustomView();
|
|
|
|
|
+ if (null == view) {
|
|
|
|
|
+ tab.setCustomView(R.layout.custom_tab_layout_text);
|
|
|
|
|
+ }
|
|
|
|
|
+ TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
|
|
|
|
|
+ textView.setTypeface(Typeface.DEFAULT);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onTabReselected(TabLayout.Tab tab) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onPageScrolled(int i, float v, int i1) {
|
|
public void onPageScrolled(int i, float v, int i1) {
|
|
@@ -139,7 +157,6 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
@Override
|
|
@Override
|
|
|
public void onPageSelected(int i) {
|
|
public void onPageSelected(int i) {
|
|
|
curPosition = i;
|
|
curPosition = i;
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -152,16 +169,18 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
CommonUtil.getInstance().reflex(indicator, activity);
|
|
CommonUtil.getInstance().reflex(indicator, activity);
|
|
|
pager.setCurrentItem(curPosition);
|
|
pager.setCurrentItem(curPosition);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
public static final int POSITION_ACTIVITY = 0;
|
|
public static final int POSITION_ACTIVITY = 0;
|
|
|
public static final int POSITION_SUCCESS = 1;
|
|
public static final int POSITION_SUCCESS = 1;
|
|
|
public static final int POSITION_FAILED = 2;
|
|
public static final int POSITION_FAILED = 2;
|
|
|
|
|
+
|
|
|
protected void initView() {
|
|
protected void initView() {
|
|
|
mAdapter = new TitleFragmentListAdapter(getChildFragmentManager());
|
|
mAdapter = new TitleFragmentListAdapter(getChildFragmentManager());
|
|
|
mAdapter.add(FgtAudit.newInstance(POSITION_ACTIVITY + 1), getString(R.string.auditing));
|
|
mAdapter.add(FgtAudit.newInstance(POSITION_ACTIVITY + 1), getString(R.string.auditing));
|
|
|
mAdapter.add(FgtAudit.newInstance(POSITION_SUCCESS + 1), getString(R.string.task_success));
|
|
mAdapter.add(FgtAudit.newInstance(POSITION_SUCCESS + 1), getString(R.string.task_success));
|
|
|
mAdapter.add(FgtAudit.newInstance(POSITION_FAILED + 1), getString(R.string.task_failed));
|
|
mAdapter.add(FgtAudit.newInstance(POSITION_FAILED + 1), getString(R.string.task_failed));
|
|
|
FgtAudit fgtAudit = (FgtAudit) mAdapter.getItem(curPosition);
|
|
FgtAudit fgtAudit = (FgtAudit) mAdapter.getItem(curPosition);
|
|
|
- if(fgtAudit != null){
|
|
|
|
|
|
|
+ if (fgtAudit != null) {
|
|
|
fgtAudit.setFirstPage(true);
|
|
fgtAudit.setFirstPage(true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -181,9 +200,10 @@ public class FgtMainAudit extends BaseFragment {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@Subscribe
|
|
@Subscribe
|
|
|
public void onEventMainThread(BigEvent event) {
|
|
public void onEventMainThread(BigEvent event) {
|
|
|
switch (event.getEventTypes()) {
|
|
switch (event.getEventTypes()) {
|