android.view.View#setLongClickable ( )源码实例Demo

下面列出了android.view.View#setLongClickable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BaseProject   文件: BaseViewHolder.java
/**
 * add long click view id
 *
 * @param viewId
 * @return if you use adapter bind listener
 * @link {(adapter.setOnItemChildLongClickListener(listener))}
 * <p>
 * or if you can use  recyclerView.addOnItemTouch(listerer)  wo also support this menthod
 */
@SuppressWarnings("unchecked")
public BaseViewHolder addOnLongClickListener(@IdRes final int viewId) {
    itemChildLongClickViewIds.add(viewId);
    final View view = getView(viewId);
    if (view != null) {
        if (!view.isLongClickable()) {
            view.setLongClickable(true);
        }
        view.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                return adapter.getOnItemChildLongClickListener() != null &&
                        adapter.getOnItemChildLongClickListener().onItemChildLongClick(adapter, v, getClickPosition());
            }
        });
    }
    return this;
}
 
源代码2 项目: Kandroid   文件: TaskDetailActivity.java
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    if (position < getCount() - (mShowAdd ? 1 : 0)) {
        convertView = mInflater.inflate(R.layout.listitem_comment, parent, false);
        convertView.setLongClickable(true);
        ((TextView) convertView.findViewById(R.id.username)).setText(Utils.fromHtml(String.format("<small>%s</small>", users == null ? mObjects.get(position).getUsername() : users.get(mObjects.get(position).getUserId()))));
        ((TextView) convertView.findViewById(R.id.date)).setText(Utils.fromHtml(String.format("<small>%tF</small>", mObjects.get(position).getDateModification())));
        ((TextView) convertView.findViewById(R.id.comment)).setText(Utils.fromHtml(mRenderer.render(mParser.parse(mObjects.get(position).getContent()))));
    } else {
        convertView = mInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
        ((TextView) convertView.findViewById(android.R.id.text1)).setText(getString(R.string.taskview_fab_new_comment));
        ((TextView) convertView.findViewById(android.R.id.text1)).setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
    }

    return convertView;
}
 
源代码3 项目: holoaccent   文件: ButtonFragment.java
@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View result = inflater.inflate(R.layout.buttons, null);
		
		View coloredButton = result.findViewById(R.id.coloredButton);
		coloredButton.setLongClickable(true);
//		registerForContextMenu(coloredButton);
		
//		mListPopupButton = result.findViewById(R.id.listPopupButton);
//		mListPopupButton.setOnLongClickListener(mPopupListener);

        QuickContactBadge badge = (QuickContactBadge)result.findViewById(R.id.badge);
        badge.assignContactFromEmail("[email protected]", false);
		
		return result;
	}
 
源代码4 项目: dynamic-support   文件: DynamicTooltip.java
/**
 * Set the tooltip for the view.
 *
 * @param view The view to set the tooltip on.
 * @param backgroundColor The background color for the tooltip.
 * @param tintColor The tint color for the tooltip.
 * @param icon The icon drawable for the tooltip.
 * @param text The text for the tooltip.
 */
public static void set(@NonNull View view, @ColorInt int backgroundColor,
        @ColorInt int tintColor, @Nullable Drawable icon, @Nullable CharSequence text) {
    // The code below is not attempting to update the tooltip text
    // for a pending or currently active tooltip, because it may lead
    // to updating the wrong tooltip in in some rare cases (e.g. when
    // action menu item views are recycled). Instead, the tooltip is
    // canceled/hidden. This might still be the wrong tooltip,
    // but hiding a wrong tooltip is less disruptive UX.
    if (sPendingHandler != null && sPendingHandler.mAnchor == view) {
        setPendingHandler(null);
    }
    if (TextUtils.isEmpty(text)) {
        if (sActiveHandler != null && sActiveHandler.mAnchor == view) {
            sActiveHandler.hide();
        }
        view.setOnLongClickListener(null);
        view.setLongClickable(false);
        view.setOnHoverListener(null);
    } else {
        new DynamicTooltip(view, backgroundColor, tintColor, icon, text);
    }
}
 
源代码5 项目: fuckView   文件: Hook.java
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
    super.beforeHookedMethod(param);
    View view = (View) param.thisObject;

    // java.lang.RuntimeException:
    // Don't call setOnClickListener for an AdapterView.
    // You probably want setOnItemClickListener() instead.

    if (isAdapterView(view) || view == null) {
        return;
    }
    try {
        view.setFocusable(true);
        view.setClickable(true);
        view.setEnabled(true);
        view.setLongClickable(true);
        view.setOnTouchListener(null);
        view.setOnClickListener(null);
        view.setOnLongClickListener(null);
    } catch (Throwable ignored) {

    }
}
 
源代码6 项目: litho   文件: MountState.java
/**
 * Installs the long click listeners that will dispatch the click handler defined in the
 * component's props. Unconditionally set the clickable flag on the view.
 */
private static void setLongClickHandler(
    EventHandler<LongClickEvent> longClickHandler, View view) {
  if (longClickHandler != null) {
    ComponentLongClickListener listener = getComponentLongClickListener(view);

    if (listener == null) {
      listener = new ComponentLongClickListener();
      setComponentLongClickListener(view, listener);
    }

    listener.setEventHandler(longClickHandler);

    view.setLongClickable(true);
  }
}
 
源代码7 项目: JD-Test   文件: BaseViewHolder.java
/**
 * add long click view id
 *
 * @param viewId
 * @return if you use adapter bind listener
 * @link {(adapter.setOnItemChildLongClickListener(listener))}
 * <p>
 * or if you can use  recyclerView.addOnItemTouch(listerer)  wo also support this menthod
 */
public BaseViewHolder addOnLongClickListener(final int viewId) {
    itemChildLongClickViewIds.add(viewId);
    final View view = getView(viewId);
    if (!view.isLongClickable()) {
        view.setLongClickable(true);
    }
    if (view != null) {
        view.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (adapter.getmOnItemChildLongClickListener() != null) {
                    adapter.getmOnItemChildLongClickListener().onItemChildLongClick(adapter, v, getClickPosition());
                }
                return false;
            }
        });
    }

    return this;
}
 
源代码8 项目: Kandroid   文件: TaskDetailActivity.java
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    if (position < getCount() - (mShowAdd ? 1 : 0)) {
        convertView = mInflater.inflate(R.layout.listitem_comment, parent, false);
        convertView.setLongClickable(true);
        ((TextView) convertView.findViewById(R.id.username)).setText(Utils.fromHtml(String.format("<small>%s</small>", users == null ? mObjects.get(position).getUsername() : users.get(mObjects.get(position).getUserId()))));
        ((TextView) convertView.findViewById(R.id.date)).setText(Utils.fromHtml(String.format("<small>%tF</small>", mObjects.get(position).getDateModification())));
        ((TextView) convertView.findViewById(R.id.comment)).setText(Utils.fromHtml(mRenderer.render(mParser.parse(mObjects.get(position).getContent()))));
    } else {
        convertView = mInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
        ((TextView) convertView.findViewById(android.R.id.text1)).setText(getString(R.string.taskview_fab_new_comment));
        ((TextView) convertView.findViewById(android.R.id.text1)).setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
    }

    return convertView;
}
 
源代码9 项目: Kandroid   文件: TaskDetailActivity.java
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.listitem_taskfiles, parent, false);
        convertView.setLongClickable(true);
    }

    ((TextView) convertView.findViewById(R.id.username)).setText(Utils.fromHtml(String.format("<small>%s</small>", users == null ? mObjects.get(position).getUsername() : users.get(mObjects.get(position).getUserId()))));
    ((TextView) convertView.findViewById(R.id.date)).setText(Utils.fromHtml(String.format("<small>%tF</small>", mObjects.get(position).getFileDate())));
    ((TextView) convertView.findViewById(R.id.filename)).setText(String.format("%s", mObjects.get(position).getName()));
    double size = mObjects.get(position).getSize();
    int rounds = 0;
    while (size > 1024 && rounds < 4) {
        size /= 1024;
        rounds++;
    }
    ((TextView) convertView.findViewById(R.id.filesize)).setText(String.format(Locale.getDefault(), "%.2f %s", size, mContext.getResources().getStringArray(R.array.file_sizes)[rounds]));
    return convertView;
}
 
源代码10 项目: Kandroid   文件: TaskDetailActivity.java
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.listitem_taskfiles, parent, false);
        convertView.setLongClickable(true);
    }

    ((TextView) convertView.findViewById(R.id.username)).setText(Utils.fromHtml(String.format("<small>%s</small>", users == null ? mObjects.get(position).getUsername() : users.get(mObjects.get(position).getUserId()))));
    ((TextView) convertView.findViewById(R.id.date)).setText(Utils.fromHtml(String.format("<small>%tF</small>", mObjects.get(position).getFileDate())));
    ((TextView) convertView.findViewById(R.id.filename)).setText(String.format("%s", mObjects.get(position).getName()));
    double size = mObjects.get(position).getSize();
    int rounds = 0;
    while (size > 1024 && rounds < 4) {
        size /= 1024;
        rounds++;
    }
    ((TextView) convertView.findViewById(R.id.filesize)).setText(String.format(Locale.getDefault(), "%.2f %s", size, mContext.getResources().getStringArray(R.array.file_sizes)[rounds]));
    return convertView;
}
 
源代码11 项目: DevUtils   文件: ViewUtils.java
/**
 * 设置 View 是否可以长按
 * @param longClickable {@code true} 可长按, {@code false} 不可长按
 * @param views         View[]
 * @return {@code true} 可长按, {@code false} 不可长按
 */
public static boolean setLongClickable(final boolean longClickable, final View... views) {
    if (views != null) {
        for (int i = 0, len = views.length; i < len; i++) {
            View view = views[i];
            if (view != null) {
                view.setLongClickable(longClickable);
            }
        }
    }
    return longClickable;
}
 
源代码12 项目: trackworktime   文件: EventListActivity.java
public EventViewHolder(View itemView, int viewType) {
	super(itemView, myMultiSelector);
	if (viewType == VIEW_TYPE_EVENT) {
		itemView.setLongClickable(true);
		itemView.setOnLongClickListener(this);
		itemView.setOnClickListener(this);
	}
	setSelectionModeBackgroundDrawable(getSelectedStateDrawable());
}
 
源代码13 项目: EfficientAdapter   文件: AdapterHelper.java
void setLongClickListenerOnView(EfficientViewHolder viewHolder) {
    View view = viewHolder.getView();
    View.OnLongClickListener listener = viewHolder.getOnLongClickListener(mOnItemClickListener != null);
    view.setOnLongClickListener(listener);
    if (listener == null) {
        view.setLongClickable(false);
    }
}
 
源代码14 项目: litho   文件: MountState.java
static void unsetViewAttributes(
    final Object content, final LayoutOutput output, final int mountFlags) {
  final Component component = output.getComponent();
  final boolean isHostView = isHostSpec(component);

  if (!isMountViewSpec(component)) {
    return;
  }

  final View view = (View) content;
  final NodeInfo nodeInfo = output.getNodeInfo();

  if (nodeInfo != null) {
    if (nodeInfo.getClickHandler() != null) {
      unsetClickHandler(view);
    }

    if (nodeInfo.getLongClickHandler() != null) {
      unsetLongClickHandler(view);
    }

    if (nodeInfo.getFocusChangeHandler() != null) {
      unsetFocusChangeHandler(view);
    }

    if (nodeInfo.getTouchHandler() != null) {
      unsetTouchHandler(view);
    }

    if (nodeInfo.getInterceptTouchHandler() != null) {
      unsetInterceptTouchEventHandler(view);
    }

    unsetViewTag(view);
    unsetViewTags(view, nodeInfo.getViewTags());

    unsetShadowElevation(view, nodeInfo.getShadowElevation());
    unsetOutlineProvider(view, nodeInfo.getOutlineProvider());
    unsetClipToOutline(view, nodeInfo.getClipToOutline());
    unsetClipChildren(view, nodeInfo.getClipChildren());

    if (!TextUtils.isEmpty(nodeInfo.getContentDescription())) {
      unsetContentDescription(view);
    }

    unsetScale(view, nodeInfo);
    unsetAlpha(view, nodeInfo);
    unsetRotation(view, nodeInfo);
    unsetRotationX(view, nodeInfo);
    unsetRotationY(view, nodeInfo);
  }

  view.setClickable(isViewClickable(mountFlags));
  view.setLongClickable(isViewLongClickable(mountFlags));

  unsetFocusable(view, mountFlags);
  unsetEnabled(view, mountFlags);
  unsetSelected(view, mountFlags);

  if (output.getImportantForAccessibility() != IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
    unsetImportantForAccessibility(view);
  }

  unsetAccessibilityDelegate(view);

  final ViewNodeInfo viewNodeInfo = output.getViewNodeInfo();
  if (viewNodeInfo != null) {
    unsetViewStateListAnimator(view, viewNodeInfo);
    // Host view doesn't set its own padding, but gets absolute positions for inner content from
    // Yoga. Also bg/fg is used as separate drawables instead of using View's bg/fg attribute.
    if (LayoutOutput.areDrawableOutputsDisabled(output.getFlags())) {
      unsetViewBackground(view, viewNodeInfo);
      unsetViewForeground(view, viewNodeInfo);
    }
    if (!isHostView) {
      unsetViewPadding(view, output, viewNodeInfo);
      unsetViewBackground(view, viewNodeInfo);
      unsetViewForeground(view, viewNodeInfo);
      unsetViewLayoutDirection(view);
    }
  }
}
 
源代码15 项目: JianshuApp   文件: SubscriptionAdapter.java
@Override
protected void convert(BaseViewHolder holder, SubscriptionListEntity.Subscription entity) {
    View itemView = holder.getConvertView();
    itemView.setTag(entity);
    itemView.setOnClickListener(this);
    if (entity.getSubscriptionType() == null || entity.getSubscriptionType() == SubscriptionType.notebook) {
        itemView.setLongClickable(false);
    } else {
        itemView.setLongClickable(true);
        final String userId = entity.getSource_identity().split(":")[0];
        itemView.setOnLongClickListener(v -> {
            showAddToDesktop(entity.getSubscriptionType(), userId, entity.getImage(), entity.getName());
            return true;
        });
    }


    TextView tvName = holder.getView(R.id.tv_name);
    tvName.setMaxWidth(DisplayInfo.getWidthPixels() / 2);

    holder.setText(R.id.tv_name, entity.getName());
    holder.setText(R.id.tv_desc, entity.getNewNoteTitle());

    // 未读数
    int unreadCount = entity.getUnreadCount();
    if (unreadCount == 0) {
        holder.setVisible(R.id.tv_unread, false);
        holder.setVisible(R.id.tv_notify, false);
    } else {
        holder.setVisible(R.id.tv_unread, true);
        holder.setVisible(R.id.tv_notify, true);

        String txt = unreadCount > 99 ? "99+" : String.valueOf(unreadCount);
        holder.setText(R.id.tv_unread, String.format(AppUtils.getContext().getString(R.string.count_article_update), txt));
    }


    UniversalDraweeView icon = holder.getView(R.id.avatar);
    SubscriptionType subscriptionType = entity.getSubscriptionType();
    if (subscriptionType != null) {
        switch (subscriptionType) {
            case user:
                icon.setCircle(true);
                icon.setImageURI(entity.getImage());
                break;
            case notebook:
                icon.setCircle(false);
                icon.setCornerRadiusRes(R.dimen.dp_4);
                icon.setImageURI(ImageUtils.parseUri(R.drawable.wj_image));
                break;
            default:
                icon.setCircle(false);
                icon.setCornerRadiusRes(R.dimen.dp_4);
                icon.setImageURI(entity.getImage());
                break;
        }
    }
}
 
源代码16 项目: xDrip-plus   文件: BgReadingTable.java
void bindView(View view, final Context context, final BgReading bgReading) {
    final BgReadingCursorAdapterViewHolder tag = (BgReadingCursorAdapterViewHolder) view.getTag();
    tag.raw_data_id.setText(BgGraphBuilder.unitized_string_with_units_static(bgReading.calculated_value)
            + "  " + JoH.qs(bgReading.calculated_value, 1)
            + " " + (!bgReading.isBackfilled() ? bgReading.slopeArrow() : ""));
    tag.raw_data_value.setText("Aged raw: " + JoH.qs(bgReading.age_adjusted_raw_value, 2));
    tag.raw_data_slope.setText(bgReading.isBackfilled() ? ("Backfilled" + " " + ((bgReading.source_info != null) ? bgReading.source_info : "")) : "Raw: " + JoH.qs(bgReading.raw_data, 2) + " " + ((bgReading.source_info != null) ? bgReading.source_info : ""));
    tag.raw_data_timestamp.setText(new Date(bgReading.timestamp).toString());

    if (bgReading.ignoreForStats) {
        // red invalid/cancelled/overridden
        view.setBackgroundColor(Color.parseColor("#660000"));
    } else {
        // normal grey
        view.setBackgroundColor(Color.parseColor("#212121"));
    }

    view.setLongClickable(true);
    view.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (which){
                        case DialogInterface.BUTTON_POSITIVE:
                            bgReading.ignoreForStats = true;
                            bgReading.save();
                            notifyDataSetChanged();
                            if (Pref.getBooleanDefaultFalse("wear_sync")) BgReading.pushBgReadingSyncToWatch(bgReading, false);
                            break;

                        case DialogInterface.BUTTON_NEGATIVE:
                            bgReading.ignoreForStats = false;
                            bgReading.save();
                            notifyDataSetChanged();
                            if (Pref.getBooleanDefaultFalse("wear_sync")) BgReading.pushBgReadingSyncToWatch(bgReading, false);
                            break;
                    }
                }
            };

            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage("Flag reading as \"bad\".\nFlagged readings have no impact on the statistics.").setPositiveButton("Yes", dialogClickListener)
                    .setNegativeButton("No", dialogClickListener).show();
            return true;
        }
    });

}
 
源代码17 项目: xDrip   文件: CalibrationDataTable.java
void bindView(View view, final Context context, final Calibration calibration) {
    final CalibrationDataCursorAdapterViewHolder tag = (CalibrationDataCursorAdapterViewHolder) view.getTag();
    tag.raw_data_id.setText(JoH.qs(calibration.bg, 4) + "    "+ BgGraphBuilder.unitized_string_static(calibration.bg));
    tag.raw_data_value.setText("raw: " + JoH.qs(calibration.estimate_raw_at_time_of_calibration, 4));
    tag.raw_data_slope.setText("slope: " + JoH.qs(calibration.slope, 4) + " intercept: " + JoH.qs(calibration.intercept, 4));
    tag.raw_data_timestamp.setText(JoH.dateTimeText(calibration.timestamp) + "  (" + JoH.dateTimeText(calibration.raw_timestamp) + ")");

    if (calibration.isNote()) {
        // green note
        view.setBackgroundColor(Color.parseColor("#004400"));
    } else if (!calibration.isValid()) {
        // red invalid/cancelled/overridden
        view.setBackgroundColor(Color.parseColor("#660000"));
    } else {
        // normal grey
        view.setBackgroundColor(Color.parseColor("#212121"));
    }

    view.setLongClickable(true);
    view.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (which){
                        case DialogInterface.BUTTON_POSITIVE:
                            calibration.clear_byuuid(calibration.uuid, false);
                            notifyDataSetChanged();
                            break;

                        case DialogInterface.BUTTON_NEGATIVE:
                            break;
                    }
                }
            };

            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage("Disable this calibration?\nFlagged calibrations will no longer have an effect.").setPositiveButton("Yes", dialogClickListener)
                    .setNegativeButton("No", dialogClickListener).show();
            return true;
        }
    });


}
 
源代码18 项目: xDrip   文件: BgReadingTable.java
void bindView(View view, final Context context, final BgReading bgReading) {
    final BgReadingCursorAdapterViewHolder tag = (BgReadingCursorAdapterViewHolder) view.getTag();
    tag.raw_data_id.setText(BgGraphBuilder.unitized_string_with_units_static(bgReading.calculated_value)
            + "  " + JoH.qs(bgReading.calculated_value, 1)
            + " " + (!bgReading.isBackfilled() ? bgReading.slopeArrow() : ""));
    tag.raw_data_value.setText("Aged raw: " + JoH.qs(bgReading.age_adjusted_raw_value, 2));
    tag.raw_data_slope.setText(bgReading.isBackfilled() ? ("Backfilled" + " " + ((bgReading.source_info != null) ? bgReading.source_info : "")) : "Raw: " + JoH.qs(bgReading.raw_data, 2) + " " + ((bgReading.source_info != null) ? bgReading.source_info : ""));
    tag.raw_data_timestamp.setText(new Date(bgReading.timestamp).toString());

    if (bgReading.ignoreForStats) {
        // red invalid/cancelled/overridden
        view.setBackgroundColor(Color.parseColor("#660000"));
    } else {
        // normal grey
        view.setBackgroundColor(Color.parseColor("#212121"));
    }

    view.setLongClickable(true);
    view.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (which){
                        case DialogInterface.BUTTON_POSITIVE:
                            bgReading.ignoreForStats = true;
                            bgReading.save();
                            notifyDataSetChanged();
                            if (Pref.getBooleanDefaultFalse("wear_sync")) BgReading.pushBgReadingSyncToWatch(bgReading, false);
                            break;

                        case DialogInterface.BUTTON_NEGATIVE:
                            bgReading.ignoreForStats = false;
                            bgReading.save();
                            notifyDataSetChanged();
                            if (Pref.getBooleanDefaultFalse("wear_sync")) BgReading.pushBgReadingSyncToWatch(bgReading, false);
                            break;
                    }
                }
            };

            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage("Flag reading as \"bad\".\nFlagged readings have no impact on the statistics.").setPositiveButton("Yes", dialogClickListener)
                    .setNegativeButton("No", dialogClickListener).show();
            return true;
        }
    });

}
 
源代码19 项目: xDrip-plus   文件: MegaStatus.java
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
    ViewHolder viewHolder;

    if (view == null) {
        viewHolder = new ViewHolder();
        view = mInflator.inflate(R.layout.listitem_megastatus, null);
        viewHolder.value = (TextView) view.findViewById(R.id.value);
        viewHolder.name = (TextView) view.findViewById(R.id.name);
        viewHolder.spacer = (TextView) view.findViewById(R.id.spacer);
        viewHolder.layout = (LinearLayout) view.findViewById(R.id.device_list_id);
        view.setTag(viewHolder);
        if (color_store1 == null) {
            color_store1 = viewHolder.name.getCurrentTextColor();
            padding_store_bottom_1 = viewHolder.layout.getPaddingBottom();
            padding_store_top_1 = viewHolder.layout.getPaddingTop();
            padding_store_left_1 = viewHolder.layout.getPaddingLeft();
            padding_store_right_1 = viewHolder.layout.getPaddingRight();
            gravity_store_1 = viewHolder.name.getGravity();
        }

    } else {
        viewHolder = (ViewHolder) view.getTag();
        //  reset all changed properties
        viewHolder.spacer.setVisibility(View.VISIBLE);
        viewHolder.name.setVisibility(View.VISIBLE);
        viewHolder.value.setVisibility(View.VISIBLE);
        viewHolder.name.setTextColor(color_store1);
        viewHolder.layout.setPadding(padding_store_left_1, padding_store_top_1, padding_store_right_1, padding_store_bottom_1);
        viewHolder.name.setGravity(gravity_store_1);
    }


    final StatusItem row = statusRows.get(i);

    // TODO  add buttons

    if (row.name.equals("line-break")) {
        viewHolder.spacer.setVisibility(View.GONE);
        viewHolder.name.setVisibility(View.GONE);
        viewHolder.value.setVisibility(View.GONE);
        viewHolder.layout.setPadding(10, 10, 10, 10);
    } else if (row.name.equals("heading-break")) {
        viewHolder.value.setVisibility(View.GONE);
        viewHolder.spacer.setVisibility(View.GONE);
        viewHolder.name.setText(row.value);
        viewHolder.name.setGravity(Gravity.CENTER_HORIZONTAL);
        viewHolder.name.setTextColor(Color.parseColor("#fff9c4"));
    } else {

        viewHolder.name.setText(row.name);
        viewHolder.value.setText(row.value);

        final int new_colour = row.highlight.color();
        //if (new_colour != -1) {
        viewHolder.value.setBackgroundColor(new_colour);
        viewHolder.spacer.setBackgroundColor(new_colour);
        viewHolder.name.setBackgroundColor(new_colour);
        //}
        view.setOnClickListener(null); // reset
        if ((row.runnable != null) && (row.button_name != null) && (row.button_name.equals("long-press"))) {
            runnableView = view; // last one
          /*  view.setLongClickable(true);
            view.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    try {
                        runOnUiThread(row.runnable);
                    } catch (Exception e) {
                        //
                    }
                    return true;
                }
            });*/
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        runOnUiThread(row.runnable);
                    } catch (Exception e) {
                        //
                    }

                }
            });
        } else {
            view.setLongClickable(false);
        }
    }

    return view;
}
 
源代码20 项目: xDrip-plus   文件: CalibrationDataTable.java
void bindView(View view, final Context context, final Calibration calibration) {
    final CalibrationDataCursorAdapterViewHolder tag = (CalibrationDataCursorAdapterViewHolder) view.getTag();
    tag.raw_data_id.setText(JoH.qs(calibration.bg, 4) + "    "+ BgGraphBuilder.unitized_string_static(calibration.bg));
    tag.raw_data_value.setText("raw: " + JoH.qs(calibration.estimate_raw_at_time_of_calibration, 4));
    tag.raw_data_slope.setText("slope: " + JoH.qs(calibration.slope, 4) + " intercept: " + JoH.qs(calibration.intercept, 4));
    tag.raw_data_timestamp.setText(JoH.dateTimeText(calibration.timestamp) + "  (" + JoH.dateTimeText(calibration.raw_timestamp) + ")");

    if (calibration.isNote()) {
        // green note
        view.setBackgroundColor(Color.parseColor("#004400"));
    } else if (!calibration.isValid()) {
        // red invalid/cancelled/overridden
        view.setBackgroundColor(Color.parseColor("#660000"));
    } else {
        // normal grey
        view.setBackgroundColor(Color.parseColor("#212121"));
    }

    view.setLongClickable(true);
    view.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (which){
                        case DialogInterface.BUTTON_POSITIVE:
                            calibration.clear_byuuid(calibration.uuid, false);
                            notifyDataSetChanged();
                            break;

                        case DialogInterface.BUTTON_NEGATIVE:
                            break;
                    }
                }
            };

            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage("Disable this calibration?\nFlagged calibrations will no longer have an effect.").setPositiveButton("Yes", dialogClickListener)
                    .setNegativeButton("No", dialogClickListener).show();
            return true;
        }
    });


}
 
 方法所在类
 同类方法