Skip to content

Instantly share code, notes, and snippets.

@zty5678
zty5678 / jetpack compose common import.kt
Created April 19, 2024 03:20
jetpack compose common import statements
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.graphics.drawscope.*
import androidx.compose.animation.core.*
import androidx.compose.foundation.*
import androidx.compose.foundation.gestures.*
import androidx.compose.foundation.interaction.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.*
import androidx.compose.foundation.lazy.grid.*
import androidx.compose.foundation.shape.*
@zty5678
zty5678 / DemoKMPBlur
Created April 10, 2024 15:23
A demo of blur for Jetpack Compose Desktop
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.GenericShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
@zty5678
zty5678 / rust_log_utils_demo.rs
Last active March 23, 2024 07:39
Rust Log Utils, use to print line number in console output. (Only tested in RustRover )
mod utils_log;
fn main() {
utils_log::log("hello world");
}
@zty5678
zty5678 / DuolingoButton.kt
Last active March 26, 2024 15:48
compose实现Duolingo按钮效果
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Surface
@zty5678
zty5678 / Mac 编译 java 版本 gdal 3.8.3.txt
Last active May 27, 2024 12:03
Mac 编译 java 版本 gdal 3.8.3
参考博客:https://www.cnblogs.com/echohye/p/17580078.html
1. 下载源码
version=3.8.3
wget http://download.osgeo.org/gdal/$version/gdal-$version.tar.xz
2. 编译。解压,执行:
cmake -S . -B build \
-DCMAKE_INSTALL_RPATH=/opt/gdal \
@zty5678
zty5678 / UIJobScheduler.java
Created May 30, 2023 02:43
UIJobScheduler: 记录当前一帧进行的操作所花费的时间,如果不够进行下一个操作,则将下一个操作放到下一帧,以此来增加画面的流畅度。
import android.os.Handler;
import android.view.Choreographer;
import java.util.ArrayDeque;
import java.util.concurrent.Callable;
public class UIJobScheduler {
private final static float MAX_JOB_TIMES_MS = 4f;
private static long elapsed = 0L;
private static ArrayDeque<Callable> jobQueue = new ArrayDeque<>();
private static Handler handler = new Handler();
private static boolean isOverMaxtime() {
@zty5678
zty5678 / LogUtils.dart
Last active June 8, 2023 17:28
flutter LOGD 打印行号
import 'package:flutter/foundation.dart';
void LOGD(Object message, StackTrace trace) {
try {
if (kDebugMode) {
CustomTrace programInfo = CustomTrace(trace);
// print("[(${programInfo.fileName}:${programInfo.lineNumber})]$message");
print("[(${programInfo.methodFullInfo})]$message");
}
} catch (e) {
adb shell am broadcast -a com.android.systemui.demo -e command exit
@zty5678
zty5678 / nested_scroll_view.dart
Created June 2, 2019 11:25 — forked from collinjackson/nested_scroll_view.dart
nestedscrollview example
// Copyright 2017, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() {
runApp(new TestApp());
}
@zty5678
zty5678 / FamiliarDefaultItemDecoration.java
Created April 15, 2017 14:18
FamiliarRecyclerView, 使用LinearLayoutManager.Vertical时, 默认第一项是没有divider的. 修改了两处代码, 给第一项的顶部加了divider.
package cn.iwgang.familiarrecyclerview;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;