-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30cd546
commit c451be8
Showing
15 changed files
with
202 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
filesearcher/src/main/java/com/will/filesearcher/file_searcher/FileDetail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package com.will.filesearcher.file_searcher; | ||
|
||
import java.io.File; | ||
import java.text.DecimalFormat; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
/** | ||
* Created by will on 2016/11/15. | ||
*/ | ||
|
||
public class FileDetail { | ||
private String name,path,size,lastModifiedTime; | ||
|
||
private File file; | ||
|
||
public FileDetail(File file){ | ||
this.file = file; | ||
name = file.getName(); | ||
path = file.getPath(); | ||
size = getSizeWithSuitableUnit(); | ||
lastModifiedTime = getLastModifiedTimeString(); | ||
} | ||
|
||
|
||
public File getFile() { | ||
return file; | ||
} | ||
|
||
public void setFile(File file) { | ||
this.file = file; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
|
||
public String getSize() { | ||
return size; | ||
} | ||
|
||
public String getLastModifiedTime() { | ||
return lastModifiedTime; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public void setLastModifiedTime(String lastModifiedTime) { | ||
this.lastModifiedTime = lastModifiedTime; | ||
} | ||
|
||
public void setSize(String size) { | ||
this.size = size; | ||
} | ||
|
||
public void setPath(String path) { | ||
this.path = path; | ||
} | ||
|
||
private String getSizeWithSuitableUnit(){ | ||
float fileSize = file.length(); | ||
int kb = 1; | ||
int mb = 2; | ||
int gb = 3; | ||
int i = 0; | ||
String unit = ""; | ||
while(fileSize >= 1024){ | ||
fileSize = fileSize / 1024; | ||
i++; | ||
} | ||
DecimalFormat format = new DecimalFormat("#.##"); | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append(format.format(fileSize)); | ||
if(i == 0){ | ||
unit = "byte"; | ||
}else if(i == kb){ | ||
unit = "kb"; | ||
}else if(i == mb){ | ||
unit = "mb"; | ||
}else if(i == gb){ | ||
unit = "gb"; | ||
} | ||
builder.append(unit); | ||
return builder.toString(); | ||
} | ||
private String getLastModifiedTimeString(){ | ||
Date date = new Date(file.lastModified()); | ||
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd,HH:mm:ss"); | ||
return format.format(date); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,53 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_height="wrap_content" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
app:cardUseCompatPadding="true"> | ||
app:cardUseCompatPadding="true" | ||
app:cardCornerRadius="5dp" | ||
app:contentPadding="5dp" | ||
app:cardElevation="4dp"> | ||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
<TextView | ||
android:id="@+id/file_searcher_item_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
<ImageView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:maxLines="1" | ||
android:ellipsize="marquee" | ||
style="@style/FileSearcherItemTextAppearance" | ||
tools:text="Name: abcde.txt"/> | ||
<TextView | ||
android:id="@+id/file_searcher_item_location" | ||
android:layout_width="match_parent" | ||
android:src="@drawable/icon" | ||
android:visibility="gone"/> | ||
<LinearLayout | ||
android:layout_width="0dp" | ||
android:layout_weight="1" | ||
android:layout_height="wrap_content" | ||
style="@style/FileSearcherItemTextAppearance" | ||
tools:text="Location: C:\Users\will\Desktop"/> | ||
<TextView | ||
android:id="@+id/file_searcher_item_size" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
style="@style/FileSearcherItemTextAppearance" | ||
tools:text="Size: 14.1 MB (14,887,654 字节)" | ||
/> | ||
<TextView | ||
android:id="@+id/file_searcher_item_create_time" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
style="@style/FileSearcherItemTextAppearance" | ||
tools:text="Create Time: 2016年11月10日,15:34:47" | ||
/> | ||
android:orientation="vertical"> | ||
<TextView | ||
android:id="@+id/file_searcher_item_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:maxLines="2" | ||
style="@style/FileSearcherItemTextAppearance" | ||
tools:text="Name: abcde.txt"/> | ||
<TextView | ||
android:id="@+id/file_searcher_item_location" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
style="@style/FileSearcherItemTextAppearance" | ||
tools:text="Location: C:\Users\will\Desktop"/> | ||
<TextView | ||
android:id="@+id/file_searcher_item_size" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
style="@style/FileSearcherItemTextAppearance" | ||
tools:text="Size: 14.1 MB (14,887,654 字节)" | ||
/> | ||
<TextView | ||
android:id="@+id/file_searcher_item_create_time" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
style="@style/FileSearcherItemTextAppearance" | ||
tools:text="Create Time: 2016年11月10日,15:34:47" | ||
/> | ||
</LinearLayout> | ||
</LinearLayout> | ||
</android.support.v7.widget.CardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.