一些有用的工具
View自定义控件
Utils工具类
AlarmUtil 闹钟事件工具类MPUtils 短信电话工具类NetUtils 网络状态工具类PicUtils 图片处理工具类ServiceUtils 服务工具类ImageHelper 图型处理类 DisplayUtils 数据转换类SpUtils Sp简化工具类(可存储list和map)ToastUtils Toast定制工具类ValidatorsUtils 正则表达式处理类##模块如何使用:
将Demo作为library加入项目,或是直接将代码拷入
使用Gradle构建:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
compile 'com.github.lfkdsk:JustWeTools:v1.0'
}
使用Maven构建:
jitpack.io
https://jitpack.io
com.github.lfkdsk
JustWeTools
v1.0
PaintView画图工具:特殊功能:保存画笔轨迹帧动画、帧动画导入导出、ReDo和UnDo paintView = (PaintView)findViewById(R.id.paint);需要新建数据集,设定纪录paintview,并且设定onPathListener()
…相关的教程和解析请看:PaintView 绘图控件解析
图例中出现的Demo: 图例Demo
图例中使用了两个开源控件:
CircularFloatingActionMenu 和 android-ColorPickerPreference
####CodeView代码查看/修改工具:
codeView = (CodeView)findViewById(R.id.mcodeview);
File dir = null;
Uri fileUri = getIntent().getData();
if (fileUri != null) {
dir = new File(fileUri.getPath());
}
if (dir != null) {
codeView.setDirSource(dir);
getSupportActionBar().setSubtitle(dir.getName());
}
else
finish();如果是手动复制代码的话,需要复制assests文件夹下的js文件。
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (item.getItemId() == R.id.action_code) {
if (!codeView.isEditable()) {
item.setTitle("完成");
codeView.setContentEditable(true);
} else {
item.setTitle("编辑");
codeView.setContentEditable(false);
}
}
return super.onOptionsItemSelected(item);
}
fileExplorer = (FileExplorer)findViewById(R.id.ex);
此时默认的打开路径为sd卡根目录: 可通过如下修改:
// 打开路径
fileExplorer.setCurrentDir(Environment.getExternalStorageDirectory().getPath());
// 根路径(能到达最深的路径,以此避免用户进入root路径)
fileExplorer.setRootDir(Environment.getExternalStorageDirectory().getPath());
Item的点击事件:
…返回键返回上一级:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK
&& event.getAction() == KeyEvent.ACTION_DOWN) {
if(!fileExplorer.toParentDir()){
if(System.currentTimeMillis() - exitTime
final ProportionView view = (ProportionView) findViewById(R.id.pv);
注册分析文件比例的接口:
//新路径下分析文件比例
fileExplorer.setOnPathChangedListener(new OnPathChangedListener() {
@Override
public void onPathChanged(String path) {
try {
view.setData(fileExplorer.getPropotionText(path));
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "此路径下不可访问或文件夹下无文件", Toast.LENGTH_LONG).show();
}
}
});
ReadView小说阅读:
ReadView readView = new ReadView(this,dir.getPath());
setContentView(readView);
File dir = null;
Uri fileUri = getIntent().getData();
if (fileUri != null) {
dir = new File(fileUri.getPath());
}
readView = null;
if (dir != null) {
readView = new ReadView(this,dir.getPath());
}
else
finish();
setContentView(readView);
MarkDownView支持MarkDown语法的渲染器:CodeView保持一致使用简便
并添加:
MarkDownView markDownView = (MarkDownView)findViewById(R.id.markdownview);
if(getIntent().getStringExtra("str") != null){
markDownView.setStringSource(getIntent().getStringExtra("str"));
}
File dir = null;
Uri fileUri = getIntent().getData();
if (fileUri != null) {
dir = new File(fileUri.getPath());
}
if (dir != null) {
markDownView.setDirSource(dir);
}
VerTextView竖行排版的TextView:
并添加:
VerTextView verTextView = (VerTextView)findViewById(R.id.vertextview);
verTextView.setText(getResources().getString(R.string.poem));
verTextView.setFontSize(100); // 设定字体尺寸
verTextView.setIsOpenUnderLine(true); // 设定开启下划线
verTextView.setUnderLineColor(Color.RED); // 设定下划线颜色
verTextView.setUnderLineWidth(3); // 设定下划线宽度
verTextView.setUnderLineSpacing(10); // 设定下划线到字的间距
verTextView.setTextStartAlign(VerTextView.RIGHT); // 从右侧或左侧开始排版
verTextView.setTextColor(color); // 设定字体颜色
...
Clock 绘制时钟:自定义View绘制的时钟
void setColor(int color);
void setNeedleColor(int needleColor);
void setTextColor(int textColor);
void setCircleColor(int circleColor);
void setUnthehourLineColor(int unthehourLineColor);
void setThehourLineColor(int thehourLineColor);
void setHourSize(int hourSize);
...
在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流
Copyright 2015 [刘丰恺](http://www.cnblogs.com/lfk-dsk/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.暂无开放 Issues,或尚未同步最近议题。