ソースを参照

[增加]审核中心ViewPager滑动,tablayout字体选中时加粗

zeki 5 年 前
コミット
7b397ce443

+ 0 - 8
app/src/main/java/com/sheep/gamegroup/module/guide/NewbieGuideHelper.java

@@ -1,15 +1,12 @@
 package com.sheep.gamegroup.module.guide;
 
 import android.app.Activity;
-import android.content.Context;
-import android.content.SharedPreferences;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.AlphaAnimation;
 import android.view.animation.Animation;
-
 import com.app.hubert.guide.NewbieGuide;
 import com.app.hubert.guide.core.Builder;
 import com.app.hubert.guide.core.Controller;
@@ -20,26 +17,21 @@ import com.app.hubert.guide.model.GuidePage;
 import com.app.hubert.guide.model.HighLight;
 import com.app.hubert.guide.model.HighlightOptions;
 import com.app.hubert.guide.model.RelativeGuide;
-import com.app.hubert.guide.core.Controller;
 import com.kfzs.duanduan.cardview.ScreenUtil;
 import com.sheep.gamegroup.event.BigEvent;
 import com.sheep.gamegroup.event.EventTypes;
 import com.sheep.gamegroup.module.game.fragment.FgtGameCenter;
 import com.sheep.gamegroup.module.home.fragment.FgtHome;
 import com.sheep.gamegroup.module.home.fragment.FgtMainHeader;
-import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.view.activity.ActMain;
 import com.sheep.gamegroup.view.fragment.FgtPersonalCenter;
 import com.sheep.gamegroup.view.fragment.FgtSmallSheep;
 import com.sheep.jiuyan.samllsheep.R;
-
 import org.greenrobot.eventbus.EventBus;
 import org.xutils.common.util.LogUtil;
-
 import java.util.Arrays;
 import java.util.List;
-
 import static com.sheep.gamegroup.event.EventTypes.GUIDE_SWITCH_GAME;
 
 public class NewbieGuideHelper {

+ 1 - 0
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -5,6 +5,7 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.Color;
+import android.graphics.Typeface;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.GradientDrawable;
 import android.net.Uri;

+ 0 - 1
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -933,7 +933,6 @@ public class Jump2View {
         }
     }
 
-
     /**
      * 跳到web页面
      *

+ 56 - 36
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtMainAudit.java

@@ -1,36 +1,27 @@
 package com.sheep.gamegroup.view.fragment;
 
 import android.app.Activity;
+import android.graphics.Typeface;
 import android.os.Bundle;
 import android.support.design.widget.TabLayout;
 import android.support.v4.view.ViewPager;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
 import android.widget.TextView;
-
 import com.sheep.gamegroup.event.BigEvent;
-import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.TaskAuditEntity;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
-import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.view.activity.ActMain;
 import com.sheep.gamegroup.view.adapter.TitleFragmentListAdapter;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.base.BaseFragment;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
-
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
-
 import butterknife.BindView;
-import rx.functions.Action1;
 
 /**
  * Created by ljy on 2018/8/20.
@@ -49,7 +40,7 @@ public class FgtMainAudit extends BaseFragment {
     ViewPager pager;
     private Activity activity;
 
-//    public static final String[] tabNames = {"审核中", "任务成功", "任务失败"};
+    //    public static final String[] tabNames = {"审核中", "任务成功", "任务失败"};
     private TitleFragmentListAdapter mAdapter;
 
     public static FgtMainAudit newInstance(int index) {
@@ -61,14 +52,17 @@ public class FgtMainAudit extends BaseFragment {
     }
 
     public FgtMainAudit() {
+
     }
+
     private Integer curPosition = 0;
+
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         Bundle bundle = getArguments();
         if (bundle != null) {
             Integer position = DataUtil.getObject(bundle, Integer.class);
-            if(position != null){
+            if (position != null) {
                 curPosition = position;
             }
         }
@@ -88,7 +82,7 @@ public class FgtMainAudit extends BaseFragment {
         } catch (Exception e) {
             e.printStackTrace();
         }
-        if(activity instanceof ActMain){
+        if (activity instanceof ActMain) {
             TitleBarUtils.getInstance()
                     .setTitle(getActivity(), "审核中心")
                     .setTitleListen(getActivity(), 0, null);
@@ -103,33 +97,57 @@ public class FgtMainAudit extends BaseFragment {
 
     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() {
         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() {
             @Override
             public void onPageScrolled(int i, float v, int i1) {
@@ -139,7 +157,6 @@ public class FgtMainAudit extends BaseFragment {
             @Override
             public void onPageSelected(int i) {
                 curPosition = i;
-
             }
 
             @Override
@@ -152,16 +169,18 @@ public class FgtMainAudit extends BaseFragment {
         CommonUtil.getInstance().reflex(indicator, activity);
         pager.setCurrentItem(curPosition);
     }
+
     public static final int POSITION_ACTIVITY = 0;
     public static final int POSITION_SUCCESS = 1;
     public static final int POSITION_FAILED = 2;
+
     protected void initView() {
         mAdapter = new TitleFragmentListAdapter(getChildFragmentManager());
         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_FAILED + 1), getString(R.string.task_failed));
         FgtAudit fgtAudit = (FgtAudit) mAdapter.getItem(curPosition);
-        if(fgtAudit != null){
+        if (fgtAudit != null) {
             fgtAudit.setFirstPage(true);
         }
 
@@ -181,9 +200,10 @@ public class FgtMainAudit extends BaseFragment {
     }
 
     public void setCurrentItem(int item, boolean smoothScroll) {
-        if(pager != null)
+        if (pager != null)
             pager.setCurrentItem(item, smoothScroll);
     }
+
     @Subscribe
     public void onEventMainThread(BigEvent event) {
         switch (event.getEventTypes()) {

+ 0 - 1
app/src/main/java/com/sheep/jiuyan/samllsheep/SheepApp.java

@@ -331,7 +331,6 @@ public class SheepApp extends MultiDexApplication {
                     @Override
                     public void initSuccess() {
                         LogUtils2.info("initSuccess");
-
                     }
 
                     @Override

+ 21 - 5
app/src/main/res/layout/act_audit_layout.xml

@@ -2,6 +2,7 @@
 <com.kfzs.android.view.widget.TouchEventConsumerLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
+        xmlns:tools="http://schemas.android.com/tools"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical"
@@ -18,6 +19,7 @@
                 android:layout_height="wrap_content"
                 android:adjustViewBounds="true"
                 android:scaleType="fitXY"
+                tools:src="@color/black"
                 android:src="@mipmap/audit_top_bg"
                 app:layout_constraintTop_toTopOf="parent"/>
 
@@ -30,6 +32,8 @@
                 android:paddingStart="@dimen/content_padding_20"
                 android:paddingEnd="@dimen/content_padding_20"
                 android:scaleType="centerInside"
+                tools:src="@drawable/back"
+                tools:tint="@color/white"
                 android:src="@drawable/narrow_back_white"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toTopOf="parent"/>
@@ -40,7 +44,7 @@
                 android:layout_height="?attr/actionBarSize"
                 android:layout_marginTop="24dp"
                 android:gravity="center"
-                android:text="@string/app_name"
+                android:text="审核中心"
                 android:textColor="@color/white"
                 android:textSize="@dimen/text_size_5"
                 app:layout_constraintTop_toTopOf="parent"/>
@@ -50,13 +54,23 @@
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:gravity="center"
-                android:text="111"
+                tools:text="3"
                 android:textColor="@color/white"
-                android:textSize="@dimen/text_size_3"
+                android:textSize="34dp"
                 app:layout_constraintBottom_toBottomOf="parent"
                 app:layout_constraintTop_toTopOf="parent"/>
 
         <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:layout_marginTop="8dp"
+                android:text="审核中"
+                android:textColor="@color/white"
+                android:textSize="@dimen/text_size_3"
+                app:layout_constraintTop_toBottomOf="@id/number_tv"/>
+
+        <TextView
                 android:id="@+id/audit_total_complete_tv"
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"
@@ -72,9 +86,9 @@
         <View
                 android:id="@+id/act_audit_line_1"
                 android:layout_width="1dp"
-                android:layout_height="20dp"
+                android:layout_height="12dp"
                 android:layout_gravity="center"
-                android:background="@color/disenable_color"
+                android:background="#E6E6E6"
                 app:layout_constraintBottom_toBottomOf="@id/audit_total_complete_tv"
                 app:layout_constraintStart_toEndOf="parent"
                 app:layout_constraintEnd_toStartOf="parent"
@@ -96,7 +110,9 @@
 
     <android.support.design.widget.TabLayout
             android:id="@+id/indicator"
+            android:layout_height="wrap_content"
             style="@style/style_tab"
+            app:tabIndicatorHeight="4dp"
             android:background="@color/white"/>
 
     <android.support.v4.view.ViewPager

+ 4 - 1
app/src/main/res/layout/act_bottom_bar.xml

@@ -16,7 +16,9 @@
             android:id="@+id/main_header"
             android:layout_width="match_parent"
             android:layout_height="40dp"
-            android:layout_marginTop="42dp"></RelativeLayout>
+            android:layout_marginTop="42dp">
+
+    </RelativeLayout>
 
     <include
             layout="@layout/main_frame_layout"
@@ -61,6 +63,7 @@
                 android:id="@+id/tab_2"
                 android:layout_width="75dp"
                 android:layout_height="68dp"
+                android:layout_marginBottom="7dp"
                 android:layout_gravity="bottom"
                 android:background="@drawable/tab_big_yq"
                 android:button="@null"

+ 7 - 0
app/src/main/res/layout/custom_tab_layout_text.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+          android:id="@android:id/text1"
+          android:layout_width="match_parent"
+          android:layout_height="match_parent"
+          android:gravity="center"
+/>

+ 4 - 0
app/src/main/res/values/style_theme.xml

@@ -34,6 +34,10 @@
     <style name="AppThemeMain" parent="AppTheme">
     </style>
 
+    <style name="TabText" parent="TextAppearance.AppCompat">
+        <item name="android:textStyle">bold</item>
+    </style>
+
     <style name="AppThemeTransparent" parent="AppTheme">
         <item name="android:windowBackground">@android:color/transparent</item>
         <item name="android:windowAnimationStyle">@null</item>

+ 2 - 2
view/src/main/res/values/dimens.xml

@@ -3,8 +3,8 @@
     <!-- Default screen margins, per the Android Design guidelines. -->
     <dimen name="tab_width">45dp</dimen>
     <dimen name="tab_height">45dp</dimen>
-    <dimen name="bottom_height">50dp</dimen>
-    <dimen name="bottom_tab_pt">6dp</dimen>
+    <dimen name="bottom_height">64dp</dimen>
+    <dimen name="bottom_tab_pt">12dp</dimen>
     <dimen name="tag_vertical_spacing">6.0dip</dimen>
     <dimen name="common_margin_10">10.0dip</dimen>