Back to project page Planets-Gradle.
The source code is released under:
Apache License
If you think the Android project Planets-Gradle listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.andrewq.planets.moons; /* www.ja va2 s .c om*/ import android.app.ActionBar; import android.app.Activity; import android.app.ActivityOptions; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.preference.PreferenceManager; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import android.widget.ScrollView; import com.andrewq.planets.R; import com.andrewq.planets.image_views.EuropaImageView; import com.andrewq.planets.util.NotifyingScrollView; import com.google.analytics.tracking.android.EasyTracker; public class EuropaActivity extends Activity { ImageView imgV; ImageView img; ActionBar mActionBar; private Drawable mActionBarBackgroundDrawable; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.europa_activity); mActionBar = getActionBar(); assert mActionBar != null; mActionBar.setCustomView(R.layout.custom_actionbar_europa); mActionBar.setDisplayShowCustomEnabled(true); mActionBar.setDisplayHomeAsUpEnabled(false); img = (ImageView) findViewById(R.id.backButtonSettings); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); SharedPreferences getPrefs2 = PreferenceManager .getDefaultSharedPreferences(getBaseContext()); //Give theme_chooser the preference key defined in XML int theme_chooser = Integer.parseInt(getPrefs2.getString("prefSetTheme", "3")); //Set the action bar colors to whatever the user selects from the ListPreference if (theme_chooser == 1) { //Red mActionBarBackgroundDrawable = getResources().getDrawable(R.drawable.ab_background_red); } else if (theme_chooser == 2) { //Orange mActionBarBackgroundDrawable = getResources().getDrawable(R.drawable.ab_background_orange); } else if (theme_chooser == 3) { //Blue mActionBarBackgroundDrawable = getResources().getDrawable(R.drawable.ab_background_blue); } else if (theme_chooser == 4) { //Green mActionBarBackgroundDrawable = getResources().getDrawable(R.drawable.ab_background_green); } else if (theme_chooser == 5) { //Purple mActionBarBackgroundDrawable = getResources().getDrawable(R.drawable.ab_background_purple); } else if (theme_chooser == 6) { //Black mActionBarBackgroundDrawable = getResources().getDrawable(R.drawable.ab_background_black); } mActionBarBackgroundDrawable.setAlpha(0); getActionBar().setBackgroundDrawable(mActionBarBackgroundDrawable); ((NotifyingScrollView) findViewById(R.id.scroll_view_europa)).setOnScrollChangedListener(mOnScrollChangedListener); imgV = (ImageView) findViewById(R.id.image_header_europa); View.OnTouchListener upDownListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { imgV.setAlpha(0.8f); return true; } else if (event.getAction() == MotionEvent.ACTION_UP) { imgV.setAlpha(1.0f); Intent i = new Intent(getBaseContext(), EuropaImageView.class); Bundle scaleBundle = ActivityOptions.makeScaleUpAnimation( v, 0, 0, v.getWidth(), v.getHeight()).toBundle(); startActivity(i, scaleBundle); return true; } return false; } }; imgV.setOnTouchListener(upDownListener); } @Override public boolean onTouchEvent(MotionEvent event) { imgV = (ImageView) findViewById(R.id.image_header_europa); if (event.getAction() == MotionEvent.ACTION_DOWN) { imgV.setAlpha(0.8f); } else if (event.getAction() == MotionEvent.ACTION_UP) { imgV.setAlpha(1.0f); } return super.onTouchEvent(event); } private NotifyingScrollView.OnScrollChangedListener mOnScrollChangedListener = new NotifyingScrollView.OnScrollChangedListener() { public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { @SuppressWarnings("ConstantConditions") final int headerHeight = findViewById(R.id.image_header_europa).getHeight() - getActionBar().getHeight(); final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight; final int newAlpha = (int) (ratio * 255); mActionBarBackgroundDrawable.setAlpha(newAlpha); } }; @Override public void onStart() { super.onStart(); EasyTracker.getInstance(this).activityStart(this); // Add this method. } @Override public void onStop() { super.onStop(); EasyTracker.getInstance(this).activityStop(this); // Add this method. } }