Ver código fonte

封装请求,绑定微信,

zhaoyi 8 anos atrás
pai
commit
80067ac053
42 arquivos alterados com 1347 adições e 171 exclusões
  1. 6 0
      .idea/vcs.xml
  2. 3 0
      app/build.gradle
  3. 18 5
      app/src/main/AndroidManifest.xml
  4. 19 0
      app/src/main/java/com/jiuyan/sheep_children/SheepApp.java
  5. 38 0
      app/src/main/java/com/jiuyan/sheep_children/base/BaseActivity.java
  6. 9 0
      app/src/main/java/com/jiuyan/sheep_children/event/FloatMsg.java
  7. 103 32
      app/src/main/java/com/jiuyan/sheep_children/floatwindow/FloatService.java
  8. 6 3
      app/src/main/java/com/jiuyan/sheep_children/floatwindow/FloatWindow.java
  9. 1 1
      app/src/main/java/com/jiuyan/sheep_children/floatwindow/ShotScreen.java
  10. 16 9
      app/src/main/java/com/jiuyan/sheep_children/net/NetManager.java
  11. 86 0
      app/src/main/java/com/jiuyan/sheep_children/net/SheepCallback.java
  12. 4 1
      app/src/main/java/com/jiuyan/sheep_children/net/Url.java
  13. 90 0
      app/src/main/java/com/jiuyan/sheep_children/page/BindWxActivity.java
  14. 22 5
      app/src/main/java/com/jiuyan/sheep_children/page/DownloadActivity.java
  15. 50 0
      app/src/main/java/com/jiuyan/sheep_children/page/LoginActivity.java
  16. 91 27
      app/src/main/java/com/jiuyan/sheep_children/page/MainActivity.java
  17. 10 25
      app/src/main/java/com/jiuyan/sheep_children/page/ShotScreenActivity.java
  18. 93 10
      app/src/main/java/com/jiuyan/sheep_children/page/UserCenterActivity.java
  19. 114 2
      app/src/main/java/com/jiuyan/sheep_children/page/WithdrawActivity.java
  20. 34 11
      app/src/main/java/com/jiuyan/sheep_children/page/adapter/TaskAdapter.java
  21. 103 0
      app/src/main/java/com/jiuyan/sheep_children/page/entry/Task.java
  22. 86 0
      app/src/main/java/com/jiuyan/sheep_children/page/entry/TaskPublish.java
  23. 12 2
      app/src/main/java/com/jiuyan/sheep_children/utils/DeviceInfo.java
  24. 26 0
      app/src/main/java/com/jiuyan/sheep_children/utils/GsonUtil.java
  25. 39 0
      app/src/main/java/com/jiuyan/sheep_children/utils/PremissUtils.java
  26. 32 0
      app/src/main/java/com/jiuyan/sheep_children/utils/SpUtils.java
  27. BIN
      app/src/main/res/drawable-hdpi/floate_back.9.png
  28. BIN
      app/src/main/res/drawable-hdpi/home.png
  29. BIN
      app/src/main/res/drawable-hdpi/task.png
  30. BIN
      app/src/main/res/drawable-hdpi/wx_logo.png
  31. 8 0
      app/src/main/res/drawable/texe_background_normal.xml
  32. 8 0
      app/src/main/res/drawable/texe_background_selected.xml
  33. 6 0
      app/src/main/res/drawable/text_backgroud.xml
  34. 7 0
      app/src/main/res/drawable/text_color.xml
  35. 65 0
      app/src/main/res/layout/bind_wx_activity.xml
  36. 43 17
      app/src/main/res/layout/float_window.xml
  37. 32 0
      app/src/main/res/layout/float_window_dialog.xml
  38. 24 0
      app/src/main/res/layout/login_actvity.xml
  39. 24 20
      app/src/main/res/layout/withdraw_activity.xml
  40. 18 0
      app/src/main/res/layout/withdraw_item.xml
  41. 1 1
      gradle.properties
  42. BIN
      sign.jks

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 3 - 0
app/build.gradle

@@ -29,8 +29,11 @@ dependencies {
     compile 'com.didi.virtualapk:core:0.9.1'
     testCompile 'junit:junit:4.12'
     compile 'com.shark:screencapture:1.0.0'
+    compile 'com.google.code.gson:gson:2.7'
     compile 'com.jcodecraeer:xrecyclerview:1.5.2'
+    compile 'com.github.bumptech.glide:glide:3.7.0'
     compile 'com.squareup.okhttp3:okhttp:3.9.1'
+    compile 'org.greenrobot:eventbus:3.1.1'
     debugCompile 'com.readystatesoftware.chuck:library:1.1.0'
     releaseCompile 'com.readystatesoftware.chuck:library-no-op:1.1.0'
 }

+ 18 - 5
app/src/main/AndroidManifest.xml

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          xmlns:tools="http://schemas.android.com/tools"
           package="com.jiuyan.sheep_children">
 
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
@@ -9,7 +10,12 @@
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
 
+    <permission
+        android:name="android.permission.PACKAGE_USAGE_STATS"
+        tools:ignore="ProtectedPermissions"/>
+
     <application
+        android:name=".SheepApp"
         android:allowBackup="true"
         android:icon="@drawable/icon"
         android:supportsRtl="true"
@@ -19,10 +25,6 @@
             android:exported="true"
             android:launchMode="singleTask"
             android:screenOrientation="portrait">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN"/>
-                <category android:name="android.intent.category.LAUNCHER"/>
-            </intent-filter>
         </activity>
         <activity
             android:name=".floatwindow.FloatWindow"
@@ -34,6 +36,13 @@
         <activity android:name=".page.UserCenterActivity"/>
         <activity android:name=".page.WithdrawActivity"/>
         <activity android:name=".page.DownloadActivity"/>
+        <activity android:name=".page.LoginActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+
+                <category android:name="android.intent.category.LAUNCHER"/>
+            </intent-filter>
+        </activity>
 
         <service
             android:name=".floatwindow.FloatService"
@@ -46,11 +55,15 @@
             android:authorities="com.jiuyan.sheep_children"
             android:exported="false"
             android:grantUriPermissions="true">
-            <!--元数据-->
+
+            <!-- 元数据 -->
             <meta-data
                 android:name="android.support.FILE_PROVIDER_PATHS"
                 android:resource="@xml/file_paths"/>
         </provider>
+
+        <activity android:name=".page.BindWxActivity">
+        </activity>
     </application>
 
 </manifest>

+ 19 - 0
app/src/main/java/com/jiuyan/sheep_children/SheepApp.java

@@ -0,0 +1,19 @@
+package com.jiuyan.sheep_children;
+
+import android.app.Application;
+import android.content.Context;
+
+/**
+ * Created by kemllor on 2017/12/21.
+ */
+
+public class SheepApp extends Application {
+
+    public static Context mContext;
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        mContext = getApplicationContext();
+    }
+}

+ 38 - 0
app/src/main/java/com/jiuyan/sheep_children/base/BaseActivity.java

@@ -0,0 +1,38 @@
+package com.jiuyan.sheep_children.base;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.View;
+
+import org.greenrobot.eventbus.EventBus;
+
+/**
+ * Created by kemllor on 2017/12/15.
+ */
+
+public abstract class BaseActivity extends Activity {
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+//        EventBus.getDefault().register(this);
+        setContentView(getLayoutId());
+        initView();
+        initListener();
+        initData();
+    }
+
+    protected abstract int getLayoutId();
+
+    public abstract void initView();
+
+    public abstract void initListener();
+
+    public abstract void initData();
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+//        EventBus.getDefault().unregister(this);
+    }
+}

+ 9 - 0
app/src/main/java/com/jiuyan/sheep_children/event/FloatMsg.java

@@ -0,0 +1,9 @@
+package com.jiuyan.sheep_children.event;
+
+/**
+ * Created by kemllor on 2017/12/20.
+ */
+
+public class FloatMsg {
+    public boolean  shouldShow;
+}

+ 103 - 32
app/src/main/java/com/jiuyan/sheep_children/floatwindow/FloatService.java

@@ -7,27 +7,42 @@ import android.app.usage.UsageStatsManager;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.PixelFormat;
+import android.graphics.Point;
 import android.os.Build;
 import android.os.IBinder;
+import android.provider.Settings;
+import android.text.TextUtils;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
 import android.view.WindowManager;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
 import android.widget.TextView;
 import android.widget.Toast;
 
 import com.jiuyan.sheep_children.R;
+import com.jiuyan.sheep_children.event.FloatMsg;
 import com.jiuyan.sheep_children.page.MainActivity;
 import com.jiuyan.sheep_children.page.ShotScreenActivity;
+import com.jiuyan.sheep_children.page.entry.Task;
+import com.jiuyan.sheep_children.utils.DeviceInfo;
+import com.jiuyan.sheep_children.utils.PackageUtil;
+import com.jiuyan.sheep_children.utils.PremissUtils;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
 
 import java.util.List;
 
 
-public class FloatService extends Service {
+public class FloatService extends Service implements View.OnClickListener {
 
     private static final String TAG = "MainService";
 
@@ -39,6 +54,9 @@ public class FloatService extends Service {
 
     //状态栏高度.
     int statusBarHeight = -1;
+    private Point mSize;
+    private View mLeft;
+    private View mRight;
 
     //不与Activity进行绑定.
     @Override
@@ -49,7 +67,9 @@ public class FloatService extends Service {
     @Override
     public void onCreate() {
         super.onCreate();
+        EventBus.getDefault().register(this);
         Log.i(TAG, "MainService Created");
+        mSize = DeviceInfo.getDeviceSize(this);
         createToucher();
     }
 
@@ -71,14 +91,12 @@ public class FloatService extends Service {
 
         //设置悬浮窗口长宽数据.
         params.width = -2;
-        params.height = 50;
+        params.height = DeviceInfo.dip2px(this,50f);
 
         LayoutInflater inflater = LayoutInflater.from(getApplication());
         //获取浮动窗口视图所在布局.
         mFloatwindow = (LinearLayout) inflater.inflate(R.layout.float_window, null);
         //添加toucherlayout
-        mWm.addView(mFloatwindow, params);
-
         Log.i(TAG, "toucherlayout-->left:" + mFloatwindow.getLeft());
         Log.i(TAG, "toucherlayout-->right:" + mFloatwindow.getRight());
         Log.i(TAG, "toucherlayout-->top:" + mFloatwindow.getTop());
@@ -95,35 +113,20 @@ public class FloatService extends Service {
         Log.i(TAG, "状态栏高度为:" + statusBarHeight);
 
         //浮动窗口按钮.
-        floaticon = (ImageView) mFloatwindow.findViewById(R.id.floaticon);
-        final View view = mFloatwindow.findViewById(R.id.ll_info);
-        TextView tvCommit = (TextView) mFloatwindow.findViewById(R.id.tv_commit);
-        TextView tvOpen = (TextView) mFloatwindow.findViewById(R.id.tv_open);
+        floaticon = (ImageView) mFloatwindow.findViewById(R.id.floate_icon);
+        mLeft = mFloatwindow.findViewById(R.id.ll_info_left);
+        mRight = mFloatwindow.findViewById(R.id.ll_info_right);
 
-        tvCommit.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                view.setVisibility(View.GONE);
-                Intent intent = new Intent(FloatService.this, ShotScreenActivity.class);
-                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-                startActivity(intent);
-            }
-        });
-        tvOpen.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                view.setVisibility(View.GONE);
-                Intent intent = new Intent(FloatService.this, MainActivity.class);
-                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-                startActivity(intent);
-            }
-        });
-        floaticon.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                view.setVisibility(View.VISIBLE);
-            }
-        });
+        ImageView imgCommitRight = (ImageView) mFloatwindow.findViewById(R.id.img_commit_right);
+        ImageView imgCommitLeft = (ImageView) mFloatwindow.findViewById(R.id.img_commit_left);
+        ImageView imgOpenRight = (ImageView) mFloatwindow.findViewById(R.id.img_open_right);
+        ImageView imgOpenLeft = (ImageView) mFloatwindow.findViewById(R.id.img_open_left);
+
+        imgCommitRight.setOnClickListener(this);
+        imgCommitLeft.setOnClickListener(this);
+        imgOpenRight.setOnClickListener(this);
+        imgOpenLeft.setOnClickListener(this);
+        floaticon.setOnClickListener(this);
 
         floaticon.setOnTouchListener(new View.OnTouchListener() {
             @Override
@@ -131,6 +134,17 @@ public class FloatService extends Service {
                 params.x = (int) event.getRawX() - 25;
                 params.y = (int) event.getRawY() - 25 - statusBarHeight;
                 mWm.updateViewLayout(mFloatwindow, params);
+                switch (event.getAction()) {
+                    case MotionEvent.ACTION_UP:
+                    case MotionEvent.ACTION_CANCEL:
+                        int x = (int) event.getRawX();
+                        if (x > mSize.x / 2) {
+                            params.x = mSize.x;
+                        } else {
+                            params.x = 0;
+                        }
+                        mWm.updateViewLayout(mFloatwindow, params);
+                }
                 return false;
             }
         });
@@ -141,7 +155,64 @@ public class FloatService extends Service {
         if (floaticon != null) {
             mWm.removeView(mFloatwindow);
         }
+        EventBus.getDefault().unregister(this);
         super.onDestroy();
     }
 
+    @Override
+    public void onClick(View v) {
+        Intent intent;
+        switch (v.getId()) {
+            case R.id.img_commit_left:
+            case R.id.img_commit_right:
+                mLeft.setVisibility(View.GONE);
+                mRight.setVisibility(View.GONE);
+                String pkg = PackageUtil.getLauncherTopApp(FloatService.this);
+                intent = new Intent(FloatService.this, ShotScreenActivity.class);
+                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                intent.putExtra("pkg", pkg);
+                startActivity(intent);
+                break;
+            case R.id.img_open_left:
+            case R.id.img_open_right:
+                mLeft.setVisibility(View.GONE);
+                mRight.setVisibility(View.GONE);
+                intent = new Intent(FloatService.this, MainActivity.class);
+                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                startActivity(intent);
+                break;
+            case R.id.floate_icon:
+                int[] ints = new int[2];
+                v.getLocationOnScreen(ints);
+                if (ints[0] > mSize.x / 2) {
+                    if (mLeft.getVisibility() == View.GONE) {
+                        mLeft.setVisibility(View.VISIBLE);
+                        mRight.setVisibility(View.GONE);
+                    } else {
+                        mLeft.setVisibility(View.GONE);
+                    }
+                } else {
+                    if (mRight.getVisibility() == View.GONE) {
+                        mRight.setVisibility(View.VISIBLE);
+                        mLeft.setVisibility(View.GONE);
+                    } else {
+                        mRight.setVisibility(View.GONE);
+                    }
+                }
+                break;
+        }
+    }
+
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMessageEvent(FloatMsg event) {
+        if (event.shouldShow) {
+            if (mFloatwindow != null) {
+                mWm.addView(mFloatwindow, params);
+            }
+        } else {
+            if (mFloatwindow != null && mFloatwindow.isAttachedToWindow())
+                mWm.removeViewImmediate(mFloatwindow);
+        }
+    }
 }

+ 6 - 3
app/src/main/java/com/jiuyan/sheep_children/floatwindow/FloatWindow.java

@@ -17,17 +17,20 @@ public class FloatWindow extends Activity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        if (Build.VERSION.SDK_INT >= 23)
+        if (Build.VERSION.SDK_INT >= 23){
             if (Settings.canDrawOverlays(FloatWindow.this)) {
                 Intent intent = new Intent(FloatWindow.this, FloatService.class);
                 startService(intent);
-                finish();
             } else {
                 //若没有权限,提示获取.
                 Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
                 Toast.makeText(FloatWindow.this, "需要取得权限以使用悬浮窗", Toast.LENGTH_SHORT).show();
                 startActivity(intent);
-                finish();
             }
+        }else {
+            Intent intent = new Intent(FloatWindow.this, FloatService.class);
+            startService(intent);
+        }
+        finish();
     }
 }

+ 1 - 1
app/src/main/java/com/jiuyan/sheep_children/floatwindow/ShotScreen.java

@@ -140,7 +140,7 @@ public class ShotScreen {
                 try {
                     if (TextUtils.isEmpty(mLocalUrl)) {
                         mLocalUrl = getContext().getExternalFilesDir("screenshot").getAbsoluteFile()
-                                + "/" + SystemClock.currentThreadTimeMillis() + ".png";
+                                + "/task.png";
                     }
                     fileImage = new File(mLocalUrl);
 

+ 16 - 9
app/src/main/java/com/jiuyan/sheep_children/net/NetManager.java

@@ -46,12 +46,20 @@ public class NetManager {
     }
 
 
-    public static void get(String url, Callback callback, Context context) {
+    public static void get(String url, Map<String, String> parma, Context context, Callback callback) {
+        if (parma != null) {
+            String param = "";
+            for (Map.Entry<String, String> el : parma.entrySet()) {
+                param += el.getKey() + "=" + el.getValue();
+                param += "&";
+            }
+            url += "?" + param;
+        }
         Request request = new Request.Builder().url(url).get().build();
         getInstancce(context).newCall(request).enqueue(callback);
     }
 
-    public static void post(String url, Map<String, String> parma, Callback callback, Context context) {
+    public static void post(String url, Map<String, String> parma, Context context, Callback callback) {
         FormBody.Builder builder = new FormBody.Builder();
         for (Map.Entry<String, String> el : parma.entrySet()) {
             builder.add(el.getKey(), el.getValue());
@@ -61,23 +69,22 @@ public class NetManager {
         getInstancce(context).newCall(request).enqueue(callback);
     }
 
-    public static void upload(String url, Map<String, String> parma, File file, Callback callback, Context context) {
-        FormBody.Builder builder = new FormBody.Builder();
+    public static void upload(String url, Map<String, String> parma, File file, Context context, Callback callback) {
+        String param = "";
         for (Map.Entry<String, String> el : parma.entrySet()) {
-            builder.add(el.getKey(), el.getValue());
+            param += el.getKey() + "=" + el.getValue();
+            param += "&";
         }
-        FormBody body = builder.build();
+        url += "?" + param;
 
         MediaType type = MediaType.parse("application/octet-stream");
         RequestBody fileBody = RequestBody.create(type, file);
 
+
         RequestBody multipartBody = new MultipartBody.Builder()
                 .setType(MultipartBody.FORM)
                 .addPart(Headers.of(
                         "Content-Disposition",
-                        "form-data; name=\"params\""), body)
-                .addPart(Headers.of(
-                        "Content-Disposition",
                         "form-data; name=\"file\"; filename=\"screenshot.png\""), fileBody)
                 .build();
 

+ 86 - 0
app/src/main/java/com/jiuyan/sheep_children/net/SheepCallback.java

@@ -0,0 +1,86 @@
+package com.jiuyan.sheep_children.net;
+
+import android.app.Activity;
+import android.os.Looper;
+import android.widget.Toast;
+
+import com.google.gson.internal.$Gson$Types;
+import com.google.gson.reflect.TypeToken;
+import com.jiuyan.sheep_children.SheepApp;
+import com.jiuyan.sheep_children.utils.GsonUtil;
+
+import java.io.IOException;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.List;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Response;
+
+/**
+ * Created by kemllor on 2017/12/21.
+ */
+
+public abstract class SheepCallback<T> implements Callback {
+
+    Activity mActivity;
+    public Type mType;
+
+    public SheepCallback(Activity activity) {
+        mActivity = activity;
+        mType = getSuperclassTypeParameter(getClass());
+    }
+
+    @Override
+    public void onFailure(Call call, final IOException e) {
+        mActivity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                Toast.makeText(SheepApp.mContext, "网络错误", Toast.LENGTH_SHORT).show();
+                failure(e);
+            }
+        });
+    }
+
+
+    @Override
+    public void onResponse(Call call, final Response response) throws IOException {
+        final String string = response.body().string();
+        if (response.code() == 200) {
+            final T data = (T) GsonUtil.getEntry(string, mType);
+            mActivity.runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    success(data);
+                }
+            });
+
+        } else {
+            mActivity.runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    Toast.makeText(SheepApp.mContext, string, Toast.LENGTH_SHORT).show();
+                }
+            });
+        }
+
+    }
+
+    public abstract void success(T t);
+
+    public void failure(IOException e) {
+    }
+
+    private static Type getSuperclassTypeParameter(Class<?> subclass) {
+        //得到带有泛型的类
+        Type superclass = subclass.getGenericSuperclass();
+        if (superclass instanceof Class) {
+            throw new RuntimeException("Missing type parameter.");
+        }
+        //取出当前类的泛型
+        ParameterizedType parameter = (ParameterizedType) superclass;
+        return $Gson$Types.canonicalize(parameter.getActualTypeArguments()[0]);
+    }
+
+}

+ 4 - 1
app/src/main/java/com/jiuyan/sheep_children/net/Url.java

@@ -7,5 +7,8 @@ import com.jiuyan.sheep_children.Config;
  */
 
 public class Url {
-    public  String Upload_img= Config.mBaseUrl+"/v1/up/";
+    public static String UPLOAD_IMG = Config.mBaseUrl + "/v1/up/";
+    public static String PUBLISH_TASKS = Config.mBaseUrl + "/v1/task_publish/getTasks/";
+    public static String BIND_WX = Config.mBaseUrl + "/v1/user/bindWx";
+
 }

+ 90 - 0
app/src/main/java/com/jiuyan/sheep_children/page/BindWxActivity.java

@@ -0,0 +1,90 @@
+package com.jiuyan.sheep_children.page;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.design.widget.TextInputEditText;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.jiuyan.sheep_children.R;
+import com.jiuyan.sheep_children.base.BaseActivity;
+import com.jiuyan.sheep_children.net.NetManager;
+import com.jiuyan.sheep_children.net.SheepCallback;
+import com.jiuyan.sheep_children.net.Url;
+import com.jiuyan.sheep_children.utils.SpUtils;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
+
+public class BindWxActivity extends BaseActivity implements View.OnClickListener {
+    private ImageView mBack;
+    private TextView mTitle;
+    private TextInputEditText mEtWx;
+    private TextView mTvWx;
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.bind_wx_activity;
+    }
+
+    @Override
+    public void initView() {
+        mEtWx = findViewById(R.id.et_wx);
+        mTvWx = findViewById(R.id.tv_wx);
+        mBack = findViewById(R.id.img_back);
+        mTitle = findViewById(R.id.tv_title);
+        mTitle.setText("绑定微信");
+    }
+
+    @Override
+    public void initListener() {
+        mBack.setOnClickListener(this);
+        mTvWx.setOnClickListener(this);
+
+    }
+
+    @Override
+    public void initData() {
+
+    }
+
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.img_back:
+                finish();
+                break;
+            case R.id.tv_wx:
+                bindWx();
+                break;
+        }
+    }
+
+    private void bindWx() {
+        String wxId = mEtWx.getText().toString().trim();
+        String openId = SpUtils.getOpenId(getApplicationContext());
+        if (TextUtils.isEmpty(openId)) {
+            startActivity(new Intent(this, LoginActivity.class));
+        } else {
+            HashMap<String, String> map = new HashMap<>();
+            map.put("wx_id", wxId);
+            map.put("wx_open_id", openId);
+            NetManager.get(Url.BIND_WX, map, getApplicationContext(), new SheepCallback<String>(this) {
+                @Override
+                public void success(String s) {
+                    Toast.makeText(BindWxActivity.this, s, Toast.LENGTH_SHORT).show();
+                }
+            });
+        }
+    }
+}

+ 22 - 5
app/src/main/java/com/jiuyan/sheep_children/page/DownloadActivity.java

@@ -16,6 +16,7 @@ import android.widget.ProgressBar;
 import android.widget.TextView;
 
 import com.jiuyan.sheep_children.R;
+import com.jiuyan.sheep_children.base.BaseActivity;
 import com.jiuyan.sheep_children.net.NetManager;
 
 import java.io.File;
@@ -42,7 +43,7 @@ import static com.jiuyan.sheep_children.page.DownloadActivity.DownloadState.PEND
  * Created by kemllor on 2017/12/14.
  */
 
-public class DownloadActivity extends Activity implements View.OnClickListener {
+public class DownloadActivity extends BaseActivity implements View.OnClickListener {
 
 
     private static final String DOWNLOAD_URL = "https://qiniu.kuaifazs.com/fszhskp_12493_haowan_2.1.2.apk";
@@ -67,9 +68,27 @@ public class DownloadActivity extends Activity implements View.OnClickListener {
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.download_activity);
-        findViews();
+    }
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.download_activity;
+    }
+
+    @Override
+    public void initListener() {
+        mTvDownload.setOnClickListener(this);
+    }
+
+    @Override
+    public void initData() {
+
+    }
+
+    @Override
+    public void initView() {
         initClient();
+        findViews();
     }
 
     private void initClient() {
@@ -81,8 +100,6 @@ public class DownloadActivity extends Activity implements View.OnClickListener {
     private void findViews() {
         mTvDownload = (TextView) findViewById(R.id.tv_download);
         mPbDownload = (ProgressBar) findViewById(R.id.pb_download);
-
-        mTvDownload.setOnClickListener(this);
     }
 
     @Override

+ 50 - 0
app/src/main/java/com/jiuyan/sheep_children/page/LoginActivity.java

@@ -0,0 +1,50 @@
+package com.jiuyan.sheep_children.page;
+
+import android.content.Intent;
+import android.view.View;
+import android.widget.ImageView;
+
+import com.jiuyan.sheep_children.R;
+import com.jiuyan.sheep_children.base.BaseActivity;
+import com.jiuyan.sheep_children.utils.SpUtils;
+
+/**
+ * Created by kemllor on 2017/12/21.
+ */
+
+public class LoginActivity extends BaseActivity {
+    private ImageView mImgLogin;
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.login_actvity;
+    }
+
+
+    @Override
+    public void initData() {
+
+    }
+
+    @Override
+    public void initView() {
+        mImgLogin = (ImageView) findViewById(R.id.img_login);
+    }
+
+    @Override
+    public void initListener() {
+        mImgLogin.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                loginFromWx();
+                Intent intent = new Intent(LoginActivity.this, MainActivity.class);
+                startActivity(intent);
+                finish();
+            }
+        });
+    }
+
+    private void loginFromWx() {
+        SpUtils.login(this, "testkajhsdasdjoasd");
+    }
+}

+ 91 - 27
app/src/main/java/com/jiuyan/sheep_children/page/MainActivity.java

@@ -20,17 +20,39 @@ import android.widget.LinearLayout;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.google.gson.reflect.TypeToken;
 import com.jcodecraeer.xrecyclerview.XRecyclerView;
 import com.jiuyan.sheep_children.R;
+import com.jiuyan.sheep_children.base.BaseActivity;
+import com.jiuyan.sheep_children.event.FloatMsg;
 import com.jiuyan.sheep_children.floatwindow.FloatService;
 import com.jiuyan.sheep_children.floatwindow.FloatWindow;
+import com.jiuyan.sheep_children.net.NetManager;
+import com.jiuyan.sheep_children.net.SheepCallback;
+import com.jiuyan.sheep_children.net.Url;
 import com.jiuyan.sheep_children.page.adapter.TaskAdapter;
+import com.jiuyan.sheep_children.page.entry.Task;
+import com.jiuyan.sheep_children.page.entry.TaskPublish;
 import com.jiuyan.sheep_children.utils.DeviceInfo;
+import com.jiuyan.sheep_children.utils.GsonUtil;
+import com.jiuyan.sheep_children.utils.PremissUtils;
+import com.jiuyan.sheep_children.utils.SpUtils;
 import com.readystatesoftware.chuck.Chuck;
 
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.io.IOException;
+import java.lang.reflect.Type;
 import java.util.ArrayList;
+import java.util.List;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.Response;
 
-public class MainActivity extends Activity implements View.OnClickListener {
+public class MainActivity extends BaseActivity implements View.OnClickListener {
 
     private XRecyclerView mRecyclerView;
     private TaskAdapter mAdapter;
@@ -39,11 +61,46 @@ public class MainActivity extends Activity implements View.OnClickListener {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.main_activity);
-        findviews();
+        requestPermission();
+        Intent intent = new Intent(MainActivity.this, FloatWindow.class);
+        startActivity(intent);
+    }
 
+    @Override
+    protected int getLayoutId() {
+        return R.layout.main_activity;
+    }
 
-        requestPermission();
+    @Override
+    public void initListener() {
+        mTvWithdraw.setOnClickListener(this);
+        mTvWithdraw.setOnLongClickListener(new View.OnLongClickListener() {
+
+            @Override
+            public boolean onLongClick(View v) {
+                Intent intent = Chuck.getLaunchIntent(MainActivity.this);
+                startActivity(intent);
+                return true;
+            }
+        });
+    }
+
+
+    @Override
+    public void initData() {
+        NetManager.get(Url.PUBLISH_TASKS, null, getApplicationContext(), new SheepCallback<List<TaskPublish>>(this) {
+            @Override
+            public void success(List<TaskPublish> tasks) {
+                mAdapter.setData(tasks);
+                mAdapter.notifyDataSetChanged();
+                mRecyclerView.refreshComplete();
+            }
+        });
+    }
+
+    @Override
+    public void initView() {
+        findviews();
         Point deviceSize = DeviceInfo.getDeviceSize(this);
         View head = View.inflate(this, R.layout.task_head, null);
         findViewHead(head);
@@ -54,7 +111,7 @@ public class MainActivity extends Activity implements View.OnClickListener {
         LinearLayoutManager layoutManager = new LinearLayoutManager(this);
         layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
         mRecyclerView.setLayoutManager(layoutManager);
-        mAdapter = new TaskAdapter(new ArrayList<String>());
+        mAdapter = new TaskAdapter(new ArrayList<TaskPublish>(), MainActivity.this);
         mAdapter.setClickCallBack(new TaskAdapter.ItemClickCallBack<String>() {
             @Override
             public void onItemClick(String pos) {
@@ -64,57 +121,58 @@ public class MainActivity extends Activity implements View.OnClickListener {
             }
         });
         mRecyclerView.setAdapter(mAdapter);
-        /*if (ContextCompat.checkSelfPermission(this, Manifest.permission.PACKAGE_USAGE_STATS) != PackageManager.PERMISSION_GRANTED) {
-            Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
-            startActivity(intent);
-        }*/
+        mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
+            @Override
+            public void onRefresh() {
+                initData();
+            }
+
+            @Override
+            public void onLoadMore() {
 
-        setListener();
+            }
+        });
+        mRecyclerView.setLoadingMoreEnabled(false);
     }
 
     private void requestPermission() {
+        boolean has = PremissUtils.hasPermission(this);
+        if (!has) {
+            PremissUtils.openUsageAccessPage(this);
+        }
         if (Build.VERSION.SDK_INT >= 23)
             if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                 ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
             }
+
     }
 
     private void findViewHead(View head) {
         mTvWithdraw = (TextView) head.findViewById(R.id.tv_withdraw);
     }
 
-
-    private void setListener() {
-        mTvWithdraw.setOnClickListener(this);
-        mTvWithdraw.setOnLongClickListener(new View.OnLongClickListener() {
-
-            @Override
-            public boolean onLongClick(View v) {
-                Intent intent = Chuck.getLaunchIntent(MainActivity.this);
-                startActivity(intent);
-                return true;
-            }
-        });
-    }
-
     private void findviews() {
         mRecyclerView = (XRecyclerView) findViewById(R.id.tasks);
     }
 
     @Override
     protected void onResume() {
+        FloatMsg floatMsg = new FloatMsg();
+        floatMsg.shouldShow = false;
+        EventBus.getDefault().post(floatMsg);
         super.onResume();
     }
 
     @Override
     protected void onStop() {
-        Intent intent = new Intent(MainActivity.this, FloatWindow.class);
-        startActivity(intent);
         super.onStop();
     }
 
     @Override
     protected void onDestroy() {
+        FloatMsg floatMsg = new FloatMsg();
+        floatMsg.shouldShow = true;
+        EventBus.getDefault().post(floatMsg);
         super.onDestroy();
     }
 
@@ -122,8 +180,14 @@ public class MainActivity extends Activity implements View.OnClickListener {
     public void onClick(View v) {
         switch (v.getId()) {
             case R.id.tv_withdraw:
-                Intent intent = new Intent(MainActivity.this, UserCenterActivity.class);
+                Intent intent;
+                if (SpUtils.isLogin(getApplicationContext())) {
+                    intent = new Intent(MainActivity.this, UserCenterActivity.class);
+                } else {
+                    intent = new Intent(MainActivity.this, LoginActivity.class);
+                }
                 startActivity(intent);
+
                 break;
         }
     }

+ 10 - 25
app/src/main/java/com/jiuyan/sheep_children/page/ShotScreenActivity.java

@@ -3,18 +3,16 @@ package com.jiuyan.sheep_children.page;
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
-import android.graphics.drawable.ColorDrawable;
 import android.media.projection.MediaProjectionManager;
 import android.os.Build;
 import android.os.Bundle;
-import android.os.Environment;
 import android.view.Window;
 import android.widget.TextView;
 import android.widget.Toast;
 
-import com.jiuyan.sheep_children.floatwindow.FloatService;
 import com.jiuyan.sheep_children.floatwindow.ShotScreen;
 import com.jiuyan.sheep_children.net.NetManager;
+import com.jiuyan.sheep_children.net.SheepCallback;
 import com.jiuyan.sheep_children.net.Url;
 import com.jiuyan.sheep_children.utils.PackageUtil;
 import com.shark.screencapture.ScreenCapture;
@@ -34,14 +32,12 @@ import okhttp3.Response;
 public class ShotScreenActivity extends Activity {
 
     public static final int REQUEST_MEDIA_PROJECTION = 0x2893;
-    private ScreenCapture mScreenCapture;
 
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         requestWindowFeature(Window.FEATURE_NO_TITLE);
-        setContentView(new TextView(this));
         requestScreenShot();
     }
 
@@ -78,34 +74,23 @@ public class ShotScreenActivity extends Activity {
     }
 
     private void commitTask(String path) {
-        String topApp = PackageUtil.getLauncherTopApp(getApplicationContext());
+        String topApp = "";
+        Intent intent = getIntent();
+        if (intent != null) {
+            topApp = intent.getStringExtra("pkg");
+        }
         HashMap<String, String> parma = new HashMap<>();
         parma.put("task_pkg", topApp);
-        NetManager.upload(new Url().Upload_img, parma, new File(path), new Callback() {
+        NetManager.upload(Url.UPLOAD_IMG, parma, new File(path), getApplicationContext(), new SheepCallback<String>(this) {
             @Override
-            public void onFailure(Call call, final IOException e) {
-                runOnUiThread(new Runnable() {
-                    @Override
-                    public void run() {
-                        toast(e.getMessage());
-                    }
-                });
+            public void success(String s) {
                 finish();
             }
 
             @Override
-            public void onResponse(Call call, Response response) throws IOException {
-                final String msg = response.body().string();
-                runOnUiThread(new Runnable() {
-                    @Override
-                    public void run() {
-                        toast(msg);
-                    }
-                });
+            public void failure(IOException e) {
                 finish();
             }
-        }, getApplicationContext());
+        });
     }
-
-
 }

+ 93 - 10
app/src/main/java/com/jiuyan/sheep_children/page/UserCenterActivity.java

@@ -6,24 +6,107 @@ import android.os.Bundle;
 import android.os.PersistableBundle;
 import android.support.annotation.Nullable;
 import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
 
 import com.jiuyan.sheep_children.R;
+import com.jiuyan.sheep_children.base.BaseActivity;
+import com.jiuyan.sheep_children.utils.SpUtils;
 
 /**
  * Created by kemllor on 2017/12/13.
  */
 
-public class UserCenterActivity extends Activity {
+public class UserCenterActivity extends BaseActivity implements View.OnClickListener {
+    private ImageView mImgIcon;
+    private ImageView mBack;
+    private TextView mTitle;
+    private TextView mTvNick;
+    private TextView mTvLevel;
+    private TextView mTvMoney;
+    private TextView mTvWithdraw;
+    private TextView mTvTask;
+    private TextView mTvWithdrawHostroy;
+
+
     @Override
-    protected void onCreate(Bundle savedInstanceState){
+    protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.usercenter_activity);
-        findViewById(R.id.tv_withdraw).setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                Intent intent = new Intent(UserCenterActivity.this, WithdrawActivity.class);
-                startActivity(intent);
-            }
-        });
     }
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.usercenter_activity;
+    }
+
+    @Override
+    public void initListener() {
+        mTvWithdraw.setOnClickListener(this);
+        mTvTask.setOnClickListener(this);
+        mTvWithdrawHostroy.setOnClickListener(this);
+        mBack.setOnClickListener(this);
+    }
+
+    @Override
+    public void initData() {
+        mTitle.setText("个人中心");
+
+    }
+
+    @Override
+    public void initView() {
+        mImgIcon = (ImageView) findViewById(R.id.img_icon);
+        mTvNick = (TextView) findViewById(R.id.tv_nick);
+        mTvLevel = (TextView) findViewById(R.id.tv_level);
+        mTvMoney = (TextView) findViewById(R.id.tv_money);
+        mTvWithdraw = (TextView) findViewById(R.id.tv_withdraw);
+        mTvTask = (TextView) findViewById(R.id.tv_task);
+        mTvWithdrawHostroy = (TextView) findViewById(R.id.tv_withdraw_hostroy);
+        mBack = (ImageView) findViewById(R.id.img_back);
+        mTitle = (TextView) findViewById(R.id.tv_title);
+    }
+
+    @Override
+    public void onClick(View v) {
+        Intent intent;
+        switch (v.getId()) {
+            case R.id.tv_withdraw:
+                if (checkLogin()) {
+                    intent = new Intent(UserCenterActivity.this, WithdrawActivity.class);
+                    startActivity(intent);
+                } else {
+                    toLogin();
+                }
+                break;
+            case R.id.tv_withdraw_hostroy:
+                if (checkLogin()) {
+                    intent = new Intent(UserCenterActivity.this, WithdrawActivity.class);
+                    startActivity(intent);
+                } else {
+                    toLogin();
+                }
+                break;
+            case R.id.tv_task:
+                if (checkLogin()) {
+                    intent = new Intent(UserCenterActivity.this, WithdrawActivity.class);
+                    startActivity(intent);
+                } else {
+                    toLogin();
+                }
+                break;
+            case R.id.img_back:
+                finish();
+                break;
+        }
+    }
+
+    private void toLogin() {
+        Intent intent = new Intent(UserCenterActivity.this, LoginActivity.class);
+        startActivity(intent);
+    }
+
+    private boolean checkLogin() {
+        return SpUtils.isLogin(getApplicationContext());
+    }
+
 }

+ 114 - 2
app/src/main/java/com/jiuyan/sheep_children/page/WithdrawActivity.java

@@ -1,20 +1,132 @@
 package com.jiuyan.sheep_children.page;
 
 import android.app.Activity;
+import android.content.Intent;
 import android.os.Bundle;
 import android.os.PersistableBundle;
 import android.support.annotation.Nullable;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
+import android.widget.BaseAdapter;
+import android.widget.GridLayout;
+import android.widget.GridView;
+import android.widget.ImageView;
+import android.widget.RadioButton;
+import android.widget.TextView;
 
 import com.jiuyan.sheep_children.R;
+import com.jiuyan.sheep_children.base.BaseActivity;
+import com.jiuyan.sheep_children.utils.SpUtils;
 
 /**
  * Created by kemllor on 2017/12/13.
  */
 
-public class WithdrawActivity  extends Activity{
+public class WithdrawActivity extends BaseActivity implements View.OnClickListener {
+    private ImageView mBack;
+    private TextView mTitle;
+    private TextView mMoney;
+    private GridView mGvMoney;
+    int[] mMoneys = new int[]{5, 10, 20, 50, 100, 500};
+    private TextView mTvWx;
+
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.withdraw_activity);
+    }
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.withdraw_activity;
+    }
+
+    @Override
+    public void initListener() {
+        mBack.setOnClickListener(this);
+        mTvWx.setOnClickListener(this);
+    }
+
+    @Override
+    public void initData() {
+
+    }
+
+    @Override
+    public void initView() {
+        mBack = (ImageView) findViewById(R.id.img_back);
+        mTitle = (TextView) findViewById(R.id.tv_title);
+        mMoney = (TextView) findViewById(R.id.tv_money);
+        mTvWx = (TextView) findViewById(R.id.tv_wx);
+        mGvMoney = (GridView) findViewById(R.id.gv_money);
+        mTitle.setText("提  现");
+        GvAdapter adapter = new GvAdapter();
+        mGvMoney.setAdapter(adapter);
+    }
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.img_back:
+                finish();
+                break;
+            case R.id.tv_wx:
+                commit();
+                break;
+        }
+    }
+
+    //提现
+    private void commit() {
+        if (!SpUtils.isLogin(getApplicationContext())) {
+            startActivity(new Intent(this, LoginActivity.class));
+        } else {
+            startActivity(new Intent(this, BindWxActivity.class));
+        }
+    }
+
+
+    private class GvAdapter extends BaseAdapter {
+        int checked = 0;
+
+
+        @Override
+        public int getCount() {
+            return mMoneys.length;
+        }
+
+        @Override
+        public Object getItem(int position) {
+            return position;
+        }
+
+        @Override
+        public long getItemId(int position) {
+            return position;
+        }
+
+        @Override
+        public View getView(final int position, View convertView, ViewGroup parent) {
+            View item = View.inflate(getApplicationContext(), R.layout.withdraw_item, null);
+            final RadioButton btn = (RadioButton) item.findViewById(R.id.rb_money);
+            btn.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    checked = position;
+                    ViewGroup gv = (ViewGroup) btn.getParent().getParent();
+                    for (int i = 0; i < mMoneys.length; i++) {
+                        RadioButton child = (RadioButton) ((ViewGroup) gv.getChildAt(i)).getChildAt(0);
+                        child.setSelected(false);
+                    }
+                    btn.setSelected(true);
+                }
+            });
+            btn.setText(mMoneys[position] + "  元");
+            return item;
+        }
+
+        public int getChecked() {
+            return checked;
+        }
     }
 }

+ 34 - 11
app/src/main/java/com/jiuyan/sheep_children/page/adapter/TaskAdapter.java

@@ -1,16 +1,20 @@
 package com.jiuyan.sheep_children.page.adapter;
 
-import android.content.Intent;
+import android.app.Activity;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.ImageView;
 import android.widget.TextView;
 
+import com.bumptech.glide.Glide;
 import com.jiuyan.sheep_children.R;
+import com.jiuyan.sheep_children.page.entry.Task;
+import com.jiuyan.sheep_children.page.entry.TaskPublish;
 
 import java.util.ArrayList;
-import java.util.Objects;
+import java.util.List;
 
 /**
  * Created by kemllor on 2017/12/13.
@@ -18,6 +22,9 @@ import java.util.Objects;
 
 public class TaskAdapter extends RecyclerView.Adapter<TaskAdapter.ViewHolder> {
 
+    Activity mActivity;
+    private List<TaskPublish> datas;
+    private ItemClickCallBack clickCallBack;
 
     public void setClickCallBack(ItemClickCallBack clickCallBack) {
         this.clickCallBack = clickCallBack;
@@ -27,10 +34,13 @@ public class TaskAdapter extends RecyclerView.Adapter<TaskAdapter.ViewHolder> {
         void onItemClick(T pos);
     }
 
-    public ArrayList datas = null;
-    private ItemClickCallBack clickCallBack;
 
-    public TaskAdapter(ArrayList datas) {
+    public TaskAdapter(ArrayList<TaskPublish> datas, Activity activity) {
+        this.datas = datas;
+        mActivity = activity;
+    }
+
+    public void setData(List<TaskPublish> datas) {
         this.datas = datas;
     }
 
@@ -44,8 +54,11 @@ public class TaskAdapter extends RecyclerView.Adapter<TaskAdapter.ViewHolder> {
     //将数据与界面进行绑定的操作
     @Override
     public void onBindViewHolder(ViewHolder viewHolder, final int position) {
-        //        viewHolder.mTextView.setText(datas.get(position));
-
+        viewHolder.mTvTitle.setText(datas.get(position).getTask().getTitle());
+        viewHolder.mTvCount.setText(datas.get(position).getSurplusCount() + "/" + datas.get(position).getTotalCouont());
+        viewHolder.mTvDesc.setText(datas.get(position).getTask().getDesc());
+        viewHolder.mTvMoney.setText(datas.get(position).getTask().getPrice());
+        Glide.with(mActivity).load(datas.get(position).getTask().getIcon()).placeholder(R.drawable.sheep).into(viewHolder.mImgIcon);
         viewHolder.mRootView.setOnClickListener(
                 new View.OnClickListener() {
                     @Override
@@ -61,19 +74,29 @@ public class TaskAdapter extends RecyclerView.Adapter<TaskAdapter.ViewHolder> {
     //获取数据的数量
     @Override
     public int getItemCount() {
-        //        return datas.size();
-        return 5;
+        return datas.size();
+        //        return 5;
     }
 
     //自定义的ViewHolder,持有每个Item的的所有界面元素
     public static class ViewHolder extends RecyclerView.ViewHolder {
-        public TextView mTextView;
+        public ImageView mImgIcon;
+        public TextView mTvTitle;
+        public TextView mTvDesc;
+        public TextView mTvCount;
+        public TextView mTvGuide;
+        public TextView mTvMoney;
         public View mRootView;
 
         public ViewHolder(View view) {
             super(view);
             mRootView = view;
-            mTextView = (TextView) view.findViewById(R.id.tv_guide);
+            mImgIcon = (ImageView) view.findViewById(R.id.img_icon);
+            mTvTitle = (TextView) view.findViewById(R.id.tv_title);
+            mTvDesc = (TextView) view.findViewById(R.id.tv_desc);
+            mTvCount = (TextView) view.findViewById(R.id.tv_count);
+            mTvGuide = (TextView) view.findViewById(R.id.tv_guide);
+            mTvMoney = (TextView) view.findViewById(R.id.tv_money);
         }
     }
 }

+ 103 - 0
app/src/main/java/com/jiuyan/sheep_children/page/entry/Task.java

@@ -0,0 +1,103 @@
+package com.jiuyan.sheep_children.page.entry;
+
+import java.io.Serializable;
+
+/**
+ * Created by kemllor on 2017/12/15.
+ */
+
+public  class Task implements Serializable {
+    /**
+     * Id : 1
+     * Type : 1
+     * DownLoadUrl : hh
+     * Guide : asd
+     * Desc : asdasd
+     * Icon :
+     * Title : asds
+     * Price : 5.00
+     * Pkg : asasd
+     */
+
+    private int Id;
+    private int Type;
+    private String DownLoadUrl;
+    private String Guide;
+    private String Desc;
+    private String Icon;
+    private String Title;
+    private String Price;
+    private String Pkg;
+
+    public int getId() {
+        return Id;
+    }
+
+    public void setId(int Id) {
+        this.Id = Id;
+    }
+
+    public int getType() {
+        return Type;
+    }
+
+    public void setType(int Type) {
+        this.Type = Type;
+    }
+
+    public String getDownLoadUrl() {
+        return DownLoadUrl;
+    }
+
+    public void setDownLoadUrl(String DownLoadUrl) {
+        this.DownLoadUrl = DownLoadUrl;
+    }
+
+    public String getGuide() {
+        return Guide;
+    }
+
+    public void setGuide(String Guide) {
+        this.Guide = Guide;
+    }
+
+    public String getDesc() {
+        return Desc;
+    }
+
+    public void setDesc(String Desc) {
+        this.Desc = Desc;
+    }
+
+    public String getIcon() {
+        return Icon;
+    }
+
+    public void setIcon(String Icon) {
+        this.Icon = Icon;
+    }
+
+    public String getTitle() {
+        return Title;
+    }
+
+    public void setTitle(String Title) {
+        this.Title = Title;
+    }
+
+    public String getPrice() {
+        return Price;
+    }
+
+    public void setPrice(String Price) {
+        this.Price = Price;
+    }
+
+    public String getPkg() {
+        return Pkg;
+    }
+
+    public void setPkg(String Pkg) {
+        this.Pkg = Pkg;
+    }
+}

+ 86 - 0
app/src/main/java/com/jiuyan/sheep_children/page/entry/TaskPublish.java

@@ -0,0 +1,86 @@
+package com.jiuyan.sheep_children.page.entry;
+
+import java.io.Serializable;
+
+/**
+ * Created by kemllor on 2017/12/14.
+ */
+
+public class TaskPublish  implements Serializable {
+
+    /**
+     * Id : 1
+     * TotalCouont : 200
+     * SurplusCount : 120
+     * CreateTime : 11
+     * OverTime : 11
+     * Status : 1
+     * Task : {"Id":1,"Type":1,"DownLoadUrl":"hh","Guide":"asd","Desc":"asdasd","Icon":"","Title":"asds","Price":"5.00","Pkg":"asasd"}
+     */
+
+    private int Id;
+    private int TotalCouont;
+    private int SurplusCount;
+    private String CreateTime;
+    private String OverTime;
+    private String Status;
+    private Task Task;
+
+    public int getId() {
+        return Id;
+    }
+
+    public void setId(int Id) {
+        this.Id = Id;
+    }
+
+    public int getTotalCouont() {
+        return TotalCouont;
+    }
+
+    public void setTotalCouont(int TotalCouont) {
+        this.TotalCouont = TotalCouont;
+    }
+
+    public int getSurplusCount() {
+        return SurplusCount;
+    }
+
+    public void setSurplusCount(int SurplusCount) {
+        this.SurplusCount = SurplusCount;
+    }
+
+    public String getCreateTime() {
+        return CreateTime;
+    }
+
+    public void setCreateTime(String CreateTime) {
+        this.CreateTime = CreateTime;
+    }
+
+    public String getOverTime() {
+        return OverTime;
+    }
+
+    public void setOverTime(String OverTime) {
+        this.OverTime = OverTime;
+    }
+
+    public String getStatus() {
+        return Status;
+    }
+
+    public void setStatus(String Status) {
+        this.Status = Status;
+    }
+
+    public Task getTask() {
+        return Task;
+    }
+
+    public void setTask(Task Task) {
+        this.Task = Task;
+    }
+
+
+}

+ 12 - 2
app/src/main/java/com/jiuyan/sheep_children/utils/DeviceInfo.java

@@ -10,10 +10,20 @@ import android.view.WindowManager;
 
 public class DeviceInfo {
 
-    public  static  Point getDeviceSize(Context context){
-        WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
+    public static Point getDeviceSize(Context context) {
+        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
         Point point = new Point();
         wm.getDefaultDisplay().getSize(point);
         return point;
     }
+
+    public static int dip2px(Context context, float dpValue) {
+        final float scale = context.getResources().getDisplayMetrics().density;
+        return (int) (dpValue * scale + 0.5f);
+    }
+
+    public static int px2dip(Context context, float pxValue) {
+        final float scale = context.getResources().getDisplayMetrics().density;
+        return (int) (pxValue / scale + 0.5f);
+    }
 }

+ 26 - 0
app/src/main/java/com/jiuyan/sheep_children/utils/GsonUtil.java

@@ -0,0 +1,26 @@
+package com.jiuyan.sheep_children.utils;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.jiuyan.sheep_children.page.entry.Task;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+
+/**
+ * Created by kemllor on 2017/12/15.
+ */
+
+public class GsonUtil {
+
+    public static <T>  T getEntry(String jsonstr, Type type){
+        Gson gson = new Gson();
+        Object entry = gson.fromJson(jsonstr, type);
+        return  (T) entry;
+    }
+    public static <T>  T getEntry(String jsonstr, Class<T> classOfT){
+        Gson gson = new Gson();
+        Object entry = gson.fromJson(jsonstr, (Type)classOfT);
+        return  (T) entry;
+    }
+}

+ 39 - 0
app/src/main/java/com/jiuyan/sheep_children/utils/PremissUtils.java

@@ -0,0 +1,39 @@
+package com.jiuyan.sheep_children.utils;
+
+import android.app.Activity;
+import android.app.AppOpsManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Process;
+
+/**
+ * PACKAGE_USAGE_STATS 权限申请
+ * Created by kemllor on 2017/12/20.
+ */
+
+public class PremissUtils {
+    public static final int MY_PERMISSIONS_REQUEST_PACKAGE_USAGE_STATS = 1101;
+
+    public static boolean hasPermission(Context context) {
+        if (context == null) {
+            return false;
+        }
+        int checkOpNoThrow = 0;
+        AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
+        checkOpNoThrow = appOpsManager.checkOpNoThrow("android:get_usage_stats", Process.myUid(), context.getPackageName());
+        return checkOpNoThrow == 0;
+    }
+
+    public static boolean openUsageAccessPage(Activity activity) {
+        if (activity == null) {
+            return false;
+        }
+        try {
+            activity.startActivityForResult(new Intent("android.settings.USAGE_ACCESS_SETTINGS"), MY_PERMISSIONS_REQUEST_PACKAGE_USAGE_STATS);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+}

+ 32 - 0
app/src/main/java/com/jiuyan/sheep_children/utils/SpUtils.java

@@ -0,0 +1,32 @@
+package com.jiuyan.sheep_children.utils;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.text.TextUtils;
+
+import com.jiuyan.sheep_children.page.UserCenterActivity;
+
+/**
+ * Created by kemllor on 2017/12/21.
+ */
+
+public class SpUtils {
+
+    public static boolean isLogin(Context context) {
+        SharedPreferences user = context.getSharedPreferences("user", Context.MODE_PRIVATE);
+        String wxOpenId = user.getString("wx_openId", "");
+        return !TextUtils.isEmpty(wxOpenId);
+    }
+
+    public static String getOpenId(Context context) {
+        SharedPreferences user = context.getSharedPreferences("user", Context.MODE_PRIVATE);
+        return user.getString("wx_openId", "");
+    }
+
+    public static void login(Context context, String openId) {
+        SharedPreferences user = context.getSharedPreferences("user", Context.MODE_PRIVATE);
+        SharedPreferences.Editor editor = user.edit();
+        editor.putString("wx_openId", openId);
+        editor.apply();
+    }
+}

BIN
app/src/main/res/drawable-hdpi/floate_back.9.png


BIN
app/src/main/res/drawable-hdpi/home.png


BIN
app/src/main/res/drawable-hdpi/task.png


BIN
app/src/main/res/drawable-hdpi/wx_logo.png


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

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <corners android:radius="3dp"/>
+    <stroke
+        android:width="1dp"
+        android:color="@color/red"/>
+</shape>

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

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <corners android:radius="3dp"/>
+
+    <solid android:color="@color/red"/>
+
+</shape>

+ 6 - 0
app/src/main/res/drawable/text_backgroud.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/texe_background_normal" android:state_selected="false"/>
+    <item android:drawable="@drawable/texe_background_selected" android:state_selected="true"/>
+
+</selector>

+ 7 - 0
app/src/main/res/drawable/text_color.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="@color/white" android:state_selected="true"/>
+    <item android:color="@color/theme" android:state_pressed="true"/> <!-- pressed -->
+    <item android:color="@color/red"/> <!-- default -->
+
+</selector>

+ 65 - 0
app/src/main/res/layout/bind_wx_activity.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical">
+
+    <include
+        layout="@layout/title"/>
+
+    <TextView
+        android:layout_marginTop="10dp"
+        android:textColor="@color/black_dark"
+        android:layout_marginLeft="15dp"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="步骤1"/>
+
+    <TextView
+        android:textColor="@color/theme"
+        android:layout_marginTop="15dp"
+        android:layout_marginLeft="20dp"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="添加好友->佣金发放号:45245124"/>
+
+    <TextView
+        android:layout_marginTop="15dp"
+        android:textColor="@color/black_dark"
+        android:layout_marginLeft="15dp"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="步骤2"/>
+
+    <android.support.design.widget.TextInputEditText
+        android:id="@+id/et_wx"
+        android:layout_margin="15dp"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textColorHint="@color/theme"
+        android:hint="请输入登录使用的微信号"
+        android:textColor="@color/black_dark"
+        android:textSize="14sp"/>
+
+    <TextView
+        android:layout_marginLeft="15dp"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="注:填入的微信帐号为佣金接收号,必须和登录帐号一致。\n        帐号一经绑定不能修改"
+        android:textColor="@color/red"
+        android:textSize="12sp"/>
+
+    <TextView
+        android:id="@+id/tv_wx"
+        android:layout_width="200dp"
+        android:layout_height="35dp"
+        android:layout_gravity="center"
+        android:layout_marginLeft="5dp"
+        android:layout_marginTop="15dp"
+        android:background="@drawable/text_backgroud"
+        android:gravity="center"
+        android:text="绑定微信"
+        android:textColor="@drawable/text_color"
+        android:textSize="16sp"/>
+
+</LinearLayout>

+ 43 - 17
app/src/main/res/layout/float_window.xml

@@ -4,37 +4,63 @@
               android:layout_height="wrap_content"
               android:orientation="horizontal">
 
+    <LinearLayout
+        android:id="@+id/ll_info_left"
+        android:layout_width="110dp"
+        android:layout_height="50dp"
+        android:layout_gravity="center_vertical"
+        android:background="@drawable/floate_back"
+        android:gravity="center_vertical"
+        android:orientation="horizontal"
+        android:visibility="gone">
+
+        <ImageView
+            android:id="@+id/img_commit_left"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
+            android:layout_marginLeft="10dp"
+            android:src="@drawable/task"/>
+
+        <ImageView
+            android:id="@+id/img_open_left"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
+            android:layout_marginLeft="10dp"
+            android:layout_marginRight="10dp"
+            android:src="@drawable/home"/>
+    </LinearLayout>
+
     <ImageView
-        android:id="@+id/floaticon"
+        android:id="@+id/floate_icon"
         android:layout_width="40dp"
         android:layout_height="50dp"
         android:scaleType="fitCenter"
         android:src="@drawable/sheep"/>
 
     <LinearLayout
-        android:id="@+id/ll_info"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+        android:id="@+id/ll_info_right"
+        android:layout_width="110dp"
+        android:layout_height="50dp"
         android:layout_gravity="center_vertical"
+        android:background="@drawable/floate_back"
+        android:gravity="center_vertical"
         android:orientation="horizontal"
         android:visibility="gone">
 
-        <TextView
-            android:id="@+id/tv_commit"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
+        <ImageView
+            android:id="@+id/img_commit_right"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
             android:layout_marginLeft="10dp"
-            android:text="提交任务"
-            android:textColor="@color/theme"/>
+            android:src="@drawable/task"/>
 
-        <TextView
-            android:id="@+id/tv_open"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
+        <ImageView
+            android:id="@+id/img_open_right"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
             android:layout_marginLeft="10dp"
-            android:text="进入大厅"
-            android:textColor="@color/theme"/>
+            android:layout_marginRight="10dp"
+            android:src="@drawable/home"/>
     </LinearLayout>
 
-
 </LinearLayout>

+ 32 - 0
app/src/main/res/layout/float_window_dialog.xml

@@ -0,0 +1,32 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content">
+
+
+    <LinearLayout
+        android:id="@+id/ll_info"
+        android:layout_width="110dp"
+        android:layout_height="50dp"
+        android:layout_gravity="center_vertical"
+        android:background="@drawable/floate_back"
+        android:gravity="center_vertical"
+        android:orientation="horizontal"
+        android:visibility="visible">
+
+        <ImageView
+            android:id="@+id/img_commit"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
+            android:layout_marginLeft="10dp"
+            android:src="@drawable/task"/>
+
+        <ImageView
+            android:id="@+id/img_open"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
+            android:layout_marginLeft="10dp"
+            android:layout_marginRight="10dp"
+            android:src="@drawable/home"/>
+    </LinearLayout>
+
+</LinearLayout>

+ 24 - 0
app/src/main/res/layout/login_actvity.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@color/theme"
+                android:orientation="vertical">
+
+    <ImageView
+        android:id="@+id/img_login"
+        android:layout_width="50dp"
+        android:layout_height="50dp"
+        android:layout_centerInParent="true"
+        android:src="@drawable/wx_logo"/>
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/img_login"
+        android:layout_centerHorizontal="true"
+        android:text="微信登录"
+        android:textColor="@color/white"
+        android:textSize="16sp"/>
+
+</RelativeLayout>

+ 24 - 20
app/src/main/res/layout/withdraw_activity.xml

@@ -2,41 +2,45 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:layout_width="match_parent"
               android:layout_height="match_parent"
+              android:gravity="center_horizontal"
               android:orientation="vertical">
 
     <include
         layout="@layout/title"/>
 
-    <EditText
-        android:layout_width="wrap_content"
+    <TextView
+        android:paddingLeft="15dp"
+        android:id="@+id/tv_money"
+        android:layout_marginTop="10dp"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:hint="输入提现金额"
-        android:textColor="@color/black_dark"/>
+        android:text="余 额:25.5"
+        android:textColor="@color/black_dark"
+        android:textSize="14sp"/>
 
-    <TextView
-        android:id="@+id/tv_wx"
+    <GridView
+        android:layout_marginTop="10dp"
+        android:id="@+id/gv_money"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginLeft="5dp"
-        android:layout_marginTop="5dp"
-        android:text="提现到微信"
-        android:textColor="@color/black_dark"
-        android:textSize="18sp"/>
+        android:numColumns="3">
+
+    </GridView>
 
     <include
         layout="@layout/line_h_1px"/>
 
     <TextView
-        android:id="@+id/tv_alpay"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:id="@+id/tv_wx"
+        android:layout_width="200dp"
+        android:layout_height="40dp"
         android:layout_marginLeft="5dp"
-        android:layout_marginTop="5dp"
-        android:text="提现到支付宝"
-        android:textColor="@color/black_dark"
-        android:textSize="18sp"/>
+        android:layout_marginTop="15dp"
+        android:background="@drawable/text_backgroud"
+        android:text="提现到微信"
+        android:textColor="@drawable/text_color"
+        android:textSize="16sp"/>
 
-    <include
-        layout="@layout/line_h_1px"/>
 
 </LinearLayout>

+ 18 - 0
app/src/main/res/layout/withdraw_item.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:orientation="vertical">
+
+    <RadioButton
+        android:id="@+id/rb_money"
+        android:layout_width="100dp"
+        android:layout_height="30dp"
+        android:layout_centerInParent="true"
+        android:layout_margin="10dp"
+        android:background="@drawable/text_backgroud"
+        android:button="@null"
+        android:gravity="center"
+        android:textColor="@drawable/text_color"/>
+
+</RelativeLayout>

+ 1 - 1
gradle.properties

@@ -9,7 +9,7 @@
 
 # Specifies the JVM arguments used for the daemon process.
 # The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx1024m
+org.gradle.jvmargs=-Xmx2048m
 
 # When configured, Gradle will run in incubating parallel mode.
 # This option should only be used with decoupled projects. More details, visit

BIN
sign.jks