Ver código fonte

添加新手引导界面

zengjiebin 8 anos atrás
pai
commit
cf65ccb71e

+ 5 - 4
app/src/main/java/com/kfzs/duanduan/fragment/FgtSmallSheep.java

@@ -7,7 +7,6 @@ import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
 import android.support.v4.view.ViewPager;
-import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
@@ -28,7 +27,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
 import com.bumptech.glide.request.RequestOptions;
 import com.kfzs.duanduan.BaseCompatFragment;
 import com.kfzs.duanduan.event.BigEvent;
-import com.kfzs.duanduan.react.TabsHelper;
 import com.layoutscroll.layoutscrollcontrols.view.EasyLayoutScroll;
 import com.sheep.gamegroup.di.components.DaggerSmallSheepComponent;
 import com.sheep.gamegroup.di.modules.SmallSheepModule;
@@ -46,6 +44,7 @@ import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.MyDbManager;
 import com.sheep.gamegroup.util.PreferenceUtils;
 import com.sheep.gamegroup.util.UMConfigUtils;
+import com.sheep.gamegroup.view.dialog.DialogNewbieTask1;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
@@ -54,7 +53,6 @@ import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 import org.greenrobot.eventbus.ThreadMode;
-import org.xutils.ex.DbException;
 
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -201,7 +199,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
 
     }
 
-    @OnClick({R.id.icon_img_iv, R.id.user_layout, R.id.withdrawal, R.id.couple_red_packets_iv, R.id.try_play_layout, R.id.invitation_layout, R.id.lying_layout})
+    @OnClick({R.id.icon_img_iv, R.id.user_layout, R.id.withdrawal, R.id.couple_red_packets_iv, R.id.try_play_layout, R.id.invitation_layout, R.id.lying_layout, R.id.newbie_task})
     public void onViewClicked(View view) {
         switch (view.getId()) {
             case R.id.icon_img_iv:
@@ -227,6 +225,9 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
                 Jump2View.getInstance().goLyingView(activity, null);
                 UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_TASK_LIE);
                 break;
+            case R.id.newbie_task://新手任务
+                DialogNewbieTask1.showDialog(getActivity());
+                break;
         }
     }
 

+ 73 - 0
app/src/main/java/com/sheep/gamegroup/util/RxjavaCountDownTimer.java

@@ -0,0 +1,73 @@
+package com.sheep.gamegroup.util;
+
+
+import com.sheep.jiuyan.samllsheep.BuildConfig;
+
+import java.util.concurrent.TimeUnit;
+
+import io.reactivex.Flowable;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.functions.Consumer;
+
+/**
+ * Created by realicing on 2018/4/17.
+ * realicing@sina.com
+ */
+public class RxjavaCountDownTimer {
+
+    public static RxjavaCountDownTimer getInstance(long count) {
+        RxjavaCountDownTimer timer = new RxjavaCountDownTimer();
+        timer.init(0,count,0,1, TimeUnit.SECONDS);
+        return timer;
+    }
+    public static RxjavaCountDownTimer getInstance(long start, long count, long initialDelay, long period, TimeUnit unit) {
+        RxjavaCountDownTimer timer = new RxjavaCountDownTimer();
+        timer.init(start, count, initialDelay, period, unit);
+        return timer;
+    }
+    private Disposable mDisposable;
+    private Flowable<Long> flowable;
+    private void init(long start, final long count, long initialDelay, long period, TimeUnit unit) {
+        flowable = Flowable.intervalRange(start, count+1, initialDelay, period, unit)
+                .observeOn(AndroidSchedulers.mainThread())
+                .doOnNext(new Consumer<Long>() {
+                    @Override
+                    public void accept(Long aLong){
+                        if(BuildConfig.DEBUG)
+                            System.out.println("onTimerAccept aLong = "+aLong);
+                        if(count == aLong){
+                            if(onTickListener != null)
+                                onTickListener.onFinish();
+                        } else {
+                            if(onTickListener != null)
+                                onTickListener.onTicker(count - aLong);
+                        }
+                    }
+                });
+    }
+
+    public RxjavaCountDownTimer setOnTickListener(OnTickListener onTickListener) {
+        this.onTickListener = onTickListener;
+        return this;
+    }
+
+    private OnTickListener onTickListener;
+    public RxjavaCountDownTimer start() {
+        mDisposable = flowable.subscribe();
+        return this;
+    }
+    public void clear() {
+        try {
+            mDisposable.dispose();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    public interface OnTickListener{
+
+        void onFinish();
+
+        void onTicker(long time);
+    }
+}

+ 73 - 0
app/src/main/java/com/sheep/gamegroup/view/dialog/DialogNewbieTask1.java

@@ -0,0 +1,73 @@
+package com.sheep.gamegroup.view.dialog;
+
+import android.app.Activity;
+import android.content.DialogInterface;
+import android.support.v7.app.AlertDialog;
+import android.view.View;
+import android.widget.TextView;
+
+import com.kfzs.duanduan.utils.dlg.ViewFindUtils;
+import com.sheep.gamegroup.util.RxjavaCountDownTimer;
+import com.sheep.jiuyan.samllsheep.BuildConfig;
+import com.sheep.jiuyan.samllsheep.R;
+
+import java.util.concurrent.TimeUnit;
+
+import io.reactivex.Flowable;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.Disposable;
+import io.reactivex.functions.Consumer;
+
+
+public class DialogNewbieTask1 {
+
+
+    public static AlertDialog showDialog(final Activity activity) {
+        View view = View.inflate(activity, R.layout.dialog_newbie_task_1, null);
+        final AlertDialog mAlertDialog = new AlertDialog.Builder(activity, R.style.MyDialogActivityTheme)
+                .setView(view)
+                .create();
+        final TextView dialog_i_understand_bt = ViewFindUtils.find(view, R.id.dialog_i_understand_bt);
+        final int count = BuildConfig.DEBUG ? 3 : 60;
+        final RxjavaCountDownTimer timer = RxjavaCountDownTimer.getInstance(count)
+                .setOnTickListener(new RxjavaCountDownTimer.OnTickListener() {
+                    @Override
+                    public void onFinish() {
+                        dialog_i_understand_bt.setEnabled(true);
+                        dialog_i_understand_bt.setText("点击我了解");
+                    }
+
+                    @Override
+                    public void onTicker(long time) {
+                        dialog_i_understand_bt.setEnabled(false);
+                        dialog_i_understand_bt.setText(activity.getString(R.string.tip_newbie_task_1, time));
+                    }
+                }).start();
+        dialog_i_understand_bt.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        mAlertDialog.dismiss();
+                    }
+                });
+        mAlertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
+            @Override
+            public void onDismiss(DialogInterface dialogInterface) {
+                timer.clear();
+            }
+        });
+//        Window window = mAlertDialog.getWindow();
+//        if(window != null) {
+//            WindowManager.LayoutParams params = window.getAttributes();
+//            if(params != null){
+//                params.gravity = Gravity.BOTTOM;
+//                window.setAttributes(params);
+//            }
+//        }
+        try {
+            mAlertDialog.show();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return mAlertDialog;
+    }
+}

+ 7 - 0
app/src/main/res/color/selector_color_newbie_task_1.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:state_enabled="true" android:color="@color/main_tab_activated"/>
+    <item android:state_pressed="true" android:color="@color/main_tab_activated"/>
+    <item android:color="@color/main_tab"/>
+</selector>

+ 8 - 0
app/src/main/res/drawable/selector_drawable_newbie_task_1.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@drawable/shape_bg_button_no_enable" android:state_enabled="false" />
+    <item android:drawable="@drawable/shape_bg_button_unpress" android:state_pressed="false" />
+    <item android:drawable="@drawable/shape_bg_button_onpress" android:state_pressed="true" />
+
+</selector>

+ 13 - 0
app/src/main/res/drawable/shape_bg_button_no_enable.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle" >
+    <!-- 圆角半径 -->
+    <corners android:radius="@dimen/radius_newbie_task" />
+    <!-- 填充颜色 -->
+    <solid android:color="@android:color/darker_gray"/>
+    <!-- 线的宽度,颜色灰色 -->
+    <!--<stroke android:width="1dp"-->
+        <!--android:color="#fff"-->
+        <!--/>-->
+
+</shape>

+ 13 - 0
app/src/main/res/drawable/shape_bg_button_onpress.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle" >
+    <!-- 圆角半径 -->
+    <corners android:radius="@dimen/radius_newbie_task" />
+    <!-- 填充颜色 -->
+    <solid android:color="@android:color/holo_green_light"/>
+    <!-- 线的宽度,颜色灰色 -->
+    <!--<stroke android:width="2dp"-->
+        <!--android:color="@android:color/holo_orange_dark"-->
+        <!--/>-->
+
+</shape>

+ 13 - 0
app/src/main/res/drawable/shape_bg_button_unpress.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle" >
+    <!-- 圆角半径 -->
+    <corners android:radius="@dimen/radius_newbie_task" />
+    <!-- 填充颜色 -->
+    <solid android:color="@android:color/holo_purple"/>
+    <!-- 线的宽度,颜色灰色 -->
+    <!--<stroke android:width="2dp"-->
+        <!--android:color="#fff"-->
+        <!--/>-->
+
+</shape>

+ 53 - 0
app/src/main/res/layout/dialog_newbie_task_1.xml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_gravity="bottom">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:layout_margin="@dimen/content_padding_10"
+        android:padding="@dimen/content_padding_10"
+        android:gravity="center"
+        android:background="@drawable/x_shap_shadow_bg_rectgangle_white"
+        android:orientation="vertical">
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:padding="@dimen/content_padding_10"
+            android:text="一分钟快速了解小绵羊"
+            android:textColor="@color/selector_color_choose_head"
+            android:textSize="14sp" />
+
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="1px"
+            android:layout_marginTop="@dimen/content_padding_10"
+            android:layout_marginLeft="@dimen/content_padding_20"
+            android:layout_marginRight="@dimen/content_padding_20"
+            android:background="#DFDFDF" />
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/content_padding_20"
+            android:gravity="center">
+            <Button
+                android:id="@+id/dialog_i_understand_bt"
+                android:layout_width="wrap_content"
+                android:layout_height="36dp"
+                android:paddingStart="@dimen/content_padding_40"
+                android:paddingEnd="@dimen/content_padding_40"
+                android:enabled="false"
+                android:text="点击我了解"
+                android:background="@drawable/selector_drawable_newbie_task_1"
+                android:textColor="@color/selector_color_choose_head"
+                android:textSize="14sp" />
+
+        </RelativeLayout>
+    </LinearLayout>
+</FrameLayout>

+ 21 - 2
app/src/main/res/layout/homepage_act_layout.xml

@@ -19,7 +19,10 @@
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:background="@mipmap/home_blue_bg"
-                android:padding="@dimen/content_padding_20">
+                android:paddingTop="@dimen/content_padding_20"
+                android:paddingStart="@dimen/content_padding_20"
+                android:paddingEnd="@dimen/content_padding_20"
+                >
 
                 <RelativeLayout
                     android:id="@+id/user_layout"
@@ -70,7 +73,8 @@
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_below="@+id/user_layout"
-                    android:layout_marginTop="@dimen/content_padding_20">
+                    android:layout_marginTop="@dimen/content_padding_20"
+                    android:layout_marginBottom="@dimen/content_padding_20">
                     <TextView
                         android:id="@+id/withdrawal"
                         android:layout_width="wrap_content"
@@ -110,6 +114,21 @@
                         android:textColor="@color/txt_white"
                         android:textSize="@dimen/text_size_12"/>
                 </RelativeLayout>
+                <RelativeLayout
+                    android:id="@+id/newbie_task"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentEnd="true"
+                    android:layout_alignParentBottom="true">
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginEnd="@dimen/content_padding_10"
+                        android:layout_marginBottom="@dimen/content_padding_10"
+                        android:padding="@dimen/content_padding_small"
+                        android:background="@color/green"
+                        android:text="新手任务"/>
+                </RelativeLayout>
 
             </RelativeLayout>
 

+ 1 - 0
app/src/main/res/values/common.xml

@@ -107,6 +107,7 @@
         <dimen name="radius_10">10dp</dimen>
         <dimen name="radius_20">20dp</dimen>
         <dimen name="radius_5">5dp</dimen>
+        <dimen name="radius_newbie_task">18dp</dimen>
 
     <dimen name="view_size_20">20dp</dimen>
     <dimen name="view_size_30">30dp</dimen>

+ 2 - 0
app/src/main/res/values/gamegroup_string.xml

@@ -24,4 +24,6 @@
     <string name="niker">昵称</string>
     <string name="sheep_id">绵羊号</string>
     <string name="my_qr">我的二维码</string>
+
+    <string name="tip_newbie_task_1">我了解了(%1$4d秒)</string>
 </resources>