Parcourir la source

Merge remote-tracking branch 'origin/sheep_develop' into sheep_develop

zengjiebin il y a 7 ans
Parent
commit
77e1dd0d0c

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -753,6 +753,7 @@
             android:name=".ui.activity.SignActivity"
             android:screenOrientation="portrait"
             android:theme="@style/AppTheme.NoTitleBar.AlphaStatusBar" />
+        <activity android:name=".ui.activity.UserNavActivity" />
     </application>
 
 </manifest>

+ 20 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/ui/activity/SignActivity.java

@@ -1,7 +1,13 @@
 package com.sheep.jiuyan.samllsheep.ui.activity;
 
+import android.widget.TextView;
+
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.ui.base.BaseActivity;
+import com.sheep.jiuyan.samllsheep.ui.view.EggView;
+
+import butterknife.BindView;
+import butterknife.OnClick;
 
 /**
  * Created by: zhoujuncai.
@@ -10,6 +16,11 @@ import com.sheep.jiuyan.samllsheep.ui.base.BaseActivity;
  */
 public class SignActivity extends BaseActivity {
 
+    @BindView(R.id.eggs_view)
+    EggView eggsView;
+    @BindView(R.id.sign_info_text)
+    TextView signInfoText;
+
     @Override
     protected int onLayout() {
         return R.layout.activity_sign;
@@ -29,4 +40,13 @@ public class SignActivity extends BaseActivity {
     protected void onData() {
 
     }
+
+    @OnClick(R.id.back_but)
+    public void onBackButClicked() {
+        finish();
+    }
+
+    @OnClick(R.id.active_info)
+    public void onActiveInfoClicked() {
+    }
 }

+ 31 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/ui/activity/UserNavActivity.java

@@ -0,0 +1,31 @@
+package com.sheep.jiuyan.samllsheep.ui.activity;
+
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.ui.base.BaseActivity;
+
+/**
+ * Created by: zhoujuncai.
+ * Created date: 2018/11/2.
+ * Description: 新手导航界面
+ */
+public class UserNavActivity extends BaseActivity {
+    @Override
+    protected int onLayout() {
+        return R.layout.activity_user_nav;
+    }
+
+    @Override
+    protected void onObject() {
+
+    }
+
+    @Override
+    protected void onView() {
+
+    }
+
+    @Override
+    protected void onData() {
+
+    }
+}

+ 207 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/ui/view/EggView.java

@@ -0,0 +1,207 @@
+package com.sheep.jiuyan.samllsheep.ui.view;
+
+import android.animation.ValueAnimator;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.animation.LinearInterpolator;
+
+import com.sheep.jiuyan.samllsheep.R;
+
+import java.util.Random;
+
+/**
+ * Created by: zhoujuncai.
+ * Created date: 2018/11/2.
+ * Description: 跳动扭蛋机
+ */
+public class EggView extends View {
+
+    /* 控件宽度 */
+    private int width;
+    /* 控件高度 */
+    private int height;
+    /* 扭蛋图片集合 */
+    private Bitmap[] drawables;
+    /* 扭蛋集合 */
+    private Egg[] eggs;
+    /* 画笔 */
+    private Paint paint;
+    /* 是否停止 */
+    private boolean isStop = false;
+
+    public EggView(Context context) {
+        super(context);
+    }
+
+    public EggView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        init();
+    }
+
+    public EggView(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    /**
+     * 初始化
+     */
+    private void init() {
+        paint = new Paint();
+        paint.setAntiAlias(true);
+        paint.setStyle(Paint.Style.FILL);
+        setBackgroundColor(getResources().getColor(android.R.color.transparent));
+        drawables = new Bitmap[]{
+                BitmapFactory.decodeResource(getResources(), R.drawable.niudan1),
+                BitmapFactory.decodeResource(getResources(), R.drawable.niudan2),
+                BitmapFactory.decodeResource(getResources(), R.drawable.niudan3),
+                BitmapFactory.decodeResource(getResources(), R.drawable.niudan4),
+                BitmapFactory.decodeResource(getResources(), R.drawable.niudan5),
+                BitmapFactory.decodeResource(getResources(), R.drawable.niudan6),
+                BitmapFactory.decodeResource(getResources(), R.drawable.niudan7),
+                BitmapFactory.decodeResource(getResources(), R.drawable.niudan8),
+        };
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        width = getWidth();
+        height = getHeight();
+        if (eggs == null) {
+            initEggs();
+        }
+        if (!isStop) {
+            for (Egg egg : eggs) {
+                if (egg.getX() > egg.getWidth() || egg.getX() < 0) {
+                    egg.xValue.reverse();
+                }
+                if (egg.getY() > egg.getHeight() || egg.getY() < 0) {
+                    egg.yValue.reverse();
+                }
+                canvas.drawBitmap(egg.getBitmap(), egg.getX(), egg.getY(), paint);
+            }
+        }
+        super.onDraw(canvas);
+        invalidate();
+    }
+
+    public void setStop(boolean stop) {
+        isStop = stop;
+    }
+
+    /**
+     * 初始化扭蛋
+     */
+    private void initEggs() {
+        eggs = new Egg[8];
+        for (int i = 0; i < eggs.length; i++) {
+            Egg egg = new Egg(width, height, drawables[i]);
+            eggs[i] = egg;
+        }
+    }
+
+    /**
+     * 扭蛋对象
+     */
+    private class Egg {
+
+        /* 活动范围宽度 */
+        private int width;
+        /* 活动范围高度 */
+        private int height;
+        /* X坐标 */
+        private int x;
+        /* Y坐标 */
+        private int y;
+        /* X轴动画偏移量 */
+        private int offsetX;
+        /* Y轴动画偏移量 */
+        private int offsetY;
+        /* 扭蛋图片 */
+        private Bitmap bitmap;
+        private ValueAnimator xValue;
+        private ValueAnimator yValue;
+
+        /**
+         * 构造方法
+         *
+         * @param width  活动范围的宽度
+         * @param height 活动范围的高度
+         * @param bitmap 扭蛋图片
+         */
+        public Egg(int width, int height, Bitmap bitmap) {
+            this.width = width - bitmap.getWidth();
+            this.height = height - bitmap.getHeight();
+            this.bitmap = bitmap;
+            this.init();
+        }
+
+        /* 初始化 */
+        private void init() {
+//            this.x = random(0, width);
+            this.x = 0;
+//            this.y = random(0, height);
+            this.y = 0;
+            xValue = ValueAnimator.ofInt(0, width);
+            xValue.setDuration(random(200, 1000));
+            xValue.setRepeatCount(-1);
+            xValue.setRepeatMode(ValueAnimator.REVERSE);
+            xValue.setInterpolator(new LinearInterpolator());
+            xValue.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+                @Override
+                public void onAnimationUpdate(ValueAnimator animation) {
+                    offsetX = (int) animation.getAnimatedValue();
+                }
+            });
+            xValue.start();
+            yValue = ValueAnimator.ofInt(0, height);
+            yValue.setDuration(random(200, 1000));
+            yValue.setRepeatCount(-1);
+            yValue.setRepeatMode(ValueAnimator.REVERSE);
+            yValue.setInterpolator(new LinearInterpolator());
+            yValue.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+                @Override
+                public void onAnimationUpdate(ValueAnimator animation) {
+                    offsetY = (int) animation.getAnimatedValue();
+                }
+            });
+            yValue.start();
+        }
+
+        public int getX() {
+            return x + offsetX;
+        }
+
+        public int getY() {
+            return y + offsetY;
+        }
+
+        public Bitmap getBitmap() {
+            return bitmap;
+        }
+
+        public int getWidth() {
+            return width;
+        }
+
+        public int getHeight() {
+            return height;
+        }
+
+        /**
+         * 随机取数
+         *
+         * @param min 最小值
+         * @param max 最大值
+         * @return 返回一个在最小值和最大值之间的数
+         */
+        private int random(int min, int max) {
+            Random r = new Random();
+            return r.nextInt(max) % (max - min + 1) + min;
+        }
+    }
+}

+ 30 - 5
app/src/main/res/layout/activity_sign.xml

@@ -6,24 +6,24 @@
     <RelativeLayout
         android:id="@+id/title_bar"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="?actionBarSize"
         android:background="#ffffff"
         android:gravity="center_vertical"
         android:paddingLeft="16dp"
-        android:paddingTop="3dp"
-        android:paddingRight="16dp"
-        android:paddingBottom="3dp">
+        android:paddingRight="16dp">
 
         <ImageView
+            android:id="@+id/back_but"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_centerVertical="true"
             android:contentDescription="@string/image_des"
             android:padding="10dp"
             android:src="@drawable/narrow_back_black" />
 
         <TextView
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
+            android:layout_height="match_parent"
             android:layout_centerInParent="true"
             android:gravity="center"
             android:text="签到"
@@ -39,6 +39,7 @@
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:background="#ffffff"
             android:orientation="vertical">
 
             <RelativeLayout
@@ -53,6 +54,7 @@
                     android:src="@drawable/ic_sign_bg" />
 
                 <TextView
+                    android:id="@+id/active_info"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_alignParentEnd="true"
@@ -66,7 +68,30 @@
                     android:text="活动规则"
                     android:textColor="#ffffff"
                     android:textSize="12sp" />
+
+                <com.sheep.jiuyan.samllsheep.ui.view.EggView
+                    android:id="@+id/eggs_view"
+                    android:layout_width="190dp"
+                    android:layout_height="140dp"
+                    android:layout_centerInParent="true" />
             </RelativeLayout>
+
+            <TextView
+                android:id="@+id/sign_info_text"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="20dp"
+                android:gravity="center"
+                android:text="已签到1天 ,继续6天打卡可参与刮奖"
+                android:textColor="#999999"
+                android:textSize="12sp" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+
+            </LinearLayout>
         </LinearLayout>
     </ScrollView>
 </RelativeLayout>

+ 49 - 0
app/src/main/res/layout/activity_user_nav.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <RelativeLayout
+        android:id="@+id/title_bar"
+        android:layout_width="match_parent"
+        android:layout_height="?actionBarSize"
+        android:background="#ffffff"
+        android:gravity="center_vertical"
+        android:paddingLeft="16dp"
+        android:paddingRight="16dp">
+
+        <ImageView
+            android:id="@+id/back_but"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerVertical="true"
+            android:contentDescription="@string/image_des"
+            android:padding="10dp"
+            android:src="@drawable/narrow_back_black" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_centerInParent="true"
+            android:gravity="center"
+            android:text="新手引导"
+            android:textColor="#333333"
+            android:textSize="17sp" />
+    </RelativeLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:orientation="vertical"
+        app:layout_constraintTop_toBottomOf="@id/title_bar">
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="10dp"
+            android:text="@string/new_nav_tips_title" />
+    </LinearLayout>
+
+</android.support.constraint.ConstraintLayout>

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

@@ -112,4 +112,5 @@
     <string name="image_des">icon</string>
     <string name="search_but_text">搜索</string>
     <string name="search_hint_txt">搜索任务名称/游戏名称</string>
+    <string name="new_nav_tips_title">亲爱的羊羊伙伴:\n\n  为了让你赚更多的钱,羊羊平台经过仔细整理,特整理出如下新手引导及赚钱攻略,按此攻略可赚取更多的钱!具体攻略如下:</string>
 </resources>