Commit 06ab4a0f authored by 赵鹏翔's avatar 赵鹏翔

日志相关数据模型转换成kotlin

parent 970ba942
package com.miya.fastcashier.log;
import java.io.File;
import java.io.FileFilter;
/**
* 作者:Leon
* 时间:2017/3/24 13:43
*/
public class LFileFilter implements FileFilter {
private String[] mTypes;
public LFileFilter(String[] types) {
this.mTypes = types;
}
@Override
public boolean accept(File file) {
if (file.isDirectory()) {
return true;
}
if (mTypes != null && mTypes.length > 0) {
for (int i = 0; i < mTypes.length; i++) {
if (file.getName().endsWith(mTypes[i].toLowerCase()) || file.getName().endsWith(mTypes[i].toUpperCase())) {
return true;
}
}
}else {
return true;
}
return false;
}
}
package com.miya.fastcashier.log
import java.io.File
import java.io.FileFilter
/**
* 作者:Leon
* 时间:2017/3/24 13:43
*/
class LFileFilter(private val mTypes: Array<String>?) : FileFilter {
override fun accept(file: File): Boolean {
if (file.isDirectory) {
return true
}
if (mTypes != null && mTypes.size > 0) {
for (i in mTypes.indices) {
if (file.name.endsWith(mTypes[i].toLowerCase()) || file.name.endsWith(mTypes[i].toUpperCase())) {
return true
}
}
} else {
return true
}
return false
}
}
\ No newline at end of file
package com.miya.fastcashier.log; package com.miya.fastcashier.log
import android.app.Activity; import android.app.Activity
import android.app.Fragment; import android.app.Fragment
import android.content.Intent; import android.content.Intent
import android.os.Bundle; import android.os.Bundle
import androidx.annotation.StyleRes
import com.miya.fastcashier.R; import com.miya.fastcashier.R
import androidx.annotation.NonNull;
import androidx.annotation.StyleRes;
/** /**
* 作者:Leon * 作者:Leon
* 时间:2017/3/20 16:57 * 时间:2017/3/20 16:57
*/ */
public class LFilePicker { class LFilePicker {
private Activity mActivity; private var mActivity: Activity? = null
private Fragment mFragment; private var mFragment: Fragment? = null
private String mTitle; private var mTitle: String? = null
private String mTitleColor; private var mTitleColor: String? = null
private int theme = R.style.LFileTheme; private var theme = R.style.LFileTheme
private int mTitleStyle = R.style.LFileToolbarTextStyle; private var mTitleStyle = R.style.LFileToolbarTextStyle
private String mBackgroundColor; private var mBackgroundColor: String? = null
private int mBackStyle; private var mBackStyle = 0
private int mRequestCode; private var mRequestCode = 0
private boolean mMutilyMode = true; private var mMutilyMode = true
private boolean mChooseMode = true; private var mChooseMode = true
private String mAddText; private var mAddText: String? = null
private int mIconStyle; private var mIconStyle = 0
private String[] mFileTypes; private var mFileTypes: Array<String>? = null
private String mNotFoundFiles; private var mNotFoundFiles: String? = null
private int mMaxNum; private var mMaxNum = 0
private String mStartPath; private var mStartPath: String? = null
private boolean mIsGreater = true;//是否大于 private var mIsGreater = true //是否大于
private long mFileSize; private var mFileSize: Long = 0
private String mFileName; private var mFileName: String? = null
/** /**
* 绑定Activity * 绑定Activity
...@@ -42,9 +39,9 @@ public class LFilePicker { ...@@ -42,9 +39,9 @@ public class LFilePicker {
* @param activity * @param activity
* @return * @return
*/ */
public LFilePicker withActivity(Activity activity) { fun withActivity(activity: Activity?): LFilePicker {
this.mActivity = activity; mActivity = activity
return this; return this
} }
/** /**
...@@ -53,9 +50,9 @@ public class LFilePicker { ...@@ -53,9 +50,9 @@ public class LFilePicker {
* @param fragment * @param fragment
* @return * @return
*/ */
public LFilePicker withFragment(Fragment fragment) { fun withFragment(fragment: Fragment?): LFilePicker {
this.mFragment = fragment; mFragment = fragment
return this; return this
} }
/** /**
...@@ -64,9 +61,9 @@ public class LFilePicker { ...@@ -64,9 +61,9 @@ public class LFilePicker {
* @param title * @param title
* @return * @return
*/ */
public LFilePicker withTitle(String title) { fun withTitle(title: String?): LFilePicker {
this.mTitle = title; mTitle = title
return this; return this
} }
/** /**
...@@ -75,10 +72,10 @@ public class LFilePicker { ...@@ -75,10 +72,10 @@ public class LFilePicker {
* @param color * @param color
* @return * @return
*/ */
@Deprecated @Deprecated("")
public LFilePicker withTitleColor(String color) { fun withTitleColor(color: String?): LFilePicker {
this.mTitleColor = color; mTitleColor = color
return this; return this
} }
/** /**
...@@ -87,9 +84,9 @@ public class LFilePicker { ...@@ -87,9 +84,9 @@ public class LFilePicker {
* @param theme * @param theme
* @return * @return
*/ */
public LFilePicker withTheme(@StyleRes int theme) { fun withTheme(@StyleRes theme: Int): LFilePicker {
this.theme = theme; this.theme = theme
return this; return this
} }
/** /**
...@@ -98,9 +95,9 @@ public class LFilePicker { ...@@ -98,9 +95,9 @@ public class LFilePicker {
* @param style * @param style
* @return * @return
*/ */
public LFilePicker withTitleStyle(@StyleRes int style) { fun withTitleStyle(@StyleRes style: Int): LFilePicker {
this.mTitleStyle = style; mTitleStyle = style
return this; return this
} }
/** /**
...@@ -109,9 +106,9 @@ public class LFilePicker { ...@@ -109,9 +106,9 @@ public class LFilePicker {
* @param color * @param color
* @return * @return
*/ */
public LFilePicker withBackgroundColor(String color) { fun withBackgroundColor(color: String?): LFilePicker {
this.mBackgroundColor = color; mBackgroundColor = color
return this; return this
} }
/** /**
...@@ -120,9 +117,9 @@ public class LFilePicker { ...@@ -120,9 +117,9 @@ public class LFilePicker {
* @param requestCode * @param requestCode
* @return * @return
*/ */
public LFilePicker withRequestCode(int requestCode) { fun withRequestCode(requestCode: Int): LFilePicker {
this.mRequestCode = requestCode; mRequestCode = requestCode
return this; return this
} }
/** /**
...@@ -131,10 +128,10 @@ public class LFilePicker { ...@@ -131,10 +128,10 @@ public class LFilePicker {
* @param backStyle * @param backStyle
* @return * @return
*/ */
public LFilePicker withBackIcon(int backStyle) { fun withBackIcon(backStyle: Int): LFilePicker {
this.mBackStyle = 0;//默认样式 mBackStyle = 0 //默认样式
this.mBackStyle = backStyle; mBackStyle = backStyle
return this; return this
} }
/** /**
...@@ -143,9 +140,9 @@ public class LFilePicker { ...@@ -143,9 +140,9 @@ public class LFilePicker {
* @param isMutily * @param isMutily
* @return * @return
*/ */
public LFilePicker withMutilyMode(boolean isMutily) { fun withMutilyMode(isMutily: Boolean): LFilePicker {
this.mMutilyMode = isMutily; mMutilyMode = isMutily
return this; return this
} }
/** /**
...@@ -154,9 +151,9 @@ public class LFilePicker { ...@@ -154,9 +151,9 @@ public class LFilePicker {
* @param text * @param text
* @return * @return
*/ */
public LFilePicker withAddText(String text) { fun withAddText(text: String?): LFilePicker {
this.mAddText = text; mAddText = text
return this; return this
} }
/** /**
...@@ -165,14 +162,14 @@ public class LFilePicker { ...@@ -165,14 +162,14 @@ public class LFilePicker {
* @param style * @param style
* @return * @return
*/ */
public LFilePicker withIconStyle(int style) { fun withIconStyle(style: Int): LFilePicker {
this.mIconStyle = style; mIconStyle = style
return this; return this
} }
public LFilePicker withFileFilter(String[] arrs) { fun withFileFilter(arrs: Array<String>): LFilePicker {
this.mFileTypes = arrs; mFileTypes = arrs
return this; return this
} }
/** /**
...@@ -181,9 +178,9 @@ public class LFilePicker { ...@@ -181,9 +178,9 @@ public class LFilePicker {
* @param notFoundFiles * @param notFoundFiles
* @return * @return
*/ */
public LFilePicker withNotFoundBooks(String notFoundFiles) { fun withNotFoundBooks(notFoundFiles: String?): LFilePicker {
this.mNotFoundFiles = notFoundFiles; mNotFoundFiles = notFoundFiles
return this; return this
} }
/** /**
...@@ -192,9 +189,9 @@ public class LFilePicker { ...@@ -192,9 +189,9 @@ public class LFilePicker {
* @param num * @param num
* @return * @return
*/ */
public LFilePicker withMaxNum(int num) { fun withMaxNum(num: Int): LFilePicker {
this.mMaxNum = num; mMaxNum = num
return this; return this
} }
/** /**
...@@ -203,21 +200,20 @@ public class LFilePicker { ...@@ -203,21 +200,20 @@ public class LFilePicker {
* @param fileName * @param fileName
* @return * @return
*/ */
public LFilePicker withFileName(String fileName) { fun withFileName(fileName: String?): LFilePicker {
this.mFileName = fileName; mFileName = fileName
return this; return this
} }
/** /**
* 设置初始显示路径 * 设置初始显示路径
* *
* @param path * @param path
* @return * @return
*/ */
public LFilePicker withStartPath(String path) { fun withStartPath(path: String?): LFilePicker {
this.mStartPath = path; mStartPath = path
return this; return this
} }
/** /**
...@@ -226,9 +222,9 @@ public class LFilePicker { ...@@ -226,9 +222,9 @@ public class LFilePicker {
* @param chooseMode * @param chooseMode
* @return * @return
*/ */
public LFilePicker withChooseMode(boolean chooseMode) { fun withChooseMode(chooseMode: Boolean): LFilePicker {
this.mChooseMode = chooseMode; mChooseMode = chooseMode
return this; return this
} }
/** /**
...@@ -237,9 +233,9 @@ public class LFilePicker { ...@@ -237,9 +233,9 @@ public class LFilePicker {
* @param isGreater true:大于 ;false:小于,同时包含指定大小在内 * @param isGreater true:大于 ;false:小于,同时包含指定大小在内
* @return * @return
*/ */
public LFilePicker withIsGreater(boolean isGreater) { fun withIsGreater(isGreater: Boolean): LFilePicker {
this.mIsGreater = isGreater; mIsGreater = isGreater
return this; return this
} }
/** /**
...@@ -248,59 +244,57 @@ public class LFilePicker { ...@@ -248,59 +244,57 @@ public class LFilePicker {
* @param fileSize * @param fileSize
* @return * @return
*/ */
public LFilePicker withFileSize(long fileSize) { fun withFileSize(fileSize: Long): LFilePicker {
this.mFileSize = fileSize; mFileSize = fileSize
return this; return this
} }
public void start() { fun start() {
if (mActivity == null && mFragment == null) { if (mActivity == null && mFragment == null) {
throw new RuntimeException("You must pass Activity or Fragment by withActivity or withFragment or withSupportFragment method"); throw RuntimeException("You must pass Activity or Fragment by withActivity or withFragment or withSupportFragment method")
} }
Intent intent = initIntent(); val intent = initIntent()
Bundle bundle = getBundle(); val bundle = bundle
intent.putExtras(bundle); intent.putExtras(bundle)
if (mActivity != null) { if (mActivity != null) {
mActivity.startActivityForResult(intent, mRequestCode); mActivity!!.startActivityForResult(intent, mRequestCode)
} else { } else {
mFragment.startActivityForResult(intent, mRequestCode); mFragment!!.startActivityForResult(intent, mRequestCode)
} }
} }
private fun initIntent(): Intent {
private Intent initIntent() { val intent: Intent
Intent intent; intent = if (mActivity != null) {
if (mActivity != null) { Intent(mActivity, LFilePickerActivity::class.java)
intent = new Intent(mActivity, LFilePickerActivity.class);
} else { } else {
intent = new Intent(mFragment.getActivity(), LFilePickerActivity.class); Intent(mFragment!!.activity, LFilePickerActivity::class.java)
} }
return intent; return intent
} }
@NonNull private val bundle: Bundle
private Bundle getBundle() { private get() {
ParamEntity paramEntity = new ParamEntity(); val paramEntity = ParamEntity()
paramEntity.setTitle(mTitle); paramEntity.title = mTitle
paramEntity.setTheme(theme); paramEntity.theme = theme
paramEntity.setTitleColor(mTitleColor); paramEntity.titleColor = mTitleColor
paramEntity.setTitleStyle(mTitleStyle); paramEntity.titleStyle = mTitleStyle
paramEntity.setBackgroundColor(mBackgroundColor); paramEntity.backgroundColor = mBackgroundColor
paramEntity.setBackIcon(mBackStyle); paramEntity.backIcon = mBackStyle
paramEntity.setMutilyMode(mMutilyMode); paramEntity.isMutilyMode = mMutilyMode
paramEntity.setAddText(mAddText); paramEntity.addText = mAddText
paramEntity.setIconStyle(mIconStyle); paramEntity.iconStyle = mIconStyle
paramEntity.setFileTypes(mFileTypes); paramEntity.fileTypes = mFileTypes
paramEntity.setNotFoundFiles(mNotFoundFiles); paramEntity.notFoundFiles = mNotFoundFiles
paramEntity.setMaxNum(mMaxNum); paramEntity.maxNum = mMaxNum
paramEntity.setChooseMode(mChooseMode); paramEntity.isChooseMode = mChooseMode
paramEntity.setPath(mStartPath); paramEntity.path = mStartPath
paramEntity.setFileSize(mFileSize); paramEntity.fileSize = mFileSize
paramEntity.setFileName(mFileName); paramEntity.fileName = mFileName
paramEntity.setGreater(mIsGreater); paramEntity.isGreater = mIsGreater
Bundle bundle = new Bundle(); val bundle = Bundle()
bundle.putSerializable("param", paramEntity); bundle.putSerializable("param", paramEntity)
return bundle; return bundle
} }
} }
\ No newline at end of file
package com.miya.fastcashier.log;
import java.io.Serializable;
/**
* 作者:Leon
* 时间:2017/3/21 14:50
*/
public class ParamEntity implements Serializable {
private String title;
private String titleColor;
private int titleStyle ;
private int theme ;
private String backgroundColor;
private int backIcon;
private boolean mutilyMode;
private String addText;
private int iconStyle;
private String[] fileTypes;
private String notFoundFiles;
private int maxNum;
private boolean chooseMode = true;
private String path;
private long fileSize;
private boolean isGreater;
private String fileName;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Deprecated
public String getTitleColor() {
return titleColor;
}
@Deprecated
public void setTitleColor(String titleColor) {
this.titleColor = titleColor;
}
public int getTheme() {
return theme;
}
public void setTheme(int theme) {
this.theme = theme;
}
public int getTitleStyle() {
return titleStyle;
}
public void setTitleStyle(int titleStyle) {
this.titleStyle = titleStyle;
}
public String getBackgroundColor() {
return backgroundColor;
}
public void setBackgroundColor(String backgroundColor) {
this.backgroundColor = backgroundColor;
}
public boolean isMutilyMode() {
return mutilyMode;
}
public void setMutilyMode(boolean mutilyMode) {
this.mutilyMode = mutilyMode;
}
public int getBackIcon() {
return backIcon;
}
public void setBackIcon(int backIcon) {
this.backIcon = backIcon;
}
public String getAddText() {
return addText;
}
public void setAddText(String addText) {
this.addText = addText;
}
public int getIconStyle() {
return iconStyle;
}
public void setIconStyle(int iconStyle) {
this.iconStyle = iconStyle;
}
public String[] getFileTypes() {
return fileTypes;
}
public void setFileTypes(String[] fileTypes) {
this.fileTypes = fileTypes;
}
public String getNotFoundFiles() {
return notFoundFiles;
}
public void setNotFoundFiles(String notFoundFiles) {
this.notFoundFiles = notFoundFiles;
}
public int getMaxNum() {
return maxNum;
}
public void setMaxNum(int maxNum) {
this.maxNum = maxNum;
}
public boolean isChooseMode() {
return chooseMode;
}
public void setChooseMode(boolean chooseMode) {
this.chooseMode = chooseMode;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public long getFileSize() {
return fileSize;
}
public void setFileSize(long fileSize) {
this.fileSize = fileSize;
}
public boolean isGreater() {
return isGreater;
}
public void setGreater(boolean greater) {
isGreater = greater;
}
}
package com.miya.fastcashier.log
import java.io.Serializable
/**
* 作者:Leon
* 时间:2017/3/21 14:50
*/
class ParamEntity : Serializable {
var title: String? = null
@get:Deprecated("")
@set:Deprecated("")
var titleColor: String? = null
var titleStyle = 0
var theme = 0
var backgroundColor: String? = null
var backIcon = 0
var isMutilyMode = false
var addText: String? = null
var iconStyle = 0
var fileTypes: Array<String>? = null
var notFoundFiles: String? = null
var maxNum = 0
var isChooseMode = true
var path: String? = null
var fileSize: Long = 0
var isGreater = false
var fileName: String? = null
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment