當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。