调整启动界面
This commit is contained in:
1 parent
20e2314560
commit
7d24529831
18 files changed
+303
-53
No files matched your search
+9
-1
@@ -40,9 +40,10 @@
|
||||
|
||||
<activity
|
||||
android:name=".StartActivity"
|
||||
android:configChanges="orientation|screenSize|uiMode"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar.Fullscreen.Transparent" >
|
||||
android:theme="@style/AppTheme.NoActionBar.Transparent" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
@@ -123,6 +124,13 @@
|
||||
android:value=".ui.GalleryListActivity" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.SecretActivity"
|
||||
android:configChanges="orientation|screenSize|uiMode"
|
||||
android:screenOrientation="behind"
|
||||
android:theme="@style/AppTheme.NoActionBar.Transparent" >
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".service.DownloadService"
|
||||
android:label="DownloadService" />
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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.
|
||||
-->
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<alpha
|
||||
android:fromAlpha="1.0"
|
||||
android:toAlpha="1.0"
|
||||
android:duration="200"/>
|
||||
</set>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 546 KiB |
@@ -14,17 +14,17 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.hippo.ehviewer.widget.TransitionLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/themeColor"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/themeColor" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
@@ -33,13 +33,15 @@
|
||||
android:layout_weight="2"
|
||||
android:gravity="center"
|
||||
android:textSize="32sp"
|
||||
android:text="@string/do_not_be_a_sad_pandroid" />
|
||||
android:text="@string/do_not_be_a_sad_pandroid"
|
||||
android:background="?attr/themeColor" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="6"
|
||||
android:scaleType="fitCenter" />
|
||||
android:scaleType="fitCenter"
|
||||
android:background="?attr/themeColor" />
|
||||
|
||||
</LinearLayout>
|
||||
</com.hippo.ehviewer.widget.TransitionLayout>
|
||||
@@ -27,6 +27,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="12dp"
|
||||
android:maxWidth="480dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:textColor="@android:color/holo_blue_dark"
|
||||
android:textSize="24sp" />
|
||||
|
||||
@@ -14,18 +14,17 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.hippo.ehviewer.widget.TransitionLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="?attr/themeColor" >
|
||||
android:orientation="vertical" >
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/themeColor" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
@@ -34,13 +33,15 @@
|
||||
android:layout_weight="2"
|
||||
android:gravity="center"
|
||||
android:textSize="32sp"
|
||||
android:text="@string/do_not_be_a_sad_pandroid" />
|
||||
android:text="@string/do_not_be_a_sad_pandroid"
|
||||
android:background="?attr/themeColor" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="6"
|
||||
android:scaleType="fitCenter" />
|
||||
android:scaleType="fitCenter"
|
||||
android:background="?attr/themeColor" />
|
||||
|
||||
</LinearLayout>
|
||||
</com.hippo.ehviewer.widget.TransitionLayout>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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.
|
||||
-->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<com.hippo.ehviewer.widget.FitWindowView
|
||||
android:id="@+id/standard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<include
|
||||
layout="@layout/start_activity"
|
||||
android:visibility="visible" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -285,6 +285,7 @@
|
||||
<string name="thanks_title">感谢</string>
|
||||
<string name="website_title">网站</string>
|
||||
<string name="source_title">源码</string>
|
||||
<string name="version_title">应用版本</string>
|
||||
<string name="update_about_settings_title">更新</string>
|
||||
<string name="auto_check_for_update_title">自动检查更新</string>
|
||||
<string name="auto_check_for_update_summary_on">每日第一次启动时检查更新</string>
|
||||
@@ -371,6 +372,8 @@
|
||||
<string name="rating1">快要窒息了</string>
|
||||
<string name="rating0">…</string>
|
||||
|
||||
<string name="photo_footnotes">Hippo 摄于成都大熊猫繁育研究基地</string>
|
||||
|
||||
<!-- Utils -->
|
||||
<string name="share">分享</string>
|
||||
<string name="filter">过滤</string>
|
||||
|
||||
@@ -119,6 +119,12 @@
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar.Transparent">
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:colorBackgroundCacheHint">@null</item>
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Dark.NoActionBar">
|
||||
<item name="android:windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
<PreferenceCategory
|
||||
android:title="@string/update_about_settings_title">
|
||||
|
||||
<Preference
|
||||
android:key="version"
|
||||
android:title="@string/version_title" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="auto_check_for_update"
|
||||
android:title="@string/auto_check_for_update_title"
|
||||
|
||||
@@ -178,21 +178,18 @@ public class StartActivity extends AbsActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
// Disable animate
|
||||
overridePendingTransition(0, 0);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.start_activity);
|
||||
|
||||
// View decorView = getWindow().getDecorView();
|
||||
// int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||
// decorView.setSystemUiVisibility(uiOptions);
|
||||
|
||||
View main = findViewById(R.id.main);
|
||||
TextView text = (TextView) findViewById(R.id.text);
|
||||
text.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/GloriaHallelujah.ttf"));
|
||||
ImageView image = (ImageView) findViewById(R.id.image);
|
||||
image.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
image.setImageDrawable(SVGParser.getSVGFromResource(getResources(), R.raw.sad_pandroid).createPictureDrawable());
|
||||
|
||||
// Show welcome in progress
|
||||
AppHandler.getInstance().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -200,7 +197,7 @@ public class StartActivity extends AbsActivity {
|
||||
redirectTo();
|
||||
isAnimationOver = true;
|
||||
}
|
||||
}, 2000);
|
||||
}, 3000);
|
||||
check(CHECK_WARING);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ import android.provider.MediaStore;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@@ -90,7 +89,6 @@ import com.hippo.ehviewer.widget.FitWindowView;
|
||||
import com.hippo.ehviewer.widget.GalleryListView;
|
||||
import com.hippo.ehviewer.widget.GalleryListView.OnGetListListener;
|
||||
import com.hippo.ehviewer.widget.MaterialToast;
|
||||
import com.hippo.ehviewer.widget.RatingView;
|
||||
import com.hippo.ehviewer.widget.SearchView;
|
||||
import com.hippo.ehviewer.widget.SlidingDrawerLayout;
|
||||
import com.hippo.ehviewer.widget.SuggestionHelper;
|
||||
@@ -201,9 +199,6 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
|
||||
|
||||
private String mTitle;
|
||||
|
||||
private int mListDetailThumbWidth;
|
||||
private int mListDetailThumbHeight;
|
||||
|
||||
// private int mListModeThumbHeight;
|
||||
|
||||
private void toRegister() {
|
||||
@@ -981,17 +976,6 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
|
||||
mSuggestions = SuggestionHelper.getInstance(GalleryListActivity.this, SimpleSuggestionProvider.AUTHORITY,
|
||||
SimpleSuggestionProvider.MODE);
|
||||
|
||||
// Caculate gallery detail height
|
||||
LayoutInflater inflater = LayoutInflater.from(this);
|
||||
View v = inflater.inflate(R.layout.test_gallery_list_detail_thumb, null);
|
||||
((TextView) v.findViewById(R.id.title)).setText("haha\nhaha");
|
||||
((TextView) v.findViewById(R.id.uploader)).setText("haha");
|
||||
((RatingView) v.findViewById(R.id.rate)).setRating(2.3f);
|
||||
((TextView) v.findViewById(R.id.category)).setText("haha");
|
||||
ViewUtils.measureView(v);
|
||||
mListDetailThumbHeight = Math.max(v.getMeasuredHeight(), Ui.dp2pix(120));
|
||||
mListDetailThumbWidth = mListDetailThumbHeight * 2 / 3;
|
||||
|
||||
handleIntent(getIntent());
|
||||
// Check show drawer or not
|
||||
if (ACTION_GALLERY_LIST.equals(getIntent().getAction()))
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.effect.DrawableTransition;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
import com.hippo.ehviewer.widget.MaterialToast;
|
||||
|
||||
public class SecretActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
private final long[] mHits = new long[3];
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
int themeColor = Config.getCustomThemeColor() ? Config.getThemeColor() : Ui.THEME_COLOR;
|
||||
Ui.colorStatusBarL(this, themeColor);
|
||||
|
||||
ImageView iv = new ImageView(this);
|
||||
iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
iv.setImageResource(R.drawable.pandas);
|
||||
iv.setOnClickListener(this);
|
||||
iv.setSoundEffectsEnabled(false);
|
||||
setContentView(iv);
|
||||
DrawableTransition.transit(iv.getDrawable(), false, 3000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
|
||||
mHits[mHits.length-1] = SystemClock.uptimeMillis();
|
||||
if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
|
||||
Arrays.fill(mHits, 0);
|
||||
MaterialToast.showToast(R.string.photo_footnotes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,16 +22,22 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
@@ -726,6 +732,7 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
private static final String KEY_THANKS = "thanks";
|
||||
private static final String KEY_WEBSITE = "website";
|
||||
private static final String KEY_SOURCE = "source";
|
||||
private static final String KEY_VERSION = "version";
|
||||
private static final String KEY_CHECK_UPDATE = "check_for_update";
|
||||
private static final String KEY_CLOUD_DRIVE = "cloud_drive";
|
||||
private static final String KEY_ABOUT_ANALYICS = "about_analyics";
|
||||
@@ -736,10 +743,13 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
private Preference mThanks;
|
||||
private Preference mWebsite;
|
||||
private Preference mSource;
|
||||
private Preference mVersion;
|
||||
private Preference mCheckUpdate;
|
||||
private Preference mCloudDrive;
|
||||
private Preference mAboutAnalyics;
|
||||
|
||||
private final long[] mHits = new long[3];
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -757,18 +767,36 @@ public class SettingsActivity extends AbsPreferenceActivity {
|
||||
mWebsite.setOnPreferenceClickListener(this);
|
||||
mSource = findPreference(KEY_SOURCE);
|
||||
mSource.setOnPreferenceClickListener(this);
|
||||
mVersion = findPreference(KEY_VERSION);
|
||||
mVersion.setOnPreferenceClickListener(this);
|
||||
mCheckUpdate = findPreference(KEY_CHECK_UPDATE);
|
||||
mCheckUpdate.setOnPreferenceClickListener(this);
|
||||
mCloudDrive = findPreference(KEY_CLOUD_DRIVE);
|
||||
mCloudDrive.setOnPreferenceClickListener(this);
|
||||
mAboutAnalyics = findPreference(KEY_ABOUT_ANALYICS);
|
||||
mAboutAnalyics.setOnPreferenceClickListener(this);
|
||||
|
||||
try {
|
||||
Context c = getActivity().getApplicationContext();
|
||||
PackageInfo pi= c.getPackageManager().getPackageInfo(c.getPackageName(), 0);
|
||||
mVersion.setSummary(pi.versionName);
|
||||
} catch (NameNotFoundException e) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
final String key = preference.getKey();
|
||||
if (KEY_AUTHOR.equals(key)) {
|
||||
if (KEY_VERSION.equals(key)) {
|
||||
System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
|
||||
mHits[mHits.length-1] = SystemClock.uptimeMillis();
|
||||
if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
|
||||
Arrays.fill(mHits, 0);
|
||||
Activity a = getActivity();
|
||||
Intent intent = new Intent(a, SecretActivity.class);
|
||||
a.startActivity(intent);
|
||||
getActivity().overridePendingTransition(0, 0);
|
||||
}
|
||||
} else if (KEY_AUTHOR.equals(key)) {
|
||||
Intent i = new Intent(Intent.ACTION_SENDTO);
|
||||
i.setData(Uri.parse("mailto:ehviewersu@gmail.com"));
|
||||
i.putExtra(Intent.EXTRA_SUBJECT, "About EhViewer");
|
||||
|
||||
@@ -411,7 +411,7 @@ public final class Config {
|
||||
index = 2;
|
||||
break;
|
||||
case 6407:
|
||||
index = 2;
|
||||
index = 3;
|
||||
break;
|
||||
case 6408:
|
||||
index = 4;
|
||||
|
||||
@@ -115,7 +115,13 @@ public final class ViewUtils {
|
||||
* @return
|
||||
*/
|
||||
public static Bitmap getBitmapFromView(View v) {
|
||||
Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
|
||||
int width = v.getWidth();
|
||||
int height = v.getHeight();
|
||||
if (width == 0 && height == 0) {
|
||||
width = v.getMeasuredWidth();
|
||||
height = v.getMeasuredHeight();
|
||||
}
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height,
|
||||
Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
// TODO I need to know why I need it, when ScrollView
|
||||
@@ -159,17 +165,23 @@ public final class ViewUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void measureView(View v) {
|
||||
ViewGroup.LayoutParams oldLp = v.getLayoutParams();
|
||||
ViewGroup.LayoutParams newLp = new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
v.setLayoutParams(newLp);
|
||||
int measureSpec = MeasureSpec.makeMeasureSpec(0,
|
||||
MeasureSpec.UNSPECIFIED);
|
||||
v.measure(measureSpec, measureSpec);
|
||||
if (oldLp != null)
|
||||
v.setLayoutParams(oldLp);
|
||||
public static void measureView(View v, int width, int height) {
|
||||
int widthMeasureSpec;
|
||||
int heightMeasureSpec;
|
||||
if (width == ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
widthMeasureSpec = MeasureSpec.makeMeasureSpec(0,
|
||||
MeasureSpec.UNSPECIFIED);
|
||||
else
|
||||
widthMeasureSpec = MeasureSpec.makeMeasureSpec(Math.max(width, 0),
|
||||
MeasureSpec.EXACTLY);
|
||||
if (height == ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,
|
||||
MeasureSpec.UNSPECIFIED);
|
||||
else
|
||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(Math.max(height, 0),
|
||||
MeasureSpec.EXACTLY);
|
||||
|
||||
v.measure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -176,7 +176,7 @@ public class GalleryListView extends FrameLayout implements RefreshLayout.OnFoot
|
||||
((TextView) v.findViewById(R.id.uploader)).setText("haha");
|
||||
((RatingView) v.findViewById(R.id.rate)).setRating(2.3f);
|
||||
((TextView) v.findViewById(R.id.category)).setText("haha");
|
||||
ViewUtils.measureView(v);
|
||||
ViewUtils.measureView(v, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
mListDetailThumbHeight = Math.max(v.getMeasuredHeight(), Ui.dp2pix(120));
|
||||
mListDetailThumbWidth = mListDetailThumbHeight * 2 / 3;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.hippo.ehviewer.effect.DrawableTransition;
|
||||
|
||||
public class TransitionLayout extends LinearLayout {
|
||||
|
||||
private Bitmap mBmp;
|
||||
private int mOldWidth;
|
||||
private int mOldHeight;
|
||||
|
||||
private static final String TAG = TransitionLayout.class.getSimpleName();
|
||||
|
||||
public TransitionLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public TransitionLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public TransitionLayout(Context context, AttributeSet attrs,
|
||||
int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public TransitionLayout(Context context, AttributeSet attrs,
|
||||
int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
|
||||
if (mOldWidth != width || mOldHeight != height || mBmp == null) {
|
||||
mOldWidth = width;
|
||||
mOldHeight = height;
|
||||
|
||||
if (mBmp != null && !mBmp.isRecycled())
|
||||
mBmp.recycle();
|
||||
|
||||
mBmp = Bitmap.createBitmap(getWidth(), getHeight(),
|
||||
Bitmap.Config.ARGB_8888);
|
||||
Canvas c = new Canvas(mBmp);
|
||||
c.translate(-getScrollX(), -getScrollY());
|
||||
super.dispatchDraw(c);
|
||||
BitmapDrawable b = new BitmapDrawable(getResources(), mBmp);
|
||||
DrawableTransition.transit(b, false, 3000);
|
||||
setBackgroundDrawable(b);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
setBackgroundDrawable(null);
|
||||
if (mBmp != null && !mBmp.isRecycled())
|
||||
mBmp.recycle();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user