mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-26 11:49:25 +01:00
Workaround strange getExternalFilesDir freeze
This commit is contained in:
parent
aa3af3bf67
commit
2b0a4f552b
@ -24,6 +24,7 @@ import android.preference.*;
|
||||
public class FWGSLib
|
||||
{
|
||||
private static final String TAG = "FWGSLib";
|
||||
static String externalFilesDir;
|
||||
public static boolean FBitSet( final int bits, final int mask )
|
||||
{
|
||||
return ((bits & mask) == mask);
|
||||
@ -110,19 +111,52 @@ public class FWGSLib
|
||||
return dir.getPath() + "/xash";
|
||||
return "/sdcard/xash";
|
||||
}
|
||||
|
||||
static class GetExternalFilesDir extends Thread
|
||||
{
|
||||
Context ctx;
|
||||
GetExternalFilesDir( Context ctx1 )
|
||||
{
|
||||
ctx = ctx1;
|
||||
}
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
File f = ctx.getExternalFilesDir(null);
|
||||
|
||||
f.mkdirs();
|
||||
|
||||
externalFilesDir = f.getAbsolutePath();
|
||||
Log.d(TAG, "getExternalFilesDir success");
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
Log.e( TAG, e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static String getExternalFilesDir( Context ctx )
|
||||
{
|
||||
File f = ctx.getExternalFilesDir( null );
|
||||
|
||||
if( f == null )
|
||||
if( externalFilesDir != null )
|
||||
return externalFilesDir;
|
||||
try
|
||||
{
|
||||
f = new File( getDefaultXashPath() );
|
||||
if( sdk >= 8 )
|
||||
{
|
||||
Thread t = new GetExternalFilesDir(ctx);
|
||||
t.start();
|
||||
t.join(2000);
|
||||
}
|
||||
}
|
||||
|
||||
f.mkdirs();
|
||||
|
||||
return f.getAbsolutePath();
|
||||
catch(Exception e)
|
||||
{
|
||||
Log.e( TAG, e.toString(), e);
|
||||
externalFilesDir = getDefaultXashPath();
|
||||
}
|
||||
if( externalFilesDir == null )
|
||||
externalFilesDir = getDefaultXashPath();
|
||||
return externalFilesDir;
|
||||
}
|
||||
|
||||
public static boolean isLandscapeOrientation( Activity act )
|
||||
|
Loading…
Reference in New Issue
Block a user