Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Simple code clean up #3

Closed
wants to merge 9 commits into from

3 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 22, 2012
  1. @nguyenmp
  2. @nguyenmp

    >from: using static reference to bitmap

    nguyenmp authored
    >to: passing bitmap via extras
    >reason: separation between activities and clearer variable states
  3. @nguyenmp
  4. @nguyenmp
  5. @nguyenmp
  6. @nguyenmp

    Revert "There is absolutely no reason why the builder should be a mem…

    nguyenmp authored
    …ber variable"
    
    This reverts commit 076c658e4f6287ba2dbc35ce75d109ba4d59ebc2.
  7. @nguyenmp
  8. @nguyenmp
  9. @nguyenmp
This page is out of date. Refresh to see the latest.
View
15 .classpath
@@ -1,7 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
View
172 src/com/colmmoore/RedditQuickSubmit/RedditQuickSubmitActivity.java
@@ -18,96 +18,88 @@
import android.view.View.OnClickListener;
import android.widget.Button;
-public class RedditQuickSubmitActivity extends Activity {
-
- private AlertDialog.Builder alertDialog;
-
-
- final CharSequence[] items = {"Camera", "Gallery"}; // This is used for the AlertDialog
- public static final int CAMERA_PIC_REQUEST = 0; // This is where the image captured from the camera is stored.
- public static String imageid;
- public static Intent data;
- public static Bitmap photo;
-
- Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
-
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE); // Hides the horrible title at the top of the app.
- setContentView(R.layout.main);
-
-
- Button submitImageButton = (Button) findViewById(R.id.submitImageButton); // Creates buttons to be used using the
- Button submitTextButton = (Button) findViewById(R.id.submitTextButton); // properties specified in the XML file
- Button submitLinkButton = (Button) findViewById(R.id.submitLinkButton);
-
-
- alertDialog = new AlertDialog.Builder(this); // Creates a new AlertDialog for the popup
- alertDialog.setTitle("Select Source"); // Sets its title
-
-
- alertDialog.setItems(items, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- if(item == 0){
- startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
- }
- }
-
- });
-
-
-
- submitImageButton.setOnClickListener(new OnClickListener() { // Listens for a button click on the
- @Override // Submit Image button.
- public void onClick(View v) { //
- AlertDialog myalert = alertDialog.create(); // Opens the Alert Dialog above if click on.
- myalert.show();
- }
-
- });
-
-
- submitTextButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent myIntent = new Intent(v.getContext(), SubmitTextActivity.class);
- startActivityForResult(myIntent, 0);
- }
-
- });
-
-
- submitLinkButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent myIntent = new Intent(v.getContext(), SubmitLinkActivity.class);
- startActivityForResult(myIntent, 0);
- }
-
- });
-
- }
-
- // A lot of this code is experimental, can someone improve upon it maybe? I'm trying to get the image the camera took
- // and open a new Activity displaying that image. Once we get that working, we can add a text box for title, and then a
- // submit button at the top.
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == CAMERA_PIC_REQUEST) {
- if (data != null) {
-
- photo = (Bitmap) data.getExtras().get("data");
+public class RedditQuickSubmitActivity extends Activity {
+
+
+ final CharSequence[] items = {"Camera", "Gallery"}; // This is used for the AlertDialog
+ public static final int CAMERA_PIC_REQUEST = 0; // This is the activity request code necessary for startActivityForResult(Intent);
+ public static String imageid;
+ public static Intent data;
+
+ Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
+
- Intent cameraSubmit = new Intent(RedditQuickSubmitActivity.this, SubmitImageActivity.class);
- startActivity(cameraSubmit);
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_NO_TITLE); // Hides the horrible title at the top of the app.
+ setContentView(R.layout.main);
- }
+
+ //Bind to the initialized buttons
+ Button submitImageButton = (Button) findViewById(R.id.submitImageButton); // Creates buttons to be used using the
+ Button submitTextButton = (Button) findViewById(R.id.submitTextButton); // properties specified in the XML file
+ Button submitLinkButton = (Button) findViewById(R.id.submitLinkButton);
+
+ //And assign their respective click listeners
+ submitImageButton.setOnClickListener(new SubmitImageOnClickListener());
+ submitTextButton.setOnClickListener(new SubmitTextOnClickListener());
+ submitLinkButton.setOnClickListener(new SubmitLinkOnClickListener());
+
+ }
+
+ // A lot of this code is experimental, can someone improve upon it maybe? I'm trying to get the image the camera took
+ // and open a new Activity displaying that image. Once we get that working, we can add a text box for title, and then a
+ // submit button at the top.
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == CAMERA_PIC_REQUEST) {
+ if (data != null) {
+
+ Bitmap photo = (Bitmap) data.getExtras().get("data");
+
+ Intent cameraSubmit = new Intent(RedditQuickSubmitActivity.this, SubmitImageActivity.class);
+ cameraSubmit.putExtra("data", photo);
+ startActivity(cameraSubmit);
+
+ }
+ }
+ }
+
+ private class SubmitImageOnClickListener implements OnClickListener {
+ // Listens for a button click on the
+ @Override // Submit Image button.
+ public void onClick(View v) {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(v.getContext()); // Creates a new AlertDialog for the popup
+ alertDialog.setTitle("Select Source"); // Sets its title
+
+
+ alertDialog.setItems(items, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int item) {
+ if(item == 0) {
+ startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
+ }
+ }
+ });
+ AlertDialog myalert = alertDialog.create(); // Opens the Alert Dialog above if click on.
+ myalert.show();
+ }
+ }
+
+ private class SubmitTextOnClickListener implements OnClickListener {
+ @Override
+ public void onClick(View v) {
+ Intent myIntent = new Intent(v.getContext(), SubmitTextActivity.class);
+ startActivityForResult(myIntent, 0);
+ }
+ }
+
+ private class SubmitLinkOnClickListener implements OnClickListener {
+ @Override
+ public void onClick(View v) {
+ Intent myIntent = new Intent(v.getContext(), SubmitLinkActivity.class);
+ startActivityForResult(myIntent, 0);
+ }
}
- }
-}
-
-
-
+}
View
5 src/com/colmmoore/RedditQuickSubmit/SubmitImageActivity.java
@@ -25,7 +25,10 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.submitimage);
this.imageView = (ImageView)this.findViewById(R.id.cameraPhoto);
- imageView.setImageBitmap(RedditQuickSubmitActivity.photo);
+
+ Bitmap photo = (Bitmap) getIntent().getExtras().get("data");
+ if (photo != null)
+ imageView.setImageBitmap(photo);
}
}
View
17 src/com/colmmoore/RedditQuickSubmit/SubmitTextActivity.java
@@ -3,6 +3,7 @@
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
+import android.view.WindowManager;
public class SubmitTextActivity extends Activity {
@@ -10,20 +11,10 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); // Hides the horrible title at the top of the app.
+ this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
setContentView(R.layout.submittext);
+
}
-}
-
-
-
-
-
-
-
-
-
-
-
-
+}
Something went wrong with that request. Please try again.