Back to project page Planets-App.
The source code is released under:
Apache License
If you think the Android project Planets-App 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; /* w w w .j av a 2s . c o m*/ import android.content.Intent; import android.content.res.Configuration; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; import com.google.analytics.tracking.android.EasyTracker; public class FragmentD extends Fragment { Button sourceButton; Button moonButton; ImageView imageView; public FragmentD() { // Required empty public constructor } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); sourceButton = (Button) getView().findViewById(R.id.button_4); moonButton = (Button) getView().findViewById(R.id.earth_satellite); imageView = (ImageView) getView().findViewById(R.id.earth); int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; switch (screenSize) { case Configuration.SCREENLAYOUT_SIZE_LARGE: sourceButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = "http://space-facts.com/earth/"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); } }); moonButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(getActivity(), SatelliteEarth.class); startActivity(intent); getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); } }); break; case Configuration.SCREENLAYOUT_SIZE_NORMAL: sourceButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = "http://space-facts.com/earth/"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); } }); moonButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(getActivity(), SatelliteEarth.class); startActivity(intent); getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); } }); Thread t = new Thread(new Runnable() { @Override public void run() { imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getActivity(), "NOTE: This is still in Beta!", Toast.LENGTH_LONG).show(); startActivity(new Intent(getActivity(), EarthGLActivity.class)); } }); } }); t.start(); break; case Configuration.SCREENLAYOUT_SIZE_SMALL: sourceButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = "http://space-facts.com/earth/"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); } }); moonButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(getActivity(), SatelliteEarth.class); startActivity(intent); getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); } }); break; default: } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; switch (screenSize) { case Configuration.SCREENLAYOUT_SIZE_LARGE: return inflater.inflate(R.layout.fragment_d_no_opengl, container, false); case Configuration.SCREENLAYOUT_SIZE_NORMAL: return inflater.inflate(R.layout.fragment_d, container, false); case Configuration.SCREENLAYOUT_SIZE_SMALL: return inflater.inflate(R.layout.fragment_d_no_opengl, container, false); default: } return inflater.inflate(R.layout.fragment_d, container, false); } @Override public void onStart() { super.onStart(); EasyTracker.getInstance(getActivity()).activityStart(getActivity()); // Add this method. } @Override public void onStop() { super.onStop(); EasyTracker.getInstance(getActivity()).activityStop(getActivity()); // Add this method. } }