Jamendo Source Code address: https://github.com/telecapoland/jamendo-android
SRC and res structure:
The module will be analyzed based on the process.
First, analyze the initial interface:
Start with the manifest file:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name="JamendoApplication">...<activity android:name=".activity.SplashscreenActivity"><intent-filter><action android:name="android.intent.action.MAIN"></action><category android:name="android.intent.category.LAUNCHER"></category></intent-filter></activity></application>
1. Global jamendoapplication
The central warehouse pre-processes some information and stores some public information, which is executed before the main activity.
Ii. launcher activity: splashscreenactivity
When you enter the main activity, load the page first, and then judge from the configuration file whether the prompt dialog is required to pop up. After dimiss drops the dialog, a fade-out animation is triggered. The animation ends, homeactivity is started, and the current activity is finished.
1. preferencemanager. getdefasharsharedpreferences (this). getboolean (first_run_preference, true)
Obtain the default configuration file from/data/package name/shared_prefs/. The default file name can be found in the source code: package name _ preferences. xml. If this parameter is set to true, a dialog box is displayed. This custom dialog box is simple.
2. Set the setondismisslistener () Listener for the dialog. This listener is triggered when the back key or close on the dialog. It checks whether the checkbook on the dialog is selected, if this option is selected, the configuration will be changed. This dialog will not be displayed next time, and the animation will be triggered.
3. Execute the animation with handler delay.
Animationutils. loadanimation (this, R. anim. fade_out); // load this fade-out animation <set xmlns: Android = "http://schemas.android.com/apk/res/android" Android: zadjustment = "bottom" Android: fillafter = "false"> <Alpha Android: fromalpha = "1.0" Android: toalpha = "0" Android: Duration = "400"/> </set> // 1.0 indicates opacity, and 0.0 indicates full transparency. Duration code Duration: 400 ms
Endanimation. setfillafter (true );
// This indicates that the animation is left in the last frame. By default, the animation is left in the first frame. If this sentence is commented out, the animation will appear in an opaque state after it ends, you can comment out the results
Endanimation. setanimationlistener ();
// Set the listener of the animation in each state. homeactivity will be started in the flag_activity_clear_top form at the end of the animation.
Next, analyze homeactivity.