Android Open Source - PhotoStrips Alt Gallery Activity






From Project

Back to project page PhotoStrips.

License

The source code is released under:

MIT License

If you think the Android project PhotoStrips 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.ahmetkizilay.image.photostrips;
// w  w  w . ja v  a2 s. co  m
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.GridView;
import android.widget.TextView;

import com.ahmetkizilay.image.photostrips.dialogs.AboutMeDialogFragment;
import com.ahmetkizilay.image.photostrips.utils.GalleryItemAdapter;
import com.ahmetkizilay.modules.donations.PaymentDialogFragment;
import com.ahmetkizilay.modules.donations.ThankYouDialogFragment;

import java.io.File;
import java.util.Locale;

public class AltGalleryActivity extends ActionBarActivity {
  private String home_directory_string = "";

    private GridView lvGallery;
    private GalleryItemAdapter mGalleryItemAdapter;


  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // mActionBarHelper.onCreate(savedInstanceState);

    setContentView(R.layout.alt_gallery);

        Configuration config = getResources().getConfiguration();
        if (config.locale == null)
            config.locale = Locale.getDefault();

        this.home_directory_string = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "perisonic" + File.separator + "image" + File.separator + "photostrips";
        this.mGalleryItemAdapter = new GalleryItemAdapter(this, this.home_directory_string);

        this.lvGallery = (GridView) findViewById(R.id.lvGallery);
        this.lvGallery.setAdapter(this.mGalleryItemAdapter);

        TextView twEmptyGallery = (TextView) findViewById(R.id.twEmptyGallery);
        if(this.mGalleryItemAdapter.getCount() != 0) {
            twEmptyGallery.setVisibility(View.GONE);
        }

  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_about:
      showAboutMe();
      return true;
    case R.id.menu_booth:
      Intent swithViewIntent = new Intent(this, PhotoBoothActivity.class);
      swithViewIntent.setAction("com.ahmetkizilay.image.photostrips.PhotoBoothActivity");
      this.startActivity(swithViewIntent);
      return true;
    default:
      return super.onOptionsItemSelected(item);
    }
  }

    private void showAboutMe() {
        AboutMeDialogFragment newFragment = AboutMeDialogFragment.newInstance();
        newFragment.setRequestListener(new AboutMeDialogFragment.RequestListener() {
            public void onDonationsRequested() {
                showDonationDialog();
            }
        });
        newFragment.show(getSupportFragmentManager(), "dialog");
    }

    private void showDonationDialog() {
        final PaymentDialogFragment newFragment = PaymentDialogFragment.getInstance(R.array.product_ids);
        newFragment.setPaymentCompletedListener(new PaymentDialogFragment.PaymentCompletedListener() {
            public void onPaymentCompleted() {
                newFragment.dismiss();
                showThankYouDialog();
            }
        });
        newFragment.show(getSupportFragmentManager(), "frag-donations");
    }

    private void showThankYouDialog() {
        final ThankYouDialogFragment newFragment = ThankYouDialogFragment.newInstance();
        newFragment.show(getSupportFragmentManager(), "frag-thanks");
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        if (requestCode == 0) {
            if(resultCode == RESULT_OK) {
                this.mGalleryItemAdapter.removeItem(data.getData().getPath());
                this.mGalleryItemAdapter.notifyDataSetChanged();
            }
        }

        // pass the request back to the fragment
        if(requestCode == PaymentDialogFragment.PAYMENT_RESULT_CODE) {
            FragmentManager fragmentManager = getSupportFragmentManager();
            Fragment fragment = fragmentManager.findFragmentByTag("frag-donations");
            if (fragment != null)
            {
                fragment.onActivityResult(requestCode, resultCode, data);
            }
        }
    }

  @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu, menu);
        return true;
    }
}




Java Source Code List

com.ahmetkizilay.image.photostrips.AltGalleryActivity.java
com.ahmetkizilay.image.photostrips.CameraPreview.java
com.ahmetkizilay.image.photostrips.PhotoBoothActivity.java
com.ahmetkizilay.image.photostrips.PhotoCreator.java
com.ahmetkizilay.image.photostrips.ViewImageActivity.java
com.ahmetkizilay.image.photostrips.dialogs.AboutMeDialogFragment.java
com.ahmetkizilay.image.photostrips.dialogs.CompletionDialogFragment.java
com.ahmetkizilay.image.photostrips.dialogs.ConfirmDialogFragment.java
com.ahmetkizilay.image.photostrips.dialogs.PhotoCreationDialogFragment.java
com.ahmetkizilay.image.photostrips.utils.CustomHorizontalScrollView.java
com.ahmetkizilay.image.photostrips.utils.GalleryItemAdapter.java
com.ahmetkizilay.image.photostrips.utils.OnDoubleTapListener.java
com.ahmetkizilay.image.photostrips.utils.OnMultiTapListener.java
com.ahmetkizilay.image.photostrips.utils.TouchImageView.java
com.ahmetkizilay.image.photostrips.utils.TransportViewGroup.java