本文整理汇总了Java中org.commcare.resources.model.MissingMediaException类的典型用法代码示例。如果您正苦于以下问题:Java MissingMediaException类的具体用法?Java MissingMediaException怎么用?Java MissingMediaException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MissingMediaException类属于org.commcare.resources.model包,在下文中一共展示了MissingMediaException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTaskBackground
import org.commcare.resources.model.MissingMediaException; //导入依赖的package包/类
@Override
protected SizeBoundVector<MissingMediaException> doTaskBackground(Void... params) {
AndroidCommCarePlatform platform = CommCareApplication.instance().getCommCarePlatform();
// This is replicated in the application in a few places.
ResourceTable global = platform.getGlobalResourceTable();
SizeBoundUniqueVector<MissingMediaException> problems =
new SizeBoundUniqueVector<>(10);
setTableListeners(global);
global.verifyInstallation(problems, platform);
unsetTableListeners(global);
if (problems.size() > 0) {
return problems;
}
return null;
}
示例2: checkReferenceURI
import org.commcare.resources.model.MissingMediaException; //导入依赖的package包/类
public static void checkReferenceURI(Resource r, String URI, Vector<MissingMediaException> problems) throws IOException {
try {
Reference mRef = ReferenceManager.instance().DeriveReference(URI);
if (!mRef.doesBinaryExist()) {
String mLocalReference = mRef.getLocalURI();
problems.addElement(new MissingMediaException(r, "Missing external media: " + mLocalReference, mLocalReference));
}
} catch (InvalidReferenceException ire) {
//do nothing for now
}
}
示例3: handleVerificationProblems
import org.commcare.resources.model.MissingMediaException; //导入依赖的package包/类
private void handleVerificationProblems(SizeBoundVector<MissingMediaException> problems) {
String message = Localization.get("verification.fail.message");
Hashtable<String, Vector<String>> problemList = new Hashtable<>();
for (Enumeration en = problems.elements(); en.hasMoreElements(); ) {
MissingMediaException ure = (MissingMediaException)en.nextElement();
String res = ure.getResource().getResourceId();
Vector<String> list;
if (problemList.containsKey(res)) {
list = problemList.get(res);
} else {
list = new Vector<>();
}
list.addElement(ure.getMessage());
problemList.put(res, list);
}
for (Enumeration en = problemList.keys(); en.hasMoreElements(); ) {
String resource = (String)en.nextElement();
message += "\n-----------";
for (String s : problemList.get(resource)) {
message += "\n" + prettyString(s);
}
}
if (problems.getAdditional() > 0) {
message += "\n\n..." + problems.getAdditional() + " more";
}
missingMediaPrompt.setText(message);
}
示例4: verifyInstallation
import org.commcare.resources.model.MissingMediaException; //导入依赖的package包/类
@Override
public boolean verifyInstallation(Resource r,
Vector<MissingMediaException> problems,
CommCarePlatform platform) {
try {
Reference local = ReferenceManager.instance().DeriveReference(localLocation);
Suite suite = AndroidSuiteParser.buildVerifyParser(local.getStream(), new DummyResourceTable()).parse();
Hashtable<String, Entry> mHashtable = suite.getEntries();
for (Enumeration en = mHashtable.keys(); en.hasMoreElements(); ) {
String key = (String)en.nextElement();
Entry mEntry = mHashtable.get(key);
FileUtil.checkReferenceURI(r, mEntry.getAudioURI(), problems);
FileUtil.checkReferenceURI(r, mEntry.getImageURI(), problems);
}
for (Menu menu : suite.getMenus()) {
FileUtil.checkReferenceURI(r, menu.getAudioURI(), problems);
FileUtil.checkReferenceURI(r, menu.getImageURI(), problems);
}
} catch (Exception e) {
Logger.log("e", "suite validation failed with: " + e.getMessage());
Log.d(TAG, "Suite validation failed");
e.printStackTrace();
}
return problems.size() != 0;
}
示例5: verifyInstallation
import org.commcare.resources.model.MissingMediaException; //导入依赖的package包/类
@Override
public boolean verifyInstallation(Resource r, Vector<MissingMediaException> problems, CommCarePlatform platform) {
SizeBoundUniqueVector<MissingMediaException> sizeBoundProblems =
(SizeBoundUniqueVector<MissingMediaException>)problems;
InstallerUtil.checkMedia(r, Localization.get("icon.demo.path"), sizeBoundProblems, InstallerUtil.MediaType.IMAGE);
InstallerUtil.checkMedia(r, Localization.get("icon.login.path"), sizeBoundProblems, InstallerUtil.MediaType.IMAGE);
//Check to see whether the formDef exists and reads correctly
Suite suite;
try {
suite = storage(platform).read(cacheLocation);
} catch (Exception e) {
e.printStackTrace();
sizeBoundProblems.addElement(new MissingMediaException(r, "Suite did not properly save into persistent storage"));
return true;
}
//Otherwise, we want to figure out if the form has media, and we need to see whether it's properly
//available
try {
for (Menu menu : suite.getMenus()) {
String aURI = menu.getAudioURI();
if (aURI != null) {
InstallerUtil.checkMedia(r, aURI, sizeBoundProblems, InstallerUtil.MediaType.AUDIO);
}
String iURI = menu.getImageURI();
if (iURI != null) {
InstallerUtil.checkMedia(r, iURI, sizeBoundProblems, InstallerUtil.MediaType.IMAGE);
}
}
} catch (Exception exc) {
System.out.println("fail: " + exc.getMessage());
System.out.println("fail: " + exc.toString());
}
return problems.size() != 0;
}
示例6: validate
import org.commcare.resources.model.MissingMediaException; //导入依赖的package包/类
public static String validate(ResourceTable mResourceTable){
SizeBoundUniqueVector<MissingMediaException> problems = new SizeBoundUniqueVector<MissingMediaException>(10);
mResourceTable.verifyInstallation(problems);
if(problems.size() > 0 ) {
int badImageRef = problems.getBadImageReferenceCount();
int badAudioRef = problems.getBadAudioReferenceCount();
int badVideoRef = problems.getBadVideoReferenceCount();
String errorMessage = "CommCare cannot start because you are missing multimedia files.";
String message = CommCareStartupInteraction.failSafeText("install.bad",errorMessage, new String[] {""+badImageRef,""+badAudioRef,""+badVideoRef});
Hashtable<String, Vector<String>> problemList = new Hashtable<String,Vector<String>>();
for(Enumeration en = problems.elements() ; en.hasMoreElements() ;) {
MissingMediaException mme = (MissingMediaException)en.nextElement();
String res = mme.getResource().getResourceId();
Vector<String> list;
if(problemList.containsKey(res)) {
list = problemList.get(res);
} else{
list = new Vector<String>();
}
// code to pretty up the output for mealz
int substringIndex = mme.getMessage().indexOf("/commcare");
String shortenedMessage = (mme.getMessage()).substring(substringIndex+1);
list.addElement(shortenedMessage);
problemList.put(res, list);
}
message += "\n-----------";
for(Enumeration en = problemList.keys(); en.hasMoreElements();) {
String resource = (String)en.nextElement();
//message += "\n-----------";
for(String s : problemList.get(resource)) {
message += "\n" + s;
}
}
if(problems.getAdditional() > 0) {
message += "\n\n..." + problems.getAdditional() + " more";
}
return message;
}
return null;
}
示例7: verifyInstallation
import org.commcare.resources.model.MissingMediaException; //导入依赖的package包/类
public boolean verifyInstallation(Resource r, Vector<MissingMediaException> resources) {
return false;
}
示例8: verifyInstallation
import org.commcare.resources.model.MissingMediaException; //导入依赖的package包/类
public boolean verifyInstallation(Resource r, Vector<MissingMediaException> problems) {
//Work by default
return true;
}
示例9: verifyInstallation
import org.commcare.resources.model.MissingMediaException; //导入依赖的package包/类
@Override
public boolean verifyInstallation(Resource r, Vector<MissingMediaException> resources, CommCarePlatform platform) {
return false;
}
示例10: verifyInstallation
import org.commcare.resources.model.MissingMediaException; //导入依赖的package包/类
@Override
public boolean verifyInstallation(Resource r, Vector<MissingMediaException> problems, CommCarePlatform platform) {
//Work by default
return true;
}