当前位置: 首页>>代码示例>>Java>>正文


Java MenuDisplayable类代码示例

本文整理汇总了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;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:21,代码来源:MenuGrid.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:24,代码来源:MenuAdapter.java

示例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);
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:24,代码来源:MenuAdapter.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:19,代码来源:MenuScreen.java

示例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());
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:8,代码来源:MenuScreen.java

示例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);
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:11,代码来源:MenuAdapter.java

示例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));
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:14,代码来源:MenuAdapter.java

示例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, "");
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:30,代码来源:MenuAdapter.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:16,代码来源:MenuAdapter.java

示例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;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:10,代码来源:MenuScreen.java

示例11: getMenuDisplayables

import org.commcare.suite.model.MenuDisplayable; //导入依赖的package包/类
public MenuDisplayable[] getMenuDisplayables(){
    return mChoices;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:4,代码来源:MenuScreen.java


注:本文中的org.commcare.suite.model.MenuDisplayable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。