Skip to content

Commit

Permalink
Revert SampleActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
vinsentli committed Dec 22, 2024
1 parent 4944651 commit 23e12c1
Showing 1 changed file with 0 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,21 @@
package com.facebook.igl.shell;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.SurfaceView;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

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

public class SampleActivity extends Activity implements View.OnClickListener {
// UI
LinearLayout mMainView;
LinearLayout mTabBar;
FrameLayout mBackendViewFrame;

private static String TAG = "SampleActivity";

// initialize runtime backend configuration / context
private int curConfig = 0;
private SampleLib.RenderSessionConfig[] mConfigs;
Expand Down Expand Up @@ -98,16 +89,6 @@ protected void onCreate(Bundle icicle) {
mMainView.addView(mTabBar);
mMainView.addView(mBackendViewFrame);
setContentView(mMainView);

boolean hasCopy = getSharedPreferences("data", Context.MODE_PRIVATE).getBoolean("HasCopyAssets", false);

if (!hasCopy) {
copyAssetsDirToSDCard(this, "", getFilesDir().getAbsolutePath());

SharedPreferences.Editor editor = getSharedPreferences("data", Context.MODE_PRIVATE).edit();
editor.putBoolean("HasCopyAssets",true);
editor.commit();
}
}

@Override
Expand Down Expand Up @@ -155,47 +136,4 @@ protected void onResume() {
((SampleView) mTabViews[curConfig]).onResume();
}
}

public static void copyAssetsDirToSDCard(Context context, String assetsDirName, String sdCardPath) {
Log.d(TAG, "copyAssetsDirToSDCard() called with: context = [" + context + "], assetsDirName = [" + assetsDirName + "], sdCardPath = [" + sdCardPath + "]");
try {
String list[] = context.getAssets().list(assetsDirName);
if (list.length == 0) {
InputStream inputStream = context.getAssets().open(assetsDirName);
byte[] mByte = new byte[1024];
int bt = 0;
File file = new File(sdCardPath + File.separator
+ assetsDirName);
if (!file.exists()) {
file.createNewFile();
} else {
return;
}
FileOutputStream fos = new FileOutputStream(file);
while ((bt = inputStream.read(mByte)) != -1) {
fos.write(mByte, 0, bt);
}
fos.flush();
inputStream.close();
fos.close();
} else {
String subDirName = assetsDirName;
if (assetsDirName.contains("/")) {
subDirName = assetsDirName.substring(assetsDirName.lastIndexOf('/') + 1);
}
sdCardPath = sdCardPath + File.separator + subDirName;
File file = new File(sdCardPath);
if (!file.exists())
file.mkdirs();
for (String s : list) {
String fileName = assetsDirName.length() > 0 ? assetsDirName + File.separator + s : s;
copyAssetsDirToSDCard(context, fileName , sdCardPath);
}
}
} catch (
Exception e) {
e.printStackTrace();
}
}

}

0 comments on commit 23e12c1

Please sign in to comment.