반응형




ViewFlipper Listener




package com.teamnote.ActivityManager.Handler;

import android.content.Context;
import android.view.animation.AnimationUtils;
import android.widget.ViewFlipper;

import com.teamnote.R;

/**
 * ViewFlipper TouchListener 클래스
 * 
 * @author DervelJunHome
 * 
 */

public class ScheduleViewFlipperHandler {

	// 현재 액티비티의 위치
	public static int nActivityIs = ViewFlipperACTIVITY_CODE.ACTIVITY_MAIN;

	private Context nContext;
	private ViewFlipper nViewFlipper;

	public ScheduleViewFlipperHandler(Context pContext, ViewFlipper pViewF) {
		this.nContext = pContext;
		this.nViewFlipper = pViewF;
	}

	public void MoveNextView() {
		if (nActivityIs == ViewFlipperACTIVITY_CODE.ACTIVITY_DAY)
			return;
		
		nViewFlipper.setInAnimation(AnimationUtils.loadAnimation(nContext,
				R.anim.appear_from_right));
		nViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(nContext,
				R.anim.disappear_to_left));
		
		nViewFlipper.showNext();
	}

	public void MovePreviousView() {
		if (nActivityIs == ViewFlipperACTIVITY_CODE.ACTIVITY_CALENDAR)
			return;
		
		nViewFlipper.setInAnimation(AnimationUtils.loadAnimation(nContext,
				R.anim.appear_from_left));
		nViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(nContext,
				R.anim.disappear_to_right));
		
		nActivityIs = ViewFlipperACTIVITY_CODE.ACTIVITY_MAIN;

		nViewFlipper.showPrevious();
	}
	
};






ViewFlipper Listener



package com.teamnote.ActivityManager.Listener;

import android.view.MotionEvent;
import android.view.View;

import com.teamnote.ActivityManager.Handler.ScheduleViewFlipperHandler;

/**
 * ViewFlipper TouchListener 클래스
 * 
 * @author DervelJunHome
 * 
 */

public class ScheduleViewFlipperTouchListener implements View.OnTouchListener {

	private int m_nPreTouchPosX = 0;

	private ScheduleViewFlipperHandler nHandler;
	
	public ScheduleViewFlipperTouchListener(ScheduleViewFlipperHandler handler) {
		this.nHandler = handler;
	}

	public boolean onTouch(View v, MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			m_nPreTouchPosX = (int) event.getX();
		}
		if (event.getAction() == MotionEvent.ACTION_UP) {

			int nTouchPosX = (int) event.getX();

			if (nTouchPosX < m_nPreTouchPosX) {
				nHandler.MovePreviousView();
			} else if (nTouchPosX > m_nPreTouchPosX) {
				nHandler.MoveNextView();
			}

			m_nPreTouchPosX = nTouchPosX;
		}

		return true;
	}

};


반응형

'Android' 카테고리의 다른 글

GridView 설정  (0) 2013.05.27
EditText 개행 문자 웹 DB 저장 법  (0) 2013.05.23
SimpleExpandableListAdapter  (0) 2013.05.16
ExpandableListViewAdapter  (0) 2013.05.16
interface를 상수처럼 사용하기  (0) 2013.05.09

WRITTEN BY
데르벨준

,