本文整理汇总了Java中org.commcare.suite.model.MenuDisplayable类的典型用法代码示例。如果您正苦于以下问题:Java MenuDisplayable类的具体用法?Java MenuDisplayable怎么用?Java MenuDisplayable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MenuDisplayable类属于org.commcare.suite.model包,在下文中一共展示了MenuDisplayable类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemLongClick
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
MenuDisplayable value = (MenuDisplayable)parent.getAdapter().getItem(position);
String audioURI = value.getAudioURI();
MediaPlayer mp = new MediaPlayer();
String audioFilename;
if (audioURI != null && !audioURI.equals("")) {
try {
audioFilename = ReferenceManager.instance().DeriveReference(audioURI).getLocalURI();
mp.setDataSource(audioFilename);
mp.prepare();
mp.start();
} catch (IOException | IllegalStateException
| InvalidReferenceException e) {
e.printStackTrace();
}
}
return false;
}
示例2: getView
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
@Override
public View getView(int i, View menuListItem, ViewGroup vg) {
MenuViewHolder menuViewHolder;
if (menuListItem == null) {
// inflate it and do not attach to parent, or we will get the 'addView not supported' exception
menuListItem = LayoutInflater.from(context).inflate(getListItemLayoutResource(), vg, false);
menuViewHolder = new MenuViewHolder(menuListItem);
} else {
menuViewHolder = (MenuViewHolder)menuListItem.getTag();
}
MenuDisplayable menuDisplayable = displayableData[i];
setupTextView(menuViewHolder.rowText, menuDisplayable);
setupAudioButton(i, menuViewHolder.audioPlaybackButton, menuDisplayable);
// set up the image, if available
setupImageView(menuViewHolder.iconView, menuDisplayable, getImageViewDimenResource());
setupBadgeView(menuViewHolder.badgeView, menuDisplayable, i);
menuListItem.setTag(menuViewHolder);
return menuListItem;
}
示例3: setupAudioButton
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
private void setupAudioButton(int rowId, AudioPlaybackButton audioPlaybackButton, MenuDisplayable menuDisplayable) {
if (audioPlaybackButton != null) {
final String audioURI = menuDisplayable.getAudioURI();
String audioFilename = "";
if (audioURI != null && !audioURI.equals("")) {
try {
audioFilename = ReferenceManager.instance().DeriveReference(audioURI).getLocalURI();
} catch (InvalidReferenceException e) {
Log.e("AVTLayout", "Invalid reference exception");
e.printStackTrace();
}
}
File audioFile = new File(audioFilename);
// First set up the audio button
ViewId viewId = ViewId.buildListViewId(rowId);
if (!"".equals(audioFilename) && audioFile.exists()) {
audioPlaybackButton.modifyButtonForNewView(viewId, audioURI, true);
} else {
audioPlaybackButton.modifyButtonForNewView(viewId, audioURI, false);
}
}
}
示例4: handleInputAndUpdateSession
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
@Override
public boolean handleInputAndUpdateSession(CommCareSession session, String input) {
try {
int i = Integer.parseInt(input);
String commandId;
MenuDisplayable menuDisplayable = mChoices[i];
if (menuDisplayable instanceof Entry) {
commandId = ((Entry)menuDisplayable).getCommandId();
} else {
commandId = ((Menu)mChoices[i]).getId();
}
session.setCommand(commandId);
return false;
} catch (NumberFormatException e) {
//This will result in things just executing again, which is fine.
}
return true;
}
示例5: prompt
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
@Override
public void prompt(PrintStream out) {
for (int i = 0; i < mChoices.length; ++i) {
MenuDisplayable d = mChoices[i];
out.println(i + ")" + d.getDisplayText());
}
}
示例6: setupTextView
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
private void setupTextView(TextView textView, MenuDisplayable menuDisplayable) {
String mQuestionText = menuDisplayable.getDisplayText();
//Final change, remove any numeric context requests. J2ME uses these to
//help with numeric navigation.
if (mQuestionText != null) {
mQuestionText = Localizer.processArguments(mQuestionText, new String[]{""}).trim();
}
textView.setText(mQuestionText);
}
示例7: setupImageView
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
private void setupImageView(ImageView mIconView, MenuDisplayable menuDisplayable, int boundingDimensionResource) {
if (mIconView != null) {
int iconDimension = (int)context.getResources().getDimension(boundingDimensionResource);
Bitmap image = MediaUtil.inflateDisplayImage(context, menuDisplayable.getImageURI(),
iconDimension, iconDimension);
if (image != null) {
mIconView.setImageBitmap(image);
mIconView.setAdjustViewBounds(true);
} else {
setupDefaultIcon(mIconView, getIconState(menuDisplayable));
}
}
}
示例8: setupBadgeView
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
private void setupBadgeView(View badgeView, MenuDisplayable menuDisplayable, int position) {
badgeView.setVisibility(View.GONE);
badgeView.setTag(position);
if (badgeCache.get(position) != null) {
updateBadgeView(badgeView, badgeCache.get(position));
} else {
Text badgeTextObject = menuDisplayable.getRawBadgeTextObject();
if(badgeTextObject != null) {
Set<String> instancesNeededByBadgeCalculation =
(new InstanceNameAccumulatingAnalyzer()).accumulate(badgeTextObject);
context.attachDisposableToLifeCycle(
menuDisplayable.getTextForBadge(asw.getRestrictedEvaluationContext(menuDisplayable.getCommandID(), instancesNeededByBadgeCalculation))
.subscribeOn(Schedulers.single())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(badgeText -> {
// Make sure that badgeView corresponds to the right position and update it
if (((int)badgeView.getTag()) == position) {
updateBadgeView(badgeView, badgeText);
}
},
throwable -> UserfacingErrorHandling.createErrorDialog(context, throwable.getLocalizedMessage(), true)
)
);
} else {
updateBadgeView(badgeView, "");
}
}
}
示例9: getIconState
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
private NavIconState getIconState(MenuDisplayable menuDisplayable) {
NavIconState iconChoice = NavIconState.NEXT;
//figure out some icons
if (menuDisplayable instanceof Entry) {
SessionDatum datum = asw.getSession().getNeededDatum((Entry)menuDisplayable);
if (datum == null || !(datum instanceof EntityDatum)) {
iconChoice = NavIconState.JUMP;
}
}
if (!DeveloperPreferences.isNewNavEnabled()) {
iconChoice = NavIconState.NONE;
}
return iconChoice;
}
示例10: getOptions
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
@Override
public String[] getOptions() {
String[] ret = new String[mChoices.length];
for (int i = 0; i < mChoices.length; ++i) {
MenuDisplayable d = mChoices[i];
ret[i] = d.getDisplayText();
}
return ret;
}
示例11: getMenuDisplayables
import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
public MenuDisplayable[] getMenuDisplayables(){
return mChoices;
}