gpt4 book ai didi

com.facebook.device.yearclass.YearClass类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 17:31:31 26 4
gpt4 key购买 nike

本文整理了Java中com.facebook.device.yearclass.YearClass类的一些代码示例,展示了YearClass类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearClass类的具体详情如下:
包路径:com.facebook.device.yearclass.YearClass
类名称:YearClass

YearClass介绍

暂无

代码示例

代码示例来源:origin: facebook/device-year-class

/**
 * Entry Point of YearClass. Extracts YearClass variable with memoizing.
 * Example usage:
 * <p>
 * <pre>
 *   int yearClass = YearClass.get(context);
 * </pre>
 */
public static int get(Context c) {
 if (mYearCategory == null) {
  synchronized(YearClass.class) {
   if (mYearCategory == null) {
    mYearCategory = categorizeByYear2016Method(c);
   }
  }
 }
 return mYearCategory;
}

代码示例来源:origin: facebook/device-year-class

/**
 * Calculates the "best-in-class year" of the device. This represents the top-end or flagship
 * devices of that year, not the actual release year of the phone. For example, the Galaxy Duos
 * S was released in 2012, but its specs are very similar to the Galaxy S that was released in
 * 2010 as a then top-of-the-line phone, so it is a 2010 device.
 *
 * @return The year when this device would have been considered top-of-the-line.
 */
private static int categorizeByYear2014Method(Context c) {
 ArrayList<Integer> componentYears = new ArrayList<Integer>();
 conditionallyAdd(componentYears, getNumCoresYear());
 conditionallyAdd(componentYears, getClockSpeedYear());
 conditionallyAdd(componentYears, getRamYear(c));
 if (componentYears.isEmpty())
  return CLASS_UNKNOWN;
 Collections.sort(componentYears);
 if ((componentYears.size() & 0x01) == 1) {  // Odd number; pluck the median.
  return componentYears.get(componentYears.size() / 2);
 } else { // Even number. Average the two "center" values.
  int baseIndex = componentYears.size() / 2 - 1;
  // There's an implicit rounding down in here; 2011.5 becomes 2011.
  return componentYears.get(baseIndex) +
    (componentYears.get(baseIndex + 1) - componentYears.get(baseIndex)) / 2;
 }
}

代码示例来源:origin: facebook/device-year-class

@Override
protected Integer doInBackground(Void... voids) {
 int yearClass = YearClass.CLASS_UNKNOWN;
 SharedPreferences prefs = getSharedPreferences(PREF_FILE, 0);
 if (prefs.contains(PREF_NAME)) {
  yearClass = prefs.getInt(PREF_NAME, YearClass.CLASS_UNKNOWN);
 }
 //Try again if device was previously unknown.
 if (yearClass == YearClass.CLASS_UNKNOWN) {
  yearClass = YearClass.get(getApplicationContext());
  SharedPreferences.Editor editor = prefs.edit();
  editor.putInt(PREF_NAME, yearClass);
  editor.apply();
 }
 return yearClass;
}

代码示例来源:origin: facebook/device-year-class

/**
 * This formulation of year class smooths out the distribution of devices in the field
 * in early 2016 so that the buckets are a bit more even in size and performance metrics
 * (specifically app startup time, scrolling perf, animations) are more uniform within
 * the buckets than with the 2014 calculations.
 */
private static int categorizeByYear2016Method(Context c) {
 long totalRam = DeviceInfo.getTotalMemory(c);
 if (totalRam == DeviceInfo.DEVICEINFO_UNKNOWN) {
  return categorizeByYear2014Method(c);
 }
 if (totalRam <= 768 * MB) {
  return DeviceInfo.getNumberOfCPUCores() <= 1 ? CLASS_2009 : CLASS_2010;
 }
 if (totalRam <= 1024 * MB) {
  return DeviceInfo.getCPUMaxFreqKHz() < 1300 * MHZ_IN_KHZ ? CLASS_2011 : CLASS_2012;
 }
 if (totalRam <= 1536 * MB) {
  return DeviceInfo.getCPUMaxFreqKHz() < 1800 * MHZ_IN_KHZ ? CLASS_2012 : CLASS_2013;
 }
 if (totalRam <= 2048 * MB) {
  return CLASS_2013;
 }
 if (totalRam <= 3 * 1024 * MB) {
  return CLASS_2014;
 }
 return totalRam <= 5 * 1024 * MB ? CLASS_2015 : CLASS_2016;
}

代码示例来源:origin: com.facebook.device.yearclass/yearclass

/**
 * This formulation of year class smooths out the distribution of devices in the field
 * in early 2016 so that the buckets are a bit more even in size and performance metrics
 * (specifically app startup time, scrolling perf, animations) are more uniform within
 * the buckets than with the 2014 calculations.
 */
private static int categorizeByYear2016Method(Context c) {
 long totalRam = DeviceInfo.getTotalMemory(c);
 if (totalRam == DeviceInfo.DEVICEINFO_UNKNOWN) {
  return categorizeByYear2014Method(c);
 }
 if (totalRam <= 768 * MB) {
  return DeviceInfo.getNumberOfCPUCores() <= 1 ? CLASS_2009 : CLASS_2010;
 }
 if (totalRam <= 1024 * MB) {
  return DeviceInfo.getCPUMaxFreqKHz() < 1300 * MHZ_IN_KHZ ? CLASS_2011 : CLASS_2012;
 }
 if (totalRam <= 1536 * MB) {
  return DeviceInfo.getCPUMaxFreqKHz() < 1800 * MHZ_IN_KHZ ? CLASS_2012 : CLASS_2013;
 }
 if (totalRam <= 2048 * MB) {
  return CLASS_2013;
 }
 if (totalRam <= 3 * 1024 * MB) {
  return CLASS_2014;
 }
 return totalRam <= 5 * 1024 * MB ? CLASS_2015 : CLASS_2016;
}

代码示例来源:origin: com.facebook.device.yearclass/yearclass

/**
 * Calculates the "best-in-class year" of the device. This represents the top-end or flagship
 * devices of that year, not the actual release year of the phone. For example, the Galaxy Duos
 * S was released in 2012, but its specs are very similar to the Galaxy S that was released in
 * 2010 as a then top-of-the-line phone, so it is a 2010 device.
 *
 * @return The year when this device would have been considered top-of-the-line.
 */
private static int categorizeByYear2014Method(Context c) {
 ArrayList<Integer> componentYears = new ArrayList<Integer>();
 conditionallyAdd(componentYears, getNumCoresYear());
 conditionallyAdd(componentYears, getClockSpeedYear());
 conditionallyAdd(componentYears, getRamYear(c));
 if (componentYears.isEmpty())
  return CLASS_UNKNOWN;
 Collections.sort(componentYears);
 if ((componentYears.size() & 0x01) == 1) {  // Odd number; pluck the median.
  return componentYears.get(componentYears.size() / 2);
 } else { // Even number. Average the two "center" values.
  int baseIndex = componentYears.size() / 2 - 1;
  // There's an implicit rounding down in here; 2011.5 becomes 2011.
  return componentYears.get(baseIndex) +
    (componentYears.get(baseIndex + 1) - componentYears.get(baseIndex)) / 2;
 }
}

代码示例来源:origin: DaxiaK/MyDiary

private void init(Context context, Calendar calendar) {
  //In the Android 4.2 , LAYER_TYPE_SOFTWARE will cause some question
  int year = YearClass.get(context.getApplicationContext());
  if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR1 ||
      year < YearClass.CLASS_2013) {
    this.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
  }
  //View
  setScreen(context);
  createBitmaps();
  //Set calendar , this object should be created after w,h was set.
  calendarFactory = new CalendarFactory(context, calendar, mWidth, mHeight);
  //Page effect
  mPath0 = new Path();
  mPath1 = new Path();
  createDrawable();
  mPaint = new Paint();
  mPaint.setStyle(Paint.Style.FILL);
  ColorMatrix cm = new ColorMatrix();
  float array[] = {0.55f, 0, 0, 0, 80.0f, 0, 0.55f, 0, 0, 80.0f, 0, 0,
      0.55f, 0, 80.0f, 0, 0, 0, 0.2f, 0};
  cm.set(array);
  mColorMatrixFilter = new ColorMatrixColorFilter(cm);
  mMatrix = new Matrix();
  mScroller = new Scroller(getContext());
  mTouch.x = 0.01f; // 不让x,y为0,否则在点计算时会有问题
  mTouch.y = 0.01f;
  //Set today text
  calendarFactory.onDraw(mCurrentPageCanvas);
}

代码示例来源:origin: com.facebook.device.yearclass/yearclass

/**
 * Entry Point of YearClass. Extracts YearClass variable with memoizing.
 * Example usage:
 * <p>
 * <pre>
 *   int yearClass = YearClass.get(context);
 * </pre>
 */
public static int get(Context c) {
 if (mYearCategory == null) {
  synchronized(YearClass.class) {
   if (mYearCategory == null) {
    mYearCategory = categorizeByYear2016Method(c);
   }
  }
 }
 return mYearCategory;
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com