Example usage for android.view.animation AnimationUtils loadAnimation

List of usage examples for android.view.animation AnimationUtils loadAnimation

Introduction

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

Prototype

public static Animation loadAnimation(Context context, @AnimRes int id) throws NotFoundException 

Source Link

Document

Loads an Animation object from a resource

Usage

From source file:com.architjn.acjmusicplayer.elements.ScrollAwareFABBehavior.java

private void animateOut(final FloatingActionButton button) {
    Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.abc_slide_out_bottom);
    anim.setInterpolator(INTERPOLATOR);//w w  w .jav  a  2 s .  co m
    anim.setDuration(600L);
    anim.setAnimationListener(new Animation.AnimationListener() {
        public void onAnimationStart(Animation animation) {
            ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
        }

        public void onAnimationEnd(Animation animation) {
            ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
            button.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(final Animation animation) {
        }
    });
    button.startAnimation(anim);
}

From source file:cn.finalteam.galleryfinal.adapter.PhotoListAdapter.java

@Override
public void onBindViewHolder(PhotoViewHolder holder, int position) {
    PhotoInfo photoInfo = getDatas().get(position);

    String path = "";
    if (photoInfo != null) {
        path = photoInfo.getPhotoPath();
    }//from  ww  w  .  ja  va2 s  .  co  m

    holder.mIvThumb.setImageResource(R.drawable.ic_gf_default_photo);
    Drawable defaultDrawable = ContextCompat.getDrawable(mActivity, R.drawable.ic_gf_default_photo);
    GalleryFinal.getCoreConfig().getImageLoader().displayImage(mActivity, path, holder.mIvThumb,
            defaultDrawable, mRowWidth, mRowWidth);
    holder.mView.setAnimation(null);
    if (GalleryFinal.getCoreConfig().getAnimation() > 0) {
        holder.mView.setAnimation(
                AnimationUtils.loadAnimation(mActivity, GalleryFinal.getCoreConfig().getAnimation()));
    }
    holder.mIvCheck.setImageResource(GalleryFinal.getGalleryTheme().getIconCheck());
    if (GalleryFinal.getFunctionConfig().isMutiSelect()) {
        holder.mIvCheck.setVisibility(View.VISIBLE);
        if (mSelectList.contains(photoInfo)) {
            holder.mIvCheck.setBackgroundColor(GalleryFinal.getGalleryTheme().getCheckSelectedColor());
        } else {
            holder.mIvCheck.setBackgroundColor(GalleryFinal.getGalleryTheme().getCheckNornalColor());
        }
    } else {
        holder.mIvCheck.setVisibility(View.GONE);
    }
}

From source file:com.suyonoion.mymath.Menus.fragment_page1.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle SavedInstanceStace) {
    tampilpage1 = inflater.inflate(R.layout.page1, container, false);
    shake = AnimationUtils.loadAnimation(getContext(), R.anim.shake);
    /** Persamaan (i) **/
    editText_a = (EditText) tampilpage1.findViewById(R.id.EditTxt_a);
    editText_b = (EditText) tampilpage1.findViewById(R.id.EditTxt_b);
    editText_c = (EditText) tampilpage1.findViewById(R.id.EditTxt_c);
    /** Persamaan (ii) **/
    editText_d = (EditText) tampilpage1.findViewById(R.id.EditTxt_d);
    editText_e = (EditText) tampilpage1.findViewById(R.id.EditTxt_e);
    editText_f = (EditText) tampilpage1.findViewById(R.id.EditTxt_f);
    /** hasil */// w  ww. j  a v  a  2s .  c o m
    txtHasil_x = (TextView) tampilpage1.findViewById(R.id.hasilSPLDV_x);
    txtHasil_y = (TextView) tampilpage1.findViewById(R.id.hasilSPLDV_y);
    txtHasil_xy = (TextView) tampilpage1.findViewById(R.id.hasilSPLDV_xy);
    // persamaan (i) - spldv_penyamaan
    tvPenyamaanKiri1 = (TextView) tampilpage1.findViewById(R.id.penyamaan_kiri1);
    tvPenyamaanKiri2 = (TextView) tampilpage1.findViewById(R.id.penyamaan_kiri2);
    tvPenyamaanKiri3 = (TextView) tampilpage1.findViewById(R.id.penyamaan_kiri3);
    tvPenyamaanKanan1 = (TextView) tampilpage1.findViewById(R.id.penyamaan_kanan1);
    tvPenyamaanKanan2 = (TextView) tampilpage1.findViewById(R.id.penyamaan_kanan2);
    tvPenyamaanKanan3_atas = (TextView) tampilpage1.findViewById(R.id.penyamaan_kanan3_atas);
    tvPenyamaanKanan3_bawah = (TextView) tampilpage1.findViewById(R.id.penyamaan_kanan3_bawah);
    // persamaan (ii) - spldv_penyamaan
    tvPenyamaanKiri1_ii = (TextView) tampilpage1.findViewById(R.id.penyamaan_kiri1_ii);
    tvPenyamaanKiri2_ii = (TextView) tampilpage1.findViewById(R.id.penyamaan_kiri2_ii);
    tvPenyamaanKiri3_ii = (TextView) tampilpage1.findViewById(R.id.penyamaan_kiri3_ii);
    tvPenyamaanKanan1_ii = (TextView) tampilpage1.findViewById(R.id.penyamaan_kanan1_ii);
    tvPenyamaanKanan2_ii = (TextView) tampilpage1.findViewById(R.id.penyamaan_kanan2_ii);
    tvPenyamaanKanan3_atas_ii = (TextView) tampilpage1.findViewById(R.id.penyamaan_kanan3_ii_atas);
    tvPenyamaanKanan3_bawah_ii = (TextView) tampilpage1.findViewById(R.id.penyamaan_kanan3_ii_bawah);
    // maka
    tvMaka_kiri1_atas = (TextView) tampilpage1.findViewById(R.id.maka_kiri1_atas);
    tvMaka_kiri1_bawah = (TextView) tampilpage1.findViewById(R.id.maka_kiri1_bawah);
    tvMaka_kanan1_atas = (TextView) tampilpage1.findViewById(R.id.maka_kanan1_atas);
    tvMaka_kanan1_bawah = (TextView) tampilpage1.findViewById(R.id.maka_kanan1_bawah);
    tvMaka_kiri2 = (TextView) tampilpage1.findViewById(R.id.maka_kiri2);
    tvMaka_kanan2 = (TextView) tampilpage1.findViewById(R.id.maka_kanan2);
    tvMaka_kiri3 = (TextView) tampilpage1.findViewById(R.id.maka_kiri3);
    tvMaka_kanan3 = (TextView) tampilpage1.findViewById(R.id.maka_kanan3);
    tvMaka_kiri4 = (TextView) tampilpage1.findViewById(R.id.maka_kiri4);
    tvMaka_kanan4 = (TextView) tampilpage1.findViewById(R.id.maka_kanan4);
    tvMaka_kiri5 = (TextView) tampilpage1.findViewById(R.id.maka_kiri5);
    tvMaka_kanan5 = (TextView) tampilpage1.findViewById(R.id.maka_kanan5);
    tvMaka_kanan6_atas = (TextView) tampilpage1.findViewById(R.id.maka_kanan6_atas);
    tvMaka_kanan6_bawah = (TextView) tampilpage1.findViewById(R.id.maka_kanan6_bawah);
    tvMaka_kanan7 = (TextView) tampilpage1.findViewById(R.id.maka_kanan7);
    tvKetemu = (TextView) tampilpage1.findViewById(R.id.ketemu);
    // proses maka masukkan
    tvmasuk_persamaan_i_baris1_atas = (TextView) tampilpage1.findViewById(R.id.masuk_persamaan_i_baris1_atas);
    tvmasuk_persamaan_i_baris1_bawah = (TextView) tampilpage1.findViewById(R.id.masuk_persamaan_i_baris1_bawah);
    tvmasuk_persamaan_i_baris2_atas = (TextView) tampilpage1.findViewById(R.id.masuk_persamaan_i_baris2_atas);
    tvmasuk_persamaan_i_baris2_bawah = (TextView) tampilpage1.findViewById(R.id.masuk_persamaan_i_baris2_bawah);
    tvmasuk_persamaan_i_baris3_atas = (TextView) tampilpage1.findViewById(R.id.masuk_persamaan_i_baris3_atas);
    tvmasuk_persamaan_i_baris3_bawah = (TextView) tampilpage1.findViewById(R.id.masuk_persamaan_i_baris3_bawah);
    tvmasuk_persamaan_i_baris4 = (TextView) tampilpage1.findViewById(R.id.masuk_persamaan_i_baris4);
    // spldv.xml
    penyelesaianSPLDV = (LinearLayout) tampilpage1.findViewById(R.id.penyelesaianSPLDV);
    metodePenyamaanSPLDV = (LinearLayout) tampilpage1.findViewById(R.id.metode_penyamaan);
    persamaan_i = (LinearLayout) tampilpage1.findViewById(R.id.persamaan_i);
    persamaan_ii = (LinearLayout) tampilpage1.findViewById(R.id.persamaan_ii);
    maka_x = (LinearLayout) tampilpage1.findViewById(R.id.maka_x);
    maka_y = (LinearLayout) tampilpage1.findViewById(R.id.maka_y);

    btnHasil = (Button) tampilpage1.findViewById(R.id.btnHasil);
    btnSubstitusi = (Button) tampilpage1.findViewById(R.id.btnSubstitusi);
    btnEliminasi = (Button) tampilpage1.findViewById(R.id.btnEliminasi);
    btnDeterminan = (Button) tampilpage1.findViewById(R.id.btnDeterminan);
    btnGrafik = (Button) tampilpage1.findViewById(R.id.btnGrafik);
    /** Button Proses */
    prosesButton();
    return tampilpage1;
}

From source file:id.zelory.tanipedia.activity.BacaActivity.java

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

    tmp = getIntent().getParcelableExtra("berita");

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//ww w. ja v a 2 s .c o  m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("TaniPedia");

    animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow);
    gambar = (ImageView) findViewById(R.id.gambar);
    judul = (TextView) findViewById(R.id.judul);
    tanggal = (TextView) findViewById(R.id.tanggal);
    isi = (DocumentView) findViewById(R.id.isi);
    root = (LinearLayout) findViewById(R.id.ll_root_berita);

    fabButton = (FabButton) findViewById(R.id.determinate);
    fabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_SUBJECT, berita.getJudul());
            intent.putExtra(Intent.EXTRA_TEXT, berita.getJudul() + "\n" + berita.getAlamat());
            startActivity(Intent.createChooser(intent, "Bagikan"));
        }
    });

    generateBeritaLainnya();

    new DownloadData().execute();
}

From source file:id.zelory.tanipedia.activity.BeritaActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_berita);
    toolbar = (Toolbar) findViewById(R.id.anim_toolbar);

    setSupportActionBar(toolbar);/*  w  w w  .ja v a  2  s .  c  o  m*/
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("Berita Terbaru");

    animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow);

    drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer);
    setUpNavDrawer();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.getMenu().getItem(1).setChecked(true);
    TextView nama = (TextView) navigationView.findViewById(R.id.nama);
    nama.setText(PrefUtils.ambilString(this, "nama"));
    TextView email = (TextView) navigationView.findViewById(R.id.email);
    email.setText(PrefUtils.ambilString(this, "email"));
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            menuItem.setChecked(true);
            drawerLayout.closeDrawers();
            Intent intent;
            switch (menuItem.getItemId()) {
            case R.id.cuaca:
                intent = new Intent(BeritaActivity.this, CuacaActivity.class);
                break;
            case R.id.berita:
                return true;
            case R.id.tanya:
                intent = new Intent(BeritaActivity.this, TanyaActivity.class);
                break;
            case R.id.harga:
                intent = new Intent(BeritaActivity.this, KomoditasActivity.class);
                break;
            case R.id.logout:
                PrefUtils.simpanString(BeritaActivity.this, "nama", null);
                intent = new Intent(BeritaActivity.this, LoginActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
                return true;
            case R.id.tentang:
                intent = new Intent(BeritaActivity.this, TentangActivity.class);
                startActivity(intent);
                return true;
            default:
                return true;
            }
            startActivity(intent);
            finish();
            return true;
        }
    });
    imageHeader = (ImageView) findViewById(R.id.header);
    recyclerView = (RecyclerView) findViewById(R.id.scrollableview);

    recyclerView.setHasFixedSize(true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);

    fabButton = (FabButton) findViewById(R.id.determinate);
    fabButton.showProgress(true);
    new DownloadData().execute();
    fabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fabButton.showProgress(true);
            new DownloadData().execute();
        }
    });
}

From source file:com.aniruddhc.acemusic.player.MiscFragments.BuildingLibraryProgressFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;//from w ww.  java  2s . c  o m
    mRootView = (View) getActivity().getLayoutInflater().inflate(R.layout.fragment_building_library_progress,
            null);

    mProgressElementsContainer = (RelativeLayout) mRootView.findViewById(R.id.progress_elements_container);
    mProgressElementsContainer.setVisibility(View.INVISIBLE);

    mCurrentTaskText = (TextView) mRootView.findViewById(R.id.building_library_task);
    mCurrentTaskText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light"));
    mCurrentTaskText
            .setPaintFlags(mCurrentTaskText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    mProgressBar = (ProgressBar) mRootView.findViewById(R.id.building_library_progress);
    mProgressBar.setMax(1000000);

    mFadeInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.fade_in);
    mFadeInAnimation.setAnimationListener(fadeInListener);
    mFadeInAnimation.setDuration(700);

    return mRootView;
}

From source file:com.evandroid.musica.utils.RefreshButtonBehavior.java

public void animateOut(final FloatingActionButton button) {
    int translationY = button.getHeight()
            + ((CoordinatorLayout.LayoutParams) button.getLayoutParams()).bottomMargin;
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).translationY(translationY).setInterpolator(INTERPOLATOR).withLayer()
                .setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        RefreshButtonBehavior.this.mIsAnimatingOut = true;
                    }// ww  w .j av a 2s.co m

                    public void onAnimationCancel(View view) {
                        RefreshButtonBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        RefreshButtonBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                        visible = false;
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.refresh_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                RefreshButtonBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                RefreshButtonBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
                visible = false;
            }

            @Override
            public void onAnimationRepeat(final Animation animation) {
            }
        });
        button.startAnimation(anim);
    }
}

From source file:com.raja.knowme.FragmentProjects.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_projects, null);
    shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
    adapter = new ProjectsListAdapter(getActivity());
    functions = new AppCommonFunctions(getActivity());
    pref = new AppPreferences(getActivity());
    knowmeData = new KnowMeDataObject(getActivity());
    mProgressDialog = new ProgressDialog(getActivity());
    mProgressDialog.setCancelable(false);
    mProgressDialog.setMessage(getString(R.string.loading));

    projects_list = (ListView) mHolderView.findViewById(R.id.projects_listview);
    comapny_switcher = (TextSwitcher) mHolderView.findViewById(R.id.projects_company_name_text);
    instruction_btn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout);

    projects_list.setSelector(this.getResources().getDrawable(R.drawable.transparent_shape));

    if (!pref.getProjectsFirstRun()) {
        instruction_btn.setVisibility(RelativeLayout.GONE);
    }//from   w w  w . ja va2  s  .  com

    instruction_btn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            pref.setProjectsRunned();
            instruction_btn.setVisibility(RelativeLayout.GONE);
        }
    });
    /*                 Multiple Screen Size Condition             */

    // Small Size

    if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
        //  Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(16 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });
    }

    //Normal Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(14 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

    }

    // Large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        // Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(32 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

    }

    //X-large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        //  Toast.makeText(getActivity(), "xlarge", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(48 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

    }

    //Undefined Size

    else {
        //  Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(20 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });
    }
    mProgressDialog.show();
    new LoadData().execute();

    // Gesture detection
    gestureDetector = new GestureDetector(getActivity(), new OnGestureListener() {

        public boolean onSingleTapUp(MotionEvent e) {
            return false;
        }

        public void onShowPress(MotionEvent e) {
        }

        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            return false;
        }

        public void onLongPress(MotionEvent e) {
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            try {
                if (Math.abs(e1.getY() - e2.getY()) > AppGlobalVariables.SWIPE_MAX_OFF_PATH)
                    return false;
                /** Left swipe */
                if (e1.getX() - e2.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count < (MAX_COUNT - 1))
                        nextCompany();
                    else {
                        comapny_switcher.startAnimation(shake);
                        projects_list.startAnimation(shake);
                    }
                    /** Right Swipe */
                } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count != 0)
                        previousComapny();
                    else {
                        comapny_switcher.startAnimation(shake);
                        projects_list.startAnimation(shake);
                    }
                }
            } catch (Exception e) {
            }

            return false;
        }

        public boolean onDown(MotionEvent e) {
            return false;
        }
    });

    gestureListener = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    };

    projects_list.setOnTouchListener(gestureListener);
    return mHolderView;
}

From source file:com.android.idearse.Login.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login);/*from   w  ww.  jav  a  2  s.  c  om*/

    getWindow().getAttributes().windowAnimations = R.style.Fade;

    preferences = PreferenceManager.getDefaultSharedPreferences(this);

    loadima = (ImageView) findViewById(R.id.loading);
    rotation = AnimationUtils.loadAnimation(getApplicationContext(), R.drawable.rotate_loading);
    rotation.setRepeatCount(Animation.INFINITE);

    ActionBar actionBar = getSupportActionBar();

    setTitle("");
    getSupportActionBar().setIcon(R.drawable.title_logo);

    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME);

    username = (EditText) findViewById(R.id.username);
    password = (EditText) findViewById(R.id.password);

    preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    String user = preferences.getString("user", "");
    String pass = preferences.getString("password", "");

    username.setText(user);
    password.setText(pass);

    error_msg = (TextView) findViewById(R.id.error_msg);
    Button login = (Button) findViewById(R.id.login_btn);

    final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbtn);

    checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                SharedPreferences.Editor editor = preferences.edit();
                editor.putString("user", "");
                editor.putString("password", "");
                editor.commit();
                username.setText("");
                password.setText("");
            }
        }
    });

    if (user.length() != 0 && pass.length() != 0) {
        checkBox.setChecked(true);
    }

    login.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            InputMethodManager inputManager = (InputMethodManager) getSystemService(
                    Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);

            if (username.length() == 0 || password.length() == 0) {
                error_msg.setText("Completa los campos");
                error_msg.setVisibility(View.VISIBLE);
            } else {
                if (checkBox.isChecked()) {
                    SharedPreferences.Editor editor = preferences.edit();
                    editor.putString("user", username.getText().toString());
                    editor.putString("password", password.getText().toString());
                    editor.commit();
                }
                error_msg.setVisibility(View.GONE);
                loadima.startAnimation(rotation);
                loadima.setVisibility(View.VISIBLE);
                new LoginQuery().execute(getString(R.string.URL) + "conectar_mobil/user/login");
            }
        }
    });
}

From source file:com.hybris.mobile.app.commerce.utils.UIUtils.java

/**
 * Animate the layout to collapse/*w  w w  . j  a  v  a2  s  .  c  om*/
 */
public static void collapseLayout(Context context, View view) {
    Animation animation = AnimationUtils.loadAnimation(context, R.anim.collapse);
    view.setAnimation(animation);
    view.animate();
    animation.start();
}