Skip to content

Commit

Permalink
BaseActivity: Move navigate() to ListActivity().
Browse files Browse the repository at this point in the history
Because it is the only place it is used.
  • Loading branch information
murraycu committed Jan 8, 2015
1 parent f255866 commit 657b885
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
31 changes: 0 additions & 31 deletions app/src/main/java/com/murrayc/galaxyzoo/app/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@
package com.murrayc.galaxyzoo.app;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
//import android.os.StrictMode;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;

/**
* Created by murrayc on 2/7/14.
Expand Down Expand Up @@ -61,33 +57,6 @@ protected void onCreate(final Bundle savedInstanceState) {
//Log.v("glomdebug", "type=" + type);
}

/**
*
* @param itemId
* @param done
* @param sharedElementView A shared element for use with a transition animation.
*/
void navigate(final String itemId, final boolean done, final View sharedElementView) {
// Start the detail activity
// for the selected item ID.
final Intent intent = new Intent(this,
done ? SubjectViewerActivity.class : ClassifyActivity.class);
if (!TextUtils.isEmpty(itemId)) {
intent.putExtra(ItemFragment.ARG_ITEM_ID, itemId);
}

// get the common element for the transition in this activity
if (sharedElementView != null) {

//"subjectImageTransition" is also specified as transitionName="subjectImageTransition"
//on the ImageView in both gridview_cell_fragment_list.xml and fragment_subject.xml.
//TODO: Why do we need to specify it again here?
ActivityCompat.startActivity(this, intent, UiUtils.getTransitionOptionsBundle(this, sharedElementView));
} else {
startActivity(intent);
}
}

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
// Handle presses on the action bar items
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/java/com/murrayc/galaxyzoo/app/ListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

package com.murrayc.galaxyzoo.app;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.text.TextUtils;
import android.view.View;


Expand Down Expand Up @@ -65,4 +68,31 @@ public void onItemSelected(final String itemId, final boolean done, final View s
public void navigateToNextAvailable() {
navigate(null, false /* not done */, null); //null means next for itemId
}

/**
*
* @param itemId
* @param done
* @param sharedElementView A shared element for use with a transition animation.
*/
private void navigate(final String itemId, final boolean done, final View sharedElementView) {
// Start the detail activity
// for the selected item ID.
final Intent intent = new Intent(this,
done ? SubjectViewerActivity.class : ClassifyActivity.class);
if (!TextUtils.isEmpty(itemId)) {
intent.putExtra(ItemFragment.ARG_ITEM_ID, itemId);
}

// get the common element for the transition in this activity
if (sharedElementView != null) {

//"subjectImageTransition" is also specified as transitionName="subjectImageTransition"
//on the ImageView in both gridview_cell_fragment_list.xml and fragment_subject.xml.
//TODO: Why do we need to specify it again here?
ActivityCompat.startActivity(this, intent, UiUtils.getTransitionOptionsBundle(this, sharedElementView));
} else {
startActivity(intent);
}
}
}

0 comments on commit 657b885

Please sign in to comment.