Sfoglia il codice sorgente

幂动 初始化 修改、加uid、ui 优化

liujiangyao 7 anni fa
parent
commit
0f3c30fab5

+ 0 - 6
app/src/main/java/com/kfzs/duanduan/ActMain.java

@@ -69,12 +69,6 @@ public class ActMain extends BaseActivity {
         mImgDot = findViewById(R.id.img_download_manager_dot);
         tabsHelper.init();
 
-
-        /**
-         * 幂动科技
-         *  appId为应用id,开发者可联系后台获取
-         */
-        AdManager.getInstance(this).init(this, "40");
     }
 
     @Override

+ 51 - 26
app/src/main/java/com/kfzs/duanduan/fragment/FgtMiDong.java

@@ -2,6 +2,7 @@ package com.kfzs.duanduan.fragment;
 
 import android.app.Activity;
 import android.os.Bundle;
+import android.os.Handler;
 import android.support.annotation.Nullable;
 import android.support.v4.widget.SwipeRefreshLayout;
 import android.support.v7.widget.LinearLayoutManager;
@@ -16,6 +17,7 @@ import com.mdad.sdk.mdsdk.AdManager;
 import com.mdad.sdk.mdsdk.GetAdListListener;
 import com.mdad.sdk.mdsdk.RewardListener;
 import com.mdad.sdk.mdsdk.common.AdData;
+import com.sheep.gamegroup.model.entity.AdDataSon;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.GameAgencyRechargePlatformEntity;
 import com.sheep.gamegroup.model.entity.RecyleObj;
@@ -29,6 +31,7 @@ import com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.utils.G;
 
+import java.util.Collection;
 import java.util.List;
 
 import butterknife.BindView;
@@ -56,9 +59,9 @@ public class FgtMiDong extends BaseCompatFragment {
     private AdListAdapter adListAdapter;
     private int pageNo = 1;
     private int pageSize = 30;
-    private List<AdData> listData = ListUtil.emptyList();
+    private List<AdDataSon> listData = ListUtil.emptyList();
 
-    public static FgtMiDong newInstance(int type){
+    public static FgtMiDong newInstance(int type) {
         FgtMiDong fgtMiDong = new FgtMiDong();
         Bundle bundle = new Bundle();
         bundle.putInt("type", type);
@@ -70,7 +73,7 @@ public class FgtMiDong extends BaseCompatFragment {
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         Bundle bundle = getArguments();
-        if(bundle != null){
+        if (bundle != null) {
             type = bundle.getInt("type", 0);
         }
     }
@@ -83,7 +86,8 @@ public class FgtMiDong extends BaseCompatFragment {
         initView();
         initData(false);
     }
-    private void initView(){
+
+    private void initView() {
         title.setVisibility(View.GONE);
         refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
             @Override
@@ -119,24 +123,34 @@ public class FgtMiDong extends BaseCompatFragment {
         initListen();
     }
 
-    private void initData(boolean isRefresh){
+    private void initData(final boolean isRefresh) {
         empty_view.setVisibility(View.INVISIBLE);
         SysAppUtil.checkNet(new Action1<Integer>() {
             @Override
             public void call(Integer result) {
-                if(result != 0){//无网络
-                    if(check_net_ll != null)
+                if (result != 0) {//无网络
+                    if (check_net_ll != null)
                         check_net_ll.setVisibility(View.VISIBLE);
                 } else {
-                    if(check_net_ll != null)
+                    if (check_net_ll != null)
                         check_net_ll.setVisibility(View.GONE);
                 }
             }
         });
-        loadData(false, isRefresh);
+        try{
+            loadData(false, isRefresh);
+        }catch (Exception e){
+            e.printStackTrace();
+            new Handler().postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    loadData(false, isRefresh);
+                }
+            }, 500);
+        }
     }
 
-    private void notifyDataSetChanged(){
+    private void notifyDataSetChanged() {
         CommonUtil.getInstance().updateEmptyView(empty_view, listData.isEmpty());
         refresh.setRefreshing(false);
         adListAdapter.notifyDataSetChanged();
@@ -150,15 +164,21 @@ public class FgtMiDong extends BaseCompatFragment {
             pageNo++;
         else
             pageNo = 1;
-        if(type == 0){
+        if (type == 0) {
             AdManager.getInstance(activity).getAdListAsync(activity, new GetAdListListener() {
                 @Override
                 public void onLoadAdSuccess(List<AdData> list) {
                     refresh.setRefreshing(false);
                     if (list != null) {
-                        if(pageNo == 1)
+                        if (pageNo == 1)
                             listData.clear();
-                        listData.addAll(list);
+
+                        for (AdData adData : list) {
+                            AdDataSon adDataSon = new AdDataSon();
+                            adDataSon.setAdData(adData);
+                            listData.add(adDataSon);
+                        }
+//                        listData.addAll((Collection<? extends AdDataSon>) list);
                         adListAdapter.setData(listData);
                     }
                     notifyDataSetChanged();
@@ -167,21 +187,21 @@ public class FgtMiDong extends BaseCompatFragment {
                 @Override
                 public void onLoadAdFailure() {
                     refresh.setRefreshing(false);
-                    if(isRefresh)
+                    if (isRefresh)
                         G.showToast(activity, "网络异常,请稍后再试", Toast.LENGTH_SHORT);
                     notifyDataSetChanged();
                 }
 
                 @Override
                 public void onAdEmpty() {
-                    if(isRefresh)
+                    if (isRefresh)
                         G.showToast(activity, "暂无数据", Toast.LENGTH_SHORT);
                     notifyDataSetChanged();
 
                 }
             }, pageNo, pageSize);
 
-        }else {
+        } else {
             /**
              * 异步获取签到任务,回调是在主线程,可以直接更新UI,加载更多的逻辑只需更新pageNo和pageSize即可。
              */
@@ -190,12 +210,16 @@ public class FgtMiDong extends BaseCompatFragment {
                 public void onLoadAdSuccess(List<AdData> list) {
                     refresh.setRefreshing(false);
                     if (list != null && list.size() > 0) {
-                        if(pageNo == 1)
+                        if (pageNo == 1)
                             listData.clear();
-                        listData.addAll(list);
+                        for (AdData adData : list) {
+                            AdDataSon adDataSon = new AdDataSon();
+                            adDataSon.setAdData(adData);
+                            listData.add(adDataSon);
+                        }
                         adListAdapter.setData(listData);
                     } else {
-                        if(isRefresh)
+                        if (isRefresh)
                             G.showToast(activity, "暂无数据", Toast.LENGTH_SHORT);
                     }
                     notifyDataSetChanged();
@@ -204,7 +228,7 @@ public class FgtMiDong extends BaseCompatFragment {
                 @Override
                 public void onLoadAdFailure() {
                     refresh.setRefreshing(false);
-                    if(isRefresh)
+                    if (isRefresh)
                         G.showToast(activity, "网络异常,请稍后再试", Toast.LENGTH_SHORT);
                     notifyDataSetChanged();
                 }
@@ -212,7 +236,7 @@ public class FgtMiDong extends BaseCompatFragment {
                 @Override
                 public void onAdEmpty() {
                     refresh.setRefreshing(false);
-                    if(isRefresh)
+                    if (isRefresh)
                         G.showToast(activity, "暂无数据", Toast.LENGTH_SHORT);
                     notifyDataSetChanged();
 
@@ -222,15 +246,15 @@ public class FgtMiDong extends BaseCompatFragment {
 
     }
 
-    private void initListen(){
+    private void initListen() {
         recyclerview.addOnScrollListener(new RecyclerView.OnScrollListener() {
             @Override
             public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                 super.onScrollStateChanged(recyclerView, newState);
-                if(newState == RecyclerView.SCROLL_STATE_IDLE){//滑动到了底部
-                    if(listData.size() >= pageNo*pageSize){
+                if (newState == RecyclerView.SCROLL_STATE_IDLE) {//滑动到了底部
+                    if (listData.size() >= pageNo * pageSize) {
                         loadData(true, false);
-                    }else {
+                    } else {
 //                        G.showToast("没有更多数据了");
                     }
 
@@ -238,11 +262,12 @@ public class FgtMiDong extends BaseCompatFragment {
             }
         });
     }
+
     /**
      * 刷新数据
      */
     public void refreshData() {
-        if(adListAdapter != null)
+        if (adListAdapter != null)
             adListAdapter.notifyDataSetChanged();
     }
 }

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

@@ -33,6 +33,7 @@ import com.kfzs.duanduan.event.BigEvent;
 import com.kfzs.duanduan.react.ReactUtil;
 import com.kfzs.duanduan.react.SharedPreferences;
 import com.kfzs.duanduan.utils.NumberFormatUtils;
+import com.mdad.sdk.mdsdk.AdManager;
 import com.sheep.gamegroup.di.components.DaggerSmallSheepComponent;
 import com.sheep.gamegroup.di.modules.SmallSheepModule;
 import com.sheep.gamegroup.di.modules.TryMakeMoneyModule;
@@ -548,6 +549,10 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
         if(userEntity == null){
             return;
         }
+
+        //幂动科技
+        CommonUtil.getInstance().initMiDong(activity, userEntity.getId());
+
         //保存用户id信息
         PreferenceUtils.setPrefString(SheepApp.mContext, UMConfigUtils.LOGIN_OPENID, userEntity.getOpen_id());
         //保存用户邀请人邀请码

+ 30 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/AdDataSon.java

@@ -0,0 +1,30 @@
+package com.sheep.gamegroup.model.entity;
+
+import com.mdad.sdk.mdsdk.common.AdData;
+
+import java.io.Serializable;
+
+/**
+ * Created by ljy on 2018/7/26.
+ */
+
+public class AdDataSon implements Serializable{
+    private boolean select;
+    private AdData adData;
+
+    public AdData getAdData() {
+        return adData;
+    }
+
+    public void setAdData(AdData adData) {
+        this.adData = adData;
+    }
+
+    public boolean isSelect() {
+        return select;
+    }
+
+    public void setSelect(boolean select) {
+        this.select = select;
+    }
+}

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

@@ -28,6 +28,7 @@ import com.kfzs.duanduan.datashare.provider.download.DownLoadInfo;
 import com.kfzs.duanduan.event.BigEvent;
 import com.kfzs.duanduan.event.EventTypes;
 import com.kfzs.duanduan.utils.NumberFormatUtils;
+import com.mdad.sdk.mdsdk.AdManager;
 import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.alipay.PayResult;
 import com.sheep.gamegroup.model.api.BaseMessageConverter;
@@ -1508,4 +1509,16 @@ public class CommonUtil {
             empty_view.setVisibility(View.GONE);
         }
     }
+
+    /**
+     * 幂动科技
+     *  appId为应用id,开发者可联系后台获取
+     *  id 用户uid
+     */
+    public void initMiDong(Activity activity, String id){
+        if(!PreferenceUtils.getPrefBoolean(activity, "init_midong_key", false)){
+            PreferenceUtils.setPrefBoolean(activity, "init_midong_key", true);
+            AdManager.getInstance(activity).init(activity, "40",id+"");
+        }
+    }
 }

+ 16 - 12
app/src/main/java/com/sheep/gamegroup/view/adapter/AdListAdapter.java

@@ -15,6 +15,7 @@ import android.widget.TextView;
 import com.bumptech.glide.Glide;
 import com.mdad.sdk.mdsdk.AdManager;
 import com.mdad.sdk.mdsdk.common.AdData;
+import com.sheep.gamegroup.model.entity.AdDataSon;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 
@@ -31,7 +32,7 @@ import java.util.Locale;
 public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder> {
 
     private boolean isSign = false;
-    private List<AdData> mList;
+    private List<AdDataSon> mList;
     private Context mContext;
     private final int TYPE_APP_LAYOUT = 0;
     private final int TYPE_FOOTER_LAYOUT = 1;//底部加载更多动画样式
@@ -45,14 +46,14 @@ public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapte
     //加载完成
     public static final int LOADING_FINISH = 2;
 
-    public AdListAdapter(Context context, List<AdData> list) {
+    public AdListAdapter(Context context, List<AdDataSon> list) {
         this.mContext = context;
         this.mList = new ArrayList<>();
         if (list != null)
             mList.addAll(list);
     }
 
-    public AdListAdapter(Context context, List<AdData> list, boolean isSign) {
+    public AdListAdapter(Context context, List<AdDataSon> list, boolean isSign) {
         this.mContext = context;
         this.mList = new ArrayList<>();
         if (list != null)
@@ -60,7 +61,7 @@ public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapte
         this.isSign = isSign;
     }
 
-    public void setData(List<AdData> list) {
+    public void setData(List<AdDataSon> list) {
         mList.clear();
         if (list != null)
             mList.addAll(list);
@@ -70,8 +71,8 @@ public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapte
         int pos = -1;
         if (mList != null && mList.size() > 0) {
             for (int i = 0; i < mList.size(); i++) {
-                AdData data = mList.get(i);
-                if (data.getId().equals(id)) {
+                AdDataSon data = mList.get(i);
+                if (data.getAdData().getId().equals(id)) {
                     pos = i;
                     break;
                 }
@@ -83,7 +84,7 @@ public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapte
         }
     }
 
-    public void addData(List<AdData> list) {
+    public void addData(List<AdDataSon> list) {
         if (list != null)
             mList.addAll(list);
     }
@@ -104,14 +105,14 @@ public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapte
     }
 
     @Override
-    public void onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder holder, int position) {
+    public void onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder holder, final int position) {
         if (holder instanceof FootViewHolder) {
             FootViewHolder footViewHolder = (FootViewHolder) holder;
             footViewHolder.foot_view_item_tv.setText("");
         } else if (holder instanceof AppViewHolder) {
-            AppViewHolder appViewHolder = (AppViewHolder) holder;
+            final AppViewHolder appViewHolder = (AppViewHolder) holder;
             if (mList != null && mList.size() > 0) {
-                final AdData data = mList.get(position);
+                final AdData data = mList.get(position).getAdData();
                 if (data != null) {
                     appViewHolder.mTitleTv.setText(data.getName());
                     String description = data.getDescription();
@@ -131,7 +132,7 @@ public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapte
                         setDownloadTvText(appViewHolder, data);
                     } else {
                         String todayTask = data.getDate();
-                        if (todayTask!=null && todayTask.equals(TimeStamp2Date(System.currentTimeMillis(), "yyyy-MM-dd"))) {
+                        if (todayTask != null && todayTask.equals(TimeStamp2Date(System.currentTimeMillis(), "yyyy-MM-dd"))) {
                             setDownloadTvText(appViewHolder, data);
                             appViewHolder.mDownloadTv.setEnabled(true);
                             appViewHolder.mDownloadTv.setBackgroundColor(Color.parseColor("#d12121"));
@@ -167,7 +168,7 @@ public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapte
             appViewHolder.mDownloadTv.setText("继续体验");
         } else {
             String downloadState = ACache.get(SheepApp.getInstance()).getAsString(String.format(Locale.CHINA, "%s%s", AdManager.class.getSimpleName(), data.getId()));
-            if(downloadState == null){
+            if (downloadState == null) {
                 appViewHolder.mDownloadTv.setText("立即下载");
             } else {
                 switch (downloadState) {
@@ -199,6 +200,7 @@ public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapte
         }
         return date;
     }
+
     @Override
     public int getItemViewType(int position) {
         // 最后一个item设置为footerView
@@ -242,6 +244,7 @@ public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapte
         TextView mDateTv;
         TextView mTagTv;
         TextView mDownloadTv;
+        ImageView my_money_item_recharge_amount_iv;
 
         public AppViewHolder(View itemView) {
             super(itemView);
@@ -255,6 +258,7 @@ public class AdListAdapter extends android.support.v7.widget.RecyclerView.Adapte
             mTagTv = (TextView) itemView.findViewById(R.id.tv_tag);//标题
             mDownloadTv = (TextView) itemView.findViewById(R.id.tv_download);//标题
             mIconIv = (ImageView) itemView.findViewById(R.id.iv_icon);//标题
+            my_money_item_recharge_amount_iv = (ImageView) itemView.findViewById(R.id.my_money_item_recharge_amount_iv);//标题
 
         }
     }

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/adapter/TryMakeMoneyAdp.java

@@ -491,7 +491,7 @@ public class TryMakeMoneyAdp extends AdpCommonRecy<RecyleObj> {
                 }else {
                     detail_task_tv.setVisibility(View.VISIBLE);
                     detail_task_tv_down.setVisibility(View.GONE);
-                    detail_task_tv.setText("领取游戏帐号");
+                    detail_task_tv.setText("领取帐号");
                     detail_task_tv.setBackground(context.getResources().getDrawable(R.drawable.sp_bg_gradient_rectangle_blue));
                     detail_task_tv.setEnabled(true);
                     viewHolder.itemView.setEnabled(false);

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

@@ -21,6 +21,7 @@ import com.sheep.gamegroup.util.AppUtil;
 import com.sheep.gamegroup.util.ConnectAddress;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.LogUtil;
+import com.sheep.gamegroup.util.PreferenceUtils;
 import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.UMConfigUtils;
 import com.sheep.gamegroup.view.activity.LoginAct;
@@ -204,6 +205,7 @@ public class SheepApp extends BaseApplication {
             if(mActivityAount == 0) {
                 LogUtil.println("SheepApp SHEEP_STOP");
                 UMConfigUtils.Event.SHEEP_STOP.onEvent();
+                PreferenceUtils.setPrefBoolean(mContext, "init_midong_key", false);
             }
         }
     };
@@ -221,4 +223,9 @@ public class SheepApp extends BaseApplication {
         super.attachBaseContext(base);
         MultiDex.install(this);
     }
+
+    @Override
+    public void onTerminate() {
+        super.onTerminate();
+    }
 }

+ 23 - 8
app/src/main/res/layout/wall_list_item.xml

@@ -86,18 +86,33 @@
             android:textSize="12sp" />
     </RelativeLayout>
 
-    <TextView
-        android:id="@+id/tv_des"
-        android:layout_width="wrap_content"
+    <LinearLayout
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginLeft="14dp"
         android:layout_marginRight="14dp"
         android:layout_marginTop="15dp"
-        android:ellipsize="end"
-        android:maxLines="2"
-        android:textColor="#666666"
-        android:textSize="13sp"
-        tools:text="啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊" />
+        android:orientation="horizontal"
+        android:gravity="center_vertical">
+        <TextView
+            android:id="@+id/tv_des"
+            android:layout_weight="1"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:ellipsize="end"
+            android:maxLines="5"
+            android:textColor="#666666"
+            android:textSize="13sp"
+            tools:text="啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊" />
+
+        <ImageView
+            android:id="@+id/my_money_item_recharge_amount_iv"
+            android:layout_width="15dp"
+            android:layout_height="15dp"
+            android:src="@mipmap/myprice_on"
+            android:layout_marginLeft="@dimen/content_padding_1"
+            android:visibility="gone"/>
+    </LinearLayout>
 
     <View
         android:layout_width="match_parent"