本文整理汇总了Java中com.lody.virtual.os.VEnvironment.getAccountConfigFile方法的典型用法代码示例。如果您正苦于以下问题:Java VEnvironment.getAccountConfigFile方法的具体用法?Java VEnvironment.getAccountConfigFile怎么用?Java VEnvironment.getAccountConfigFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lody.virtual.os.VEnvironment
的用法示例。
在下文中一共展示了VEnvironment.getAccountConfigFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveAllAccounts
import com.lody.virtual.os.VEnvironment; //导入方法依赖的package包/类
/**
* Serializing all accounts
*/
private void saveAllAccounts() {
File accountFile = VEnvironment.getAccountConfigFile();
Parcel dest = Parcel.obtain();
try {
dest.writeInt(1);
List<VAccount> accounts = new ArrayList<>();
for (int i = 0; i < this.accountsByUserId.size(); i++) {
List<VAccount> list = this.accountsByUserId.valueAt(i);
if (list != null) {
accounts.addAll(list);
}
}
dest.writeInt(accounts.size());
for (VAccount account : accounts) {
account.writeToParcel(dest, 0);
}
dest.writeLong(lastAccountChangeTime);
FileOutputStream fileOutputStream = new FileOutputStream(accountFile);
fileOutputStream.write(dest.marshall());
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
dest.recycle();
}
示例2: saveAllAccounts
import com.lody.virtual.os.VEnvironment; //导入方法依赖的package包/类
/**
* Serializing all accounts
*/
private void saveAllAccounts() {
File accountFile = VEnvironment.getAccountConfigFile();
Parcel dest = Parcel.obtain();
try {
dest.writeInt(1);
List<VAccount> accounts = new ArrayList<>();
for (int i = 0; i < this.accountsByUserId.size(); i++) {
List<VAccount> list = this.accountsByUserId.valueAt(i);
if (list != null) {
accounts.addAll(list);
}
}
dest.writeInt(accounts.size());
for (VAccount account : accounts) {
account.writeToParcel(dest, 0);
}
dest.writeLong(lastAccountChangeTime);
FileOutputStream fileOutputStream = new FileOutputStream(accountFile);
fileOutputStream.write(dest.marshall());
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
dest.recycle();
}
示例3: serializeAllAccounts
import com.lody.virtual.os.VEnvironment; //导入方法依赖的package包/类
/**
* Serializing all accounts
*/
private void serializeAllAccounts() {
File accountFile = VEnvironment.getAccountConfigFile();
Parcel dest = Parcel.obtain();
try {
dest.writeInt(1);
List<VAccount> accounts = new ArrayList<>();
for (int i = 0; i < this.accountsByUserId.size(); i++) {
List<VAccount> list = this.accountsByUserId.valueAt(i);
if (list != null) {
accounts.addAll(list);
}
}
dest.writeInt(accounts.size());
for (VAccount account : accounts) {
account.writeToParcel(dest, 0);
}
dest.writeLong(lastAccountChangeTime);
FileOutputStream fileOutputStream = new FileOutputStream(accountFile);
fileOutputStream.write(dest.marshall());
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
dest.recycle();
}
示例4: readAllAccounts
import com.lody.virtual.os.VEnvironment; //导入方法依赖的package包/类
/**
* Read all accounts from file.
*/
private void readAllAccounts() {
File accountFile = VEnvironment.getAccountConfigFile();
refreshAuthenticatorCache(null);
if (accountFile.exists()) {
accountsByUserId.clear();
Parcel dest = Parcel.obtain();
try {
FileInputStream is = new FileInputStream(accountFile);
byte[] bytes = new byte[(int) accountFile.length()];
int readLength = is.read(bytes);
is.close();
if (readLength != bytes.length) {
throw new IOException(String.format(Locale.ENGLISH, "Expect length %d, but got %d.", bytes.length, readLength));
}
dest.unmarshall(bytes, 0, bytes.length);
dest.setDataPosition(0);
dest.readInt(); // skip the magic
int size = dest.readInt(); // the VAccount's size we need to read
boolean invalid = false;
while (size-- > 0) {
VAccount account = new VAccount(dest);
VLog.d(TAG, "Reading account : " + account.type);
AuthenticatorInfo info = cache.authenticators.get(account.type);
if (info != null) {
List<VAccount> accounts = accountsByUserId.get(account.userId);
if (accounts == null) {
accounts = new ArrayList<>();
accountsByUserId.put(account.userId, accounts);
}
accounts.add(account);
} else {
invalid = true;
}
}
lastAccountChangeTime = dest.readLong();
if (invalid) {
saveAllAccounts();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
dest.recycle();
}
}
}
示例5: readAllAccounts
import com.lody.virtual.os.VEnvironment; //导入方法依赖的package包/类
/**
* Read all accounts from file.
*/
private void readAllAccounts() {
File accountFile = VEnvironment.getAccountConfigFile();
refreshAuthenticatorCache(null);
if (accountFile.exists()) {
accountsByUserId.clear();
Parcel dest = Parcel.obtain();
try {
FileInputStream is = new FileInputStream(accountFile);
byte[] bytes = new byte[(int) accountFile.length()];
int readLength = is.read(bytes);
is.close();
if (readLength != bytes.length) {
throw new IOException(String.format(Locale.ENGLISH, "Expect length %d, but got %d.", bytes.length, readLength));
}
dest.unmarshall(bytes, 0, bytes.length);
dest.setDataPosition(0);
dest.readInt(); // skip the magic
int size = dest.readInt(); // the VAccount's size we need to read
boolean invalid = false;
while (size-- > 0) {
VAccount account = new VAccount(dest);
VLog.d(TAG, "Reading account : " + account.type);
AuthenticatorInfo info = cache.authenticators.get(account.type);
if (info != null) {
List<VAccount> accounts = accountsByUserId.get(account.userId);
if (accounts == null) {
accounts = new ArrayList<>();
accountsByUserId.put(account.userId, accounts);
}
accounts.add(account);
} else {
invalid = true;
}
}
lastAccountChangeTime = dest.readLong();
if (invalid) {
saveAllAccounts();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
dest.recycle();
}
}
}
示例6: deserializeAllAccounts
import com.lody.virtual.os.VEnvironment; //导入方法依赖的package包/类
/**
* Read all accounts from file.
*/
private void deserializeAllAccounts() {
File accountFile = VEnvironment.getAccountConfigFile();
refreshAuthenticatorCache(null);
if (accountFile.exists()) {
accountsByUserId.clear();
Parcel dest = Parcel.obtain();
try {
FileInputStream is = new FileInputStream(accountFile);
byte[] bytes = new byte[(int) accountFile.length()];
int readLength = is.read(bytes);
is.close();
if (readLength != bytes.length) {
throw new IOException(String.format("Expect length %d, but got %d.", bytes.length, readLength));
}
dest.unmarshall(bytes, 0, bytes.length);
dest.setDataPosition(0);
dest.readInt(); // skip the magic
int size = dest.readInt(); // the VAccount's size we need to read
boolean invalid = false;
while (size-- > 0) {
VAccount account = new VAccount(dest);
VLog.d(TAG, "Reading account : " + account.type);
AuthenticatorInfo info = cache.authenticators.get(account.type);
if (info != null) {
List<VAccount> accounts = accountsByUserId.get(account.userId);
if (accounts == null) {
accounts = new ArrayList<>();
accountsByUserId.put(account.userId, accounts);
}
accounts.add(account);
} else {
invalid = true;
}
}
lastAccountChangeTime = dest.readLong();
if (invalid) {
serializeAllAccounts();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
dest.recycle();
}
}
}