Android Open Source - Planets-Gradle Jupiter Activity






From Project

Back to project page Planets-Gradle.

License

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.

Java Source Code

package com.andrewq.planets.planets;
//from  w w w .  j ava 2  s  . c  om
import android.app.ActionBar;
import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Toast;

import com.andrewq.planets.R;
import com.andrewq.planets.image_views.JupiterImageView;
import com.andrewq.planets.util.NotifyingScrollView;
import com.google.analytics.tracking.android.EasyTracker;
import com.suredigit.inappfeedback.FeedbackDialog;
import com.suredigit.inappfeedback.FeedbackSettings;

public class JupiterActivity extends Activity {

    private ImageView imgV;

    private ImageView img;
    private ActionBar mActionBar;

    private Drawable mActionBarBackgroundDrawable;

    Context con = this;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.jupiter_activity);

        mActionBar = getActionBar();
        assert mActionBar != null;
        mActionBar.setCustomView(R.layout.custom_actionbar_jupiter);
        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_6)).setOnScrollChangedListener(mOnScrollChangedListener);

        imgV = (ImageView) findViewById(R.id.image_header_jupiter);

        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(), JupiterImageView.class);
                    Bundle scaleBundle = ActivityOptions.makeScaleUpAnimation(
                            v, 0, 0, v.getWidth(), v.getHeight()).toBundle();
                    startActivity(i, scaleBundle);
                    return true;
                }

                return false;
            }

        };

        imgV.setOnTouchListener(upDownListener);

        Button moonButton = (Button) findViewById(R.id.jupiter_satellite);
    }

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

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        switch (item.getItemId()) {
            case R.id.sendFeedback:
                FeedbackSettings fbs = new FeedbackSettings();
                fbs.setText("Use this to send feedback, suggestions, and bugs to the developer. " +
                        "All feedback/suggestions are appreciated!");
                fbs.setYourComments("Your message here...");
                fbs.setTitle("Feedback Submitter");

                fbs.setToast("Thanks! Check back later for a reply if applicable.");
                fbs.setToastDuration(Toast.LENGTH_LONG);

                fbs.setRadioButtons(true);
                fbs.setBugLabel("Bug");
                fbs.setIdeaLabel("Suggestion");
                fbs.setQuestionLabel("General Feedback");

                fbs.setOrientation(LinearLayout.VERTICAL);
                fbs.setGravity(Gravity.LEFT);

                fbs.setModal(true);

                FeedbackDialog fdb = new FeedbackDialog(this, "AF-FD2E2AEF7F0A-27", fbs);
                fdb.show();
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {

        imgV = (ImageView) findViewById(R.id.image_header_jupiter);

        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_jupiter).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.
    }
}




Java Source Code List

com.andrewq.planets.MainActivity.java
com.andrewq.planets.iab.Base64DecoderException.java
com.andrewq.planets.iab.Base64.java
com.andrewq.planets.iab.IabException.java
com.andrewq.planets.iab.IabHelper.java
com.andrewq.planets.iab.IabResult.java
com.andrewq.planets.iab.Inventory.java
com.andrewq.planets.iab.Purchase.java
com.andrewq.planets.iab.Security.java
com.andrewq.planets.iab.SkuDetails.java
com.andrewq.planets.image_views.DeimosImageView.java
com.andrewq.planets.image_views.EarthImageView.java
com.andrewq.planets.image_views.EuropaImageView.java
com.andrewq.planets.image_views.JupiterImageView.java
com.andrewq.planets.image_views.MarsImageView.java
com.andrewq.planets.image_views.MercuryImageView.java
com.andrewq.planets.image_views.MoonImageView.java
com.andrewq.planets.image_views.NeptuneImageView.java
com.andrewq.planets.image_views.PhobosImageView.java
com.andrewq.planets.image_views.PlutoImageView.java
com.andrewq.planets.image_views.SaturnImageView.java
com.andrewq.planets.image_views.SunImageView.java
com.andrewq.planets.image_views.UranusImageView.java
com.andrewq.planets.image_views.VenusImageView.java
com.andrewq.planets.misc.Settings.java
com.andrewq.planets.moons.DeimosActivity.java
com.andrewq.planets.moons.EuropaActivity.java
com.andrewq.planets.moons.MoonActivity.java
com.andrewq.planets.moons.PhobosActivity.java
com.andrewq.planets.other_bodies.PlutoActivity.java
com.andrewq.planets.other_bodies.SunActivity.java
com.andrewq.planets.planets.EarthActivity.java
com.andrewq.planets.planets.JupiterActivity.java
com.andrewq.planets.planets.MarsActivity.java
com.andrewq.planets.planets.MercuryActivity.java
com.andrewq.planets.planets.NeptuneActivity.java
com.andrewq.planets.planets.SaturnActivity.java
com.andrewq.planets.planets.UranusActivity.java
com.andrewq.planets.planets.VenusActivity.java
com.andrewq.planets.tv.ApplicationTest.java
com.andrewq.planets.tv.CardPresenter.java
com.andrewq.planets.tv.DetailsActivity.java
com.andrewq.planets.tv.DetailsDescriptionPresenter.java
com.andrewq.planets.tv.PicassoBackgroundManagerTarget.java
com.andrewq.planets.tv.Planet.java
com.andrewq.planets.tv.PlanetsFragment.java
com.andrewq.planets.tv.PlanetsList.java
com.andrewq.planets.tv.PlayerActivity.java
com.andrewq.planets.tv.SettingsActivity.java
com.andrewq.planets.tv.TvActivity.java
com.andrewq.planets.tv.Utils.java
com.andrewq.planets.tv.VideoDetailsFragment.java
com.andrewq.planets.util.NotifyingScrollView.java
com.andrewq.planets.util.RowItem.java
com.andrewq.planets.util.SquareImageView.java
com.andrewq.planets.util.ZoomOutPageTransformer.java