Example usage for android.view.animation RotateAnimation RotateAnimation

List of usage examples for android.view.animation RotateAnimation RotateAnimation

Introduction

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

Prototype

public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType,
        float pivotYValue) 

Source Link

Document

Constructor to use when building a RotateAnimation from code

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 w  ww  . jav a2s  .  co  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 w ww . 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.gome.haoyuangong.views.SwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 * //from  w  ww . ja v  a  2 s .co m
 * @param context
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    animation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(250);
    animation.setFillAfter(true);

    reverseAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(200);
    reverseAnimation.setFillAfter(true);

    state = DONE;
    headView = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.list_head, null);
    arrowImageView = (ImageView) headView.findViewById(R.id.head_arrowImageView);
    //      arrowImageView.setMinimumWidth(70);
    //      arrowImageView.setMinimumHeight(50);
    progressBar = (ProgressBar) headView.findViewById(R.id.head_progressBar);
    tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.head_lastUpdatedTextView);
    measureView(headView);
    mHeaderHeight = headView.getMeasuredHeight();
    headView.setPadding(0, -mHeaderHeight, 0, 0);
    addView(headView);

}

From source file:io.realm.realmtasks.list.ItemViewHolder.java

public void setHintPanelVisible(boolean visible) {
    final int visibility = hintPanel.getVisibility();
    boolean previousVisible = visibility == View.VISIBLE;
    if (previousVisible == visible) {
        return;/*w w  w  . j a  v a  2s . com*/
    }
    if (visible) {
        hintPanel.setVisibility(View.VISIBLE);
        final AlphaAnimation alphaAnimation = new AlphaAnimation(0.2f, 1.0f);
        alphaAnimation.setDuration(150);
        hintPanel.setAnimation(alphaAnimation);
        final RotateAnimation rotateAnimation = new RotateAnimation(-90, 0, RotateAnimation.RELATIVE_TO_SELF,
                0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
        rotateAnimation.setDuration(500);
        arrow.startAnimation(rotateAnimation);
    } else {
        hintPanel.setVisibility(View.GONE);
    }
}

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.
 *///from w  ww .  j ava2s .  c om
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  w  w  . j ava  2 s. c  o  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 a v a  2s .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: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 w  w w . ja  va2 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:se.lu.nateko.edca.BackboneSvc.java

@Override
public void onCreate() {
    Log.d(TAG, "onCreate() called.");
    PACKAGE_NAME = getPackageName();/*w ww  . j  av  a 2  s  . com*/

    /* 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();
}