Example usage for android.widget ImageView setVisibility

List of usage examples for android.widget ImageView setVisibility

Introduction

In this page you can find the example usage for android.widget ImageView setVisibility.

Prototype

@RemotableViewMethod
    @Override
    public void setVisibility(int visibility) 

Source Link

Usage

From source file:br.edu.ifpb.breath.slidingtabs.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;//from  www. j  a  va 2 s .  com
        TextView tabTitleView = null;
        ImageView tabIconView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
            tabIconView = (ImageView) tabView.findViewById(mTabViewImageViewId);
        }

        if (tabView == null && !mUseIcons) {
            tabView = createDefaultTabView(getContext(), 0);
            tabView.setAlpha(i == 0 ? 1.0f : 0.25f);
        }

        if (tabView == null && mUseIcons) {
            tabView = createDefaultTabView(getContext(), 1);
            tabView.setAlpha(i == 0 ? 1.0f : 0.25f);
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
            tabTitleView.setAlpha(i == 0 ? 1.0f : 0.25f);
        }

        if (tabIconView == null && ImageView.class.isInstance(tabView)) {
            tabIconView = (ImageView) tabView;
            tabIconView.setAlpha(i == 0 ? 1.0f : 0.25f);
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        if (mUseIcons) {
            tabIconView.setVisibility(View.VISIBLE);
            if (tabTitleView != null)
                tabTitleView.setVisibility(View.GONE);

            if (mIcons.containsKey(i))
                tabIconView.setImageDrawable(mIcons.get(i));
        } else {
            tabTitleView.setVisibility(View.VISIBLE);
            if (tabIconView != null)
                tabIconView.setVisibility(View.GONE);

            tabTitleView.setText(adapter.getPageTitle(i));
            tabTitleView.setTextColor(mTextColor);
        }

        tabView.setOnClickListener(tabClickListener);
        String desc = mContentDescriptions.get(i, null);
        if (desc != null) {
            tabView.setContentDescription(desc);
        }

        mTabStrip.addView(tabView);
        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }
    }
}

From source file:ca.marklauman.dominionpicker.CardAdapter.java

/** Binds the contents of the Cursor to View elements
 *  provided by this adapter. When a value is bound
 *  by this method, it returns {@code true}, so
 *  that no other binding is performed. If it
 *  returns false, the value is bound by the default
 *  SimpleCursorAdapter methods./*from  ww w. jav  a  2  s.  c o m*/
 *  @param view the view to bind the data to.
 *  @param cursor the cursor to get the data from
 *  (it has been moved to the appropriate position
 *  for this row).
 *  @param columnIndex the index of the column
 *  that is being bound right now.
 *  @return {@code true} if that column was bound to
 *  the view, {@code false} otherwise.            */
@Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
    if (col_cost == columnIndex || col_gold == columnIndex || col_vict == columnIndex) {
        if ("0".equals(cursor.getString(columnIndex)))
            view.setVisibility(View.GONE);
        else
            view.setVisibility(View.VISIBLE);
        return false;

    } else if (col_potion == columnIndex) {
        if (1 > cursor.getInt(columnIndex))
            view.setVisibility(View.GONE);
        else
            view.setVisibility(View.VISIBLE);
        return true;

    } else if (col_expansion == columnIndex) {
        String val = cursor.getString(col_expansion);
        ImageView v = (ImageView) view;
        v.setContentDescription(val);
        Integer icon_id = exp_icons.get(val);
        if (icon_id == null)
            icon_id = R.drawable.ic_set_unknown;
        v.setImageResource(icon_id);
        return true;

    } else if (col_buy == columnIndex) {
        String res = "";
        String val = cursor.getString(col_buy);
        if (!"0".equals(val))
            res += ", +" + val + " buy";
        val = cursor.getString(col_draw);
        if (!"0".equals(val))
            res += ", +" + val + " card";
        val = cursor.getString(col_act);
        if (!"0".equals(val))
            res += ", +" + val + " action";
        if (0 != col_gold && 0 != col_vict && res.length() > 2)
            res = res.substring(2);
        if ("".equals(res))
            view.setVisibility(View.GONE);
        else {
            view.setVisibility(View.VISIBLE);
            TextView v = (TextView) view;
            v.setText(res);
        }
        return true;

    } else if (col_desc == columnIndex) {
        String desc = cursor.getString(columnIndex);
        if ("".equals(desc)) {
            view.setVisibility(View.GONE);
            return true;
        }
        view.setVisibility(View.VISIBLE);
        return false;

    } else if (col_id == columnIndex) {
        TextView v = (TextView) view;
        if (yw_bane != cursor.getLong(col_id))
            v.setVisibility(View.GONE);
        else
            v.setVisibility(View.VISIBLE);
        return true;
    }

    return false;
}

From source file:com.gizwits.smartlight.activity.MainListActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.ivBack:
    case R.id.ivMenu:
        Log.i(TAG, "back key is pressed");
        mView.toggle();// w w w  . j  av a2 s.  c o  m
        break;
    case R.id.btnSwitch:
        //?0.6?????--600
        if (switchTime + 1000 > System.currentTimeMillis()) {
            return;
        }
        switchTime = System.currentTimeMillis();
        if (!selectGroup.equals("") && selectGroup != null) {
            Log.i(TAG, "operate on group=" + selectGroup);
            //?ledList
            if (btnSwitch.getText().toString().equals("close")) {
                mCenter.cSwitchOnGroup(selectGroup, false);
            } else {
                mCenter.cSwitchOnGroup(selectGroup, true);
            }
        } else {
            //?
            if (btnSwitch.getText().toString().equals("close")) {
                mCenter.cSwitchOn(selectSubDevice, false);
            } else {
                mCenter.cSwitchOn(selectSubDevice, true);
            }
        }
        break;
    case R.id.ifttt:
        //??
        Intent intent = new Intent(MainListActivity.this, EditIfttt.class);
        intent.putStringArrayListExtra("sceneList", GroupDevice.getAllSceneName(sceneList));
        intent.putStringArrayListExtra("ControllerList", GroupDevice.getAllName(ControllerList));
        intent.putExtra("did", "" + mXpgWifiDevice.getDid());
        startActivity(intent);
        break;
    case R.id.black_alpha_bg:
        bottomClose();
        break;
    case R.id.ivEdit:
        //?
        Log.i("showDel", "" + ivDels.size());
        bottomClose();

        if (ivEdit.getTag().toString().equals("1")) {
            ivEdit.setImageResource(R.drawable.icon_confirm);
            ivEdit.setTag("0");
        } else {
            ivEdit.setImageResource(R.drawable.icon_edit_w);
            ivEdit.setTag("1");
        }

        if (ivDels.size() < 1) {
            return;
        }

        if (ivEdit.getTag().toString().equals("0")) {
            for (ImageView ivDel : ivDels) {
                ivDel.setVisibility(View.VISIBLE);
            }
        } else {
            for (ImageView ivDel : ivDels) {
                ivDel.setVisibility(View.INVISIBLE);
            }
        }
        break;
    case R.id.btn_addscene:
        String payload = "";
        scene newScene;
        boolean isIgnore = false;
        Log.i(TAG, "Click scene button");
        newScene = new scene("", "", "", 0);
        newScene.setValue(Integer.toString(mLightness) + ":" + Integer.toString(mHue) + ":"
                + Integer.toString(mSaturation));
        if (tvEditSceneName.getText().toString().trim().isEmpty()) {
            if (scene_details.isEmpty())
                newScene.setName("scene0");
            else
                newScene.setName("scene" + (scene_details.size()));
        } else {
            newScene.setName(tvEditSceneName.getText().toString());
        }
        //If same should not add, need add this logic here....
        for (int i = 0; i < scene_details.size(); i++) {
            if (scene_details.get(i).getValue().equals(newScene.getValue())) {
                isIgnore = true;
                Toast.makeText(this, "You have already add the same scene before!", Toast.LENGTH_LONG).show();
                Log.i(TAG, "Already have such scene so ignore this action");
            }
        }
        if (isIgnore)
            break;

        // Also send cmd to gateway
        Log.i(TAG, "Send scene add cmd to gateway");
        payload += newScene.getName();
        payload += ":";

        if (!selectGroup.equals("") && selectGroup != null) {
            for (int i = 0; i < groupMapList.get(selectGroup).size(); i++) {
                if (i > 0)
                    payload += ",";
                payload += groupMapList.get(selectGroup).get(i);
            }
            payload += ":";
            payload += newScene.getValue();
            mCenter.cAddScene(selectGroup, payload);
        }
        break;
    }
}

From source file:org.alfresco.mobile.android.application.fragments.properties.DetailsFragment.java

private void display(Node refreshedNode, LayoutInflater inflater) {
    node = refreshedNode;//  ww  w. ja  v  a 2s .  c  o m

    // Detect if restrictable
    isRestrictable = node.hasAspect(ContentModel.ASPECT_RESTRICTABLE);

    renditionManager = ApplicationManager.getInstance(getActivity()).getRenditionManager(getActivity());

    // Header
    TextView tv = (TextView) vRoot.findViewById(R.id.title);
    tv.setText(node.getName());
    tv = (TextView) vRoot.findViewById(R.id.details);
    tv.setText(Formatter.createContentBottomText(getActivity(), node, true));

    if (isRestrictable) {
        tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_encrypt, 0);
    }

    // Preview + Thumbnail
    displayIcon(node, R.drawable.mime_folder, (ImageView) vRoot.findViewById(R.id.icon), false);
    displayIcon(node, R.drawable.mime_256_folder, (ImageView) vRoot.findViewById(R.id.preview), true);

    // Description
    Integer generalPropertyTitle = null;
    tv = (TextView) vRoot.findViewById(R.id.description);
    List<String> filter = new ArrayList<String>();
    if (node.getDescription() != null && node.getDescription().length() > 0
            && vRoot.findViewById(R.id.description_group) != null) {
        vRoot.findViewById(R.id.description_group).setVisibility(View.VISIBLE);
        tv.setText(node.getDescription());
        generalPropertyTitle = -1;
        ((TextView) vRoot.findViewById(R.id.prop_name_value)).setText(node.getName());
        filter.add(ContentModel.PROP_NAME);
    } else if (vRoot.findViewById(R.id.description_group) != null) {
        vRoot.findViewById(R.id.description_group).setVisibility(View.GONE);
        generalPropertyTitle = R.string.metadata;
    }

    mTabHost = (TabHost) vRoot.findViewById(android.R.id.tabhost);
    setupTabs();

    if (mTabHost == null) {
        grouprootview = (ViewGroup) vRoot.findViewById(R.id.metadata);
        createPropertiesPanel(inflater, generalPropertyTitle, filter);
    }

    // BUTTONS
    ImageView b = (ImageView) vRoot.findViewById(R.id.action_openin);
    if (node.isDocument() && ((DocumentImpl) node).hasAllowableAction(Action.CAN_GET_CONTENT_STREAM.value())
            && ((Document) node).getContentStreamLength() > 0 && !isRestrictable) {
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                openin();
            }
        });
    } else {
        b.setVisibility(View.GONE);
    }

    b = (ImageView) vRoot.findViewById(R.id.action_geolocation);
    if (node.isDocument() && node.hasAspect(ContentModel.ASPECT_GEOGRAPHIC)) {
        b.setVisibility(View.VISIBLE);
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (node == null) {
                    return;
                }
                String latitude = (node.getProperty(ContentModel.PROP_LATITUDE).getValue() != null)
                        ? node.getProperty(ContentModel.PROP_LATITUDE).getValue().toString()
                        : "";
                String longitude = (node.getProperty(ContentModel.PROP_LONGITUDE).getValue() != null)
                        ? node.getProperty(ContentModel.PROP_LONGITUDE).getValue().toString()
                        : "";
                ActionManager.actionShowMap(DetailsFragment.this, node.getName(), latitude, longitude);
            }
        });
    } else {
        b.setVisibility(View.GONE);
    }

    b = (ImageView) vRoot.findViewById(R.id.like);
    if (alfSession != null && alfSession.getRepositoryInfo() != null
            && alfSession.getRepositoryInfo().getCapabilities() != null
            && alfSession.getRepositoryInfo().getCapabilities().doesSupportLikingNodes()) {
        IsLikedLoaderCallBack lcb = new IsLikedLoaderCallBack(alfSession, getActivity(), node);
        lcb.setImageButton(b);
        lcb.setProgressView(vRoot.findViewById(R.id.like_progress));
        lcb.execute(false);

        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                like(v);
            }
        });
    } else {
        b.setVisibility(View.GONE);
        if (vRoot.findViewById(R.id.like_progress) != null) {
            vRoot.findViewById(R.id.like_progress).setVisibility(View.GONE);
        }
    }

    // BUTTONS
    b = (ImageView) vRoot.findViewById(R.id.action_favorite);
    if (!isRestrictable) {
        IsFavoriteLoaderCallBack lcb = new IsFavoriteLoaderCallBack(alfSession, this, node);
        lcb.setImageButton(b);
        lcb.setProgressView(vRoot.findViewById(R.id.favorite_progress));
        lcb.execute(false);
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                favorite(v);
            }
        });
    } else {
        b.setVisibility(View.GONE);
        vRoot.findViewById(R.id.favorite_progress).setVisibility(View.GONE);
    }

    b = (ImageView) vRoot.findViewById(R.id.action_share);
    if (node.isDocument() && !isRestrictable) {
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                share();
            }
        });
    } else {
        b.setVisibility(View.GONE);
    }
}

From source file:com.saarang.samples.apps.iosched.ui.BaseActivity.java

private View makeNavDrawerItem(final int itemId, ViewGroup container) {
    boolean selected = getSelfNavDrawerItem() == itemId;
    int layoutToInflate = 0;
    if (itemId == NAVDRAWER_ITEM_SEPARATOR) {
        layoutToInflate = com.saarang.samples.apps.iosched.R.layout.navdrawer_separator;
    } else if (itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL) {
        layoutToInflate = com.saarang.samples.apps.iosched.R.layout.navdrawer_separator;
    } else {//from w  ww.j  a va  2  s . c  om
        layoutToInflate = com.saarang.samples.apps.iosched.R.layout.navdrawer_item;
    }
    View view = getLayoutInflater().inflate(layoutToInflate, container, false);

    if (isSeparator(itemId)) {
        // we are done
        UIUtils.setAccessibilityIgnore(view);
        return view;
    }

    ImageView iconView = (ImageView) view.findViewById(com.saarang.samples.apps.iosched.R.id.icon);
    TextView titleView = (TextView) view.findViewById(com.saarang.samples.apps.iosched.R.id.title);
    int iconId = itemId >= 0 && itemId < NAVDRAWER_ICON_RES_ID.length ? NAVDRAWER_ICON_RES_ID[itemId] : 0;
    int titleId = itemId >= 0 && itemId < NAVDRAWER_TITLE_RES_ID.length ? NAVDRAWER_TITLE_RES_ID[itemId] : 0;

    // set icon and text
    iconView.setVisibility(iconId > 0 ? View.VISIBLE : View.GONE);
    if (iconId > 0) {
        iconView.setImageResource(iconId);
    }
    titleView.setText(getString(titleId));

    formatNavDrawerItem(view, itemId, selected);

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onNavDrawerItemClicked(itemId);
        }
    });

    return view;
}

From source file:cn.yunluosoft.tonglou.activity.ChatActivity.java

private void setUpView() {
    back.setOnClickListener(new OnClickListener() {

        @Override/*  w w  w .j  a  v a 2s .c om*/
        public void onClick(View v) {
            finish();
        }
    });

    //      icon.setVisibility(View.VISIBLE);
    iv_emoticons_normal.setOnClickListener(this);
    iv_emoticons_checked.setOnClickListener(this);
    clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo");
    // ???
    chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE);

    if (chatType == CHATTYPE_SINGLE) { // ??
        messageInfo = (MessageInfo) getIntent().getSerializableExtra("info");
        m = getIntent().getIntExtra("dic", 0);

        if (messageInfo != null) {
            if (m == 1) {
                MessageInfo info = new MessageInfo(messageInfo.receiverUserId, messageInfo.senderUserId,
                        messageInfo.receiverImUserName, messageInfo.senderImUserName,
                        messageInfo.receiverHeadUrl, messageInfo.senderHeadUrl, messageInfo.receiverNickName,
                        messageInfo.senderNickName);
                messageInfo = info;
            }
            toChatUsername = messageInfo.receiverImUserName;
            // toChatUsername = getIntent().getStringExtra("userId");
            ((TextView) findViewById(R.id.title_title)).setText(messageInfo.receiverNickName);
            //            bitmapUtils.display(icon, messageInfo.receiverHeadUrl);
            //
            //            icon.setOnClickListener(new OnClickListener() {
            //
            //               @Override
            //               public void onClick(View v) {
            //                  Intent intent = new Intent(ChatActivity.this,
            //                        ConstactActivity.class);
            //                  intent.putExtra("id", messageInfo.receiverUserId);
            //                  intent.putExtra("name", messageInfo.receiverNickName);
            //                  intent.putExtra("flag", 155);
            //                  startActivityForResult(intent, 8226);
            //               }
            //            });

        }
        // toChatUsername = getIntent().getStringExtra("userId");
        // Map<String, RobotUser> robotMap = ((DemoHXSDKHelper) HXSDKHelper
        // .getInstance()).getRobotList();
        // if (robotMap != null && robotMap.containsKey(toChatUsername)) {
        // isRobot = true;
        // String nick = robotMap.get(toChatUsername).getNick();
        // if (!TextUtils.isEmpty(nick)) {
        // ((TextView) findViewById(R.id.title_title)).setText(nick);
        // } else {
        // ((TextView) findViewById(R.id.title_title))
        // .setText(toChatUsername);
        // }
        // }
        // else {
        // UserUtils.setUserNick(toChatUsername,
        // (TextView) findViewById(R.id.title_title));
        // }
    } else {
        // ?
        messageInfo = (MessageInfo) getIntent().getSerializableExtra("info");
        if (messageInfo == null) {
            return;
        }

        MessageInfo info = new MessageInfo(ShareDataTool.getUserId(this), messageInfo.receiverUserId,
                ShareDataTool.getImUsername(this), messageInfo.receiverImUserName, ShareDataTool.getIcon(this),
                messageInfo.receiverHeadUrl, ShareDataTool.getNickname(this), messageInfo.receiverNickName);

        info.groupDynamicID = messageInfo.receiverUserId;
        messageInfo = info;
        toChatUsername = messageInfo.receiverImUserName;
        LogManager.LogShow("222222", "----------", LogManager.ERROR);
        group = EMGroupManager.getInstance().getGroup(toChatUsername);
        ((TextView) findViewById(R.id.title_title)).setText(messageInfo.receiverNickName);
        ImageView groupchat = (ImageView) findViewById(R.id.title_groupchat);
        groupchat.setVisibility(View.VISIBLE);
        groupchat.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ChatActivity.this, GroupInfoActivity.class);
                intent.putExtra("id", messageInfo.receiverHeadUrl);
                intent.putExtra("groupId", messageInfo.receiverUserId);
                startActivity(intent);

            }
        });
    }

    // for chatroom type, we only init conversation and create view adapter
    // on success
    if (chatType != CHATTYPE_CHATROOM) {
        onConversationInit();

        onListViewCreation();

        // show forward message if the message is not null
        String forward_msg_id = getIntent().getStringExtra("forward_msg_id");
        if (forward_msg_id != null) {
            // ?????
            forwardMessage(forward_msg_id);
        }
    }
}

From source file:com.farmerbb.taskbar.service.TaskbarService.java

private View getView(List<AppEntry> list, int position) {
    View convertView = View.inflate(this, R.layout.icon, null);

    final AppEntry entry = list.get(position);
    final SharedPreferences pref = U.getSharedPreferences(this);

    ImageView imageView = (ImageView) convertView.findViewById(R.id.icon);
    ImageView imageView2 = (ImageView) convertView.findViewById(R.id.shortcut_icon);
    imageView.setImageDrawable(entry.getIcon(this));
    imageView2.setBackgroundColor(/*w  ww .  j a va 2 s .c o  m*/
            pref.getInt("accent_color", getResources().getInteger(R.integer.translucent_white)));

    String taskbarPosition = U.getTaskbarPosition(this);
    if (pref.getBoolean("shortcut_icon", true)) {
        boolean shouldShowShortcutIcon;
        if (taskbarPosition.contains("vertical"))
            shouldShowShortcutIcon = position >= list.size() - numOfPinnedApps;
        else
            shouldShowShortcutIcon = position < numOfPinnedApps;

        if (shouldShowShortcutIcon)
            imageView2.setVisibility(View.VISIBLE);
    }

    if (taskbarPosition.equals("bottom_right") || taskbarPosition.equals("top_right")) {
        imageView.setRotationY(180);
        imageView2.setRotationY(180);
    }

    FrameLayout layout = (FrameLayout) convertView.findViewById(R.id.entry);
    layout.setOnClickListener(view -> U.launchApp(TaskbarService.this, entry.getPackageName(),
            entry.getComponentName(), entry.getUserId(TaskbarService.this), null, true, false));

    layout.setOnLongClickListener(view -> {
        int[] location = new int[2];
        view.getLocationOnScreen(location);
        openContextMenu(entry, location);
        return true;
    });

    layout.setOnGenericMotionListener((view, motionEvent) -> {
        int action = motionEvent.getAction();

        if (action == MotionEvent.ACTION_BUTTON_PRESS
                && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
            int[] location = new int[2];
            view.getLocationOnScreen(location);
            openContextMenu(entry, location);
        }

        if (action == MotionEvent.ACTION_SCROLL && pref.getBoolean("visual_feedback", true))
            view.setBackgroundColor(0);

        return false;
    });

    if (pref.getBoolean("visual_feedback", true)) {
        layout.setOnHoverListener((v, event) -> {
            if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER) {
                int accentColor = U.getAccentColor(TaskbarService.this);
                accentColor = ColorUtils.setAlphaComponent(accentColor, Color.alpha(accentColor) / 2);
                v.setBackgroundColor(accentColor);
            }

            if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT)
                v.setBackgroundColor(0);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
                v.setPointerIcon(PointerIcon.getSystemIcon(TaskbarService.this, PointerIcon.TYPE_DEFAULT));

            return false;
        });

        layout.setOnTouchListener((v, event) -> {
            v.setAlpha(
                    event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE
                            ? 0.5f
                            : 1);
            return false;
        });
    }

    return convertView;
}

From source file:es.usc.citius.servando.calendula.fragments.ScheduleSummaryFragment.java

public void updateSummary() {

    int color = DB.patients().getActive(getActivity()).color();

    Log.d(TAG, "updateSummary ScheduleSUmmaryFragment");
    View rootView = getView();/*w  w  w .j a  va 2s  .  com*/

    Medicine med = ScheduleHelper.instance().getSelectedMed();
    Schedule s = ScheduleHelper.instance().getSchedule();
    List<ScheduleItem> items = ScheduleHelper.instance().getScheduleItems();

    final TextView summaryTitle = (TextView) rootView.findViewById(R.id.summaryTitle);
    final TextView medNameTv = (TextView) rootView.findViewById(R.id.sched_summary_medname);
    final TextView medDaysTv = (TextView) rootView.findViewById(R.id.sched_summary_medi_days);
    final TextView medDailyFreqTv = (TextView) rootView.findViewById(R.id.sched_summary_medi_dailyfreq);
    final ImageView medIconImage = (ImageView) rootView.findViewById(R.id.sched_summary_medicon);
    final Button showCalendarButton = (Button) rootView.findViewById(R.id.button_show_calendar);

    if (med != null) {
        medNameTv.setText(med.name());
    }

    medDaysTv.setText(s.toReadableString(getActivity()));
    medIconImage.setImageDrawable(iconFor(med != null ? med.presentation() : Presentation.PILLS));

    if (s.type() != Schedule.SCHEDULE_TYPE_HOURLY) {
        String freq = ScheduleUtils.getTimesStr(items != null ? items.size() : 0, getActivity());
        medDailyFreqTv.setText(freq);
    } else {
        String freq = ScheduleUtils.getTimesStr(24 / s.rule().interval(), getActivity());
        medDailyFreqTv.setText(freq);
    }

    showCalendarButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Schedule s = ScheduleHelper.instance().getSchedule();

            LocalDate start = s.start();

            Intent i = new Intent(getActivity(), SummaryCalendarActivity.class);

            if (start != null) {
                i.putExtra("start", start.toString(SummaryCalendarActivity.START_DATE_FORMAT));
            }

            if (s.type() == Schedule.SCHEDULE_TYPE_CYCLE) {
                i.putExtra("active_days", s.getCycleDays());
                i.putExtra("rest_days", s.getCycleRest());
            } else {
                i.putExtra("rule", s.rule().toIcal());
            }

            startActivity(i);
        }
    });

    summaryTitle.setTextColor(color);
    medNameTv.setTextColor(color);
    medDailyFreqTv.setTextColor(color);
    summaryTitle.setVisibility(View.VISIBLE);
    medNameTv.setVisibility(View.VISIBLE);
    medDailyFreqTv.setVisibility(View.VISIBLE);
    medIconImage.setVisibility(View.VISIBLE);

}

From source file:de.dfki.iui.opentok.cordova.plugin.OpenTokPlugin.java

private ImageView createAudioIcon(int initialResourceId, int initialVisibility) {

    ImageView imgView = new ImageView(this.cordova.getActivity());

    imgView.setImageResource(initialResourceId);
    imgView.setVisibility(initialVisibility);

    return imgView;
}

From source file:rikka.materialpreference.Preference.java

/**
 * Binds the created View to the data for this Preference.
 * <p>/*from   w  w  w.j a v  a2s .c  om*/
 * This is a good place to grab references to custom Views in the layout and
 * set properties on them.
 * <p>
 * Make sure to call through to the superclass's implementation.
 *
 * @param holder The ViewHolder that provides references to the views to fill in. These views
 *               will be recycled, so you should not hold a reference to them after this method
 *               returns.
 */
public void onBindViewHolder(PreferenceViewHolder holder) {
    holder.itemView.setOnClickListener(mClickListener);

    final TextView titleView = (TextView) holder.findViewById(android.R.id.title);
    if (titleView != null) {
        final CharSequence title = getTitle();
        if (!TextUtils.isEmpty(title)) {
            titleView.setText(title);
            titleView.setVisibility(View.VISIBLE);
        } else {
            titleView.setVisibility(View.GONE);
        }
    }

    final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
    if (summaryView != null) {
        final CharSequence summary = getSummary();
        if (!TextUtils.isEmpty(summary)) {
            summaryView.setText(summary);
            summaryView.setVisibility(View.VISIBLE);
        } else {
            summaryView.setVisibility(View.GONE);
        }
    }

    final ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
    if (imageView != null) {
        if (mIconResId != 0 || mIcon != null) {
            if (mIcon == null) {
                mIcon = ContextCompat.getDrawable(getContext(), mIconResId);
            }
            if (mIcon != null) {
                imageView.setImageDrawable(mIcon);
            }
        }
        imageView.setVisibility(mIcon != null ? View.VISIBLE : View.GONE);
    }

    final View imageFrame = holder.findViewById(R.id.icon_frame);
    if (imageFrame != null) {
        imageFrame.setVisibility(mIcon != null ? View.VISIBLE : View.GONE);
    }

    if (mShouldDisableView) {
        setEnabledStateOnViews(holder.itemView, isEnabled());
    } else {
        setEnabledStateOnViews(holder.itemView, true);
    }

    final boolean selectable = isSelectable();
    holder.itemView.setFocusable(selectable);

    holder.setDividerAllowedAbove(selectable);
    holder.setDividerAllowedBelow(selectable);
}