進公司的第18天 2020/4/9 隨便寫點

今天又是平凡的一天。昨天碰到了一個稍微有點棘手的問題。一直整到了晚上8點半。準點下班就懶得寫博客了。想要保持不斷更真難呢。今天也不刻意補了。就把這兩天的事一起隨便寫寫把。
昨天早上一如既往的研究將副屏放入service後臺服務中。還是沒有結果。Presentation顯示出了問題。我明明讓他顯示在副屏。最後發現他的生命週期到了副屏。顯示卻還是在主屏。搞不懂這是怎麼回事。
下午老大跟我說了個BUG,測試發現切歌的時候APP有時候會卡住。並且懷疑是不是有可能我前面加的定時器的問題。我表示這不可能。定時器異步操作怎麼會影響主線程的UI。但是我還是需要測試一番來表示我的結論並沒有錯。然後就是無限的測試。我發現了在某種情況下整個APP進程會卡住3秒左右。我這麼判斷的原因是logcat停止打印了三秒後才繼續打印。並且頁面卡頓。但是愚蠢的我並沒有把整個log記錄下來。而是刷了之前沒有改動的版本測試。發現並沒有這個問題。然後我幾乎確定最新版本有問題的時候。我重新刷回來想測試測試BUG。
在這時我突然想起爲了測試準確點。我將LuncherAPP直接幹掉。恢復出廠設置把。這樣感覺準確一點。愚蠢的我已經忘記了恢復出廠設置並不會重置系統應用的事情了。最終結果導致了沒有luncherAPP。設備也沒有自動連上wifi。有線IP我也不知道是多少(後來我才知道我網線被誰給拔了。
總而言之。我沒有辦法用ADB連上設備。也沒有辦法重置luncher應用。設備崩了。。
我跟我老大說了之後他表示很無語。表示這種瞎幾把我都能整出來。然後使出了一招nmap -sP 192.168.1.0/24。並且插拔網線之後的IP變化。我才用adb連上了設備。重置了整個系統。
期間我ping了無數次各種192.168.0.xx。就是沒試出來。我從192.168.0.30試到了192.168.0.60.最後發現IP竟然是192.168.0.73.emmmmmmmmm。算你狠。事情解決已經八點半了。準點下班。懶得寫博客了。
最後下班之前我老大說有個新任務可能會交給我去做。讓我做一個語音提示頁面(彈框)。我第一反應就是小米的那啥小愛同學。

在這裏插入圖片描述
然後我寫了一個小demo。用了兩種方式變現這個功能需求的解決UI。
在這裏插入圖片描述
在這裏插入圖片描述
我知道你們都想吐槽巨醜。但是我感覺還行。給我老大看了。他表示可以作爲備選方案。以及具體的UI需要我和UI設計小姐姐討論。主要還是看甲方老爺喜歡啥樣的。
隨便寫的一個工具類

package com.android.videodemo;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.GradientDrawable;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.List;
import java.util.Random;

public class TextViewUtil {

    private String TAG = "TextViewUtil";

    public LinearLayout show(Context context, String[][] Category, int[] Colors){
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        LinearLayout linearLayout2 = new LinearLayout(context);
        linearLayout2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));


        for (int k = 0;k < Category.length;k++){
            LinearLayout linearLayout1 = new LinearLayout(context);
            linearLayout1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
            for (int i = 0;i < Category[k].length;i++){
                GradientDrawable drawable = new GradientDrawable();
                Random ra =new Random();
                drawable.setColor(context.getResources().getColor(Colors[ra.nextInt(4)+0]));
                drawable.setCornerRadius(90);

                TextView textView = new TextView(context);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                layoutParams.setMargins(10,10,10,10);
                textView.setText(Category[k][i]);
                textView.setBackground(drawable);
                textView.setTextSize(20);
                textView.setPadding(20,20,20,20);
                textView.setLayoutParams(layoutParams);
                int w = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
                int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
                linearLayout1.measure(w, h);

                int textsize = getwidth(textView)*(i+1);
                int linearsize = getDisplay(context);

                Log.e("int",textsize+"||"+linearsize);
                if (textsize < linearsize){
                    linearLayout1.addView(textView);
                }else {
                    linearLayout2.addView(textView);
                }
            }
            linearLayout.addView(linearLayout1);
            if (linearLayout2!=null){
                linearLayout.addView(linearLayout2);
                linearLayout2 = null;
            }
        }
        return linearLayout;
    }

    public LinearLayout show(Context context, List<String[]> Category, int[] Colors){
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.setClipChildren(false);

        LinearLayout linearLayout2 = new LinearLayout(context);
        linearLayout2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));

        for (int k = 0;k < Category.size();k++){
            LinearLayout linearLayout1 = new LinearLayout(context);
            linearLayout1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
            for (int i = 0;i < Category.get(k).length;i++){
                GradientDrawable drawable = new GradientDrawable();
                Random ra =new Random();
                drawable.setColor(context.getResources().getColor(Colors[ra.nextInt(4)+0]));
                drawable.setCornerRadius(90);

                TextView textView = new TextView(context);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 100);
                layoutParams.setMargins(10,10,10,10);
                textView.setText(Category.get(k)[i]);
                textView.setBackground(drawable);
                textView.setTextSize(20);
                textView.setPadding(20,20,20,20);
                textView.setLayoutParams(layoutParams);
                int w = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
                int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
                linearLayout1.measure(w, h);

                int textsize = getwidth(textView)*(i+1);
                int linearsize = getDisplay(context);

//                Log.e("int",textsize+"||"+linearsize);
//                if (textsize < linearsize){
//                    linearLayout1.addView(textView);
//                }else {
//                    linearLayout2.addView(textView);
//                }
                linearLayout1.addView(textView);

            }
            linearLayout.addView(linearLayout1);
            if (linearLayout2!=null){
                linearLayout.addView(linearLayout2);
                linearLayout2 = null;
            }
        }
        return linearLayout;
    }

    private int getDisplay(Context context) {
        Activity activity = (Activity) context;
        Display defaultDisplay =activity.getWindowManager().getDefaultDisplay();
        Point point = new Point();
        defaultDisplay.getSize(point);
        int x = point.x;
        int y = point.y;
        Log.i(TAG, "x = " + x + ",y = " + y);
        return x;
    }

    private int getwidth(View linearLayout1) {
        int w = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
        int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
        linearLayout1.measure(w, h);
        int width =linearLayout1.getMeasuredWidth();
        return width;
    }
}

我的調用方式
在這裏插入圖片描述
今天就這樣把。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章