AlarmUtil
鬧鐘事件工具類MPUtils
短信電話工具類NetUtils
網絡狀態工具類PicUtils
圖片處理工具類ServiceUtils
服務工具類ImageHelper
圖型處理類DisplayUtils
數據轉換類SpUtils
Sp簡化工具類(可存儲list和map
)ToastUtils
Toast定製工具類ValidatorsUtils
正則表達式處理類PaintView
畫圖工具:特殊功能
:保存畫筆軌跡幀動畫
、幀動畫導入導出、ReDo和UnDo<com.lfk.justwetools.View.PaintIt.PaintView android:id="@+id/paintView" android:layout_width="match_parent" android:layout_height="match_parent" />
paintView = (PaintView)findViewById(R.id.paint);
須要新建數據集,設定紀錄paintview,而且設定onPathListener()html
pathNode = (PathNode)getApplication(); paintView.setIsRecordPath(true,pathNode); paintView.setOnPathListener(new OnPathListener() { @Override public void AddNodeToPath(float x, float y, int event, boolean IsPaint) { PathNode.Node tempnode = pathNode.new Node(); tempnode.x = x; tempnode.y = y; if (IsPaint) { tempnode.PenColor = UserInfo.PaintColor; tempnode.PenWidth = UserInfo.PaintWidth; } else { tempnode.EraserWidth = UserInfo.EraserWidth; } tempnode.IsPaint = IsPaint; Log.e(tempnode.PenColor + ":" + tempnode.PenWidth + ":" + tempnode.EraserWidth, tempnode.IsPaint + ""); tempnode.TouchEvent = event; tempnode.time = System.currentTimeMillis(); pathNode.AddNode(tempnode); } });
相關的教程和解析請看:PaintView 繪圖控件解析
圖例中出現的Demo: 圖例Demo
圖例中使用了兩個開源控件:
CircularFloatingActionMenu 和 android-ColorPickerPreferencejava
CodeView
代碼查看/修改工具:<com.lfk.justwetools.View.CodeView.CodeView android:id="@+id/mcodeview" android:layerType="hardware" android:layout_width="match_parent" android:layout_height="match_parent"/>
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文件。node
@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); }
<com.lfk.justwetools.View.FileExplorer.FileExplorer android:id="@+id/ex" android:layout_width="match_parent" android:layout_height="match_parent"/>
fileExplorer = (FileExplorer)findViewById(R.id.ex);
此時默認的打開路徑爲sd卡根目錄:
可經過以下修改:android
// 打開路徑 fileExplorer.setCurrentDir(Environment.getExternalStorageDirectory().getPath()); // 根路徑(能到達最深的路徑,以此避免用戶進入root路徑) fileExplorer.setRootDir(Environment.getExternalStorageDirectory().getPath());
Item的點擊事件:git
//覆蓋屏蔽原有長按事件 fileExplorer.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { return false; } }); //選擇文件 默認打開CodeView fileExplorer.setOnFileChosenListener(new OnFileChosenListener() { @Override public void onFileChosen(Uri fileUri) { Intent intent = new Intent(ExplorerActivity.this, CodeActivity.class); intent.setData(fileUri); startActivity(intent); } });
返回鍵返回上一級:github
@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 < 1000) finish(); exitTime = System.currentTimeMillis(); Toast.makeText(this, "再次點擊退出", Toast.LENGTH_SHORT).show(); } return true; } return super.onKeyDown(keyCode, event); }
高級功能
:根據文件夾內的各類文件類型的大小比例,分析比例圖,不建議在sd卡根目錄使用內容過多反應較慢.正則表達式
<com.lfk.justwetools.View.Proportionview.ProportionView android:id="@+id/pv" android:layout_margin="10dp" android:layout_width="match_parent" android:layout_height="30dp" />
final ProportionView view = (ProportionView) findViewById(R.id.pv);
註冊分析文件比例的接口:express
//新路徑下分析文件比例 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
保持一導致用簡便<com.lfk.justwetools.View.MarkDown.MarkDownView android:id="@+id/markdownview" android:layout_width="match_parent" android:layout_height="match_parent"> </com.lfk.justwetools.View.MarkDown.MarkDownView>
並添加:apache
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:<com.lfk.justwetools.View.VerText.VerTextView android:id="@+id/vertextview" android:layout_width="wrap_content" android:layout_height="wrap_content" />
並添加:瀏覽器
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繪製的時鐘<com.lfk.justwetools.View.Clock.Clock android:id="@+id/clock" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/flashTextView" android:layout_centerHorizontal="true" android:layout_marginTop="16dp" />
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.