Alerter.create(this@DemoActivity)
.setTitle("Alert Title")
.setText("The alert scales to accommodate larger bodies of text. " +
"The alert scales to accommodate larger bodies of text. " +
"The alert scales to accommodate larger bodies of text.")
.show()
@Override public void onCreate() { super.onCreate(); Config config = new Config.Builder() .isShowInternalDialog(false) .build(this); UpdateManager.getInstance().init(config); } }
自定义对话框,如下(详细代码在MainActivity.java里):
public void registerUpdateCallbak() { mCallback = new IUpdateCallback() { @Override public void noNewApp() { Toast.makeText(MainActivity.this, "当前已是最新版本!", Toast.LENGTH_LONG).show(); }
@Override public void hasNewApp(AppUpdateModel appUpdateModel, UpdateManager updateManager, final int updateMethod) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); mDialog = builder.setTitle("自动更新提示") .setMessage(appUpdateModel.getTip()) .setPositiveButton("更新", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { UpdateManager.getInstance().startUpdate(updateMethod); } }) .setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {
} }).create(); mDialog.show(); }
@Override public void beforeUpdate() { // 更新开始 mProgressDialog = new ProgressDialog(MainActivity.this); mProgressDialog.setTitle("更新中..."); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setMessage("正在玩命更新中..."); mProgressDialog.setMax(100); mProgressDialog.setProgress(0); mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { // 退到后台自动更新,进度由通知栏显示 if (UpdateManager.getInstance().isRunning()) { UpdateManager.getInstance().onBackgroundTrigger(); } } }); mProgressDialog.show(); }
@Override public void onProgress(int percent, long totalLength, int patchIndex, int patchCount) { String tip; if (patchCount > 0) { tip = String.format("正在下载补丁%d/%d", patchIndex, patchCount); } else { tip = "正在下载更新中..."; } mProgressDialog.setProgress(percent); mProgressDialog.setMessage(tip); }
@Override public void onCompleted() { mProgressDialog.dismiss(); }
add_library( # Sets the name of the library. update-lib # Sets the library as a shared library. SHARED # Provides a relative path to your source file(s). ${NATIVE_SRC})
appenderOpen(int level, int mode, String cacheDir, String logDir, String nameprefix, int cacheDays, String pubkey)
level
日志级别 没啥好说的 XLog 中已经写得很清楚了
public static final int LEVEL_ALL = 0; public static final int LEVEL_VERBOSE = 0; public static final int LEVEL_DEBUG = 1; public static final int LEVEL_INFO = 2; public static final int LEVEL_WARNING = 3; public static final int LEVEL_ERROR = 4; public static final int LEVEL_FATAL = 5; public static final int LEVEL_NONE = 6;
/* * By default, all logs will write to one file everyday. You can split logs to multi-file by changing max_file_size. * * @param _max_byte_size Max byte size of single log file, default is 0, meaning do not split. */ void appender_set_max_file_size(uint64_t _max_byte_size);
$ python gen_key.py WARNING: Executing a script that is loading libcrypto in an unsafe way. This will fail in a future version of macOS. Set the LIBRESSL_REDIRECT_STUB_ABORT=1in the environment toforce this into an error. saveprivatekey 471e607b1bb3760205f74a5e53d2764f795601e241ebc780c849e7fde1b4ce40
debugImplementation'com.github.smartbackme.SimpleInterceptor:simpleinterceptor-debug:3.0' releaseImplementation'com.github.smartbackme.SimpleInterceptor:simpleinterceptor-release:3.0' } or
<devs.mulham.horizontalcalendar.HorizontalCalendarView android:id="@+id/calendarView" android:layout_width="match_parent" android:layout_height="wrap_content" app:textColorNormal="#bababa" app:textColorSelected="#FFFF" app:selectorColor="#c62828"//default to colorAccent app:selectedDateBackground="@drawable/myDrawable"/>
Activity 或者 Fragment 使用 HorizontalCalendar.Builder:
HorizontalCalendar horizontalCalendar =newHorizontalCalendar.Builder(this, R.id.calendarView)
.range(Calendar startDate, Calendar endDate)
.datesNumberOnScreen(intnumber) // Number of Dates cells shown on screen (default to 5).
.configure() // starts configuration.
.formatTopText(String dateFormat) // default to "MMM".
.formatMiddleText(String dateFormat) // default to "dd".
.formatBottomText(String dateFormat) // default to "EEE".
.showTopText(boolean show) // show or hide TopText (default to true).
.showBottomText(boolean show) // show or hide BottomText (default to true).
.textColor(int normalColor, int selectedColor) // default to (Color.LTGRAY, Color.WHITE).
.selectedDateBackground(Drawable background) // set selected date cell background.
.selectorColor(int color) // set selection indicator bar's color (default to colorAccent).
.end() // ends configuration.
.defaultSelectedDate(Calendar date) // Date to be selected at start (default to current day `Calendar.getInstance()`).
.build();
更多的自定义
builder.configure()
.textSize(float topTextSize, float middleTextSize, float bottomTextSize)
.sizeTopText(float size)
.sizeMiddleText(float size)
.sizeBottomText(float size)
.colorTextTop(int normalColor, int selectedColor)
.colorTextMiddle(int normalColor, int selectedColor)
.colorTextBottom(int normalColor, int selectedColor)
.end()
builder.disableDates(newHorizontalCalendarPredicate() { @Override publicbooleantest(Calendardate){ returnfalse; // return true if this date should be disabled, false otherwise.
}
@Override publicCalendarItemStylestyle(){ returnnull; // create and return a new Style for disabled dates, or null if no styling needed.
}
})
app:left_cell_width //left header cell's width, not support wrap_content app:normal_cell_width //container cell's width, not support wrap_content app:top_cell_height //top header cell's height, not support wrap_content
2、定义自定义适配器
适配器必须扩展BaseExcelPanelAdapter并重写七个方法,如下所示:
public class Adapter extends BaseExcelPanelAdapter<RowTitle, ColTitle, Cell>{
public Adapter(Context context) { super(context); }
//=========================================normal cell========================================= @Override public RecyclerView.ViewHolder onCreateCellViewHolder(ViewGroup parent, int viewType) { return null; }
@Override public void onBindCellViewHolder(RecyclerView.ViewHolder holder, int verticalPosition, int horizontalPosition) {
}
//=========================================top cell=========================================== @Override public RecyclerView.ViewHolder onCreateTopViewHolder(ViewGroup parent, int viewType) { return null; }
@Override public void onBindTopViewHolder(RecyclerView.ViewHolder holder, int position) {
}
//=========================================left cell=========================================== @Override public RecyclerView.ViewHolder onCreateLeftViewHolder(ViewGroup parent, int viewType) { return null; }
@Override public void onBindLeftViewHolder(RecyclerView.ViewHolder holder, int position) {
}
//=========================================top left cell======================================= @Override public View onCreateTopLeftView() { return null; } }
3、使用你的适配器
//============================== private List<RowTitle> rowTitles; private List<ColTitle> colTitles; private List<List<Cell>> cells; private ExcelPanel excelPanel; private CustomAdapter adapter; private View.OnClickListener blockListener //.......................................... excelPanel = (ExcelPanel) findViewById(R.id.content_container); adapter = new CustomAdapter(this, blockListener); excelPanel.setAdapter(adapter); excelPanel.setOnLoadMoreListener(this);//your Activity or Fragment implement ExcelPanel.OnLoadMoreListener adapter.setAllData(colTitles, rowTitles, cells); adapter.enableFooter();//load more, you can also call disableFooter()----default adapter.enableHeader();//load history, you can also call disableHeader()----default
//索引
public int index;
// 图片的类型
public Object photoObj;
// 在屏幕上的位置
public int[] locOnScreen = new int[]{-1, -1};
// 图片的宽
public int photoWidth = 0;
// 图片的高
public int photoHeight = 0;
// ImageView的宽
public int imageWidth = 0;
// ImageView的高
public int imageHeight = 0;
// ImageView的缩放类型
public ImageView.ScaleType scaleType;
主要包括:缓存(图片缓存、预取缓存、网络缓存)、公共View(下拉及底部加载更多ListView、底部加载更多ScrollView、滑动一页Gallery)及Android常用工具类(网络、下载、Android资源操作、shell、文件、Json、随机数、Collection等等)。 示例源码:TrineaAndroidDemo。 使 用:拉取代码导入IDE,右击你的工程->properties->Android,在library中选择TrineaAndroidCommon。 Api Guide:TrineaAndroidCommon API Guide。
Dev Tools App
The Dev Tools App is a powerful android development tool that can help you improve efficiency greatly, It can be used to view the latest open source projects, view activity history, view manifest, decompile, color picker, extract apk or so, view app info, open or close the options in the developer options quickly, and more.
public synchronized static void init(Context context, ThreadPoolExecutor tpe) throws HandlerException {
Set<String> routerMap;
// It will rebuild router map every times when debuggable.
if (ARouter.debuggable() || PackageUtils.isNewVersion(context)) {
// These class was generated by arouter-compiler.
routerMap = ClassUtils.getFileNameByPackageName(mContext, ROUTE_ROOT_PAKCAGE);
if (!routerMap.isEmpty()) {
context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE).edit().putStringSet(AROUTER_SP_KEY_MAP, routerMap).apply();
}
PackageUtils.updateVersion(context); // Save new version name when router map update finishes.
} else {
routerMap = new HashSet<>(context.getSharedPreferences(AROUTER_SP_CACHE_KEY, Context.MODE_PRIVATE).getStringSet(AROUTER_SP_KEY_MAP, new HashSet<String>()));
}
for (String className : routerMap) {
if (className.startsWith(ROUTE_ROOT_PAKCAGE + DOT + SDK_NAME + SEPARATOR + SUFFIX_ROOT)) {
// This one of root elements, load root.
((IRouteRoot) (Class.forName(className).getConstructor().newInstance())).loadInto(Warehouse.groupsIndex);
}
......
}
}
//模拟数据,实际开发中一般是从后台获取数据
userList = new ArrayList<>();
for (int i = 0; i < 20; i++) {
userList.add(new User("http://img2.imgtn.bdimg.com/it/u=3749323882,846155126&fm=26&gp=0.jpg",
"第" + i + "条"));
}
curveGraphView.configure(
new CurveGraphConfig.Builder(this)
.setAxisColor(R.color.Blue) // Set X and Y axis line color stroke.
.setIntervalDisplayCount(7) // Setnumberofvaluesto be displayed in X ax
.setGuidelineCount(2) // Setnumberof background guidelines to be shown.
.setGuidelineColor(R.color.GreenYellow) // Set color of the visible guidelines.
.setNoDataMsg(" No Data ") // Message whennodatais provided to the view.
.setxAxisScaleTextColor(R.color.Black) // Set X axis scale text color.
.setyAxisScaleTextColor(R.color.Black) // Set Y axis scale text color
.build()
););
val rgb = color.asRgb() val argb = color.asArgb() val hex = color.asHex() val hsl = color.asHsl() val hsla = color.asHsla() val hsv = color.asHsv() val cmyk = color.asCmyk()
val colorInt = colorHsl.asColorInt() val rgb = colorHsl.asRgb() val argb = colorHsl.asArgb() val hex = colorHsl.asHex() val cmyk = colorHsl.asCmyk() val hsla = colorHsl.asHsla() val hsv = colorHsl.asHsv()