Example usage for android.view.animation Animation RELATIVE_TO_SELF

List of usage examples for android.view.animation Animation RELATIVE_TO_SELF

Introduction

In this page you can find the example usage for android.view.animation Animation RELATIVE_TO_SELF.

Prototype

int RELATIVE_TO_SELF

To view the source code for android.view.animation Animation RELATIVE_TO_SELF.

Click Source Link

Document

The specified dimension holds a float and should be multiplied by the height or width of the object being animated.

Usage

From source file:org.videolan.vlc.gui.helpers.UiTools.java

public static void fillAboutView(View v) {
    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(VLCApplication.getAppResources().getString(R.string.about_link)));

    String revision = VLCApplication.getAppResources().getString(R.string.build_revision) + " VLC: "
            + VLCApplication.getAppResources().getString(R.string.build_vlc_revision);
    String builddate = VLCApplication.getAppResources().getString(R.string.build_time);
    String builder = VLCApplication.getAppResources().getString(R.string.build_host);

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(VLCApplication.getAppResources().getString(R.string.revision) + " " + revision + " ("
            + builddate + ") " + BuildConfig.FLAVOR_abi);

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new View.OnClickListener() {
        @Override//from  www .j  av  a 2  s .c  o m
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });
}

From source file:com.nextgis.maplibui.activity.ModifyAttributesActivity.java

protected void createLocationPanelView(final IGISApplication app) {
    if (null == mGeometry && mFeatureId == NOT_FOUND) {
        mLatView = (TextView) findViewById(R.id.latitude_view);
        mLongView = (TextView) findViewById(R.id.longitude_view);
        mAltView = (TextView) findViewById(R.id.altitude_view);
        mAccView = (TextView) findViewById(R.id.accuracy_view);
        final ImageButton refreshLocation = (ImageButton) findViewById(R.id.refresh);
        mAccurateLocation = (SwitchCompat) findViewById(R.id.accurate_location);
        mAccurateLocation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override//from www .  j av  a  2  s  .  c  om
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (mAccurateLocation.getTag() == null) {
                    refreshLocation.performClick();
                    mAccurateLocation.setTag(new Object());
                }
            }
        });
        mAccuracyCE = (AppCompatSpinner) findViewById(R.id.accurate_ce);

        refreshLocation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
                        Animation.RELATIVE_TO_SELF, 0.5f);
                rotateAnimation.setDuration(500);
                rotateAnimation.setRepeatCount(1);
                refreshLocation.startAnimation(rotateAnimation);

                if (mAccurateLocation.isChecked()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(ModifyAttributesActivity.this);
                    View layout = View.inflate(ModifyAttributesActivity.this,
                            R.layout.dialog_progress_accurate_location, null);
                    TextView message = (TextView) layout.findViewById(R.id.message);
                    final ProgressBar progress = (ProgressBar) layout.findViewById(R.id.progress);
                    final TextView progressPercent = (TextView) layout.findViewById(R.id.progress_percent);
                    final TextView progressNumber = (TextView) layout.findViewById(R.id.progress_number);
                    final CheckBox finishBeep = (CheckBox) layout.findViewById(R.id.finish_beep);
                    builder.setView(layout);
                    builder.setTitle(R.string.accurate_location);

                    final AccurateLocationTaker accurateLocation = new AccurateLocationTaker(view.getContext(),
                            100f, mMaxTakeCount, MAX_TAKE_TIME, PROGRESS_DELAY,
                            (String) mAccuracyCE.getSelectedItem());

                    progress.setIndeterminate(true);
                    message.setText(R.string.accurate_taking);
                    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            accurateLocation.cancelTaking();
                        }
                    });
                    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {
                            accurateLocation.cancelTaking();
                        }
                    });
                    builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            ControlHelper.unlockScreenOrientation(ModifyAttributesActivity.this);
                        }
                    });

                    final AlertDialog dialog = builder.create();
                    accurateLocation
                            .setOnProgressUpdateListener(new AccurateLocationTaker.OnProgressUpdateListener() {
                                @SuppressLint("SetTextI18n")
                                @Override
                                public void onProgressUpdate(Long... values) {
                                    int value = values[0].intValue();
                                    if (value == 1) {
                                        progress.setIndeterminate(false);
                                        progress.setMax(mMaxTakeCount);
                                    }

                                    if (value > 0)
                                        progress.setProgress(value);

                                    progressPercent.setText(value * 100 / mMaxTakeCount + " %");
                                    progressNumber.setText(value + " / " + mMaxTakeCount);
                                }
                            });

                    accurateLocation.setOnGetAccurateLocationListener(
                            new AccurateLocationTaker.OnGetAccurateLocationListener() {
                                @Override
                                public void onGetAccurateLocation(Location accurateLocation, Long... values) {
                                    dialog.dismiss();
                                    if (finishBeep.isChecked())
                                        playBeep();

                                    setLocationText(accurateLocation);
                                }
                            });

                    ControlHelper.lockScreenOrientation(ModifyAttributesActivity.this);
                    dialog.setCanceledOnTouchOutside(false);
                    dialog.show();
                    accurateLocation.startTaking();
                } else if (null != app) {
                    GpsEventSource gpsEventSource = app.getGpsEventSource();
                    Location location = gpsEventSource.getLastKnownLocation();
                    setLocationText(location);
                }
            }
        });
    } else {
        //hide location panel
        ViewGroup rootView = (ViewGroup) findViewById(R.id.controls_list);
        rootView.removeView(findViewById(R.id.location_panel));
    }
}

From source file:com.javadog.cgeowear.cgeoWear.java

/**
 * Handles rotation of the compass to a new direction.
 *
 * @param newDirection Direction to turn to, in degrees.
 *//*w  ww  .  ja  v a2 s .  com*/
private void rotateCompass(float newDirection) {
    if (direction != newDirection) {
        RotateAnimation anim = new RotateAnimation(direction, newDirection, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        anim.setDuration(200l);
        anim.setFillAfter(true);
        iv_compass.startAnimation(anim);

        direction = newDirection;
    }
}

From source file:ac.robinson.paperchains.PaperChainsActivity.java

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

    if (!CameraUtilities.getIsCameraAvailable(getPackageManager())) {
        Toast.makeText(PaperChainsActivity.this, getString(R.string.hint_no_camera), Toast.LENGTH_SHORT).show();
        finish();//from   w ww  .j av a2  s  .co m
        return;
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);

    setViews(R.id.viewfinder_view, R.id.preview_view, R.id.image_view);
    setResizeImageToView(false); // we want the high quality image

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // set up action bar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(R.string.title_activity_capture);
    actionBar.setDisplayShowTitleEnabled(true);

    int resultPointColour = getResources().getColor(R.color.accent);
    ((ViewfinderView) findViewById(R.id.viewfinder_view)).setResultPointColour(resultPointColour);

    // set up SoundCloud API wrappers (without a user token - for playback only, initially)
    setupSoundCloudApiWrappers();

    mCurrentMode = MODE_CAPTURE;

    // set up a zoomable view for the photo
    mImageView = (PaperChainsView) findViewById(R.id.image_view);
    mZoomControl = new DynamicZoomControl();
    mImageView.setZoomState(mZoomControl.getZoomState());
    mZoomControl.setAspectQuotient(mImageView.getAspectQuotient());
    mZoomListener = new LongPressZoomListener(PaperChainsActivity.this);
    mZoomListener.setZoomControl(mZoomControl);

    // set up buttons/handlers
    mImageView.setOnTouchListener(mZoomListener);
    mImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onImageClick();
        }
    });
    mImageView.setScribbleCallback(new PaperChainsView.ScribbleCallback() {
        @Override
        public void scribbleCompleted(Path scribble) {
            processScribble(scribble);
        }
    });

    mRecordButton = (AudioRecorderCircleButton) findViewById(R.id.record_button);
    mRecordButton.setOnClickListener(mRecordButtonListener);

    mPlayButton = (AudioRecorderCircleButton) findViewById(R.id.play_button);
    mPlayButton.setOnClickListener(mPlayButtonListener);

    mDeleteButton = (AudioRecorderCircleButton) findViewById(R.id.delete_button);
    mDeleteButton.setOnClickListener(mDeleteButtonListener);

    mSaveButton = (AudioRecorderCircleButton) findViewById(R.id.save_button);
    mSaveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            saveAudio();
        }
    });

    // set up animation for the play/save buttons
    mRotateAnimation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setDuration(BUTTON_ANIMATION_DURATION);
    mRotateAnimation.setInterpolator(new LinearInterpolator());
    mRotateAnimation.setRepeatCount(Animation.INFINITE);
    mRotateAnimation.setRepeatMode(Animation.RESTART);
}

From source file:io.development.tymo.adapters.FeedZoomMoreAdapter.java

public FeedZoomMoreAdapter(Context context, int itemCount) {
    SharedPreferences mSharedPreferences = context.getSharedPreferences(Constants.USER_CREDENTIALS,
            MODE_PRIVATE);/*from w  ww .  j ava 2  s  .c o  m*/
    email = mSharedPreferences.getString(Constants.EMAIL, "");

    dateFormat = new DateFormat(context);

    mContext = context;
    mItems = new ArrayList<>(itemCount);
    for (int i = 0; i < itemCount; i++) {
        addItem(i);
    }

    animation = new TranslateAnimation(0.0f, 0.0f, -Utilities.convertDpToPixel(3, context),
            Utilities.convertDpToPixel(4, context));
    animation.setDuration(1400);
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);

    animation2 = new TranslateAnimation(0.0f, 0.0f, Utilities.convertDpToPixel(3, context),
            -Utilities.convertDpToPixel(4, context));
    animation2.setDuration(1000);
    animation2.setRepeatCount(Animation.INFINITE);
    animation2.setRepeatMode(Animation.REVERSE);

    rotation = new RotateAnimation(-3, 3, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotation.setDuration(1200);
    rotation.setRepeatCount(Animation.INFINITE);
    rotation.setRepeatMode(Animation.REVERSE);
}

From source file:com.plusub.lib.example.view.TabView.java

/**
 * ?//from   w  w  w. j  a va2s  . com
 * @param arg0
 */
private void moveCursor(int arg0) {
    TranslateAnimation animation = new TranslateAnimation(mCursorCurPosition, arg0 * mScreenWidth / tabCount,
            Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_SELF);
    mCursorCurPosition = arg0 * mScreenWidth / tabCount;
    animation.setDuration(200);
    animation.setInterpolator(new LinearInterpolator());
    animation.setFillAfter(true);
    mIvCursor.startAnimation(animation);
}

From source file:com.github.shareme.gwsmaterialuikit.library.mscrollbar.MaterialScrollBar.java

private void generalSetup() {
    recyclerView.setVerticalScrollBarEnabled(false); // disable any existing scrollbars
    recyclerView.addOnScrollListener(new scrollListener()); // lets us read when the recyclerView scrolls

    setTouchIntercept(); // catches touches on the bar

    identifySwipeRefreshParents();//from  w  w w  .  ja va2 s .  c o  m

    //Hides the view
    TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_SELF, getHideRatio(), Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);
    anim.setDuration(0);
    anim.setFillAfter(true);
    hidden = true;
    startAnimation(anim);
}

From source file:qr.cloud.qrpedia.MessageViewerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_message_viewer);

    // set up tabs and collapse the action bar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(false);
    if (QRCloudUtils.actionBarIsSplit(MessageViewerActivity.this)) {
        actionBar.setDisplayShowHomeEnabled(false); // TODO: also need to show inverted/rearranged icons
    }//from ww w  .  j av a 2  s  .c  om

    // load Google Play Services location client
    mWaitingForGooglePlayLocation = true;
    mGooglePlayLocationConnected = false;
    mLocationClient = new LocationClient(MessageViewerActivity.this, MessageViewerActivity.this,
            MessageViewerActivity.this);

    // refresh interval for location queries and load whether location has been updated, and product details
    mMinimumLocationRefreshWaitTime = getResources().getInteger(R.integer.minimum_location_refresh_time);
    if (savedInstanceState != null) {
        mLocationTabEnabled = savedInstanceState.getBoolean(getString(R.string.key_location_tab_visited));
        mProductDetails = savedInstanceState.getString(getString(R.string.key_product_details));
        double savedLat = savedInstanceState.getDouble(QRCloudUtils.DATABASE_PROP_LATITUDE);
        double savedLon = savedInstanceState.getDouble(QRCloudUtils.DATABASE_PROP_LONGITUDE);
        if (savedLat != 0.0d && savedLon != 0.0d) {
            mLocation = new Location(QRCloudUtils.DATABASE_PROP_GEOCELL); // just need any string to initialise
            mLocation.setLatitude(savedLat);
            mLocation.setLongitude(savedLon);
        }
        mManualLocationRequestTime = savedInstanceState.getLong(getString(R.string.key_location_request_time));
        long currentTime = System.currentTimeMillis();
        if (currentTime - mManualLocationRequestTime < LocationRetriever.LOCATION_WAIT_TIME) {
            // we've started but probably not finished getting the location (manual method) - try again
            requestManualLocationAndUpdateTab();
        }
    }

    // get the code hash and details (must be after getting mProductDetails to stop multiple queries)
    final Intent launchIntent = getIntent();
    // Bundle barcodeDetailsBundle = null;
    if (launchIntent != null) {
        final String codeContents = launchIntent.getStringExtra(QRCloudUtils.DATABASE_PROP_CONTENTS);
        if (codeContents != null) {
            // we need the hash for database lookups
            mCodeHash = QRCloudUtils.sha1Hash(codeContents);
            parseCodeDetailsAndUpdate(launchIntent, codeContents, savedInstanceState == null);
        }
    }
    if (mCodeHash == null) {
        finish();
    }

    // set up animation for the refresh button
    mRotateAnimation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setDuration(600);
    mRotateAnimation.setRepeatCount(Animation.INFINITE);
    mRotateAnimation.setRepeatMode(Animation.RESTART);

    // set up tab paging
    mViewPager = (ViewPager) findViewById(R.id.message_sort_pager);
    mViewPager.setOffscreenPageLimit(3); // tried to save data, but 1 is the minimum - just pre-cache everything

    // load the tabs (see: http://stackoverflow.com/a/12090317/1993220)
    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(actionBar.newTab().setIcon(R.drawable.ic_action_clock_inverse),
            CloudEntityListFragment.class, getSortBundle(CloudEntity.PROP_CREATED_AT), false);
    mTabsAdapter.addTab(actionBar.newTab().setIcon(R.drawable.ic_action_location_inverse),
            CloudEntityListFragment.class, getSortBundle(QRCloudUtils.DATABASE_PROP_GEOCELL), true);
    mTabsAdapter.addTab(actionBar.newTab().setIcon(R.drawable.ic_action_star_10_inverse),
            CloudEntityListFragment.class, getSortBundle(QRCloudUtils.DATABASE_PROP_RATING), false);
    mTabsAdapter.addTab(actionBar.newTab().setIcon(R.drawable.ic_action_user_inverse),
            CloudEntityListFragment.class,
            getFilterBundle(F.Op.EQ.name(), CloudEntity.PROP_CREATED_BY, getCredentialAccountName()), false);
    // mTabsAdapter
    // .addTab(actionBar.newTab().setIcon(
    // mBarcodeFormat == BarcodeFormat.QR_CODE ? R.drawable.ic_action_qrcode_inverse
    // : R.drawable.ic_action_barcode_inverse), CodeViewerFragment.class, barcodeDetailsBundle);
}

From source file:com.emmasuzuki.quickreturnlistview.view.QuickReturnListView.java

private void animateQuickReturnViewToDest(final int destY) {
    // Pre-honeycomb style
    Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
            Animation.ABSOLUTE, 0, Animation.ABSOLUTE, destY - mQuickReturnView.getTop());
    animation.setFillEnabled(true);/* w w  w  . j  a v a2 s  .  c o m*/
    animation.setDuration(mSettleAnimationDuration);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            // Noop
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            // TranslateAnimation does not change view's position, so
            // after the animation end, manually set quick return view position to destination
            setQuickReturnViewY(destY);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // Noop
        }
    });

    mQuickReturnView.startAnimation(animation);
}

From source file:se.lu.nateko.edca.BackboneSvc.java

@Override
public void onCreate() {
    Log.d(TAG, "onCreate() called.");
    PACKAGE_NAME = getPackageName();/* w  w w .  j  a v  a2s . c  o  m*/

    /* Setup the animation which shows when a connection to the geospatial server is active. */
    mConnectionAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, (float) 0.5,
            Animation.RELATIVE_TO_SELF, (float) 0.5);
    mConnectionAnimation.setDuration(ROTATION_DURATION);
    mConnectionAnimation.setInterpolator(this, android.R.anim.linear_interpolator);
    mConnectionAnimation.setFillAfter(true);
    mConnectionAnimation.setRepeatCount(0);

    mSQLhelper = new LocalSQLDBhelper(this);
    mSQLhelper.open();
    super.onCreate();
}