调整启动界面与默认头像
This commit is contained in:
1 parent
b61699a9e2
commit
afece72b58
18 files changed
+182
-48
No files matched your search
@@ -28,6 +28,8 @@ Just import into Eclipse and build. Do it youself if you prefer Android Studio.
|
||||
- 按钮控件
|
||||
- [GIFLIB](http://giflib.sourceforge.net)
|
||||
- gif 解码
|
||||
- [Gloria Hallelujah](https://www.google.com/fonts/specimen/Gloria+Hallelujah)
|
||||
- 启动界面字体
|
||||
- [libjpeg-turbo](http://www.libjpeg-turbo.org)
|
||||
- jpge 解码
|
||||
- [libpng](http://www.libpng.org/pub/png/libpng.html)
|
||||
@@ -37,11 +39,13 @@ Just import into Eclipse and build. Do it youself if you prefer Android Studio.
|
||||
- [OpenCC](https://github.com/BYVoid/OpenCC)
|
||||
- 繁化工作
|
||||
- [Slabo](https://github.com/TiroTypeworks/Slabo)
|
||||
- 字体
|
||||
- 图标字体
|
||||
- [SlidingMenu](https://github.com/jfeinstein10/SlidingMenu)
|
||||
- 曾作为抽屉控件
|
||||
- [source-code-pro](https://github.com/adobe/source-code-pro)
|
||||
- 字体
|
||||
- 刷新控件字体
|
||||
- [svg-android](https://code.google.com/p/svg-android/)
|
||||
- svg 解析
|
||||
- [SystemBarTint](https://github.com/jgilfelt/SystemBarTint)
|
||||
- 状态栏背景设置
|
||||
- [zlib](http://www.zlib.net)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 39 KiB |
@@ -0,0 +1,45 @@
|
||||
<?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.
|
||||
-->
|
||||
<LinearLayout 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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:gravity="center"
|
||||
android:textSize="32sp"
|
||||
android:text="@string/do_not_be_a_sad_pandroid" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="6"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<LinearLayout 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" >
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="2"
|
||||
android:gravity="center"
|
||||
android:textSize="32sp"
|
||||
android:text="@string/do_not_be_a_sad_pandroid" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="6"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="768px" height="768px" viewBox="0 0 768 768" enable-background="new 0 0 768 768" xml:space="preserve">
|
||||
<g>
|
||||
<circle fill="#009688" cx="384" cy="384" r="384"/>
|
||||
<path fill="#FFFFFF" d="M555.4,283.6l-18.2-9.8c-39.1-19.5-83.2-32.3-130.6-36.5c-47.4-4.2-93.1,0.8-135,13.2l-19.6,6.5c-97.8,35.5-171.1,112.8-188,209l640,56.2C704.1,424.4,645.5,335.6,555.4,283.6"/>
|
||||
<path d="M525.5,417.3c-19.5-1.7-34-19-32.3-38.5c1.7-19.6,19-34,38.5-32.3c19.6,1.7,34,19,32.3,38.5C562.3,404.5,545,419,525.5,417.3"/>
|
||||
<path d="M258.1,393.8c-19.6-1.7-34-19-32.3-38.5c1.7-19.6,19-34,38.5-32.3c19.5,1.7,34,19,32.3,38.5C294.9,381,277.6,395.5,258.1,393.8"/>
|
||||
<path d="M556.3,283.7l66.6-80.6c4-4.8,3.7-11.6-0.6-15.1c-4.3-3.6-11-2.6-14.9,2.2l-69.3,83.7L556.3,283.7"/>
|
||||
<path d="M270.7,250.4l-53.6-94.5c-3.1-5.4-9.5-7.5-14.4-4.8c-4.9,2.8-6.3,9.4-3.3,14.8l51.6,91L270.7,250.4z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="500px" height="500px" viewBox="0 0 500 500" enable-background="new 0 0 500 500" xml:space="preserve">
|
||||
<g>
|
||||
<path fill="#FFFFFF" d="M306.5,110.5l-6.2-3.3c-13.3-6.6-28.3-11-44.4-12.4S224.3,95,210,99.3l-6.7,2.2c-33.2,12.1-58.1,38.3-63.9,71L357,191.6C357,158.4,337.1,128.2,306.5,110.5"/>
|
||||
<path d="M296.3,155.9c-6.6-0.6-11.6-6.4-11-13.1c0.6-6.6,6.4-11.6,13.1-11c6.6,0.6,11.6,6.4,11,13.1C308.8,151.6,302.9,156.5,296.3,155.9"/>
|
||||
<path d="M205.4,147.9c-6.6-0.6-11.6-6.4-11-13.1c0.6-6.6,6.4-11.6,13.1-11c6.6,0.6,11.6,6.4,11,13.1C217.9,143.6,212.1,148.5,205.4,147.9"/>
|
||||
<path d="M306.8,110.5l22.6-27.4c1.3-1.6,1.2-3.9-0.2-5.1c-1.5-1.2-3.7-0.9-5.1,0.8l-23.5,28.5L306.8,110.5"/>
|
||||
<path d="M209.7,99.2l-18.2-32.1c-1-1.8-3.2-2.6-4.9-1.6c-1.7,0.9-2.1,3.2-1.1,5l17.5,30.9L209.7,99.2z"/>
|
||||
<path d="M373.2,335.6c0,13.5,10.9,24.4,24.4,24.4l0,0c13.5,0,24.4-10.9,24.4-24.4v-98.5c0-13.4-10.9-24.4-24.4-24.4l0,0c-13.5,0-24.4,10.9-24.4,24.4V335.6z"/>
|
||||
<path d="M126.8,335.6c0,13.5-10.9,24.4-24.4,24.4l0,0c-13.4,0-24.4-10.9-24.4-24.4v-98.5c0-13.4,10.9-24.4,24.4-24.4l0,0c13.5,0,24.4,10.9,24.4,24.4C126.8,237.1,126.8,335.6,126.8,335.6z"/>
|
||||
<path fill="#FFFFFF" d="M140.8,213.5v177.9c0,10.6,8.6,19.1,19.1,19.1H340c10.6,0,19.1-8.6,19.1-19.1V213.5H140.8z"/>
|
||||
<path d="M293,386.2h-54.7c-13.5,0-24.4,10.9-24.4,24.4c0,13.5,10.9,24.4,24.4,24.4H293V386.2z"/>
|
||||
<path d="M207,386.2h-54.7c-13.5,0-24.4,10.9-24.4,24.4c0,13.5,10.9,24.4,24.4,24.4H207V386.2z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -23,6 +23,8 @@
|
||||
<br>
|
||||
<a href="https://github.com/FaizMalkani/FloatingActionButton">FloatingActionButton</a>
|
||||
<br>
|
||||
<a href="https://www.google.com/fonts/specimen/Gloria+Hallelujah">Gloria Hallelujah</a>
|
||||
<br>
|
||||
<a href="http://giflib.sourceforge.net/">GIFLIB</a>
|
||||
<br>
|
||||
<a href="http://www.libjpeg-turbo.org/">libjpeg-turbo</a>
|
||||
@@ -39,6 +41,8 @@
|
||||
<br>
|
||||
<a href="https://github.com/adobe/source-code-pro">source-code-pro</a>
|
||||
<br>
|
||||
<a href="https://code.google.com/p/svg-android/">svg-android</a>
|
||||
<br>
|
||||
<a href="https://github.com/jgilfelt/SystemBarTint">SystemBarTint</a>
|
||||
<br>
|
||||
<a href="http://www.zlib.net/">zlib</a>
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<dimen name="color_scheme_dialog_row_padding">8.0dip</dimen>
|
||||
|
||||
<!-- Text size -->
|
||||
<dimen name="text_super_large">24sp</dimen>
|
||||
<dimen name="text_large">22sp</dimen>
|
||||
<dimen name="text_little_large">20sp</dimen>
|
||||
<dimen name="text_medium">18sp</dimen>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<resources>
|
||||
|
||||
<string name="app_name" translatable="false">EhViewer</string>
|
||||
<string name="do_not_be_a_sad_pandroid" translatable="false">Do not be a\nsad pandroid</string>
|
||||
|
||||
<!-- Warning -->
|
||||
<string name="dailog_waring_title">Waring</string>
|
||||
|
||||
@@ -23,9 +23,11 @@ import java.io.IOException;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.view.ContextThemeWrapper;
|
||||
|
||||
import com.hippo.ehviewer.cache.ImageCache;
|
||||
import com.hippo.ehviewer.data.Data;
|
||||
@@ -69,16 +71,18 @@ public class AppContext extends Application implements UncaughtExceptionHandler
|
||||
Intent it = new Intent(this, DownloadService.class);
|
||||
bindService(it, mServiceConn, BIND_AUTO_CREATE);
|
||||
|
||||
Context mContextThemeWrapper = new ContextThemeWrapper(this, R.style.AppTheme);
|
||||
|
||||
// Init everything
|
||||
Config.init(this);
|
||||
Log.init(this);
|
||||
Ui.init(this);
|
||||
Crash.init(this);
|
||||
EhClient.createInstance(this);
|
||||
Favorite.init(this);
|
||||
Data.createInstance(this);
|
||||
ExDownloaderManager.createInstance(this);
|
||||
MaterialToast.setContext(this);
|
||||
Config.init(mContextThemeWrapper);
|
||||
Log.init(mContextThemeWrapper);
|
||||
Ui.init(mContextThemeWrapper);
|
||||
Crash.init(mContextThemeWrapper);
|
||||
EhClient.createInstance(mContextThemeWrapper);
|
||||
Favorite.init(mContextThemeWrapper);
|
||||
Data.createInstance(mContextThemeWrapper);
|
||||
ExDownloaderManager.createInstance(mContextThemeWrapper);
|
||||
MaterialToast.setContext(mContextThemeWrapper);
|
||||
|
||||
// Set drawer margin
|
||||
SlidingDrawerLayout.setDefaultMinDrawerMargin(Ui.ACTION_BAR_HEIGHT * 2);
|
||||
@@ -94,13 +98,13 @@ public class AppContext extends Application implements UncaughtExceptionHandler
|
||||
}
|
||||
|
||||
// Update proxy urls
|
||||
HttpHelper.updateProxyUrls(this);
|
||||
HttpHelper.updateProxyUrls(mContextThemeWrapper);
|
||||
|
||||
String keyVersionCode = "version_code";
|
||||
int oldVersion = Config.getInt(keyVersionCode, Integer.MAX_VALUE);
|
||||
// Fix <=22 login error
|
||||
if (oldVersion <= 22)
|
||||
EhInfo.getInstance(this).logout();
|
||||
EhInfo.getInstance(mContextThemeWrapper).logout();
|
||||
|
||||
// Fix <=25 Update
|
||||
if (oldVersion <= 25) {
|
||||
|
||||
@@ -17,25 +17,29 @@
|
||||
package com.hippo.ehviewer;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.View;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.ehviewer.app.MaterialAlertDialog;
|
||||
import com.hippo.ehviewer.network.Network;
|
||||
import com.hippo.ehviewer.ui.AbsActivity;
|
||||
import com.hippo.ehviewer.ui.GalleryListActivity;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Crash;
|
||||
import com.larvalabs.svgandroid.SVGParser;
|
||||
|
||||
public class StartActivity extends Activity {
|
||||
public class StartActivity extends AbsActivity {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = StartActivity.class.getSimpleName();
|
||||
@@ -183,24 +187,19 @@ public class StartActivity extends Activity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
View wellcome = new View(this);
|
||||
wellcome.setBackgroundDrawable(getResources().getDrawable(
|
||||
R.drawable.welcome));
|
||||
setContentView(wellcome);
|
||||
setContentView(R.layout.start_activity);
|
||||
|
||||
// For fullscreen
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
wellcome.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
||||
}
|
||||
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
|
||||
AlphaAnimation aa = new AlphaAnimation(0.3f, 1.0f);
|
||||
aa.setDuration(2000);
|
||||
aa.setInterpolator(new DecelerateInterpolator(3.0f));
|
||||
aa.setAnimationListener(new AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animation arg0) {
|
||||
@@ -217,7 +216,7 @@ public class StartActivity extends Activity {
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
});
|
||||
wellcome.startAnimation(aa);
|
||||
main.startAnimation(aa);
|
||||
check(CHECK_WARING);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ import org.json.JSONObject;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.os.Process;
|
||||
|
||||
@@ -283,7 +285,7 @@ public class EhClient {
|
||||
/**
|
||||
* Return avatar, if not return default avatar
|
||||
*/
|
||||
public Bitmap getAvatar() {
|
||||
public Drawable getAvatar() {
|
||||
return mInfo.getAvatar();
|
||||
}
|
||||
|
||||
@@ -394,7 +396,7 @@ public class EhClient {
|
||||
Bitmap avatar = hp.getImage(avatarUrl);
|
||||
// Set avatar if not null
|
||||
if (avatar != null)
|
||||
mInfo.setAvatar(avatar);
|
||||
mInfo.setAvatar(new BitmapDrawable(EhClient.this.mContext.getResources(), avatar));
|
||||
// notification
|
||||
listener.onGetAvatar(GET_AVATAR_OK);
|
||||
}
|
||||
|
||||
@@ -28,11 +28,13 @@ import java.util.List;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Utils;
|
||||
import com.larvalabs.svgandroid.SVGParser;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -46,7 +48,7 @@ public class EhInfo {
|
||||
private static final String DIR_NAME = "file";
|
||||
private static final String AVATAR_NAME = "avatar.png";
|
||||
private static final Bitmap.CompressFormat AVATAR_FORMAT = Bitmap.CompressFormat.PNG;
|
||||
private static Bitmap DEFAULT_AVATAR;
|
||||
private static Drawable DEFAULT_AVATAR;
|
||||
|
||||
public static final String EX_HOST = "exhentai.org";
|
||||
public static final String[] COOKIABLE_HOSTS = {"exhentai.org",
|
||||
@@ -69,14 +71,14 @@ public class EhInfo {
|
||||
private boolean mIsLogin;
|
||||
private String mUsername;
|
||||
private String mDisplayname;
|
||||
private Bitmap mAvatar;
|
||||
private BitmapDrawable mAvatar;
|
||||
private int mDefaultCat;
|
||||
private String mPreviewMode;
|
||||
private int mExculdeTagGroup;
|
||||
private String mExculdeLanguage;
|
||||
private static EhInfo sInstance;
|
||||
|
||||
private Bitmap getAvatarFromFile() {
|
||||
private BitmapDrawable getAvatarFromFile() {
|
||||
File dir = mContext.getDir(DIR_NAME, 0);
|
||||
File avatarFile = new File(dir, AVATAR_NAME);
|
||||
if (!avatarFile.exists())
|
||||
@@ -85,7 +87,7 @@ public class EhInfo {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = new FileInputStream(avatarFile);
|
||||
return BitmapFactory.decodeStream(is);
|
||||
return (BitmapDrawable) BitmapDrawable.createFromStream(is, null);
|
||||
} catch (FileNotFoundException e) {
|
||||
return null;
|
||||
} finally {
|
||||
@@ -97,8 +99,7 @@ public class EhInfo {
|
||||
mContext = context;
|
||||
mInfoPref = mContext.getSharedPreferences(PREF_NAME, 0);
|
||||
if (DEFAULT_AVATAR == null)
|
||||
DEFAULT_AVATAR = BitmapFactory.decodeStream(
|
||||
context.getResources().openRawResource(R.drawable.default_avatar));
|
||||
DEFAULT_AVATAR = SVGParser.getSVGFromResource(context.getResources(), R.raw.default_avatar).createPictureDrawable();
|
||||
|
||||
mIsLogin = mInfoPref.getBoolean(KEY_LOGIN, DEFAULT_LOGIN);
|
||||
mUsername = mInfoPref.getString(KEY_USERNAME, DEFAULT_NAME);
|
||||
@@ -201,7 +202,7 @@ public class EhInfo {
|
||||
mIsLogin = false;
|
||||
// Remove avatar
|
||||
if (mAvatar != null) {
|
||||
mAvatar.recycle();
|
||||
mAvatar.getBitmap().recycle();
|
||||
mAvatar = null;
|
||||
File dir = mContext.getDir(DIR_NAME, 0);
|
||||
File avatarFile = new File(dir, AVATAR_NAME);
|
||||
@@ -221,11 +222,11 @@ public class EhInfo {
|
||||
return mDisplayname;
|
||||
}
|
||||
|
||||
public Bitmap getAvatar() {
|
||||
public Drawable getAvatar() {
|
||||
return isLogin() && mAvatar != null ? mAvatar : DEFAULT_AVATAR;
|
||||
}
|
||||
|
||||
public void setAvatar(Bitmap avatar) {
|
||||
public void setAvatar(BitmapDrawable avatar) {
|
||||
mAvatar = avatar;
|
||||
|
||||
File dir = mContext.getDir(DIR_NAME, 0);
|
||||
@@ -233,7 +234,7 @@ public class EhInfo {
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = new FileOutputStream(avatarFile);
|
||||
avatar.compress(AVATAR_FORMAT, 100, os);
|
||||
avatar.getBitmap().compress(AVATAR_FORMAT, 100, os);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
@@ -1545,7 +1545,7 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
|
||||
|
||||
switch (state) {
|
||||
case LOGIN:
|
||||
mAvatar.setImageBitmap(mClient.getAvatar());
|
||||
mAvatar.setImageDrawable(mClient.getAvatar());
|
||||
mUsernameView.setVisibility(View.GONE);
|
||||
mLoginButton.setVisibility(View.VISIBLE);
|
||||
mRegisterButton.setVisibility(View.VISIBLE);
|
||||
@@ -1553,7 +1553,7 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
|
||||
mWaitLogView.setVisibility(View.GONE);
|
||||
break;
|
||||
case LOGOUT:
|
||||
mAvatar.setImageBitmap(mClient.getAvatar());
|
||||
mAvatar.setImageDrawable(mClient.getAvatar());
|
||||
mUsernameView.setText(mClient.getDisplayname());
|
||||
mUsernameView.setVisibility(View.VISIBLE);
|
||||
mLoginButton.setVisibility(View.GONE);
|
||||
@@ -1562,7 +1562,7 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
|
||||
mWaitLogView.setVisibility(View.GONE);
|
||||
break;
|
||||
case WAIT:
|
||||
mAvatar.setImageBitmap(mClient.getAvatar());
|
||||
mAvatar.setImageDrawable(mClient.getAvatar());
|
||||
mUsernameView.setVisibility(View.GONE);
|
||||
mLoginButton.setVisibility(View.GONE);
|
||||
mRegisterButton.setVisibility(View.GONE);
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@@ -31,7 +30,7 @@ public class MaterialToast extends Toast {
|
||||
private static Context sContext;
|
||||
|
||||
public static void setContext(Context context) {
|
||||
sContext = new ContextThemeWrapper(context, R.style.AppTheme);
|
||||
sContext = context;
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
|
||||
Reference in new issue
Block a user