Android Open Source - android-training-tutorial Main Activity






From Project

Back to project page android-training-tutorial.

License

The source code is released under:

MIT License

If you think the Android project android-training-tutorial listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package im.ene.zanimationsample;
//from   w w w.j  av a 2 s.  c om
import com.squareup.picasso.Picasso;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class MainActivity extends ActionBarActivity {

  private ImageView mImage1, mImage2;
  private Animation animation_fadein, animation_fadeout;

  private Context mContext;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_main);
    mContext = this;

    mImage1 = (ImageView) findViewById(R.id.image_main);
    mImage2 = (ImageView) findViewById(R.id.image_sub);

    // set default image to imageviews
    Picasso.with(mContext).load(R.drawable.image_1).fit().centerCrop()
        .into(mImage1);
    Picasso.with(mContext).load(R.drawable.image_2).fit().centerCrop()
        .into(mImage2);

    // define fade animations
    animation_fadeout = AnimationUtils.loadAnimation(this,
        R.anim.abc_fade_out);
    animation_fadeout.setDuration(500);
    animation_fadeout.setAnimationListener(fadeout_animation_listener);

    animation_fadein = AnimationUtils.loadAnimation(this,
        R.anim.abc_fade_in);
    animation_fadein.setDuration(500);
    animation_fadein.setAnimationListener(fadein_animation_listener);

    mImage2.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        // start the fade out animation here
        mImage1.startAnimation(animation_fadeout);
        mImage2.startAnimation(animation_fadeout);
      }
    });
    
  }

  private AnimationListener fadeout_animation_listener = new AnimationListener() {

    @Override
    public void onAnimationStart(Animation animation) {

    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }

    @Override
    public void onAnimationEnd(Animation animation) {
      mImage1.startAnimation(animation_fadein);
      mImage2.startAnimation(animation_fadein);
    }
  };

  int counter = 1;
  
  private AnimationListener fadein_animation_listener = new AnimationListener() {

    @Override
    public void onAnimationStart(Animation animation) {
      Log.d("counter", counter ++ + "");
      Picasso.with(mContext).load(R.drawable.image_2).fit().centerCrop()
          .into(mImage1);
      Picasso.with(mContext).load(R.drawable.image_1).fit().centerCrop()
          .into(mImage2);
    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }

    @Override
    public void onAnimationEnd(Animation animation) {
      
    }
  };
}




Java Source Code List

com.flavienlaurent.vdh.DragActivity.java
com.flavienlaurent.vdh.DragLayout.java
com.flavienlaurent.vdh.HorizontalDragLayout.java
com.flavienlaurent.vdh.MainActivity.java
com.flavienlaurent.vdh.YoutubeActivity.java
com.flavienlaurent.vdh.YoutubeLayout.java
com.flavienlaurent.vdh.listener.SwipeDismissTouchListener.java
com.hb.views.PinnedSectionListView.java
fi.harism.curl.CurlActivity.java
fi.harism.curl.CurlMesh.java
fi.harism.curl.CurlPage.java
fi.harism.curl.CurlRenderer.java
fi.harism.curl.CurlView.java
im.ene.dev.zbroadcastreceiver2.MainActivity.java
im.ene.dev.zbroadcastreceiver2.receivers.CustomBroadcastReceiver.java
im.ene.dev.zbroadcastreceiver2.services.CustomBroadcastService.java
im.ene.dev.zbroadcastreceiver.MainActivity.java
im.ene.dev.zbroadcastreceiver.SecondActivity.java
im.ene.dev.zbroadcastreceiver.receivers.CustomBroadcastReceiver.java
im.ene.dev.zbroadcastreceiver.services.CustomBroadcastService.java
im.ene.dev.zserviceibinder.MainActivity.java
im.ene.dev.zserviceibinder.services.CustomService.java
im.ene.pinnedheaderlistviewsample.MainActivity.java
im.ene.samplevideoplayer.MainActivity.java
im.ene.samplevideoplayer.constant.Constant.java
im.ene.samplevideoplayer.views.CustomSurfaceView.java
im.ene.samplevideoplayer.views.VideoControllerView.java
im.ene.zaidlservicesample.MainActivity.java
im.ene.zaidlservicesample.Second.java
im.ene.zanimationsample.MainActivity.java
im.ene.zcustomvideoview.MainActivity.java
im.ene.zcustomvideoview.views.CustomVideoView.java
im.ene.zcustomvideoview.views.VideoControllerView.java
im.ene.zintenttutorial.MainActivity.java
im.ene.zintenttutorial.broadcastreceiver.CustomBroadcastReceiver.java
im.ene.zintenttutorial.services.CustomService.java
im.ene.zviewpager.MainActivity.java