Example usage for android.view ScaleGestureDetector ScaleGestureDetector

List of usage examples for android.view ScaleGestureDetector ScaleGestureDetector

Introduction

In this page you can find the example usage for android.view ScaleGestureDetector ScaleGestureDetector.

Prototype

public ScaleGestureDetector(Context context, OnScaleGestureListener listener) 

Source Link

Document

Creates a ScaleGestureDetector with the supplied listener.

Usage

From source file:com.android.mms.rcs.FavoriteDetailActivity.java

private void initUi() {
    setProgressBarIndeterminateVisibility(true);

    mScaleDetector = new ScaleGestureDetector(this, new MyScaleListener());

    if (mCursor != null && mCursor.moveToFirst()) {
        mPagerAdapter = new FavoriteDetailAdapter(this, mCursor);
        mPagerAdapter.setScaleTextList(mSlidePaperItemTextViews);
        mContentPager = (ViewPager) findViewById(R.id.details_view_pager);
        mContentPager.setAdapter(mPagerAdapter);
        mContentPager.setCurrentItem(mCursor.getPosition());
    }/*from  w w  w  .ja va2s. c  o  m*/

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
}

From source file:org.akop.crosswords.view.CrosswordView.java

public CrosswordView(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (!isInEditMode()) {
        setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }// w  ww . j  a va 2 s  .co  m

    // Set drawing defaults
    Resources r = context.getResources();
    DisplayMetrics dm = r.getDisplayMetrics();

    int cellFillColor = NORMAL_CELL_FILL_COLOR;
    int cheatedCellFillColor = CHEATED_CELL_FILL_COLOR;
    int mistakeCellFillColor = MISTAKE_CELL_FILL_COLOR;
    int selectedWordFillColor = SELECTED_WORD_FILL_COLOR;
    int selectedCellFillColor = SELECTED_CELL_FILL_COLOR;
    int textColor = TEXT_COLOR;
    int cellStrokeColor = CELL_STROKE_COLOR;
    int circleStrokeColor = CIRCLE_STROKE_COLOR;

    float numberTextSize = NUMBER_TEXT_SIZE * dm.scaledDensity;
    float answerTextSize = ANSWER_TEXT_SIZE * dm.scaledDensity;

    mCellSize = CELL_SIZE * dm.density;
    mNumberTextPadding = NUMBER_TEXT_PADDING * dm.density;
    mAnswerTextPadding = ANSWER_TEXT_PADDING * dm.density;

    // Read supplied attributes
    if (attrs != null) {
        Resources.Theme theme = context.getTheme();
        TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.Crossword, 0, 0);
        mCellSize = a.getDimension(R.styleable.Crossword_cellSize, mCellSize);
        mNumberTextPadding = a.getDimension(R.styleable.Crossword_numberTextPadding, mNumberTextPadding);
        numberTextSize = a.getDimension(R.styleable.Crossword_numberTextSize, numberTextSize);
        mAnswerTextPadding = a.getDimension(R.styleable.Crossword_answerTextPadding, mAnswerTextPadding);
        answerTextSize = a.getDimension(R.styleable.Crossword_answerTextSize, answerTextSize);
        cellFillColor = a.getColor(R.styleable.Crossword_defaultCellFillColor, cellFillColor);
        cheatedCellFillColor = a.getColor(R.styleable.Crossword_cheatedCellFillColor, cheatedCellFillColor);
        mistakeCellFillColor = a.getColor(R.styleable.Crossword_mistakeCellFillColor, mistakeCellFillColor);
        selectedWordFillColor = a.getColor(R.styleable.Crossword_selectedWordFillColor, selectedWordFillColor);
        selectedCellFillColor = a.getColor(R.styleable.Crossword_selectedCellFillColor, selectedCellFillColor);
        cellStrokeColor = a.getColor(R.styleable.Crossword_cellStrokeColor, cellStrokeColor);
        circleStrokeColor = a.getColor(R.styleable.Crossword_circleStrokeColor, circleStrokeColor);
        textColor = a.getColor(R.styleable.Crossword_textColor, textColor);
        a.recycle();
    }

    mMarkerSideLength = mCellSize * MARKER_TRIANGLE_LENGTH_FRACTION;

    // Init paints
    mCellFillPaint = new Paint();
    mCellFillPaint.setColor(cellFillColor);
    mCellFillPaint.setStyle(Paint.Style.FILL);

    mCheatedCellFillPaint = new Paint();
    mCheatedCellFillPaint.setColor(cheatedCellFillColor);
    mCheatedCellFillPaint.setStyle(Paint.Style.FILL);

    mMistakeCellFillPaint = new Paint();
    mMistakeCellFillPaint.setColor(mistakeCellFillColor);
    mMistakeCellFillPaint.setStyle(Paint.Style.FILL);

    mSelectedWordFillPaint = new Paint();
    mSelectedWordFillPaint.setColor(selectedWordFillColor);
    mSelectedWordFillPaint.setStyle(Paint.Style.FILL);

    mSelectedCellFillPaint = new Paint();
    mSelectedCellFillPaint.setColor(selectedCellFillColor);
    mSelectedCellFillPaint.setStyle(Paint.Style.FILL);

    mCellStrokePaint = new Paint();
    mCellStrokePaint.setColor(cellStrokeColor);
    mCellStrokePaint.setStyle(Paint.Style.STROKE);
    //      mCellStrokePaint.setStrokeWidth(1);

    mCircleStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCircleStrokePaint.setColor(circleStrokeColor);
    mCircleStrokePaint.setStyle(Paint.Style.STROKE);
    mCircleStrokePaint.setStrokeWidth(1);

    mNumberTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mNumberTextPaint.setColor(textColor);
    mNumberTextPaint.setTextAlign(Paint.Align.CENTER);
    mNumberTextPaint.setTextSize(numberTextSize);

    mNumberStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mNumberStrokePaint.setColor(cellFillColor);
    mNumberStrokePaint.setTextAlign(Paint.Align.CENTER);
    mNumberStrokePaint.setTextSize(numberTextSize);
    mNumberStrokePaint.setStyle(Paint.Style.STROKE);
    mNumberStrokePaint.setStrokeWidth(NUMBER_TEXT_STROKE_WIDTH * dm.scaledDensity);

    mAnswerTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mAnswerTextPaint.setColor(textColor);
    mAnswerTextPaint.setTextSize(answerTextSize);
    mAnswerTextPaint.setTextAlign(Paint.Align.CENTER);

    // http://www.google.com/fonts/specimen/Kalam
    Typeface typeface = Typeface.createFromAsset(context.getAssets(), "kalam-regular.ttf");
    mAnswerTextPaint.setTypeface(typeface);

    // Init rest of the values
    mCircleRadius = (mCellSize / 2) - mCircleStrokePaint.getStrokeWidth();
    mPuzzleCells = EMPTY_CELLS;
    mPuzzleWidth = 0;
    mPuzzleHeight = 0;
    mAllowedChars = EMPTY_CHARS;

    mRenderScale = 0;
    mBitmapOffset = new PointF();
    mCenteredOffset = new PointF();
    mTranslationBounds = new RectF();

    mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
    mGestureDetector = new GestureDetector(context, new GestureListener());

    mContentRect = new RectF();
    mPuzzleRect = new RectF();

    mBitmapPaint = new Paint(Paint.FILTER_BITMAP_FLAG);

    mScroller = new Scroller(context, null, true);
    mZoomer = new Zoomer(context);

    setFocusableInTouchMode(true);
    setOnKeyListener(this);
}

From source file:com.freerdp.freerdpcore.presentation.SessionActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // show status bar or make fullscreen?
    if (GlobalSettings.getHideStatusBar())
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.setContentView(R.layout.session);
    rladvertising = (AdvertisingView) findViewById(R.id.advertising);
    rladvertising.startImagePlay();/*from   ww w.  j  av a2s .c  o m*/
    final View activityRootView = findViewById(R.id.session_root_view);
    //
    activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            screen_width = activityRootView.getWidth();
            screen_height = activityRootView.getHeight();
            if (!sessionRunning && getIntent() != null) {
                thread = new Thread(SessionActivity.this);
                thread.start();
                sessionRunning = true;
            }
        }
    });

    sessionView = (SessionView) findViewById(R.id.sessionView);
    sessionView.setScaleGestureDetector(new ScaleGestureDetector(this, new PinchZoomListener()));
    sessionView.setSessionViewListener(this);
    sessionView.requestFocus();

    touchPointerView = (TouchPointerView) findViewById(R.id.touchPointerView);
    touchPointerView.setTouchPointerListener(this);

    keyboardMapper = new KeyboardMapper();
    keyboardMapper.init(this);
    keyboardMapper.reset(this);

    modifiersKeyboard = new Keyboard(getApplicationContext(), R.xml.modifiers_keyboard);
    specialkeysKeyboard = new Keyboard(getApplicationContext(), R.xml.specialkeys_keyboard);
    numpadKeyboard = new Keyboard(getApplicationContext(), R.xml.numpad_keyboard);
    cursorKeyboard = new Keyboard(getApplicationContext(), R.xml.cursor_keyboard);

    // hide keyboard below the sessionView
    keyboardView = (KeyboardView) findViewById(R.id.extended_keyboard);
    keyboardView.setKeyboard(specialkeysKeyboard);
    keyboardView.setOnKeyboardActionListener(this);

    modifiersKeyboardView = (KeyboardView) findViewById(R.id.extended_keyboard_header);
    modifiersKeyboardView.setKeyboard(modifiersKeyboard);
    modifiersKeyboardView.setOnKeyboardActionListener(this);

    scrollView = (ScrollView2D) findViewById(R.id.sessionScrollView);
    scrollView.setScrollViewListener(this);
    uiHandler = new UIHandler();
    libFreeRDPBroadcastReceiver = new LibFreeRDPBroadcastReceiver();

    zoomControls = (ZoomControls) findViewById(R.id.zoomControls);
    zoomControls.hide();
    zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            resetZoomControlsAutoHideTimeout();
            zoomControls.setIsZoomInEnabled(sessionView.zoomIn(ZOOMING_STEP));
            zoomControls.setIsZoomOutEnabled(true);
        }
    });
    zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            resetZoomControlsAutoHideTimeout();
            zoomControls.setIsZoomOutEnabled(sessionView.zoomOut(ZOOMING_STEP));
            zoomControls.setIsZoomInEnabled(true);
        }
    });

    toggleMouseButtons = false;

    createDialogs();

    // register freerdp events broadcast receiver
    IntentFilter filter = new IntentFilter();
    filter.addAction(GlobalApp.ACTION_EVENT_FREERDP);
    registerReceiver(libFreeRDPBroadcastReceiver, filter);

    mClipboardManager = ClipboardManagerProxy.getClipboardManager(this);
    mClipboardManager.addClipboardChangedListener(this);

}

From source file:chenyoufu.hciprojectes10.MyGLSurfaceView.java

public MyGLSurfaceView(Context context) {
    super(context);

    readMesh();/*from w  ww  . j a  va2  s .  c o  m*/

    // Set the Renderer for drawing on the GLSurfaceView
    mRenderer = new MyGLRenderer();
    setRenderer(mRenderer);

    // Render the view only when there is a change in the drawing data
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

    mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
}

From source file:org.akop.ararat.view.CrosswordView.java

public CrosswordView(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (!isInEditMode()) {
        setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }/*from  w w w. j  a v a 2 s . c  o m*/

    // Set drawing defaults
    Resources r = context.getResources();
    DisplayMetrics dm = r.getDisplayMetrics();

    int cellFillColor = NORMAL_CELL_FILL_COLOR;
    int cheatedCellFillColor = CHEATED_CELL_FILL_COLOR;
    int mistakeCellFillColor = MISTAKE_CELL_FILL_COLOR;
    int selectedWordFillColor = SELECTED_WORD_FILL_COLOR;
    int selectedCellFillColor = SELECTED_CELL_FILL_COLOR;
    int markedCellFillColor = MARKED_CELL_FILL_COLOR;
    int numberTextColor = NUMBER_TEXT_COLOR;
    int cellStrokeColor = CELL_STROKE_COLOR;
    int circleStrokeColor = CIRCLE_STROKE_COLOR;
    int answerTextColor = ANSWER_TEXT_COLOR;

    mScaledDensity = dm.scaledDensity;
    float numberTextSize = NUMBER_TEXT_SIZE * mScaledDensity;
    mAnswerTextSize = ANSWER_TEXT_SIZE * mScaledDensity;

    mCellSize = CELL_SIZE * dm.density;
    mNumberTextPadding = NUMBER_TEXT_PADDING * dm.density;
    mIsEditable = true;
    mInputMode = INPUT_MODE_KEYBOARD;
    mSkipOccupiedOnType = false;
    mSelectFirstUnoccupiedOnNav = true;
    mMaxBitmapSize = DEFAULT_MAX_BITMAP_DIMENSION;

    // Read supplied attributes
    if (attrs != null) {
        Resources.Theme theme = context.getTheme();
        TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.CrosswordView, 0, 0);

        mCellSize = a.getDimension(R.styleable.CrosswordView_cellSize, mCellSize);
        mNumberTextPadding = a.getDimension(R.styleable.CrosswordView_numberTextPadding, mNumberTextPadding);
        numberTextSize = a.getDimension(R.styleable.CrosswordView_numberTextSize, numberTextSize);
        mAnswerTextSize = a.getDimension(R.styleable.CrosswordView_answerTextSize, mAnswerTextSize);
        answerTextColor = a.getColor(R.styleable.CrosswordView_answerTextColor, answerTextColor);
        cellFillColor = a.getColor(R.styleable.CrosswordView_defaultCellFillColor, cellFillColor);
        cheatedCellFillColor = a.getColor(R.styleable.CrosswordView_cheatedCellFillColor, cheatedCellFillColor);
        mistakeCellFillColor = a.getColor(R.styleable.CrosswordView_mistakeCellFillColor, mistakeCellFillColor);
        selectedWordFillColor = a.getColor(R.styleable.CrosswordView_selectedWordFillColor,
                selectedWordFillColor);
        selectedCellFillColor = a.getColor(R.styleable.CrosswordView_selectedCellFillColor,
                selectedCellFillColor);
        markedCellFillColor = a.getColor(R.styleable.CrosswordView_markedCellFillColor, markedCellFillColor);
        cellStrokeColor = a.getColor(R.styleable.CrosswordView_cellStrokeColor, cellStrokeColor);
        circleStrokeColor = a.getColor(R.styleable.CrosswordView_circleStrokeColor, circleStrokeColor);
        numberTextColor = a.getColor(R.styleable.CrosswordView_numberTextColor, numberTextColor);
        mIsEditable = a.getBoolean(R.styleable.CrosswordView_editable, mIsEditable);
        mSkipOccupiedOnType = a.getBoolean(R.styleable.CrosswordView_skipOccupiedOnType, mSkipOccupiedOnType);
        mSelectFirstUnoccupiedOnNav = a.getBoolean(R.styleable.CrosswordView_selectFirstUnoccupiedOnNav,
                mSelectFirstUnoccupiedOnNav);

        a.recycle();
    }

    mRevealSetsCheatFlag = true;
    mMarkerSideLength = mCellSize * MARKER_TRIANGLE_LENGTH_FRACTION;

    // Init paints
    mCellFillPaint = new Paint();
    mCellFillPaint.setColor(cellFillColor);
    mCellFillPaint.setStyle(Paint.Style.FILL);

    mCheatedCellFillPaint = new Paint();
    mCheatedCellFillPaint.setColor(cheatedCellFillColor);
    mCheatedCellFillPaint.setStyle(Paint.Style.FILL);

    mMistakeCellFillPaint = new Paint();
    mMistakeCellFillPaint.setColor(mistakeCellFillColor);
    mMistakeCellFillPaint.setStyle(Paint.Style.FILL);

    mSelectedWordFillPaint = new Paint();
    mSelectedWordFillPaint.setColor(selectedWordFillColor);
    mSelectedWordFillPaint.setStyle(Paint.Style.FILL);

    mSelectedCellFillPaint = new Paint();
    mSelectedCellFillPaint.setColor(selectedCellFillColor);
    mSelectedCellFillPaint.setStyle(Paint.Style.FILL);

    mMarkedCellFillPaint = new Paint();
    mMarkedCellFillPaint.setColor(markedCellFillColor);
    mMarkedCellFillPaint.setStyle(Paint.Style.FILL);

    mCellStrokePaint = new Paint();
    mCellStrokePaint.setColor(cellStrokeColor);
    mCellStrokePaint.setStyle(Paint.Style.STROKE);
    //      mCellStrokePaint.setStrokeWidth(1);

    mCircleStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCircleStrokePaint.setColor(circleStrokeColor);
    mCircleStrokePaint.setStyle(Paint.Style.STROKE);
    mCircleStrokePaint.setStrokeWidth(1);

    mNumberTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mNumberTextPaint.setColor(numberTextColor);
    mNumberTextPaint.setTextAlign(Paint.Align.CENTER);
    mNumberTextPaint.setTextSize(numberTextSize);

    // Compute number height
    mNumberTextPaint.getTextBounds("0", 0, "0".length(), mTempRect);
    mNumberTextHeight = mTempRect.height();

    mNumberStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mNumberStrokePaint.setColor(cellFillColor);
    mNumberStrokePaint.setTextAlign(Paint.Align.CENTER);
    mNumberStrokePaint.setTextSize(numberTextSize);
    mNumberStrokePaint.setStyle(Paint.Style.STROKE);
    mNumberStrokePaint.setStrokeWidth(NUMBER_TEXT_STROKE_WIDTH * mScaledDensity);

    mAnswerTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mAnswerTextPaint.setColor(answerTextColor);
    mAnswerTextPaint.setTextSize(mAnswerTextSize);

    // Init rest of the values
    mCircleRadius = (mCellSize / 2) - mCircleStrokePaint.getStrokeWidth();
    mPuzzleCells = EMPTY_CELLS;
    mPuzzleWidth = 0;
    mPuzzleHeight = 0;
    mAllowedChars = EMPTY_CHARS;

    mRenderScale = 0;
    mBitmapOffset = new PointF();
    mCenteredOffset = new PointF();
    mTranslationBounds = new RectF();

    mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
    mGestureDetector = new GestureDetector(context, new GestureListener());

    mContentRect = new RectF();
    mPuzzleRect = new RectF();

    mBitmapPaint = new Paint(Paint.FILTER_BITMAP_FLAG);

    mScroller = new Scroller(context, null, true);
    mZoomer = new Zoomer(context);
    mUndoBuffer = new Stack<>();

    setFocusableInTouchMode(mIsEditable && mInputMode != INPUT_MODE_NONE);
    setOnKeyListener(this);
}

From source file:com.mediatek.galleryfeature.stereo.segment.ImageShow.java

private void setupImageShow(Context context) {
    Resources res = context.getResources();
    res.getColor(R.color.background_screen);
    mGestureDetector = new GestureDetector(context, this);
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    mActivity = (Activity) context;//w  w  w  .ja  v a 2s.  co  m
    mEdgeEffect = new EdgeEffectCompat(context);
    mEdgeSize = res.getDimensionPixelSize(R.dimen.edge_glow_size);
}

From source file:com.jjoe64.graphview.Viewport.java

/**
 * creates the viewport//from   w ww .  j  a v a  2s. c om
 *
 * @param graphView graphview
 */
Viewport(GraphView graphView) {
    mScroller = new OverScroller(graphView.getContext());
    mEdgeEffectTop = new EdgeEffectCompat(graphView.getContext());
    mEdgeEffectBottom = new EdgeEffectCompat(graphView.getContext());
    mEdgeEffectLeft = new EdgeEffectCompat(graphView.getContext());
    mEdgeEffectRight = new EdgeEffectCompat(graphView.getContext());
    mGestureDetector = new GestureDetector(graphView.getContext(), mGestureListener);
    mScaleGestureDetector = new ScaleGestureDetector(graphView.getContext(), mScaleGestureListener);

    mGraphView = graphView;
    mXAxisBoundsStatus = AxisBoundsStatus.INITIAL;
    mYAxisBoundsStatus = AxisBoundsStatus.INITIAL;
    mBackgroundColor = Color.TRANSPARENT;
    mPaint = new Paint();
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

public DayView(Context context, CalendarController controller, ViewSwitcher viewSwitcher,
        EventLoader eventLoader, int numDays) {
    super(context);
    mContext = context;// w w w . j a v a  2  s  .  c om

    mResources = context.getResources();
    mNumDays = numDays;

    DATE_HEADER_FONT_SIZE = (int) mResources.getDimension(R.dimen.date_header_text_size);
    DAY_HEADER_FONT_SIZE = (int) mResources.getDimension(R.dimen.day_label_text_size);
    DAY_HEADER_HEIGHT = (int) mResources.getDimension(R.dimen.day_header_height);
    DAY_HEADER_BOTTOM_MARGIN = (int) mResources.getDimension(R.dimen.day_header_bottom_margin);
    HOURS_TEXT_SIZE = (int) mResources.getDimension(R.dimen.hours_text_size);
    AMPM_TEXT_SIZE = (int) mResources.getDimension(R.dimen.ampm_text_size);
    MIN_HOURS_WIDTH = (int) mResources.getDimension(R.dimen.min_hours_width);
    HOURS_LEFT_MARGIN = (int) mResources.getDimension(R.dimen.hours_left_margin);
    HOURS_RIGHT_MARGIN = (int) mResources.getDimension(R.dimen.hours_right_margin);
    int eventTextSizeId;
    if (mNumDays == 1) {
        eventTextSizeId = R.dimen.day_view_event_text_size;
    } else {
        eventTextSizeId = R.dimen.week_view_event_text_size;
    }
    EVENT_TEXT_FONT_SIZE = (int) mResources.getDimension(eventTextSizeId);
    MIN_EVENT_HEIGHT = mResources.getDimension(R.dimen.event_min_height);
    EVENT_TEXT_TOP_MARGIN = (int) mResources.getDimension(R.dimen.event_text_vertical_margin);
    EVENT_TEXT_BOTTOM_MARGIN = EVENT_TEXT_TOP_MARGIN;

    EVENT_TEXT_LEFT_MARGIN = (int) mResources.getDimension(R.dimen.event_text_horizontal_margin);
    EVENT_TEXT_RIGHT_MARGIN = EVENT_TEXT_LEFT_MARGIN;

    if (mScale == 0) {

        mScale = mResources.getDisplayMetrics().density;
        if (mScale != 1) {

            GRID_LINE_LEFT_MARGIN *= mScale;
            HOURS_TOP_MARGIN *= mScale;
            MIN_CELL_WIDTH_FOR_TEXT *= mScale;

            CURRENT_TIME_LINE_SIDE_BUFFER *= mScale;
            CURRENT_TIME_LINE_TOP_OFFSET *= mScale;

            MIN_Y_SPAN *= mScale;
            MAX_CELL_HEIGHT *= mScale;
            DEFAULT_CELL_HEIGHT *= mScale;
            DAY_HEADER_RIGHT_MARGIN *= mScale;
            DAY_HEADER_ONE_DAY_LEFT_MARGIN *= mScale;
            DAY_HEADER_ONE_DAY_RIGHT_MARGIN *= mScale;
            DAY_HEADER_ONE_DAY_BOTTOM_MARGIN *= mScale;
            EVENT_RECT_TOP_MARGIN *= mScale;
            EVENT_RECT_BOTTOM_MARGIN *= mScale;
            EVENT_RECT_LEFT_MARGIN *= mScale;
            EVENT_RECT_RIGHT_MARGIN *= mScale;
            EVENT_RECT_STROKE_WIDTH *= mScale;
        }
    }
    HOURS_MARGIN = HOURS_LEFT_MARGIN + HOURS_RIGHT_MARGIN;

    mCurrentTimeLine = mResources.getDrawable(R.drawable.timeline_indicator_holo_light);
    mCurrentTimeAnimateLine = mResources.getDrawable(R.drawable.timeline_indicator_activated_holo_light);
    mTodayHeaderDrawable = mResources.getDrawable(R.drawable.today_blue_week_holo_light);
    mAcceptedOrTentativeEventBoxDrawable = mResources.getDrawable(R.drawable.panel_month_event_holo_light);

    mEventLoader = eventLoader;
    mEventGeometry = new EventGeometry();
    mEventGeometry.setMinEventHeight(MIN_EVENT_HEIGHT);
    mEventGeometry.setHourGap(HOUR_GAP);
    mEventGeometry.setCellMargin(DAY_GAP);
    mController = controller;
    mViewSwitcher = viewSwitcher;
    mGestureDetector = new GestureDetector(context, new CalendarGestureListener());
    mScaleGestureDetector = new ScaleGestureDetector(getContext(), this);
    if (mCellHeight == 0) {
        mCellHeight = DEFAULT_CELL_HEIGHT;
    }
    mScroller = new OverScroller(context);
    mHScrollInterpolator = new ScrollInterpolator();
    mEdgeEffectTop = new EdgeEffectCompat(context);
    mEdgeEffectBottom = new EdgeEffectCompat(context);
    ViewConfiguration vc = ViewConfiguration.get(context);
    mScaledPagingTouchSlop = vc.getScaledPagingTouchSlop();
    mOnDownDelay = ViewConfiguration.getTapTimeout();
    OVERFLING_DISTANCE = vc.getScaledOverflingDistance();

    init(context);
}

From source file:net.nanocosmos.bintu.demo.encoder.activities.StreamActivity.java

private void initStreamLib() {
    if (null == streamLib) {
        try {//from   w ww  . j  ava 2s .com
            nanoStreamSettings nss = configureNanostreamSettings();
            streamLib = new nanoStream(nss);
            usedVideoResolution = new Resolution(streamLib.getVideoSourceFormat().getWidth(),
                    streamLib.getVideoSourceFormat().getHeight());
        } catch (NanostreamException en) {
            Toast.makeText(getApplicationContext(), en.toString(), Toast.LENGTH_LONG).show();
        }

        if (null != streamLib) {

            try {
                streamLib.init();
            } catch (NanostreamException e) {
                Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }

            // set the Device properties collected at the first time app was started in BintuApplication.java
            // this is necessary for pre Android 4.3 Devices, because this Devices may show some color format issues.
            // this will correct these color issues.
            // for mor information http://www.nanocosmos.de/v4/documentation/android_device_properties
            streamLib.setDeviceProperties(BintuApplication.getDeviceProperties());

            // initial check if the device is in portrait mode (default is landscape Rotation.ROTATION_0)
            if (getResources().getConfiguration().orientation == getResources()
                    .getConfiguration().ORIENTATION_PORTRAIT) {
                prevRotation = Rotation.ROTATION_90;
                streamRotation = Rotation.ROTATION_90;
                streamLib.setPreviewRotation(prevRotation);
                streamLib.setStreamRotation(streamRotation);
            }

            if (streamVideo) {
                mZoomRatios = streamLib.getZoomRatios();
                streamLib.addFocusCalback(this);
            }

            if (ENABLE_AUDIO_LEVEL_CALLBACK) {
                streamLib.addAudioLevelCallback(this);
            }
        }
        // the scaleGestureDetector is needed for pinch to zoom.
        if (null == scaleGestureDetector) {
            scaleGestureDetector = new ScaleGestureDetector(this, new ScaleGestureListener());
        }

        // the gestureDetector is needed for tap to focus and long press to focus lock
        if (null == gestureDetector) {
            gestureDetector = new GestureDetector(this, new GestureListener());
        }
    }
}

From source file:org.protocoderrunner.apprunner.api.PUI.java

@ProtocoderScript
@APIMethod(description = "Starts a gesture detector over a view", example = "")
@APIParam(params = { "View", "function(data)" })
//http://stackoverflow.com/questions/6599329/can-one-ongesturelistener-object-deal-with-two-gesturedetector-objects
public void gestureDetector(View v, final addGestureDetectorCB cb) {
    final GestureDetectorReturn g = new GestureDetectorReturn();

    final GestureDetector gestureDetector = new GestureDetector(a.get(),
            new GestureDetector.OnGestureListener() {

                @Override/* w  ww . j  a v  a  2  s  . c o  m*/
                public boolean onSingleTapUp(MotionEvent e) {

                    g.type = "up";
                    cb.event(g);
                    return false;
                }

                @Override
                public void onShowPress(MotionEvent e) {
                    g.type = "showpress";
                    cb.event(g);
                }

                @Override
                public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
                    g.type = "scroll";
                    g.data = new JSONObject();
                    try {
                        g.data.put("distanceX", distanceX);
                        g.data.put("distanceY", distanceY);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    cb.event(g);
                    return true;
                }

                @Override
                public void onLongPress(MotionEvent e) {
                    g.type = "longpress";
                    cb.event(g);
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    g.type = "fling";
                    g.data = new JSONObject();
                    try {
                        g.data.put("velocityX", velocityX);
                        g.data.put("velocityY", velocityY);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    cb.event(g);
                    return true;
                }

                @Override
                public boolean onDown(MotionEvent e) {
                    g.type = "down";
                    cb.event(g);
                    return true;
                }
            });

    final ScaleGestureDetector scaleGestureDetector = new ScaleGestureDetector(a.get(),
            new OnScaleGestureListener() {
                @Override
                public boolean onScale(ScaleGestureDetector scaleGestureDetector) {
                    g.type = "scale";
                    cb.event(g);
                    return false;
                }

                @Override
                public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector) {
                    g.type = "scaleBegin";
                    cb.event(g);
                    return false;
                }

                @Override
                public void onScaleEnd(ScaleGestureDetector scaleGestureDetector) {
                    g.type = "scaleEnd";
                    cb.event(g);
                }
            });

    v.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            scaleGestureDetector.onTouchEvent(event);
            if (scaleGestureDetector.isInProgress())
                return true;
            gestureDetector.onTouchEvent(event);

            return true;
        }
    });
}