Android Open Source - Android-Mutiple-Select-Gallery Gallery Activity






From Project

Back to project page Android-Mutiple-Select-Gallery.

License

The source code is released under:

MIT License

If you think the Android project Android-Mutiple-Select-Gallery 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 com.pgk.venusgallery;
/*w w w .j  a va  2  s  .  co  m*/
import com.pgk.venusgallery.fragments.AlbumGalleryFragment;
import com.pgk.venusgallery.fragments.PhotoGalleryFragment;
import com.pgk.venusgallery.models.VGManager;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;

public class GalleryActivity extends FragmentActivity {

  Activity   mActivity   = null;
  VGManager  mManager  = null;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);
    mActivity = this;
    mManager = new VGManager(mActivity);
    
    // load albm gallery
    loadAlbumGallery();
  }

  private void changeFragment(Fragment targetFragment) {
    /*
     * getSupportFragmentManager() .beginTransaction() .setCustomAnimations(
     * R.anim.slide_in_left, 0, 0, R.anim.slide_out_left)
     * .replace(R.id.main_fragment, targetFragment, "TAG_FRAGMENT")
     * .commit();
     */
    getSupportFragmentManager().beginTransaction()
        .replace(R.id.main_fragment, targetFragment, "TAG_FRAGMENT")
        .setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
        .commit();
  }

  private void loadAlbumGallery() {

    changeFragment(new AlbumGalleryFragment(mManager) {
      @Override
      public void openAlbum(Integer idx) {

        // load albm gallery
        changeFragment(new PhotoGalleryFragment(mManager, idx));
      }
    });
  }

  @Override
  public void onBackPressed() {
    
    Fragment fragment = (Fragment) getSupportFragmentManager().findFragmentByTag("TAG_FRAGMENT");

    if (fragment.getClass().equals(PhotoGalleryFragment.class)) {
      loadAlbumGallery();
      return;
    }
    
    Intent i = new Intent();
    mActivity.setResult(Activity.RESULT_CANCELED, i);
    mActivity.finish();
  }
}




Java Source Code List

com.pgk.venusgallery.GalleryActivity.java
com.pgk.venusgallery.TestActivity.java
com.pgk.venusgallery.adapter.AlbumAdapter.java
com.pgk.venusgallery.adapter.PhotoAdapter.java
com.pgk.venusgallery.fragments.AlbumGalleryFragment.java
com.pgk.venusgallery.fragments.PhotoGalleryFragment.java
com.pgk.venusgallery.models.VGAlbum.java
com.pgk.venusgallery.models.VGManager.java
com.pgk.venusgallery.models.VGPhoto.java
com.pgk.venusgallery.opts.VGGallery.java
com.pgk.venusgallery.opts.VGModel.java
com.pgk.venusgallery.utils.VGCompare.java
com.pgk.venusgallery.utils.VGMediaStore.java
com.pgk.venusgallery.utils.VGSquareImageView.java