Java Code Examples for android.widget.ImageButton#setOnLongClickListener()

The following examples show how to use android.widget.ImageButton#setOnLongClickListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppPickerPreference.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    LinearLayout widgetFrameView = ((LinearLayout) view.findViewById(android.R.id.widget_frame));
    mBtnAppIcon = new ImageButton(mContext);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mAppIconPreviewSizePx, mAppIconPreviewSizePx);
    lp.gravity = Gravity.CENTER;
    mBtnAppIcon.setLayoutParams(lp);
    mBtnAppIcon.setScaleType(ScaleType.CENTER_CROP);
    mBtnAppIcon.setImageDrawable(mAppInfo.icon);
    mBtnAppIcon.setFocusable(false);
    if (mIconPickerEnabled) {
        mBtnAppIcon.setOnClickListener(this);
        mBtnAppIcon.setOnLongClickListener(this);
    } else {
        mBtnAppIcon.setEnabled(false);
    }
    widgetFrameView.addView(mBtnAppIcon);
    widgetFrameView.setVisibility(View.VISIBLE);
}
 
Example 2
Source File: CustomTabToolbar.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    setBackground(new ColorDrawable(
            ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color)));
    mUrlBar = (UrlBar) findViewById(R.id.url_bar);
    mUrlBar.setHint("");
    mUrlBar.setDelegate(this);
    mUrlBar.setEnabled(false);
    mUrlBar.setAllowFocus(false);
    mTitleBar = (TextView) findViewById(R.id.title_bar);
    mLocationBarFrameLayout = findViewById(R.id.location_bar_frame_layout);
    mTitleUrlContainer = findViewById(R.id.title_url_container);
    mTitleUrlContainer.setOnLongClickListener(this);
    mSecurityButton = (TintedImageButton) findViewById(R.id.security_button);
    mSecurityIconType = ConnectionSecurityLevel.NONE;
    mCustomActionButton = (ImageButton) findViewById(R.id.action_button);
    mCustomActionButton.setOnLongClickListener(this);
    mCloseButton = (ImageButton) findViewById(R.id.close_button);
    mCloseButton.setOnLongClickListener(this);
    mAnimDelegate = new CustomTabToolbarAnimationDelegate(mSecurityButton, mTitleUrlContainer);
}
 
Example 3
Source File: CustomButtonParams.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Builds an {@link ImageButton} from the data in this params. Generated buttons should be
 * placed on the bottom bar. The button's tag will be its id.
 * @param parent The parent that the inflated {@link ImageButton}.
 * @param listener {@link OnClickListener} that should be used with the button.
 * @return Parsed list of {@link CustomButtonParams}, which is empty if the input is invalid.
 */
ImageButton buildBottomBarButton(Context context, ViewGroup parent, OnClickListener listener) {
    if (mIsOnToolbar) return null;

    ImageButton button = (ImageButton) LayoutInflater.from(context)
            .inflate(R.layout.custom_tabs_bottombar_item, parent, false);
    button.setId(mId);
    button.setImageBitmap(mIcon);
    button.setContentDescription(mDescription);
    if (mPendingIntent == null) {
        button.setEnabled(false);
    } else {
        button.setOnClickListener(listener);
    }
    button.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            final int screenWidth = view.getResources().getDisplayMetrics().widthPixels;
            final int screenHeight = view.getResources().getDisplayMetrics().heightPixels;
            final int[] screenPos = new int[2];
            view.getLocationOnScreen(screenPos);
            final int width = view.getWidth();

            Toast toast = Toast.makeText(
                    view.getContext(), view.getContentDescription(), Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.BOTTOM | Gravity.END,
                    screenWidth - screenPos[0] - width / 2,
                    screenHeight - screenPos[1]);
            toast.show();
            return true;
        }
    });
    return button;
}
 
Example 4
Source File: ColdAddressFragmentListItemView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void initView() {
    flAddress = (FrameLayout) findViewById(R.id.fl_address);
    ivQr = (QrCodeImageView) findViewById(R.id.iv_qrcode);
    tvAddress = (TextView) findViewById(R.id.tv_address);
    ivType = (ImageView) findViewById(R.id.iv_type);
    btnAlias = (Button) findViewById(R.id.btn_address_alias);
    ibtnXRandomLabel = (ImageButton) findViewById(R.id.ibtn_xrandom_label);
    ibtnXRandomLabel.setOnLongClickListener(DialogXRandomInfo.InfoLongClick);
    flAddress.setOnClickListener(copyClick);
    ivQr.setOnClickListener(qrClick);
    ivType.setOnLongClickListener(typeClick);
    btnAlias.setOnClickListener(aliasClick);
}
 
Example 5
Source File: ColdAddressFragmentHDMEnterpriseListItemView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void initView() {
    ivType = (ImageView) findViewById(R.id.iv_type);
    ibtnXRandomLabel = (ImageButton) findViewById(R.id.ibtn_xrandom_label);
    ibtnXRandomLabel.setOnLongClickListener(DialogXRandomInfo.InfoLongClick);
    ivType.setOnLongClickListener(typeClick);
    findViewById(R.id.ibtn_seed_option).setOnClickListener(seedOptionClick);
    findViewById(R.id.ibtn_qr_code_option).setOnClickListener(qrCodeOptionClick);
    dp = new DialogProgress(getContext(), R.string.please_wait);
    dp.setCancelable(false);
}
 
Example 6
Source File: ColdAddressFragmentHDMListItemView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void initView() {
    ivType = (ImageView) findViewById(R.id.iv_type);
    ibtnXRandomLabel = (ImageButton) findViewById(R.id.ibtn_xrandom_label);
    ibtnXRandomLabel.setOnLongClickListener(DialogXRandomInfo.InfoLongClick);
    ivType.setOnLongClickListener(typeClick);
    findViewById(R.id.ibtn_seed_option).setOnClickListener(seedOptionClick);
    findViewById(R.id.ibtn_qr_code_option).setOnClickListener(qrCodeOptionClick);
    dp = new DialogProgress(getContext(), R.string.please_wait);
    dp.setCancelable(false);
}
 
Example 7
Source File: EmojiView.java    From KitKatEmoji with MIT License 5 votes vote down vote up
private void init() {
    mPreference = getContext().getSharedPreferences(EMOJI_PREFERENCE, Context.MODE_PRIVATE);
    LayoutInflater inflater = LayoutInflater.from(getContext());
    View root = inflater.inflate(R.layout.emoji_layout, this);
    mTabs = (PagerSlidingTabStrip) root.findViewById(R.id.tabs);
    mPager = (ViewPager) root.findViewById(R.id.pager);
    mBackSpace = (ImageButton) root.findViewById(R.id.back_space);
    mGridViews = new ArrayList<GridView>();

    for (int i = 0, count = mIcons.length; i < count; i++) {
        String[] emoji = getResources().getStringArray(mEmojis[i]);
        EmojiGridAdapter emojiGridAdapter = new EmojiGridAdapter(getContext(), emoji);
        GridView gridView = (GridView) inflater.inflate(R.layout.emoji_gridview, null);
        gridView.setAdapter(emojiGridAdapter);
        mGridViews.add(gridView);
        if (i == 0) {
            gridView.setOnItemClickListener(mRecentItemClickListener);
            mRecentsWrap = (FrameLayout) inflater.inflate(R.layout.emoji_recent, null);
            mEmptyView = mRecentsWrap.findViewById(R.id.no_recent);
            mRecentsWrap.addView(gridView);
        } else {
            gridView.setOnItemClickListener(mItemClickListener);
        }
    }

    loadRecent();
    mPagerAdapter = new EmojiPagerAdapter();
    mPager.setAdapter(mPagerAdapter);
    mTabs.setOnPageChangeListener(mOnPageChangeListener);
    mTabs.setViewPager(mPager);
    mPager.setCurrentItem(mPreference.getInt(PREF_KEY_LAST_TAB, 0));
    mBackSpace.setOnClickListener(mBackSpaceClickListener);
    mBackSpace.setOnLongClickListener(mBackSpaceLongClickListener);
    mBackSpace.setOnTouchListener(mBackSpaceTouchListener);
}
 
Example 8
Source File: ActionMenuItemView.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
@Override
public void onFinishInflate() {

    mImageButton = (ImageButton) findViewById(R.id.abs__imageButton);
    mTextButton = (CapitalizingButton) findViewById(R.id.abs__textButton);
    mImageButton.setOnClickListener(this);
    mTextButton.setOnClickListener(this);
    mImageButton.setOnLongClickListener(this);
    setOnClickListener(this);
    setOnLongClickListener(this);
}
 
Example 9
Source File: CustomButtonParams.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Builds an {@link ImageButton} from the data in this params. Generated buttons should be
 * placed on the bottom bar. The button's tag will be its id.
 * @param parent The parent that the inflated {@link ImageButton}.
 * @param listener {@link OnClickListener} that should be used with the button.
 * @return Parsed list of {@link CustomButtonParams}, which is empty if the input is invalid.
 */
ImageButton buildBottomBarButton(Context context, ViewGroup parent, OnClickListener listener) {
    if (mIsOnToolbar) return null;

    ImageButton button = (ImageButton) LayoutInflater.from(context)
            .inflate(R.layout.custom_tabs_bottombar_item, parent, false);
    button.setId(mId);
    button.setImageBitmap(mIcon);
    button.setContentDescription(mDescription);
    if (mPendingIntent == null) {
        button.setEnabled(false);
    } else {
        button.setOnClickListener(listener);
    }
    button.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            final int screenWidth = view.getResources().getDisplayMetrics().widthPixels;
            final int screenHeight = view.getResources().getDisplayMetrics().heightPixels;
            final int[] screenPos = new int[2];
            view.getLocationOnScreen(screenPos);
            final int width = view.getWidth();

            Toast toast = Toast.makeText(
                    view.getContext(), view.getContentDescription(), Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.BOTTOM | Gravity.END,
                    screenWidth - screenPos[0] - width / 2,
                    screenHeight - screenPos[1]);
            toast.show();
            return true;
        }
    });
    return button;
}
 
Example 10
Source File: DialPadView.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
private void init(Context context, AttributeSet attrs, int defStyleAttr)
{
    inflate(context, R.layout.layout_dial_pad, this);
    mEdInput = (DigitsEditText) findViewById(R.id.ed_dial_input);
    mEdInput.setKeyListener(UnicodeDialerKeyListener.INSTANCE);
    mEdInput.setOnClickListener(this);
    mEdInput.setOnKeyListener(this);
    mEdInput.setOnLongClickListener(this);
    mEdInput.addTextChangedListener(this);

    mBtnDelete = (ImageButton) findViewById(R.id.btn_dial_input_delete);
    mBtnDelete.setOnClickListener(this);
    mBtnDelete.setOnLongClickListener(this);
    findViewById(R.id.btn_dial_digist_0).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_1).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_2).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_3).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_4).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_5).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_6).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_7).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_8).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_9).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_star).setOnClickListener(this);
    findViewById(R.id.btn_dial_digist_pound).setOnClickListener(this);
    findViewById(R.id.btn_dial_input_plus).setOnClickListener(this);
    findViewById(R.id.btn_dial_pad_call).setOnClickListener(this);

    //获取震动管理器对象
    mVibratorMgr = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
}
 
Example 11
Source File: TutorialActivity.java    From Pasta-Music with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tutorial);

    mButtonLeft = (Button) findViewById(R.id.tutorial_button_left);
    mImageButtonLeft = (ImageButton) findViewById(R.id.tutorial_button_image_left);
    mImageButtonRight = (ImageButton) findViewById(R.id.tutorial_button_image_right);
    mPageIndicator = (PageIndicator) findViewById(R.id.tutorial_page_indicator);
    mRelativeLayout = (RelativeLayout) findViewById(R.id.relative_layout);
    mViewPager = (ViewPager) findViewById(R.id.view_pager);

    mButtonLeft.setOnClickListener(this);
    mImageButtonLeft.setOnClickListener(this);
    mImageButtonRight.setOnClickListener(this);
    mImageButtonLeft.setOnLongClickListener(this);
    mImageButtonRight.setOnLongClickListener(this);

    setupFragmentList();

    mAdapter = new TutorialViewPagerAdapter(getSupportFragmentManager());

    mAdapter.setFragments(mFragmentList);

    mRelativeLayout.setBackgroundColor(Color.BLUE);
    mViewPager.setAdapter(mAdapter);
    mViewPager.addOnPageChangeListener(this);
    mViewPager.setPageTransformer(false, getPageTransformer());

    mPageIndicator.setEngine(getPageIndicatorEngine());
    mPageIndicator.setViewPager(mViewPager);

    //We use this to actualize the Strings
    mPreviousPage = 0;
    onPageSelected(0);
}
 
Example 12
Source File: ActionMenuItemView.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public void onFinishInflate() {

    mImageButton = (ImageButton) findViewById(R.id.abs__imageButton);
    mTextButton = (CapitalizingButton) findViewById(R.id.abs__textButton);
    mImageButton.setOnClickListener(this);
    mTextButton.setOnClickListener(this);
    mImageButton.setOnLongClickListener(this);
    setOnClickListener(this);
    setOnLongClickListener(this);
}
 
Example 13
Source File: CommonPlaybackButtonsListener.java    From android-vlc-remote with GNU General Public License v3.0 5 votes vote down vote up
private void setupImageButtonListeners(ImageButton... imageButtons) {
    for(ImageButton b : imageButtons) {
        if(b != null) {
            Button info = Buttons.getButton(b.getId(), Preferences.get(b.getContext()));
            b.setImageResource(info.getIconId());
            b.setContentDescription(b.getContext().getString(info.getContentDescriptionId()));
            b.setOnClickListener(this);
            b.setOnLongClickListener(this);
        }
    }
}
 
Example 14
Source File: ButtonsFragment.java    From android-vlc-remote with GNU General Public License v3.0 5 votes vote down vote up
private void setupImageButtonListeners(ImageButton... imageButtons) {
    for(ImageButton b : imageButtons) {
        if(b != null) {
            b.setOnClickListener(this);
            b.setOnLongClickListener(this);
        }
    }
}
 
Example 15
Source File: DialerFragment.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
private void attachButtonListener(View v, int id, boolean longAttach) {
    ImageButton button = (ImageButton) v.findViewById(id);
    if(button == null) {
        Log.w(THIS_FILE, "Not found button " + id);
        return;
    }
    if(longAttach) {
        button.setOnLongClickListener(this);
    }else {
        button.setOnClickListener(this);
    }
}
 
Example 16
Source File: AboutActivity.java    From QuickLyric with GNU General Public License v3.0 5 votes vote down vote up
private void setupDemoScreen() {
    ViewGroup rootView = (ViewGroup) findViewById(android.R.id.content).getRootView();
    getLayoutInflater().inflate(R.layout.tutorial_view, (ViewGroup) rootView.getChildAt(0));
    final ViewPager pager = findViewById(R.id.pager);
    CircleIndicator indicator = findViewById(R.id.indicator);
    final IntroScreenSlidePagerAdapter pagerAdapter = new IntroScreenSlidePagerAdapter(this);
    pager.setAdapter(pagerAdapter);
    pager.addOnPageChangeListener(pagerAdapter);
    indicator.setViewPager(pager);
    pager.setCurrentItem(pagerAdapter.rightToLeft ? pagerAdapter.getCount() - 1 : 0);
    indicator.setOnPageChangeListener(pagerAdapter);
    Button skipButton = rootView.findViewById(R.id.pager_button);
    ImageButton arrowButton = rootView.findViewById(R.id.pager_arrow);
    skipButton.setOnClickListener(v -> {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
            pagerAdapter.exitAction();
        else
            pager.setCurrentItem(pagerAdapter.getCount() - 1);
    });
    arrowButton.setOnClickListener(v -> pagerAdapter.nextAction());
    arrowButton.setOnLongClickListener(v -> {
        if (Build.MODEL.equalsIgnoreCase("Robin")) {
            int[] ints = new int[3];
            ints[45]++;
        }
        return false;
    });
}
 
Example 17
Source File: ActionMenuItemView.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
@Override
public void onFinishInflate() {

    mImageButton = (ImageButton) findViewById(R.id.abs__imageButton);
    mTextButton = (CapitalizingButton) findViewById(R.id.abs__textButton);
    mImageButton.setOnClickListener(this);
    mTextButton.setOnClickListener(this);
    mImageButton.setOnLongClickListener(this);
    setOnClickListener(this);
    setOnLongClickListener(this);
}
 
Example 18
Source File: PolygonCreateFeatureToolGroup.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
public void initUI() {
    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    parent.removeAllViews();

    Context context = parent.getContext();
    IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
    int padding = 2;

    if (editLayer != null) {
        gpsStreamButton = new ImageButton(context);
        gpsStreamButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        gpsStreamButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_gps_stream_24dp));
        gpsStreamButton.setPadding(0, padding, 0, padding);
        gpsStreamButton.setOnTouchListener(this);
        gpsStreamButton.setOnLongClickListener(this);
        gpsStreamButton.setOnClickListener(this);
        parent.addView(gpsStreamButton);

        addVertexButton = new ImageButton(context);
        addVertexButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        addVertexButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_vertex_24dp));
        addVertexButton.setPadding(0, padding, 0, padding);
        addVertexButton.setOnTouchListener(this);
        addVertexButton.setOnClickListener(this);
        parent.addView(addVertexButton);

        addVertexByTapButton = new ImageButton(context);
        addVertexByTapButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        addVertexByTapButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_vertex_tap_24dp));
        addVertexByTapButton.setPadding(0, padding, 0, padding);
        addVertexByTapButton.setOnTouchListener(this);
        addVertexByTapButton.setOnClickListener(this);
        parent.addView(addVertexByTapButton);

        undoButton = new ImageButton(context);
        undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
        undoButton.setPadding(0, padding, 0, padding);
        undoButton.setOnTouchListener(this);
        undoButton.setOnClickListener(this);
        parent.addView(undoButton);

        commitButton = new ImageButton(context);
        commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
        commitButton.setPadding(0, padding, 0, padding);
        commitButton.setOnTouchListener(this);
        commitButton.setOnClickListener(this);
        commitButton.setVisibility(View.GONE);
        parent.addView(commitButton);
    }
}
 
Example 19
Source File: PointCreateFeatureToolGroup.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
public void initUI() {
    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    parent.removeAllViews();

    Context context = parent.getContext();
    IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
    int padding = 2;

    if (editLayer != null) {
        gpsStreamButton = new ImageButton(context);
        gpsStreamButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        gpsStreamButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_gps_off_24dp));
        gpsStreamButton.setPadding(0, padding, 0, padding);
        gpsStreamButton.setOnTouchListener(this);
        gpsStreamButton.setOnLongClickListener(this);
        gpsStreamButton.setOnClickListener(this);
        parent.addView(gpsStreamButton);

        addVertexButton = new ImageButton(context);
        addVertexButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        addVertexButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_center_24dp));
        addVertexButton.setPadding(0, padding, 0, padding);
        addVertexButton.setOnTouchListener(this);
        addVertexButton.setOnClickListener(this);
        parent.addView(addVertexButton);

        addVertexByTapButton = new ImageButton(context);
        addVertexByTapButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        addVertexByTapButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_tap_off_24dp));
        addVertexByTapButton.setPadding(0, padding, 0, padding);
        addVertexByTapButton.setOnTouchListener(this);
        addVertexByTapButton.setOnClickListener(this);
        parent.addView(addVertexByTapButton);

        undoButton = new ImageButton(context);
        undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
        undoButton.setPadding(0, padding, 0, padding);
        undoButton.setOnTouchListener(this);
        undoButton.setOnClickListener(this);
        parent.addView(undoButton);

        commitButton = new ImageButton(context);
        commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
        commitButton.setPadding(0, padding, 0, padding);
        commitButton.setOnTouchListener(this);
        commitButton.setOnClickListener(this);
        commitButton.setVisibility(View.GONE);
        parent.addView(commitButton);
    }
}
 
Example 20
Source File: WaypointInformation.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_waypoint_information, container, false);
    final ImageButton editButton = rootView.findViewById(R.id.editButton);
    final ImageButton shareButton = rootView.findViewById(R.id.shareButton);
    final ImageButton deleteButton = rootView.findViewById(R.id.deleteButton);

    editButton.setOnClickListener(v -> setEditorMode(true));
    shareButton.setOnClickListener(v -> {
        mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
        mListener.onWaypointShare(mWaypoint);
    });
    deleteButton.setOnClickListener(v -> {
        Animation shake = AnimationUtils.loadAnimation(getContext(), R.anim.shake);
        v.startAnimation(shake);
    });
    deleteButton.setOnLongClickListener(v -> {
        mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
        mListener.onWaypointDelete(mWaypoint);
        return true;
    });

    mEditorMode = false;
    mPopAll = false;

    rootView.post(() -> {
        updatePeekHeight(rootView, false);
        mBottomSheetBehavior.setSkipCollapsed(mExpanded);
        int panelState = mExpanded ? BottomSheetBehavior.STATE_EXPANDED : BottomSheetBehavior.STATE_COLLAPSED;
        if (savedInstanceState != null) {
            panelState = savedInstanceState.getInt("panelState", panelState);
            View dragHandle = rootView.findViewById(R.id.dragHandle);
            dragHandle.setAlpha(panelState == BottomSheetBehavior.STATE_EXPANDED ? 0f : 1f);
        }
        mBottomSheetBehavior.setState(panelState);
        // Workaround for panel partially drawn on first slide
        // TODO Try to put transparent view above map
        if (Configuration.getHideSystemUI())
            rootView.requestLayout();
    });

    return rootView;
}