소스 검색

review
优化邀请赚钱分享页面布局

zengjiebin 7 년 전
부모
커밋
2a91c8c9f1

+ 32 - 130
app/src/main/java/com/sheep/gamegroup/view/activity/InvitationActivity.java

@@ -5,9 +5,6 @@ import android.app.Activity;
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Matrix;
-import android.graphics.Paint;
 import android.os.Bundle;
 import android.os.Environment;
 import android.os.Handler;
@@ -26,13 +23,6 @@ import android.widget.TextView;
 
 import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
-import com.google.zxing.BarcodeFormat;
-import com.google.zxing.EncodeHintType;
-import com.google.zxing.WriterException;
-import com.google.zxing.common.BitMatrix;
-import com.google.zxing.qrcode.QRCodeWriter;
-import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
-import com.kfzs.duanduan.cardview.CardScaleHelper;
 import com.sheep.gamegroup.helper.DownloadUtil;
 import com.sheep.gamegroup.helper.ScalableCardHelper;
 import com.sheep.gamegroup.helper.ZXingHelper;
@@ -66,7 +56,6 @@ import com.umeng.socialize.media.UMWeb;
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.Hashtable;
 import java.util.List;
 
 import butterknife.BindView;
@@ -89,40 +78,20 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
     RecyclerView ask_share_list;
     @BindView(R.id.recyclerView)
     RecyclerView mRecyclerView;
-    @BindView(R.id.blurView)
-    ImageView mBlurView;
     @BindView(R.id.img_baseactivity_title)
     ImageView ivBack;
-    @BindView(R.id.txt_baseactivity_title)
-    TextView tvTitle;
-    private List<Integer> mList = new ArrayList<>();
-    private CardScaleHelper mCardScaleHelper = null;
-    private Runnable mBlurRunnable;
-    private int mLastPos = -1;//滑动当前的位置
-    private List<String> localPathList = new ArrayList<>();
-    private List<String> RxPathList = new ArrayList<>();
-    private String localPicturePath = Environment.getDataDirectory().getAbsolutePath() + "/pic/+pic";
-    private String localRxPath = Environment.getDataDirectory().getAbsolutePath() + "/rx/+rx";
 
     GridLayoutManager gridLayoutManager;
     UserEntity userEntity = DataUtil.getInstance().getUserEntity();
     private FriendAndAwardEntity mEntity;
     private String url;
     private String description;
-    private Bitmap mBitmap;
     private File file;
     private List<PictureInvitationEntity> mPictureList = new ArrayList<>();
-    private List<File> mPictureFileList = new ArrayList<>();
-    private List<File> mRxFileList = new ArrayList<>();
-    String localPath = "";
-    String localRx = "";
     private int position = 0;
-    private List<Bitmap> listBitmap = new ArrayList<>();
     private List<Bitmap> listBitmap1 = new ArrayList<>();
     private List<Bitmap> listBitmap2 = new ArrayList<>();
     private MyAdapter adapter;
-    private int size = 0;
-    private View view = null;
 
     @Override
 
@@ -132,13 +101,12 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
         ButterKnife.bind(this);
         initView();
         initData();
-        // initPicture();
-        cerateAdapter(listBitmap1, this);
-        getPicetureList();
+        createAdapter(listBitmap1, this);
+        getPictureList();
     }
 
     private void initView() {
-        tvTitle.setText("邀请赚钱");
+//        tvTitle.setText("邀请赚钱");
         ivBack.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
@@ -151,7 +119,7 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
      * @param list    Bitmap集合
      * @param context
      */
-    private void cerateAdapter(List<Bitmap> list, Context context) {
+    private void createAdapter(List<Bitmap> list, Context context) {
         adapter = new MyAdapter(context, list, listBitmap2);
         LinearLayoutManager layoutManager = new LinearLayoutManager(context);
         layoutManager.setOrientation(OrientationHelper.HORIZONTAL);
@@ -277,29 +245,36 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
                 share_media = SHARE_MEDIA.WEIXIN_CIRCLE;
                 break;
         }
-        UMImage umImage = null;
-
-        if (type == DialogShare.QQ || type == DialogShare.WX) {
-            umImage = new UMImage(activity, bitmap);
-        } else {
-            umImage = new UMImage(activity, R.mipmap.icon);
+        UMImage umImage;
+        switch (type){
+            case DialogShare.QQ:
+            case DialogShare.WX:
+                umImage = new UMImage(activity, bitmap);
+                break;
+            default:
+                umImage = new UMImage(activity, R.mipmap.icon);
+                break;
         }
         UMWeb umWeb = new UMWeb(realUrl);
         umWeb.setTitle(activity.getResources().getString(R.string.app_name));
         umWeb.setThumb(umImage);
         umWeb.setDescription(TextUtils.isEmpty(description) ? activity.getResources().getString(R.string.app_name) : description);
-        if (type == DialogShare.QQ || type == DialogShare.WX) {
-            new ShareAction(activity)
-                    .setPlatform(share_media)
-                    .withMedia(umImage)
-                    .setCallback(new CommonUtil.UMShareListener())
-                    .share();
-        } else {
-            new ShareAction(activity)
-                    .setPlatform(share_media)
-                    .withMedia(umWeb)
-                    .setCallback(new CommonUtil.UMShareListener())
-                    .share();
+        switch (type){
+            case DialogShare.QQ:
+            case DialogShare.WX:
+                new ShareAction(activity)
+                        .setPlatform(share_media)
+                        .withMedia(umImage)
+                        .setCallback(new CommonUtil.UMShareListener())
+                        .share();
+                break;
+            default:
+                new ShareAction(activity)
+                        .setPlatform(share_media)
+                        .withMedia(umWeb)
+                        .setCallback(new CommonUtil.UMShareListener())
+                        .share();
+                break;
         }
     }
 
@@ -323,15 +298,6 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
                             description = mEntity.getShare_desc();
                             ViewUtil.newInstance().hideProgress(InvitationActivity.this);
                             getmEntity();
-                            runOnUiThread(new Runnable() {
-                                @Override
-                                public void run() {
-                                   /* tvSize.setText(mEntity.getFriend_count() + "");
-                                    tvMoney.setText(mEntity.getAward());*/
-                                }
-                            });
-                        } else {
-                            /* ViewUtil.newInstance().hideProgress(activity);*/
                         }
 
                     }
@@ -346,8 +312,6 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
             public void call(UserEntity result) {
                 if (result != null) {
                     userEntity = result;
-                    String audit_total_audit = String.format(getResources().getString(R.string.my_invitation_str), userEntity.getInvitation_code());
-                    /*  my_invitation_tv.setText(audit_total_audit);*/
                     url = userEntity.getShareLink();
                     init(url, description);
                 }
@@ -359,7 +323,6 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
     @Override
     public void onPageSelected(int position) {
         try {
-            mBitmap=getViewBitmap(mRecyclerView.getChildAt(position).findViewById(R.id.layout_view));
             file=getViewFile(mRecyclerView.getChildAt(position).findViewById(R.id.layout_view));
         } catch (Exception e) {
             e.printStackTrace();
@@ -370,8 +333,7 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
     /**
      * 来获取邀请图片,
      */
-    private void getPicetureList() {
-        ArrayList<PictureInvitationEntity> list = new ArrayList<>();
+    private void getPictureList() {
         SheepApp
                 .getInstance()
                 .getNetComponent()
@@ -382,14 +344,11 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
                     @Override
                     public void onNext(BaseMessage baseMessage) {
-                        LogUtil.logI("onNext__getPicetureList--" + new Gson().toJson(baseMessage));
                         mPictureList.addAll(baseMessage.getDataList(PictureInvitationEntity.class));
-                        downloadPictures();
                     }
 
                     @Override
                     public void onError(BaseMessage baseMessage) {
-                        LogUtil.logI("onError__getPicetureList--" + new Gson().toJson(baseMessage));
                     }
                 });
     }
@@ -407,9 +366,7 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
             DownloadUtil.get().download(mPictureList.get(position).getPicture(), "sheep", new DownloadUtil.OnDownloadListener() {
                 @Override
                 public void onDownloadSuccess() {
-                    Log.i("aaaa", "下载成功");
                     if (position == mPictureList.size()-1) {
-                        Log.i("aaaa", "下载成功"+"---"+size+"-----"+mPictureList.size());
                         createBitmapList(position);
                     }
                 }
@@ -420,7 +377,6 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
 
                 @Override
                 public void onDownloadFailed() {
-                    Log.i("aaaa", "下载失败");
                 }
             });
         }
@@ -430,8 +386,8 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
         for (int i = 0; i < mPictureList.size(); i++) {
             listBitmap1.add(BitmapFactory.decodeFile(getSavePath(mPictureList.get(i).getPicture())));
             Bitmap logo = BitmapFactory.decodeResource(getResources(), R.mipmap.sheep_logo);
-            Bitmap bitmapx = ZXingHelper.createQRCodeWithLogo(mPictureList.get(y).getLink(), logo);
-            listBitmap2.add(bitmapx);
+            Bitmap bitmap = ZXingHelper.createQRCodeWithLogo(mPictureList.get(y).getLink(), logo);
+            listBitmap2.add(bitmap);
         }
         handler.sendEmptyMessage(1);
     }
@@ -458,22 +414,6 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
         }
     };
 
-    /**
-     * @param addViewContent
-     * @return
-     */
-    private Bitmap getViewBitmap(View addViewContent) {
-        if (addViewContent==null){
-            return null;
-        }
-        addViewContent.setDrawingCacheEnabled(true);
-        addViewContent.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
-        addViewContent.layout(0, 0, addViewContent.getMeasuredWidth(), addViewContent.getMeasuredHeight());
-        addViewContent.buildDrawingCache();
-        Bitmap cacheBitmap = addViewContent.getDrawingCache();
-        Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
-        return ViewUtil.getCacheBitmapFromView((View) addViewContent.getParent());
-    }
     private File getViewFile(View addViewContent) {
         if (addViewContent==null){
             return null;
@@ -481,42 +421,4 @@ public class InvitationActivity extends AppCompatActivity implements ScalableCar
         return ViewUtil.saveImage(addViewContent, ClassFileHelper.DIR, System.currentTimeMillis() + ".jpg");
     }
 
-
-    /**
-     * 合成图片
-     * @param firstBitmap
-     * @param secondBitmap
-     * @return
-     */
-    private Bitmap mergeBitmap(Bitmap firstBitmap, Bitmap secondBitmap) {
-        Bitmap bitmap = Bitmap.createBitmap(firstBitmap.getWidth(), firstBitmap.getHeight(), firstBitmap.getConfig());
-        Canvas canvas = new Canvas(bitmap);
-        float w = firstBitmap.getWidth();
-        float h = firstBitmap.getHeight();
-        Matrix matrix = new Matrix();
-        //确定secondBitmap大小比例
-        matrix.setScale(secondBitmap.getWidth(), h / secondBitmap.getHeight());
-        canvas.drawBitmap(firstBitmap, new Matrix(), null);
-        canvas.drawBitmap(zoomImage(secondBitmap, 50, 50), 320, 320, null);
-        LogUtil.logI("bitmap----first---" + firstBitmap.getWidth() + "--" + firstBitmap.getHeight());
-        LogUtil.logI("bitmap----secound---" + secondBitmap.getWidth() + "--" + secondBitmap.getHeight());
-        return bitmap;
-    }
-
-    public static Bitmap zoomImage(Bitmap bgimage, double newWidth, double newHeight) {
-        // 获取这个图片的宽和高
-        float width = bgimage.getWidth();
-        float height = bgimage.getHeight();
-        // 创建操作图片用的matrix对象
-        Matrix matrix = new Matrix();
-        // 计算宽高缩放率
-        float scaleWidth = ((float) newWidth) / width;
-        float scaleHeight = ((float) newHeight) / height;
-        // 缩放图片动作
-        matrix.postScale(scaleWidth, scaleHeight);
-        Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width,
-                (int) height, matrix, true);
-        return bitmap;
-    }
-
 }

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

@@ -281,16 +281,16 @@ public class TaskDetailAct extends AbsChooseImageActivity implements TaskDetailC
         setSonVuewShow();
 
         loadOld();
-        //用户可主动点击进行开启查看权限
-        taskdetail_explain_layout.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                AppUsageManager.getInstance().openLookAppUsageStatsPermisson();
-            }
-        });
         //自动审核
         if (taskEty.getInspect_type() == 3) {
-
+            ViewUtil.setColorMapText(item_exlpain_title, getString(R.string.supplement_explain_n), "点我开启权限", "#FF0000");
+            //用户可主动点击进行开启查看权限
+            taskdetail_explain_layout.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    AppUsageManager.getInstance().openLookAppUsageStatsPermisson();
+                }
+            });
             taskdetail_explain_layout.setVisibility(View.VISIBLE);
         } else {
             taskdetail_explain_layout.setVisibility(View.GONE);
@@ -1318,7 +1318,6 @@ public class TaskDetailAct extends AbsChooseImageActivity implements TaskDetailC
                     detail_task_listview.setVisibility(View.GONE);
 
                     taskdetail_explain_layout.setVisibility(View.VISIBLE);
-                    item_exlpain_title.setText(getString(R.string.supplement_explain_n));
                     item_exlpain_conetent.setText(getString(R.string.supplement_explain));
                     sonListviewAdp = new TaskdetailSonListviewAdp(taskEty.getChild(), activity);
                     TaskHelper.setSelectFlag(taskEty);

+ 51 - 65
app/src/main/res/layout/activity_invitation.xml

@@ -1,15 +1,52 @@
 <?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-   >
+    android:layout_height="match_parent"
+    android:background="#F0F0F0">
+
+    <ImageView
+        android:id="@+id/img_baseactivity_title"
+        android:layout_width="?attr/actionBarSize"
+        android:layout_height="?attr/actionBarSize"
+        android:gravity="center_vertical"
+        android:scaleType="centerInside"
+        android:src="@drawable/narrow_back_black"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <LinearLayout
+        android:id="@+id/layout_f1"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:background="#F0F0F0"
+        android:gravity="center_horizontal"
+        android:orientation="vertical"
+        app:layout_constraintBottom_toTopOf="@+id/layout_f"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/img_baseactivity_title">
+
+        <android.support.v7.widget.RecyclerView
+            android:id="@+id/recyclerView"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content" />
+
+        <TextView
+            android:id="@+id/tv_flags"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="左右滑动选择推广页" />
+
+    </LinearLayout>
 
     <RelativeLayout
         android:id="@+id/layout_f"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_alignParentBottom="true"
-        android:background="#ffffffff">
+        android:background="#ffffffff"
+        app:layout_constraintTop_toBottomOf="@+id/layout_f1"
+        app:layout_constraintBottom_toBottomOf="parent">
 
         <TextView
             android:id="@+id/ask_share_title"
@@ -30,8 +67,8 @@
             android:background="@drawable/shape_blue_stroke_withe_radius_5"
             android:gravity="center"
             android:text="复制"
-            android:visibility="invisible"
-            android:textColor="@color/white" />
+            android:textColor="@color/white"
+            android:visibility="invisible" />
 
         <TextView
             android:id="@+id/tv_invitation_code"
@@ -42,8 +79,8 @@
             android:layout_toLeftOf="@id/tv_copy"
             android:gravity="center"
             android:text="12332"
-            android:visibility="invisible"
-            android:textColor="#ff333333" />
+            android:textColor="#ff333333"
+            android:visibility="invisible" />
 
         <TextView
             android:id="@+id/tv_f_invatation"
@@ -54,8 +91,8 @@
             android:layout_toLeftOf="@id/tv_invitation_code"
             android:gravity="center"
             android:text="你的邀请码:"
-            android:visibility="invisible"
-            android:textColor="#ff333333" />
+            android:textColor="#ff333333"
+            android:visibility="invisible" />
 
 
         <android.support.v7.widget.RecyclerView
@@ -63,61 +100,10 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_below="@+id/ask_share_title"
+            android:layout_marginBottom="15dp"
             android:layout_marginStart="@dimen/content_padding_15"
-            android:layout_marginTop="20dp"
-            android:layout_marginBottom="15dp"/>
-    </RelativeLayout>
-
-    <include
-        android:id="@+id/title_layout"
-        layout="@layout/title"
-        android:layout_width="match_parent"
-        android:layout_height="60dp"
-        android:layout_alignParentTop="true" />
-
-    <RelativeLayout
-        android:id="@+id/layout_f1"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_above="@id/layout_f"
-        android:layout_below="@id/title_layout"
-        android:background="#F0F0F0">
-
-
-        <TextView
-            android:id="@+id/tv_flags"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="10dp"
-            android:layout_alignParentBottom="true"
-            android:layout_centerHorizontal="true"
-            android:text="左右滑动选择推广页" />
-
-        <RelativeLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_above="@id/tv_flags">
-            <ImageView
-                android:id="@+id/blurView"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:scaleType="centerCrop"
-                android:visibility="gone"/>
-
-            <com.kfzs.duanduan.cardview.SpeedRecyclerView
-                android:id="@+id/recyclerViews"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:layout_marginBottom="30dp"
-                android:layout_marginTop="30dp"
-                android:visibility="gone"/>
-
-            <android.support.v7.widget.RecyclerView
-                android:id="@+id/recyclerView"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent" />
-        </RelativeLayout>
+            android:layout_marginTop="20dp" />
     </RelativeLayout>
 
 
-</RelativeLayout>
+</android.support.constraint.ConstraintLayout>