Java Code Examples for android.view.View.setLongClickable()

The following are Jave code examples for showing how to use setLongClickable() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: fuckView   File: Hook.java   Source Code and License Vote up 6 votes
@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) {

    }
}
 
Example 2
Project: GitHub   File: BaseViewHolder.java   Source Code and License Vote up 6 votes
/**
 * 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;
}
 
Example 3
Project: GitHub   File: BaseViewHolder.java   Source Code and License Vote up 6 votes
/**
 * 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;
}
 
Example 4
Project: Task-Reminder   File: MainActivity.java   Source Code and License Vote up 6 votes
public VerticalItemHolder(View itemView, SimpleAdapter adapter) {
    super(itemView, mMultiSelector);
    itemView.setOnClickListener(this);
    itemView.setOnLongClickListener(this);
    itemView.setLongClickable(true);

    // Initialize adapter for the items
    mAdapter = adapter;

    // Initialize views
    mTitleText = (TextView) itemView.findViewById(R.id.recycle_title);
    mDateAndTimeText = (TextView) itemView.findViewById(R.id.recycle_date_time);
    mRepeatInfoText = (TextView) itemView.findViewById(R.id.recycle_repeat_info);
    mActiveImage = (ImageView) itemView.findViewById(R.id.active_image);
    mThumbnailImage = (ImageView) itemView.findViewById(R.id.thumbnail_image);
}
 
Example 5
Project: garras   File: BaseViewHolder.java   Source Code and License Vote up 6 votes
/**
 * 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;
}
 
Example 6
Project: JD-Test   File: BaseViewHolder.java   Source Code and License Vote up 6 votes
/**
 * 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;
}
 
Example 7
Project: Kandroid   File: TaskDetailActivity.java   Source Code and License Vote up 6 votes
@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;
}
 
Example 8
Project: Kandroid   File: TaskDetailActivity.java   Source Code and License Vote up 6 votes
@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;
}
 
Example 9
Project: cwac-crossport   File: TooltipCompatHandler.java   Source Code and License Vote up 6 votes
/**
 * Set the tooltip text for the view.
 *
 * @param view        view to set the tooltip on
 * @param tooltipText the tooltip text
 */
public static void setTooltipText(View view, CharSequence tooltipText) {
    // 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 tooltipin 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 wrong tooltip is less disruptive UX.
    if (sPendingHandler != null && sPendingHandler.mAnchor == view) {
        setPendingHandler(null);
    }
    if (TextUtils.isEmpty(tooltipText)) {
        if (sActiveHandler != null && sActiveHandler.mAnchor == view) {
            sActiveHandler.hide();
        }
        view.setOnLongClickListener(null);
        view.setLongClickable(false);
        view.setOnHoverListener(null);
    } else {
        new TooltipCompatHandler(view, tooltipText);
    }
}
 
Example 10
Project: buildAPKsSamples   File: AccountsAdapter.java   Source Code and License Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
  if (convertView == null) {
    convertView = inflater.inflate(R.layout.account_entry, null);
  }
  final Account account = accounts.get(position);
  ((ImageView) convertView.findViewById(R.id.service_logo))
      .setImageResource(AccountsUtil.getAccountLogoResource(account.type));
  ((TextView) convertView.findViewById(R.id.account_name))
      .setText(account.name);
  ((TextView) convertView.findViewById(R.id.account_id)).setText(account.id);

  convertView.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
      callback.callback(account.id);
    }
  });
  convertView.setLongClickable(true);

  return convertView;
}
 
Example 11
Project: Ripple   File: MainActivity.java   Source Code and License Vote up 5 votes
/**
 * Set Android UI event handlers and connect to the RightMesh library when the
 * activity initializes.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    View buttonSend = findViewById(R.id.button_send);
    buttonSend.setOnClickListener(v -> sendMessage(target, colour));

    View buttonSendAll = findViewById(R.id.button_sendAll);
    buttonSendAll.setOnClickListener(v -> sendAll());

    // Display the RightMesh settings activity when the send button is tapped and held.
    buttonSend.setLongClickable(true);
    buttonSend.setOnLongClickListener(v -> {
        try {
            mm.showSettingsActivity();
        } catch (RightMeshException ignored) { /* Meh. */ }
        return true;
    });

    // Change the background colour when the respective colour buttons are pressed.
    findViewById(R.id.button_red).setOnClickListener(v -> setColour("RED"));
    findViewById(R.id.button_green).setOnClickListener(v -> setColour("GREEN"));
    findViewById(R.id.button_blue).setOnClickListener(v -> setColour("BLUE"));

    // Set up the recipient selection spinner.
    peersListAdapter = new MeshIDAdapter(this);
    component = (RightMeshRecipientComponent) getFragmentManager()
            .findFragmentById(R.id.recipient_component);
    component.setSpinnerAdapter(peersListAdapter);
    component.setOnRecipientChangedListener(this);

    // Initialize the RightMesh library with the SSID pattern "Ripple".
    mm = AndroidMeshManager.getInstance(MainActivity.this, MainActivity.this, "Ripple");
}
 
Example 12
Project: MusicX-music-player   File: FolderAdapter.java   Source Code and License Vote up 5 votes
public Folderviewholder(View itemView) {
    super(itemView);
    thumbnail = (CircleImageView) itemView.findViewById(R.id.artwork);
    filename = (TextView) itemView.findViewById(R.id.title);
    menu = (ImageButton) itemView.findViewById(R.id.menu_button);
    extraParam = (TextView) itemView.findViewById(R.id.artist);
    itemView.setOnClickListener(this);
    menu.setOnClickListener(this);
    itemView.setLongClickable(true);
    itemView.setOnLongClickListener(this);
    itemView.setOnClickListener(this);
    menu.setOnClickListener(this);
}