Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ proguard/

# Log Files
*.log
.idea
Android-Skin-Loader.iml
1 change: 1 addition & 0 deletions android-skin-loader-lib/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
android-skin-loader-lib.iml
1 change: 1 addition & 0 deletions android-skin-loader-sample/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
android-skin-loader-sample.iml
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import android.widget.Toast;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import cn.feng.skin.demo.R;
import cn.feng.skin.manager.base.BaseActivity;
Expand Down Expand Up @@ -91,9 +94,31 @@ private void onSkinSetClick() {

File skin = new File(SKIN_DIR);

if(skin == null || !skin.exists()){
Toast.makeText(getApplicationContext(), "请检查" + SKIN_DIR + "是否存在", Toast.LENGTH_SHORT).show();
return;
if(!skin.exists()){
InputStream is = null;
FileOutputStream fos = null;
try {
is = getResources().getAssets().open(SKIN_NAME);
fos = new FileOutputStream(SKIN_DIR);
int bytesRead = 0;
byte[] buffer = new byte[1024 * 4];
while ((bytesRead = is.read(buffer, 0, 1024 * 4)) != -1) {
fos.write(buffer, 0, bytesRead);
}
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
if (is != null){
is.close();
}
if (fos != null){
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

SkinManager.getInstance().load(skin.getAbsolutePath(),
Expand Down
1 change: 1 addition & 0 deletions android-skin-loader-skin/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
android-skin-loader-skin.iml