Skip to content

Instantly share code, notes, and snippets.

/**
* Enter the symbols found in a list of parse trees.
* As a side-effect, this puts elements on the "todo" list.
* Also stores a list of all top level classes in rootClasses.
*/
public List<JCCompilationUnit> enterTrees(List<JCCompilationUnit> roots) {
//enter symbols for all files
if (!taskListener.isEmpty()) {
for (JCCompilationUnit unit: roots) {
TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
@RubiTree
RubiTree / AutoAdjustPosition.java
Created May 30, 2018 09:21
[AutoAdjustPosition] AutoAdjustPosition
public class Main{
private void adjustPositionByVertical(List<PreDrawText> preDrawTexts) {
Collections.sort(preDrawTexts, new Comparator<PreDrawText>() {
@Override
public int compare(PreDrawText o1, PreDrawText o2) {
if (o1.getDrawY() < o2.getDrawY()) return -1; // getDrawY() 从小到大排序
if (o1.getDrawY() > o2.getDrawY()) return 1;
return 0;
}
});
@RubiTree
RubiTree / ScreenAdaptUtil.java
Last active October 15, 2018 08:23
The simplest screen adaptation scheme. From https://zhuanlan.zhihu.com/p/37199709.
public class ScreenAdaptUtil {
private static final int STANDER_SCREEN_WIDTH_IN_DP = 360;
private static float sNonCompatDensity;
private static float sNonCompatScaleDensity;
public static void setCustomDensity(Activity activity, Application application) {
final DisplayMetrics appDisplayMetrics = application.getResources().getDisplayMetrics();
if (sNonCompatDensity == 0) {