-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCorpFolderLoading.java
More file actions
99 lines (93 loc) · 2.5 KB
/
CorpFolderLoading.java
File metadata and controls
99 lines (93 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package Model;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import javax.imageio.ImageIO;
public class CorpFolderLoading
{
String path;
public String bgImage = "";
public String profileImage = "";
public String description = "";
public ArrayList<BufferedImage> img = new ArrayList<BufferedImage>();
public CorpFolderLoading(String s)
{
this.path = s.toLowerCase();
if(path != "")
{
try
{
final File folder = new File("lib/localsolarsystem/" + path);
openFolder(folder);
}
catch(Exception e)
{}
}
}
public void openFolder(final File folder)
{
for (final File fileEntry : folder.listFiles())
{
if (fileEntry.isDirectory())
{
openFolder(fileEntry);
}
else
{
checkBackgroundImg(fileEntry);
checkProfileImg(fileEntry);
checkDescription(fileEntry);
addImageToList(fileEntry);
}
}
}
void checkBackgroundImg(File file)
{
if(file.getName().equals("bg.png"))
{
bgImage = "lib/localsolarsystem/" + path + "/" + file.getName();
}
}
void checkProfileImg(File file)
{
if((file.getName().equals("profile.png"))||(file.getName().equals("profile.jpg")))
{
profileImage = "lib/localsolarsystem/" + path + "/" + file.getName();
}
}
void checkDescription(File file)
{
if(file.getName().equals("description.txt"))
{
try
{
BufferedReader in = new BufferedReader(new FileReader("lib/localsolarsystem/" + path + "/" + file.getName()));
String line;
while((line = in.readLine()) != null)
{
description += line;
}
in.close();
}
catch(Exception e)
{}
}
}
void addImageToList(File file)
{
boolean castOk = true;
BufferedImage imgToAdd = null;
try
{
imgToAdd = ImageIO.read(file);
}
catch(Exception e)
{
castOk = false;
}
if((castOk)&&(imgToAdd != null))
this.img.add(imgToAdd);
}
}