Android Open Source - gatoloco Main Activity






From Project

Back to project page gatoloco.

License

The source code is released under:

GNU General Public License

If you think the Android project gatoloco 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.grumpycat;
/*from w w w.j a  v  a  2s. co  m*/
import java.io.FileNotFoundException;
import java.io.InputStream;

import com.grumpycat.utils.FileUtils;

import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;

public class MainActivity extends Activity {
  final Context context = this;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);

    ImageButton btnSnapAndShare = (ImageButton) findViewById(R.id.btnSnapAndShare);
    ImageButton btnGrabPicts = (ImageButton) findViewById(R.id.btnGrabPicts);
    ImageButton btnAbout = (ImageButton) findViewById(R.id.btnAbout);
    btnSnapAndShare.setOnClickListener(onClickListener);
    btnGrabPicts.setOnClickListener(onClickListener);
    btnAbout.setOnClickListener(onClickListener);
  }

  private OnClickListener onClickListener = new OnClickListener() {
    @Override
    public void onClick(final View v) {
      switch (v.getId()) {
      case R.id.btnSnapAndShare:
        Intent intent1 = new Intent(MainActivity.this,
            SnapShotActivity.class);
        startActivity(intent1);
        break;
      case R.id.btnGrabPicts:
        // DO something
        // Intent intent2 = new Intent(MainActivity.this,
        // SnapShotActivity.class);
        // startActivity(intent2);
        Intent localIntent2 = new Intent();
        localIntent2.setType("image/*");
        localIntent2.setAction("android.intent.action.GET_CONTENT");
        MainActivity.this.startActivityForResult(Intent.createChooser(
            localIntent2, "Choose Gallery Application"), 2000);
        break;
      case R.id.btnAbout:
        // DO something
        final Dialog dialog = new Dialog(context);
        dialog.setContentView(R.layout.dialog_about);
        dialog.setTitle("About " + Config.APP_NAME);
        Button btnCancel = (Button) dialog
            .findViewById(R.id.dialogButtonClose);
        btnCancel.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
            dialog.dismiss();
          }
        });
        dialog.show();
        break;
      }

    }
  };

  @Override
  public void onBackPressed() {
    super.onBackPressed();
    this.finish();
  }

  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (KeyEvent.KEYCODE_BACK == keyCode) {
      finish();
      return true;
    }
    return false;
  }

  protected void onActivityResult(int paramInt1, int paramInt2,
      Intent paramIntent) {
    super.onActivityResult(paramInt1, paramInt2, paramIntent);
    switch (paramInt1) {
    default:
    case 2000:
    }
    Uri localUri = paramIntent.getData();
    try {
//      InputStream localInputStream = getContentResolver()
//          .openInputStream(localUri);
      // FileUtils.saveImageToTempFile(getApplicationContext(),
      // localInputStream);
      // FileUtils.copyFile(getApplicationContext(),Config.OUTPUT_FILENAME);
      startActivity(new Intent(this, GalleryActivity.class));
      return;
    } catch (FileNotFoundException localFileNotFoundException) {
      Log.d(Config.LOG_NAME, "No load file");
    }
  }

}




Java Source Code List

com.grumpycat.Config.java
com.grumpycat.GalleryActivity.java
com.grumpycat.MainActivity.java
com.grumpycat.Preview.java
com.grumpycat.SaveActivity.java
com.grumpycat.SnapShotActivity.java
com.grumpycat.SplashActivity.java
com.grumpycat.utils.FileUtils.java