Java Code Examples for android.widget.LinearLayout.setOnTouchListener()

The following are Jave code examples for showing how to use setOnTouchListener() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: NUI_Project   File: SongPlayerFragment.java   View Source Code Vote up 6 votes
private void setupSongPanel(View root) {
    //Set up song panel (gestures)
    LinearLayout songPanel = (LinearLayout) root.findViewById(R.id.song_player_song_panel);
    songPanel.setOnTouchListener(new OnSwipeTouchListener(getActivity()) {
        public void onSwipeTop() {
            Toast.makeText(getActivity(),"Increase Volume",Toast.LENGTH_SHORT).show();
            mPresenter.volumeUp();
        }
        public void onSwipeRight() {
            mPresenter.lastSong();
            Logger.get().log(new UserEvent(UserEvent.Source.Gesture, UserEvent.Action.Next));
        }
        public void onSwipeLeft() {
            mPresenter.nextSong();
            Logger.get().log(new UserEvent(UserEvent.Source.Gesture, UserEvent.Action.Last));
        }
        public void onSwipeBottom() {
            Toast.makeText(getActivity(), "Decrease Volume", Toast.LENGTH_SHORT).show();
            mPresenter.volumeDown();
        }
        public void onSingleTap() {
            mPresenter.playPauseSong();
            Logger.get().log(new UserEvent(UserEvent.Source.Gesture, UserEvent.Action.PlayPause));
        }
    });
}
 
Example 2
Project: Bigbang   File: ArcTipViewController.java   View Source Code Vote up 5 votes
private void initView() {
    showBigBang = SPHelper.getBoolean(ConstantUtil.TOTAL_SWITCH, true);
    isStick=SPHelper.getBoolean(ConstantUtil.FLOATVIEW_IS_STICK,false);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        Point point = new Point();
        mWindowManager.getDefaultDisplay().getSize(point);
        mScreenWidth = point.x;
        mScreenHeight = point.y;
    } else {
        mScreenWidth = mWindowManager.getDefaultDisplay().getWidth();
        mScreenHeight = mWindowManager.getDefaultDisplay().getHeight();
    }
    if (showBigBang) {
        mCurrentIconAlpha =  SPHelper.getInt(ConstantUtil.FLOATVIEW_ALPHA, 70) / 100f;
    } else {
        mCurrentIconAlpha = 0.6f * SPHelper.getInt(ConstantUtil.FLOATVIEW_ALPHA, 70) / 100f;
    }

    iconFloatView = (LinearLayout) View.inflate(mContext, R.layout.arc_float_icon, null);
    floatImageView = ((ImageView) iconFloatView.findViewById(R.id.float_image));
    acrFloatView = (RelativeLayout) View.inflate(mContext, R.layout.arc_view_float, null);
    archMenu = (ArcMenu) acrFloatView.findViewById(R.id.arc_menu);
    initIcon();
    archMenu.setOnModeSeletedListener(new ArcMenu.OnModeSeletedListener() {
        @Override
        public void onModeSelected() {
            showFloatImageView();
        }

        @Override
        public void onNothing() {

        }
    });
    // event listeners
    acrFloatView.setOnTouchListener(this);
    iconFloatView.setOnTouchListener(this);
}
 
Example 3
Project: DateScroller   File: DateScrollerView.java   View Source Code Vote up 5 votes
private void addMoreDays() {
    int currentDataSize = dateData.size();
    for (int i = 0; i < NEW_COUNT; i++) {
        DateScrollerData data = DateScrollerUitls.addDate(getContext(), calendar, 1);
        dateData.add(data);
        LinearLayout child = (LinearLayout) LayoutInflater
                .from(getContext()).inflate(R.layout.item_datescroller, null);
        ((TextView) child.findViewById(R.id.item_datescroller_dayOfWeek)).setText(data.getDay());
        ((TextView) child.findViewById(R.id.item_datescroller_day))
                .setText(data.getDayOfMonth() + "");
        final int postion = currentDataSize + i;

        child.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                if (!isScrolling)
                    setSelected(postion);
                return false;
            }


        });

        addView(child);
        isAddingDays = false;
    }
}
 
Example 4
Project: GitHub   File: CountryListView.java   View Source Code Vote up 4 votes
private void init(Context context) {
	SizeHelper.prepare(context);

	lvContries = new GroupListView(context);
	lvContries.setDividerHeight(SizeHelper.fromPxWidth(1));
	int resId = ResHelper.getBitmapRes(context, "smssdk_cl_divider");
	if (resId > 0) {
		lvContries.setDivider(context.getResources().getDrawable(resId));
	}
	adapter = new CountryAdapter(lvContries);
	lvContries.setAdapter(adapter);
	LayoutParams lpContries = new LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	int dp9 = SizeHelper.fromPxWidth(12);
	lpContries.setMargins(dp9, 0, dp9, 0);
	addView(lvContries, lpContries);

	tvScroll = new TextView(context);
	resId = ResHelper.getColorRes(context, "smssdk_white");
	if (resId > 0) {
		tvScroll.setTextColor(context.getResources().getColor(resId));
	}
	resId = ResHelper.getBitmapRes(context, "smssdk_country_group_scroll_down");
	if (resId > 0) {
		tvScroll.setBackgroundResource(resId);
	}
	tvScroll.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(80));
	tvScroll.setTypeface(Typeface.DEFAULT);
	tvScroll.setVisibility(GONE);
	tvScroll.setGravity(Gravity.CENTER);
	int dp80 = SizeHelper.fromPxWidth(120);
	LayoutParams lp = new LayoutParams(dp80, dp80);
	lp.addRule(CENTER_IN_PARENT);
	addView(tvScroll, lp);

	llScroll = new LinearLayout(context);
	resId = ResHelper.getBitmapRes(context, "smssdk_country_group_scroll_up");
	if (resId > 0) {
		llScroll.setBackgroundResource(resId);
	}
	llScroll.setOrientation(LinearLayout.VERTICAL);
	llScroll.setOnTouchListener(this);
	lp = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.addRule(ALIGN_PARENT_RIGHT);
	lp.addRule(CENTER_VERTICAL);
	lp.rightMargin = SizeHelper.fromPxWidth(7);
	addView(llScroll, lp);

	initScroll(context);
}