Deletes a specified parameter from the URL


public static String removeQueryName(String linkurl, String... names) {
        if (names == null) {
            return linkurl;
        }
        Uri uri = Uri.parse(linkurl);
        Set<String> parameterNames = uri.getQueryParameterNames();
        Set<String> tempSet = new HashSet<>(parameterNames);
        for (String name : names) {
            tempSet.remove(name);
        }
        StringBuilder param = new StringBuilder();
        if (linkurl.contains("?")) {
            param.append(linkurl.substring(0, linkurl.indexOf("?")));
        } else {
            param.append(linkurl);
        }
        if (tempSet.size() > 0) {
            param.append("?");
            for (String parameterName : tempSet) {
                param.append(parameterName)
                        .append("=")
                        .append(uri.getQueryParameter(parameterName))
                        .append("&");
            }
            return param.substring(0, param.toString().length() - 1);
        }
        return param.toString();
    }

Copy the code

The List is the best solution

 /** ** ** * 1. Delete duplicate elements * 2. Use LinkedHashSet to ensure that elements in the new List remain in their original order * *@param list
     * @return* /
    private List<String> removeSameInList(List<String> list) {
        System.out.println("origin list: " + list);
        LinkedHashSet<String> hashSet = new LinkedHashSet<>(list);
        List<String> resultList = new ArrayList<>(hashSet);
        System.out.println("Duplicate removed List: " + resultList);
        return resultList;
    }
    
 // removeSameInList(Arrays.asList("22", "23", "33", "11", "22", "11", "55"))  
 // origin list: [22, 23, 33, 11, 22, 11, 55]
 // Duplicate removed List: [22, 23, 33, 11, 55]

Copy the code

Overdraw custom View

Canvas.clipRect()


public class MultiBitmapView extends View {

    private Paint paint;
    private Bitmap bitmap;
    private int count = 2;
    private int pieWidth;

    public MultiBitmapView(Context context) {
        this(context, null);
    }

    public MultiBitmapView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MultiBitmapView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        pieWidth = w / count;
    }

    private void init(Context context) {
        setWillNotDraw(false);
        paint = new Paint();
        bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        for (int i = 0; i < count; i++) {
            canvas.save();
            canvas.clipRect(i * pieWidth, 0, (i + 1) * pieWidth, getHeight());   // Display area
            canvas.drawBitmap(bitmap, 0.0, paint);
            /*if(i==1) { isReject = canvas.quickReject(10 + i * 180, 10 + i * 180, 10 + i * 180+50, 10 + i * 180+50, Canvas.EdgeType.BW); Log.i(TAG,"isReject : "+isReject); isReject = canvas.quickReject(10 , 10 , 10 +180, 10 +180, Canvas.EdgeType.BW); Log.i(TAG,"*** isReject : "+isReject); } * /canvas.restore(); }}}Copy the code
/** ** BehaviorSubject: only receives the last data before the subscription and all data after the subscription * AsyncSubject: Only receives the last data whenever the subscription is sent * ReplaySubject: Accept all data * PublishSubject: Only accept all data after the subscription */
Copy the code

ArrayList, the Array print

List<User> userList = new ArrayList<>();
for (int i = 0; i < 20; i++) {
    userList.add(new User("ctom".12 + i));
}
System.out.println(userList);

User[] ss = new User[]{new User("ccc".11), new User("ccc".11)};
System.out.println(Arrays.toString(ss));


Copy the code

Determines whether the array contains elements

String[] cc = new String[10000];
for (int i = 0; i < cc.length; i++) {
    cc[i] = "test-" + i;
}
Arrays.asList(cc).contains("test-9999");

Copy the code