修正横屏下新建 Activity 出现卡顿的问题
This commit is contained in:
1 parent
251ed9b687
commit
7efed23ddf
6 files changed
+128
-160
No files matched your search
+37
-43
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2014 Hippo Seven
|
||||
<!--
|
||||
Copyright (C) 2014 Hippo Seven
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -12,65 +13,66 @@
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hippo.ehviewer"
|
||||
android:versionCode="19"
|
||||
android:versionName="0.5.4" >
|
||||
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
android:targetSdkVersion="19" />
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
|
||||
<application
|
||||
android:name=".AppContext"
|
||||
android:allowBackup="true"
|
||||
android:largeHeap="false"
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="false"
|
||||
android:theme="@style/AppTheme.Normal" >
|
||||
|
||||
<activity
|
||||
android:name=".StartActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar.Transparent"
|
||||
android:screenOrientation="portrait" >
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar.Transparent" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.MangaListActivity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:theme="@style/AppTheme.Main.ListActivity"
|
||||
android:launchMode="singleTask" >
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="behind"
|
||||
android:theme="@style/AppTheme.Main.ListActivity" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.searchable"
|
||||
android:resource="@xml/searchable" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.MangaDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan|adjustUnspecified|stateHidden"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:launchMode="singleTask" >
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="behind"
|
||||
android:windowSoftInputMode="adjustPan|adjustUnspecified|stateHidden" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="http" />
|
||||
<data android:host="exhentai.org" />
|
||||
<data android:host="g.e-hentai.org" />
|
||||
@@ -78,57 +80,49 @@
|
||||
<data android:pathPrefix="/g/" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.MangaActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|screenSize" >
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:screenOrientation="behind" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.SettingsActivity"
|
||||
android:label="@string/preference_settings_title"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:icon="@drawable/ic_action_settings"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|screenSize" >
|
||||
android:label="@string/preference_settings_title"
|
||||
android:screenOrientation="behind" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.FavouriteActivity"
|
||||
android:label="@string/favourite"
|
||||
android:icon="@drawable/ic_action_favorite"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:icon="@drawable/ic_action_favorite"
|
||||
android:label="@string/favourite"
|
||||
android:screenOrientation="behind"
|
||||
android:theme="@style/AppTheme.ListActivity" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.DownloadActivity"
|
||||
android:label="@string/download"
|
||||
android:icon="@drawable/ic_action_download"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:icon="@drawable/ic_action_download"
|
||||
android:label="@string/download"
|
||||
android:launchMode="singleTask"
|
||||
android:parentActivityName="com.hippo.ehviewer.ui.MangaListActivity"
|
||||
android:screenOrientation="behind"
|
||||
android:theme="@style/AppTheme.ListActivity" >
|
||||
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.hippo.ehviewer.activity.MangaListActivity" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.MangaDownloadActivity"
|
||||
android:label="@string/download"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:icon="@drawable/ic_action_download"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|screenSize" >
|
||||
android:label="@string/download"
|
||||
android:screenOrientation="behind" >
|
||||
</activity>
|
||||
|
||||
<service
|
||||
|
||||
<service
|
||||
android:name=".service.DownloadService"
|
||||
android:label="DownloadService" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
@@ -16,41 +16,35 @@
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.google.analytics.tracking.android.EasyTracker;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
|
||||
public abstract class AbstractActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
int screenOri = Config.getScreenOriMode();
|
||||
if (screenOri != getRequestedOrientation())
|
||||
setRequestedOrientation(screenOri);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
int screenOri = Config.getScreenOriMode();
|
||||
if (screenOri != getRequestedOrientation())
|
||||
setRequestedOrientation(screenOri);
|
||||
|
||||
Ui.adjustOrientation(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
if (Config.getAllowAnalyics())
|
||||
EasyTracker.getInstance(this).activityStart(this);
|
||||
|
||||
Ui.adjustOrientation(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
if (Config.getAllowAnalyics())
|
||||
EasyTracker.getInstance(this).activityStop(this);
|
||||
}
|
||||
|
||||
@@ -16,45 +16,39 @@
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import com.google.analytics.tracking.android.EasyTracker;
|
||||
import com.hippo.ehviewer.cache.ImageCache;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
|
||||
public abstract class AbstractFragmentActivity extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
int screenOri = Config.getScreenOriMode();
|
||||
if (screenOri != getRequestedOrientation())
|
||||
setRequestedOrientation(screenOri);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
int screenOri = Config.getScreenOriMode();
|
||||
if (screenOri != getRequestedOrientation())
|
||||
setRequestedOrientation(screenOri);
|
||||
|
||||
Ui.adjustOrientation(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
if (Config.getAllowAnalyics())
|
||||
EasyTracker.getInstance(this).activityStart(this);
|
||||
|
||||
Ui.adjustOrientation(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
if (Config.getAllowAnalyics())
|
||||
EasyTracker.getInstance(this).activityStop(this);
|
||||
|
||||
|
||||
ImageCache.getInstance(this).flush();
|
||||
}
|
||||
}
|
||||
@@ -16,41 +16,35 @@
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import com.google.analytics.tracking.android.EasyTracker;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
import com.google.analytics.tracking.android.EasyTracker;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
|
||||
public class AbstractPreferenceActivity extends PreferenceActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
int screenOri = Config.getScreenOriMode();
|
||||
if (screenOri != getRequestedOrientation())
|
||||
setRequestedOrientation(screenOri);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
int screenOri = Config.getScreenOriMode();
|
||||
if (screenOri != getRequestedOrientation())
|
||||
setRequestedOrientation(screenOri);
|
||||
|
||||
Ui.adjustOrientation(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
if (Config.getAllowAnalyics())
|
||||
EasyTracker.getInstance(this).activityStart(this);
|
||||
|
||||
Ui.adjustOrientation(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
if (Config.getAllowAnalyics())
|
||||
EasyTracker.getInstance(this).activityStop(this);
|
||||
}
|
||||
|
||||
@@ -16,45 +16,38 @@
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.analytics.tracking.android.EasyTracker;
|
||||
import com.hippo.ehviewer.cache.ImageCache;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity;
|
||||
|
||||
public class AbstractSlidingActivity extends SlidingActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
int screenOri = Config.getScreenOriMode();
|
||||
if (screenOri != getRequestedOrientation())
|
||||
setRequestedOrientation(screenOri);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
int screenOri = Config.getScreenOriMode();
|
||||
if (screenOri != getRequestedOrientation())
|
||||
setRequestedOrientation(screenOri);
|
||||
|
||||
Ui.adjustOrientation(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
if (Config.getAllowAnalyics())
|
||||
EasyTracker.getInstance(this).activityStart(this);
|
||||
|
||||
Ui.adjustOrientation(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
if (Config.getAllowAnalyics())
|
||||
EasyTracker.getInstance(this).activityStop(this);
|
||||
|
||||
|
||||
ImageCache.getInstance(this).flush();
|
||||
}
|
||||
}
|
||||
@@ -16,33 +16,26 @@
|
||||
|
||||
package com.hippo.ehviewer.util;
|
||||
|
||||
import com.hippo.ehviewer.ListUrls;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager.SystemBarConfig;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Movie;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.hippo.ehviewer.ListUrls;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager.SystemBarConfig;
|
||||
|
||||
public class Ui {
|
||||
@SuppressWarnings("unused")
|
||||
@@ -50,12 +43,12 @@ public class Ui {
|
||||
private static Context mContext;
|
||||
private static Resources mResources;
|
||||
private static final BitmapFactory.Options opt = new BitmapFactory.Options();
|
||||
|
||||
|
||||
private static float mDensity;
|
||||
|
||||
|
||||
public static int HOLO_BLUE_DARK;
|
||||
public static int LIST_MAIN_BG;
|
||||
|
||||
|
||||
public static int DOUJINSHI_BG_COLOR;
|
||||
public static int MANGA_BG_COLOR;
|
||||
public static int ARTIST_CG_BG_COLOR;
|
||||
@@ -67,35 +60,35 @@ public class Ui {
|
||||
public static int ASIAN_PORN_BG_COLOR;
|
||||
public static int MISC_BG_COLOR;
|
||||
public static int UNKNOWN_BG_COLOR;
|
||||
|
||||
|
||||
public static Drawable transparentDrawable;
|
||||
|
||||
|
||||
private static boolean mInit = false;
|
||||
|
||||
|
||||
/**
|
||||
* Init Crash
|
||||
*
|
||||
*
|
||||
* @param context Application context
|
||||
*/
|
||||
public static void init(Context context) {
|
||||
if (mInit)
|
||||
return;
|
||||
mInit = true;
|
||||
|
||||
|
||||
mContext = context;
|
||||
|
||||
|
||||
opt.inPreferredConfig = Bitmap.Config.RGB_565;
|
||||
opt.inPurgeable = true;
|
||||
opt.inInputShareable = true;
|
||||
|
||||
|
||||
mResources = mContext.getResources();
|
||||
|
||||
|
||||
mDensity = mResources.getDisplayMetrics().density;
|
||||
|
||||
|
||||
// init color
|
||||
HOLO_BLUE_DARK = mResources.getColor(android.R.color.holo_blue_dark);
|
||||
LIST_MAIN_BG = mResources.getColor(R.color.list_main_bg);
|
||||
|
||||
|
||||
DOUJINSHI_BG_COLOR = mResources.getColor(R.color.doujinshi_bg);
|
||||
MANGA_BG_COLOR = mResources.getColor(R.color.manga_bg);
|
||||
ARTIST_CG_BG_COLOR = mResources.getColor(R.color.artist_cg_bg);
|
||||
@@ -107,11 +100,11 @@ public class Ui {
|
||||
ASIAN_PORN_BG_COLOR = mResources.getColor(R.color.asian_porn_bg);
|
||||
MISC_BG_COLOR = mResources.getColor(R.color.misc_bg);
|
||||
UNKNOWN_BG_COLOR = mResources.getColor(R.color.unknown_bg);
|
||||
|
||||
|
||||
// init drawable
|
||||
transparentDrawable = new ColorDrawable(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is init
|
||||
* @return True if init
|
||||
@@ -119,7 +112,7 @@ public class Ui {
|
||||
public static boolean isInit() {
|
||||
return mInit;
|
||||
}
|
||||
|
||||
|
||||
public static String getCategoryText(int category) {
|
||||
switch (category) {
|
||||
case ListUrls.DOUJINSHI:
|
||||
@@ -146,7 +139,7 @@ public class Ui {
|
||||
return mResources.getString(R.string.unknown);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int getCategoryColor(int category) {
|
||||
switch (category) {
|
||||
case ListUrls.DOUJINSHI:
|
||||
@@ -173,30 +166,30 @@ public class Ui {
|
||||
return UNKNOWN_BG_COLOR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* dp conversion to pix
|
||||
*
|
||||
*
|
||||
* @param dp The value you want to conversion
|
||||
* @return value in pix
|
||||
*/
|
||||
public static int dp2pix(float dp) {
|
||||
return (int) (mDensity * dp + 0.5f);
|
||||
}
|
||||
|
||||
|
||||
public static float pix2dp(int pix) {
|
||||
return pix/mDensity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get default BitmapFactory.Options
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static BitmapFactory.Options getBitmapOpt() {
|
||||
return opt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check has navigation bar or not
|
||||
* @return
|
||||
@@ -205,12 +198,12 @@ public class Ui {
|
||||
boolean hasNavigationBar = false;
|
||||
boolean hasMenuKey = ViewConfiguration.get(mContext).hasPermanentMenuKey();
|
||||
boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
|
||||
|
||||
|
||||
if(!hasMenuKey && !hasBackKey)
|
||||
hasNavigationBar = true;
|
||||
return hasNavigationBar;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get height of status bar
|
||||
* @return
|
||||
@@ -223,7 +216,7 @@ public class Ui {
|
||||
return resources.getDimensionPixelSize(sbhResourceId);
|
||||
else return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get height of navigation bar
|
||||
* @param force If false, alway return 0 if the device has no navigation bar
|
||||
@@ -239,7 +232,7 @@ public class Ui {
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public static void measureView(View child) {
|
||||
ViewGroup.LayoutParams p = child.getLayoutParams();
|
||||
if (p == null) {
|
||||
@@ -258,10 +251,10 @@ public class Ui {
|
||||
}
|
||||
child.measure(childWidthSpec, childHeightSpec);
|
||||
}
|
||||
|
||||
|
||||
public static final int ORIENTATION_PORTRAIT = 0x0;
|
||||
public static final int ORIENTATION_LANDSCAPE = 0x1;
|
||||
|
||||
|
||||
public static int getOrientation(Activity activity) {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
@@ -271,18 +264,24 @@ public class Ui {
|
||||
return ORIENTATION_LANDSCAPE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void adjustOrientation(Activity activity) {
|
||||
int screenOri = Config.getScreenOriMode();
|
||||
if (screenOri != activity.getRequestedOrientation())
|
||||
activity.setRequestedOrientation(screenOri);
|
||||
}
|
||||
|
||||
public static SystemBarConfig translucent(
|
||||
Activity activity) {
|
||||
return translucentColor(activity,
|
||||
mResources.getColor(android.R.color.holo_blue_dark));
|
||||
}
|
||||
|
||||
|
||||
public static SystemBarConfig translucentColor(
|
||||
Activity activity, int color) {
|
||||
return translucent(activity, color);
|
||||
}
|
||||
|
||||
|
||||
public static SystemBarConfig translucent(
|
||||
Activity activity, int color) {
|
||||
SystemBarTintManager tintManager = new SystemBarTintManager(activity);
|
||||
|
||||
Reference in new issue
Block a user