Sfoglia il codice sorgente

统一获取并保存服务器url配置;发现详情分享功能

zengjiebin 7 anni fa
parent
commit
cbce8b89c2

+ 18 - 48
app/src/main/java/com/kfzs/duanduan/fragment/FgtPersonalCenter.java

@@ -35,6 +35,8 @@ import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 
+import org.afinal.simplecache.ACache;
+
 import butterknife.BindView;
 import butterknife.ButterKnife;
 import butterknife.OnClick;
@@ -116,46 +118,6 @@ public class FgtPersonalCenter extends BaseCompatFragment {
             }
         });
 
-        if (TextUtils.isEmpty(faqUrl))
-            SheepApp.getInstance().getNetComponent().getApiService().getFaqUrl()
-                    .subscribeOn(Schedulers.io())
-                    .observeOn(AndroidSchedulers.mainThread())
-                    .subscribe(new SheepSubscriber<BaseMessage>(getContext()) {
-                        @Override
-                        public void onNext(BaseMessage baseMessage) {
-                            LogUtil.println("baseMessage onNext " + JSON.toJSONString(baseMessage));
-                            Ext ext = baseMessage.getData(Ext.class);
-                            if (ext != null && !TextUtils.isEmpty(ext.getUrl())) {
-                                faqUrl = ext.getUrl();
-                            }
-                        }
-
-                        @Override
-                        public void onError(BaseMessage baseMessage) {
-                            LogUtil.println("baseMessage onError " + JSON.toJSONString(baseMessage));
-                        }
-                    });
-        if (TextUtils.isEmpty(agentUrl))
-            SheepApp.getInstance().getNetComponent().getApiService().getAgentUrl()
-                    .subscribeOn(Schedulers.io())
-                    .observeOn(AndroidSchedulers.mainThread())
-                    .subscribe(new SheepSubscriber<BaseMessage>(getContext()) {
-                        @Override
-                        public void onNext(BaseMessage baseMessage) {
-                            LogUtil.println("baseMessage onNext " + JSON.toJSONString(baseMessage));
-                            Ext ext = baseMessage.getData(Ext.class);
-                            if (ext != null && !TextUtils.isEmpty(ext.getUrl())) {
-                                agentUrl = ext.getUrl();
-                            }
-                        }
-
-                        @Override
-                        public void onError(BaseMessage baseMessage) {
-                            LogUtil.println("baseMessage onError " + JSON.toJSONString(baseMessage));
-                        }
-                    });
-
-
         String appVersonName = ApkUtils.getCurrentPkgVersionName(SheepApp.getInstance());
         version_item_tv.setText("小绵羊V");
         version_item_tv.append(appVersonName);
@@ -232,16 +194,24 @@ public class FgtPersonalCenter extends BaseCompatFragment {
                 Jump2View.getInstance().goTaskList2View(activity, null);
                 break;
             case R.id.proxy_service_layout://代理
-                if (!TextUtils.isEmpty(agentUrl))
-                    Jump2View.getInstance().goWeb(activity, agentUrl, "代理服务");
-                else
-                    G.showToast(R.string.loading_data);
+                Object url_config = ACache.get(activity).getAsObject("url_config");
+                if(url_config instanceof JSONObject) {
+                    agentUrl = ((JSONObject) url_config).getString("agenturl");
+                    if (!TextUtils.isEmpty(agentUrl))
+                        Jump2View.getInstance().goWeb(activity, agentUrl, "代理服务");
+                    else
+                        G.showToast(R.string.loading_data);
+                }
                 break;
             case R.id.faq_layout://FAQ帮助
-                if (!TextUtils.isEmpty(faqUrl))
-                    Jump2View.getInstance().goWeb(activity, faqUrl, "FAQ帮助");
-                else
-                    Jump2View.getInstance().goWeb(activity, "http://smallstation.kfzs.com/h5_faq/#/faq", "FAQ帮助");
+                Object url_config1 = ACache.get(activity).getAsObject("url_config");
+                if(url_config1 instanceof JSONObject) {
+                    faqUrl = ((JSONObject) url_config1).getString("faqurl");
+                    if (!TextUtils.isEmpty(faqUrl))
+                        Jump2View.getInstance().goWeb(activity, faqUrl, "FAQ帮助");
+                    else
+                        Jump2View.getInstance().goWeb(activity, "http://smallstation.kfzs.com/h5_faq/#/faq", "FAQ帮助");
+                }
                 break;
             case R.id.reservation_layout://游戏预约
                 Jump2View.getInstance().goActReservation(activity);

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

@@ -350,7 +350,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
         pagePresenter.homeList();//首页list
 
         //详情分享地址
-        CommonUtil.getInstance().getDetailShareUrl(activity, "task_desc_url");
+        CommonUtil.getInstance().initUrlConfigByNet(activity);
 
     }
 

+ 14 - 0
app/src/main/java/com/kfzs/duanduan/utils/NumberFormatUtils.java

@@ -74,4 +74,18 @@ public class NumberFormatUtils {
         }
         return defaultValue;
     }
+    public static long parseLong(String numStr) {
+        return parseLong(numStr, 0);
+    }
+
+    public static long parseLong(String numStr, int defaultValue) {
+        if(!TextUtils.isEmpty(numStr)){
+            try {
+                return Long.parseLong(numStr);
+            } catch (NumberFormatException e) {
+                e.printStackTrace();
+            }
+        }
+        return defaultValue;
+    }
 }

+ 3 - 18
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -464,16 +464,6 @@ public interface ApiService {
     @GET("app/punch/punch_and_sign_count")
     Observable<BaseMessage> getPunchAndSignCount();
     /**
-     * faq H5地址
-     */
-    @GET("app/url/get_faq")
-    Observable<BaseMessage> getFaqUrl();
-    /**
-     * 代理服务 H5地址
-     */
-    @GET("app/url/get_agent")
-    Observable<BaseMessage> getAgentUrl();
-    /**
      * 获取广告类型 1:开屏广告 2:弹窗广告
      */
     @GET("app/advertising/advertisements")
@@ -530,15 +520,10 @@ public interface ApiService {
     @GET("app/game_consumption/can_user_sheep_amount")
     Observable<BaseMessage> can_user_sheep_amount(@Query("amount") int amount, @Query("game_id") int game_id);
     /**
-     * 代理服务 H5地址
-     * agenturl
-     faqurl
-     dragon_boat_url
-     task_desc_url
-     world_cup_url
+     * url配置
      */
-    @GET("app/url/{name}")
-    Observable<BaseMessage> getNameUrl(@Path("name") String name);
+    @GET("app/url/")
+    Observable<BaseMessage> getNameUrl();
 
     /**
      * 充值订单列表

+ 0 - 33
app/src/main/java/com/sheep/gamegroup/model/entity/UrlConfig.java

@@ -1,33 +0,0 @@
-package com.sheep.gamegroup.model.entity;
-
-import java.io.Serializable;
-
-/**
- * Created by realicing on 2018/7/3.
- * realicing@sina.com
- */
-public class UrlConfig implements Serializable {
-//    agenturl
-//            faqurl
-//    dragon_boat_url
-//            task_desc_url
-//    world_cup_url
-    private String task_desc_url;
-    private String world_cup_url;
-
-    public String getTask_desc_url() {
-        return task_desc_url;
-    }
-
-    public void setTask_desc_url(String task_desc_url) {
-        this.task_desc_url = task_desc_url;
-    }
-
-    public String getWorld_cup_url() {
-        return world_cup_url;
-    }
-
-    public void setWorld_cup_url(String world_cup_url) {
-        this.world_cup_url = world_cup_url;
-    }
-}

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

@@ -27,7 +27,6 @@ import com.kfzs.duanduan.event.EventTypes;
 import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.alipay.PayResult;
 import com.sheep.gamegroup.model.entity.BaseMessage;
-import com.sheep.gamegroup.model.entity.Ext;
 import com.sheep.gamegroup.model.entity.HomeListEntity;
 import com.sheep.gamegroup.model.entity.RequestParameEty;
 import com.sheep.gamegroup.model.entity.TaskChild;
@@ -52,6 +51,7 @@ import com.umeng.socialize.bean.SHARE_MEDIA;
 import com.umeng.socialize.media.UMImage;
 import com.umeng.socialize.media.UMWeb;
 
+import org.afinal.simplecache.ACache;
 import org.greenrobot.eventbus.EventBus;
 
 import java.io.File;
@@ -832,13 +832,19 @@ public class CommonUtil {
     }
 
     /**
-     * 获取详情地址
+     * ACache.get(context).put("url_config", (JSONObject) urlConfig);
+     * JSONObject url_config = (JSONObject)ACache.get(context).get("url_config");
+     * agenturl;//代理
+     * faqurl;//FAQ
+     * world_cup_url;//世界杯
+     * find_share_url;//发现详情分享
+     * task_desc_url;//分享任务详情
      */
-    public void getDetailShareUrl(final Context context, String key){
+    public void initUrlConfigByNet(final Context context){
         SheepApp.get(context)
                 .getNetComponent()
                 .getApiService()
-                .getNameUrl(key)
+                .getNameUrl()
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
@@ -850,15 +856,9 @@ public class CommonUtil {
 
                     @Override
                     public void onNext(BaseMessage baseMessage) {
-
-                        try {
-                            Ext ext = baseMessage.getData(Ext.class);
-                            if (ext != null && !TextUtils.isEmpty(ext.getTask_desc_url())) {
-                                SpUtils.saveTaskDetailsUrl(context, ext.getTask_desc_url());
-                            }
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        }
+                        Object urlConfig = baseMessage.getData();
+                        if(urlConfig instanceof JSONObject)
+                            ACache.get(context).put("url_config", (JSONObject) urlConfig);
                     }
                 });
     }

+ 114 - 0
app/src/main/java/com/sheep/gamegroup/util/TaskHelper.java

@@ -0,0 +1,114 @@
+package com.sheep.gamegroup.util;
+
+import android.app.Activity;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSON;
+import com.kfzs.duanduan.utils.NumberFormatUtils;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
+import com.sheep.gamegroup.model.entity.TaskEty;
+import com.sheep.gamegroup.model.entity.TaskReleaseEty;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.G;
+
+import java.util.Locale;
+
+import rx.android.schedulers.AndroidSchedulers;
+import rx.functions.Action1;
+import rx.schedulers.Schedulers;
+
+/**
+ * Created by realicing on 2018/7/3.
+ * realicing@sina.com
+ */
+public class TaskHelper {
+    private Action1<Integer> action1;
+    public TaskHelper(Action1<Integer> action1){
+        this.action1 = action1;
+    }
+
+    private TaskAcceptedEty taskAcceptedEty;
+    private int release_task_id;
+    private Activity activity;
+    public void initAcceptedTask(Activity activity, final int release_task_id) {
+        this.activity = activity;
+        this.release_task_id = release_task_id;
+        SheepApp.getInstance().getNetComponent().getApiService().getAcceptedTaskDetail(release_task_id)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onNext "+ JSON.toJSONString(baseMessage));
+                        taskAcceptedEty = baseMessage.getData(TaskAcceptedEty.class);
+                        initTask(release_task_id);
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
+                        initTask(release_task_id);
+                    }
+                });
+    }
+    private TaskReleaseEty taskReleaseEty;
+    private void initTask(int release_task_id) {
+        SheepApp.getInstance().getNetComponent().getApiService().taskDesc(release_task_id)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onNext "+JSON.toJSONString(baseMessage));
+                        taskReleaseEty = baseMessage.getData(TaskReleaseEty.class);
+                        if(action1 != null)
+                            action1.call(1);//刷新界面
+
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
+                    }
+                });
+    }
+
+    public boolean hasTask() {
+        return taskReleaseEty != null && taskReleaseEty.getTask() != null;
+    }
+
+    public void loadTask(View itemView) {
+        itemView.setVisibility(View.VISIBLE);
+        final TaskEty taskEty = taskReleaseEty.getTask();
+        ImageView find_information_game_icon = (ImageView)itemView.findViewById(R.id.find_information_game_icon);
+        TextView find_information_game_name = (TextView)itemView.findViewById(R.id.find_information_game_name);
+        TextView find_information_game_surplus = (TextView)itemView.findViewById(R.id.find_information_game_surplus);
+        TextView find_information_game_time = (TextView)itemView.findViewById(R.id.find_information_game_time);
+        TextView find_information_game_yuan = (TextView)itemView.findViewById(R.id.find_information_game_yuan);
+        TextView find_information_game_task = (TextView)itemView.findViewById(R.id.find_information_game_task);
+        ViewUtil.setImage(find_information_game_icon, taskEty.getIcon());
+        ViewUtil.setText(find_information_game_name, taskEty.getName());
+        ViewUtil.setText(find_information_game_surplus, String.format(Locale.CHINA, "剩余%s份", taskReleaseEty.getLast_num()));
+        ViewUtil.setText(find_information_game_time, String.format(Locale.CHINA, "截止日期:%s", TimeUtil.TimeStamp2Date(NumberFormatUtils.parseLong(taskReleaseEty.getDeadline()), "yyyy/MM/dd\tHH:mm")));
+        ViewUtil.setText(find_information_game_yuan, String.format(Locale.CHINA, "+%s元", taskReleaseEty.getBonus()));
+        find_information_game_yuan.setVisibility(View.VISIBLE);
+        find_information_game_task.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                G.showToast("点击接受任务");
+            }
+        });
+
+        itemView.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                Jump2View.getInstance().goTaskDetailView(activity, release_task_id);
+            }
+        });
+    }
+}

+ 21 - 33
app/src/main/java/com/sheep/gamegroup/util/TestUtil.java

@@ -21,7 +21,6 @@ import com.kfzs.duanduan.view.DialogStorageLow;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.CreditCard;
 import com.sheep.gamegroup.model.entity.DialogConfig;
-import com.sheep.gamegroup.model.entity.Ext;
 import com.sheep.gamegroup.model.entity.LoginEntity;
 import com.sheep.gamegroup.model.entity.LoginUser;
 import com.sheep.gamegroup.model.entity.TaskEty;
@@ -30,7 +29,6 @@ import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.usage.AppUsageManager;
 import com.sheep.gamegroup.view.activity.ActInstallApkList;
 import com.sheep.gamegroup.view.activity.ActWeb;
-import com.sheep.gamegroup.view.activity.RealNameAuthenAct;
 import com.sheep.gamegroup.view.dialog.DialogNewbieTaskList;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.R;
@@ -42,6 +40,8 @@ import com.umeng.socialize.UMShareListener;
 import com.umeng.socialize.bean.SHARE_MEDIA;
 import com.umeng.socialize.media.UMImage;
 
+import org.afinal.simplecache.ACache;
+
 import java.io.File;
 import java.util.List;
 import java.util.Locale;
@@ -394,37 +394,25 @@ public class TestUtil {
 
 
     private static void copyUrl(final String name) {
-        SheepApp.getInstance().getNetComponent().getApiService().getNameUrl(name)
-                        .subscribeOn(Schedulers.io())
-                        .observeOn(AndroidSchedulers.mainThread())
-                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                            @Override
-                            public void onNext(BaseMessage baseMessage) {
-                                LogUtil.println("baseMessage onNext "+JSON.toJSONString(baseMessage));
-                                Ext ext = baseMessage.getData(Ext.class);
-                                if (ext == null){
-                                    G.showToast("data数据为null");
-                                } else if(TextUtils.isEmpty(ext.getUrl())) {
-                                    JSONObject data  = JSONObject.parseObject(baseMessage.getData().toString());
-                                    if(data.containsKey(name)){
-                                        String url = data.getString(name);
-                                        if(!TextUtils.isEmpty(url)) {
-                                            StringUtils.CopyText(SheepApp.getInstance(), ActWeb.addUrlToken(url));
-                                            return;
-                                        }
-                                    }
-                                    G.showToast("data格式不正确");
-                                } else {
-                                    StringUtils.CopyText(SheepApp.getInstance(), ActWeb.addUrlToken(ext.getUrl()));
-                                }
-                            }
-
-                            @Override
-                            public void onError(BaseMessage baseMessage) {
-                                LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
-                                G.showToast(baseMessage);
-                            }
-                        });
+        Object url_config1 = ACache.get(SheepApp.getInstance()).getAsObject("url_config");
+        if(url_config1 instanceof JSONObject) {
+            String url;
+            switch (name){
+                case "faqurl":
+                    url = ((JSONObject) url_config1).getString("faqurl");
+                    break;
+                case "agenturl":
+                    url = ((JSONObject) url_config1).getString("agenturl");
+                    break;
+                case "world_cup_url":
+                    url = ((JSONObject) url_config1).getString("world_cup_url");
+                    break;
+                default:
+                    url = ((JSONObject) url_config1).getString("find_share_url");
+                    break;
+            }
+            StringUtils.CopyText(SheepApp.getInstance(), ActWeb.addUrlToken(url));
+        }
     }
 
     private static void showHasInstallApkList(Activity activity) {

+ 18 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/ActFindGame.java

@@ -47,8 +47,10 @@ import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
+import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
+import org.afinal.simplecache.ACache;
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 
@@ -87,7 +89,22 @@ public class ActFindGame extends BaseActivity {
         id = getIntent().getIntExtra("id", 0);
         TitleBarUtils.getInstance()
                 .setTitle(this,"加载中")
-                .setTitleFinish(this);
+                .setTitleFinish(this)
+                .setRightImgBotton(this, R.mipmap.share, new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+                        try{
+                            Object url_config1 = ACache.get(SheepApp.getInstance()).getAsObject("url_config");
+                            if(url_config1 instanceof JSONObject) {
+                                String find_share_url = ((JSONObject) url_config1).getString("find_share_url");
+                                String url = String.format(Locale.CHINA, "%s?authorization=%s&find_id=%d", find_share_url, SpUtils.getOpenId(ActFindGame.this), id);
+                                CommonUtil.getInstance().popShare(ActFindGame.this, url, "all");
+                            }
+                        }catch (Exception e){
+                            e.printStackTrace();
+                        }
+                    }
+                });
 
         EventBus.getDefault().register(this);
         Aria.download(this).register();

+ 26 - 77
app/src/main/java/com/sheep/gamegroup/view/activity/ActFindInformation.java

@@ -13,6 +13,7 @@ import android.widget.ImageView;
 import android.widget.TextView;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.arialyy.annotations.Download;
 import com.arialyy.aria.core.Aria;
 import com.arialyy.aria.core.download.DownloadTask;
@@ -21,6 +22,7 @@ import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.FindApp;
 import com.sheep.gamegroup.model.entity.FindItem;
+import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
 import com.sheep.gamegroup.model.entity.TaskEty;
 import com.sheep.gamegroup.model.entity.TaskReleaseEty;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
@@ -28,8 +30,9 @@ import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.LogUtil;
-import com.sheep.gamegroup.util.MyDbManager;
+import com.sheep.gamegroup.util.StringUtils;
 import com.sheep.gamegroup.util.SysAppUtil;
+import com.sheep.gamegroup.util.TaskHelper;
 import com.sheep.gamegroup.util.TimeUtil;
 import com.sheep.gamegroup.util.ViewHolder;
 import com.sheep.gamegroup.util.ViewUtil;
@@ -41,6 +44,7 @@ import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
+import org.afinal.simplecache.ACache;
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 
@@ -61,7 +65,7 @@ import static android.content.Intent.ACTION_PACKAGE_REMOVED;
  * Created by realicing on 2018/5/10.
  * realicing@sina.com
  */
-public class ActFindInformation extends BaseActivity {
+public class ActFindInformation extends BaseActivity implements Action1<Integer>{
     @Override
     protected int getLayoutId() {
         return R.layout.net_empty_fresh_list;
@@ -89,8 +93,12 @@ public class ActFindInformation extends BaseActivity {
                     @Override
                     public void onClick(View view) {
                         try{
-                            String url = String.format(Locale.CHINA, "%s?authorization=%s&find_id=%d", "地址", SpUtils.getOpenId(ActFindInformation.this), id);
-                            CommonUtil.getInstance().popShare(ActFindInformation.this, url, "all");
+                            Object url_config1 = ACache.get(SheepApp.getInstance()).getAsObject("url_config");
+                            if(url_config1 instanceof JSONObject) {
+                                String find_share_url = ((JSONObject) url_config1).getString("find_share_url");
+                                String url = String.format(Locale.CHINA, "%s?authorization=%s&find_id=%d", find_share_url, SpUtils.getOpenId(ActFindInformation.this), id);
+                                CommonUtil.getInstance().popShare(ActFindInformation.this, url, "all");
+                            }
                         }catch (Exception e){
                             e.printStackTrace();
                         }
@@ -152,13 +160,14 @@ public class ActFindInformation extends BaseActivity {
         ViewUtil.loadDataWithBaseURL(find_information_content_wb, findItem.getContent());
 
     }
+    private TaskHelper taskHelper = new TaskHelper(this);
     private void loadBottom(ViewGroup viewGroup) {
-        if(taskReleaseEty != null && taskReleaseEty.getTask() != null) {
-            loadTask(viewGroup.getChildAt(0));
+        if(taskHelper.hasTask()) {
+            taskHelper.loadTask(viewGroup.getChildAt(0));
         } else {
             viewGroup.getChildAt(0).setVisibility(View.GONE);
         }
-        viewGroup.getChildAt(1).setVisibility(taskReleaseEty != null && taskReleaseEty.getTask() != null && findApp != null ? View.VISIBLE : View.GONE);
+        viewGroup.getChildAt(1).setVisibility(taskHelper.hasTask() && findApp != null ? View.VISIBLE : View.GONE);
         if(findApp != null) {
             loadGame(viewGroup.getChildAt(2));
         } else {
@@ -166,35 +175,6 @@ public class ActFindInformation extends BaseActivity {
         }
     }
 
-    private void loadTask(View itemView) {
-        itemView.setVisibility(View.VISIBLE);
-        final TaskEty taskEty = taskReleaseEty.getTask();
-        ImageView find_information_game_icon = (ImageView)itemView.findViewById(R.id.find_information_game_icon);
-        TextView find_information_game_name = (TextView)itemView.findViewById(R.id.find_information_game_name);
-        TextView find_information_game_surplus = (TextView)itemView.findViewById(R.id.find_information_game_surplus);
-        TextView find_information_game_time = (TextView)itemView.findViewById(R.id.find_information_game_time);
-        TextView find_information_game_yuan = (TextView)itemView.findViewById(R.id.find_information_game_yuan);
-        TextView find_information_game_task = (TextView)itemView.findViewById(R.id.find_information_game_task);
-        ViewUtil.setImage(find_information_game_icon, taskEty.getIcon());
-        ViewUtil.setText(find_information_game_name, taskEty.getName());
-        ViewUtil.setText(find_information_game_surplus, String.format(Locale.CHINA, "剩余%s份", taskReleaseEty.getLast_num()));
-        ViewUtil.setText(find_information_game_time, String.format(Locale.CHINA, "截止日期:%s", TimeUtil.TimeStamp2Date(findItem.getCreated_at(), "yyyy/MM/dd\tHH:mm")));
-        ViewUtil.setText(find_information_game_yuan, String.format(Locale.CHINA, "+%s元", taskReleaseEty.getBonus()));
-        find_information_game_yuan.setVisibility(View.VISIBLE);
-        find_information_game_task.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                G.showToast("点击接受任务");
-            }
-        });
-
-        itemView.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                Jump2View.getInstance().goTaskDetailView(ActFindInformation.this, findItem.getRelease_task_id());
-            }
-        });
-    }
     private void loadGame(View itemView) {
         itemView.setVisibility(View.VISIBLE);
         ImageView find_information_game_icon = (ImageView)itemView.findViewById(R.id.find_information_game_icon);
@@ -259,8 +239,7 @@ public class ActFindInformation extends BaseActivity {
                                     list.add("bottom");
                                     notifyDataSetChanged();
                                     if(findItem.getRelease_task_id() != 0){//包含任务
-                                        initTask(findItem.getRelease_task_id());
-//                                        initAcceptedTask(findItem.getRelease_task_id());
+                                        taskHelper.initAcceptedTask(ActFindInformation.this, findItem.getRelease_task_id());
                                     }
                                     if(findItem.getApplication_id() != 0){//包含游戏
                                         initFindApp(findItem.getApplication_id());
@@ -296,45 +275,6 @@ public class ActFindInformation extends BaseActivity {
                             }
                         });
     }
-//    private TaskAcceptedEty taskAcceptedEty;
-//    private void initAcceptedTask(final int release_task_id) {
-//        SheepApp.getInstance().getNetComponent().getApiService().getAcceptedTaskDetail(release_task_id)
-//                        .subscribeOn(Schedulers.io())
-//                        .observeOn(AndroidSchedulers.mainThread())
-//                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-//                            @Override
-//                            public void onNext(BaseMessage baseMessage) {
-//                                LogUtil.println("baseMessage onNext "+JSON.toJSONString(baseMessage));
-//                                taskAcceptedEty = baseMessage.getData(TaskAcceptedEty.class);
-//                                initTask(release_task_id);
-//                            }
-//
-//                            @Override
-//                            public void onError(BaseMessage baseMessage) {
-//                                LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
-//                            }
-//                        });
-//    }
-    private TaskReleaseEty taskReleaseEty;
-    private void initTask(int release_task_id) {
-        SheepApp.getInstance().getNetComponent().getApiService().taskDesc(release_task_id)
-                        .subscribeOn(Schedulers.io())
-                        .observeOn(AndroidSchedulers.mainThread())
-                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                            @Override
-                            public void onNext(BaseMessage baseMessage) {
-                                LogUtil.println("baseMessage onNext "+JSON.toJSONString(baseMessage));
-                                taskReleaseEty = baseMessage.getData(TaskReleaseEty.class);
-                                notifyDataSetChanged();
-
-                            }
-
-                            @Override
-                            public void onError(BaseMessage baseMessage) {
-                                LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
-                            }
-                        });
-    }
 
     private FindItem findItem;
 
@@ -473,4 +413,13 @@ public class ActFindInformation extends BaseActivity {
         super.onDestroy();
         EventBus.getDefault().unregister(this);
     }
+
+    @Override
+    public void call(Integer integer) {
+        switch (integer){
+            case 1://刷新界面
+                notifyDataSetChanged();
+                break;
+        }
+    }
 }

+ 7 - 7
app/src/main/java/com/sheep/gamegroup/view/activity/TaskDetailAct.java

@@ -71,6 +71,7 @@ import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
+import org.afinal.simplecache.ACache;
 import org.greenrobot.eventbus.EventBus;
 
 import java.util.ArrayList;
@@ -588,13 +589,12 @@ public class TaskDetailAct extends AbsChooseImageActivity implements TaskDetailC
                     break;
                 case R.id.detail_share_friend_tv:
                     try{
-                        StringBuffer stringBuffer = new StringBuffer();
-                        stringBuffer.append(SpUtils.getTaskDetailsUrl(activity)+"?");
-                        stringBuffer.append("authorization="+ SpUtils.getOpenId(activity));
-                        stringBuffer.append("&task_id="+taskId);
-                        stringBuffer.append("&invitation_code="+MyDbManager.getInstance().dbFindValue());
-                        CommonUtil.getInstance()
-                                .popShare(activity, stringBuffer.toString() +"", "all");
+                       Object url_config = ACache.get(activity).getAsObject("url_config");
+                        if(url_config instanceof JSONObject) {
+                            String url = String.format(Locale.CHINA, "%s?authorization==%s&task_id=%d&invitation_code=%s",
+                                    ((JSONObject) url_config).getString("task_desc_url"),SpUtils.getOpenId(activity),taskId,MyDbManager.getInstance().dbFindValue());
+                            CommonUtil.getInstance().popShare(activity, url, "all");
+                        }
                     }catch (Exception e){
                         e.printStackTrace();
                     }

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

@@ -6,14 +6,11 @@ import android.os.Bundle;
 import android.support.multidex.MultiDex;
 import android.util.DisplayMetrics;
 
-import com.alibaba.fastjson.JSON;
 import com.kfzs.duanduan.ActMain;
 import com.kfzs.duanduan.react.SharedPreferences;
 import com.sheep.gamegroup.di.components.DaggerNetComponent;
 import com.sheep.gamegroup.di.components.NetComponent;
 import com.sheep.gamegroup.di.modules.NetModule;
-import com.sheep.gamegroup.model.entity.UrlConfig;
-import com.sheep.gamegroup.model.util.AutoTaskListUtil;
 import com.sheep.gamegroup.util.ActivityManager;
 import com.sheep.gamegroup.util.AppUtil;
 import com.sheep.gamegroup.util.ConnectAddress;
@@ -27,9 +24,6 @@ import com.sheep.gamegroup.view.activity.SplashAct;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.tencent.bugly.Bugly;
-import com.tencent.bugly.beta.Beta;
-
-import org.afinal.simplecache.ACache;
 
 import rx.functions.Action1;
 
@@ -97,14 +91,6 @@ public class SheepApp extends BaseApplication {
             initNet();
 //            Beta.autoCheckUpgrade = false;
             Bugly.init(getApplicationContext(), Config.BUGLY_APPID, BuildConfig.DEBUG);
-            if(BuildConfig.DEBUG) {
-                UrlConfig urlConfig = new UrlConfig();
-                urlConfig.setTask_desc_url("1111111111111111");
-                urlConfig.setTask_desc_url("1111111111111111");
-                ACache.get(this).put(UrlConfig.class.getSimpleName(), urlConfig);
-                UrlConfig newUrlConfig = (UrlConfig) ACache.get(this).getAsObject(UrlConfig.class.getSimpleName());
-                LogUtil.println("test", "urlConfig", JSON.toJSON(urlConfig), JSON.toJSON(newUrlConfig));
-            }
         }
     }
 

+ 0 - 17
app/src/main/java/com/sheep/jiuyan/samllsheep/utils/SpUtils.java

@@ -156,23 +156,6 @@ public class SpUtils {
         SharedPreferences user = context.getSharedPreferences("save_deviced_id", Context.MODE_PRIVATE);
         return user.getString("device_id", "");
     }
-    /**
-     * 储存详情分享地址
-     * @param context
-     * @param vaule
-     */
-    public static void saveTaskDetailsUrl(Context context, String vaule) {
-        SharedPreferences user = context.getSharedPreferences("save_taskdetail_url", Context.MODE_PRIVATE);
-        SharedPreferences.Editor editor = user.edit();
-        editor.putString("taskdetail_url", vaule);
-        editor.apply();
-    }
-
-
-    public static String getTaskDetailsUrl(Context context) {
-        SharedPreferences user = context.getSharedPreferences("save_taskdetail_url", Context.MODE_PRIVATE);
-        return user.getString("taskdetail_url", "");
-    }
 
 
     /**

+ 2 - 2
app/src/main/java/com/sheep/jiuyan/samllsheep/utils/TitleBarUtils.java

@@ -152,8 +152,8 @@ public class TitleBarUtils {
     public void setRightImgBotton(Activity activity, int backgroundImgResId, View.OnClickListener onClickListener) {
         Button button = activity.findViewById(R.id.btn_baseactivity_right);
         ImageButton imageButton = activity.findViewById(R.id.ibtn_baseactivity_right);
-
-        button.setVisibility(View.GONE);
+        if(button != null)
+            button.setVisibility(View.GONE);
         imageButton.setVisibility(View.VISIBLE);
         if (backgroundImgResId == 0) {
             imageButton.setImageDrawable(new ColorDrawable(0x00000000));

+ 11 - 2
app/src/main/res/layout/act_find_game.xml

@@ -79,8 +79,7 @@
                     android:id="@+id/find_game_down_tv"
                     style="@style/style_button_wrap"
                     android:layout_marginTop="8dp"
-                    android:paddingEnd="40dp"
-                    android:paddingStart="40dp"
+                    android:layout_width="@dimen/find_bt_with"
                     android:text="下载" />
             </LinearLayout>
 
@@ -448,5 +447,15 @@
             android:textColor="@color/black_text_deep"
             android:textSize="@dimen/text_size_4"
             android:visibility="invisible" />
+        <!--右边图片按钮-->
+        <ImageButton
+            android:id="@+id/ibtn_baseactivity_right"
+            android:layout_width="?attr/actionBarSize"
+            android:layout_height="match_parent"
+            android:layout_alignParentEnd="true"
+            android:layout_centerVertical="true"
+            android:background="@color/translate"
+            android:gravity="center"
+            android:minWidth="?attr/actionBarSize"/>
     </RelativeLayout>
 </RelativeLayout>

+ 1 - 0
app/src/main/res/layout/find_information_bottom_item.xml

@@ -62,6 +62,7 @@
     <TextView
         android:id="@+id/find_information_game_task"
         style="@style/style_button_wrap"
+        android:layout_width="@dimen/find_bt_with"
         android:text="接受任务"
         app:layout_constraintBottom_toBottomOf="@+id/find_information_game_icon"
         app:layout_constraintEnd_toEndOf="parent"

+ 1 - 0
app/src/main/res/layout/find_item.xml

@@ -75,6 +75,7 @@
         <TextView
             android:id="@+id/find_item_download"
             style="@style/style_button_wrap"
+            android:layout_width="@dimen/find_bt_with"
             android:layout_alignParentEnd="true"
             android:layout_centerVertical="true"
             android:text="下载游戏" />

+ 2 - 0
app/src/main/res/layout/find_reservation_item.xml

@@ -40,6 +40,7 @@
     <TextView
         android:id="@+id/find_information_game_bt1"
         style="@style/style_button_wrap"
+        android:layout_width="@dimen/find_bt_with"
         android:text="立即下载"
         app:layout_constraintBottom_toTopOf="@+id/find_information_game_bt2"
         app:layout_constraintEnd_toEndOf="@+id/find_information_game_bt2"
@@ -48,6 +49,7 @@
     <TextView
         android:id="@+id/find_information_game_bt2"
         style="@style/style_button_wrap2"
+        android:layout_width="100dp"
         android:text="立即预约"
         app:layout_constraintBottom_toBottomOf="@+id/find_information_game_icon"
         app:layout_constraintEnd_toEndOf="parent"

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

@@ -87,4 +87,6 @@
 
     <dimen name="orienteering_item_gao">40dp</dimen>
     <dimen name="orienteering_list_empty_gao">240dp</dimen>
+
+    <dimen name="find_bt_with">100dp</dimen>
 </resources>