Skip to content

Commit

Permalink
Jump to the picture
Browse files Browse the repository at this point in the history
  • Loading branch information
Bakumon committed Sep 18, 2018
1 parent 50394f8 commit 6c63fbf
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@
/captures
.externalNativeBuild
/.idea/
keystore.properties
18 changes: 11 additions & 7 deletions app/build.gradle
@@ -1,5 +1,10 @@
apply plugin: 'com.android.application'

// 加载 keystore.properties 文件
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
compileSdkVersion ANDROID_BUILD_SDK_VERSION as int
buildToolsVersion ANDROID_BUILD_TOOLS_VERSION
Expand All @@ -15,9 +20,9 @@ android {
signingConfigs {
release {
storeFile file("ugank.jks")
storePassword System.getenv("KEYSTORE_PASS")
keyAlias System.getenv("ALIAS_NAME")
keyPassword System.getenv("ALIAS_PASS")
storePassword keystoreProperties['KEYSTORE_PASSWORD']
keyAlias keystoreProperties['KEY_ALIAS']
keyPassword keystoreProperties['KEY_PASSWORD']
}
}
buildTypes {
Expand Down Expand Up @@ -53,7 +58,6 @@ dependencies {
compile('com.github.Andy671:Dachshund-Tab-Layout:v0.3.0') {
exclude group: 'com.android.support'
}
// LeakCanary 检测内存泄露,打开后去 APP.java 中打开初始化 LeakCanary 代码
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:design:25.1.1'
Expand All @@ -69,10 +73,10 @@ dependencies {
compile 'org.litepal.android:core:1.5.0'
compile 'com.github.GrenderG:Toasty:1.1.3'
testCompile 'junit:junit:4.12'
// testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
// releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
compile 'com.luolc:emoji-rain:0.1.1'
compile 'com.google.android:flexbox:0.3.0-alpha3'
}
14 changes: 8 additions & 6 deletions app/src/main/java/me/bakumon/ugank/App.java
Expand Up @@ -2,6 +2,8 @@

import android.app.Application;

import com.squareup.leakcanary.LeakCanary;

import org.litepal.LitePal;

import cn.bingoogolapple.swipebacklayout.BGASwipeBackManager;
Expand All @@ -23,12 +25,12 @@ public static App getInstance() {
public void onCreate() {
super.onCreate();
// 初始化 LeakCanary
// if (LeakCanary.isInAnalyzerProcess(this)) {
// // This process is dedicated to LeakCanary for heap analysis.
// // You should not init your app in this process.
// return;
// }
// LeakCanary.install(this);
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
LeakCanary.install(this);
BGASwipeBackManager.getInstance().init(this);
INSTANCE = this;
// 初始化主题色
Expand Down
48 changes: 41 additions & 7 deletions app/src/main/java/me/bakumon/ugank/module/home/HomeActivity.java
Expand Up @@ -14,6 +14,7 @@
import android.support.v7.graphics.Palette;
import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
Expand All @@ -30,6 +31,7 @@
import me.bakumon.ugank.GlobalConfig;
import me.bakumon.ugank.R;
import me.bakumon.ugank.base.adapter.CommonViewPagerAdapter;
import me.bakumon.ugank.module.bigimg.BigimgActivity;
import me.bakumon.ugank.module.category.CategoryFragment;
import me.bakumon.ugank.module.favorite.FavoriteActivity;
import me.bakumon.ugank.module.search.SearchActivity;
Expand Down Expand Up @@ -71,6 +73,8 @@ public class HomeActivity extends AppCompatActivity implements HomeContract.View
private CategoryFragment referenceFragment;
private CategoryFragment resFragment;

private String mImgUrl;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -128,12 +132,24 @@ private void initView() {
mVpCategory.setCurrentItem(1);
}

private CollapsingToolbarLayoutState state; // CollapsingToolbarLayout 折叠状态
/**
* CollapsingToolbarLayout 折叠状态
*/
private CollapsingToolbarLayoutState state;

private enum CollapsingToolbarLayoutState {
EXPANDED, // 完全展开
COLLAPSED, // 折叠
INTERNEDIATE // 中间状态
/**
* 完全展开
*/
EXPANDED,
/**
* 折叠
*/
COLLAPSED,
/**
* 中间状态
*/
INTERNEDIATE
}

/**
Expand All @@ -146,12 +162,14 @@ public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {

if (verticalOffset == 0) {
if (state != CollapsingToolbarLayoutState.EXPANDED) {
state = CollapsingToolbarLayoutState.EXPANDED; // 修改状态标记为展开
// 修改状态标记为展开
state = CollapsingToolbarLayoutState.EXPANDED;
}
} else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
if (state != CollapsingToolbarLayoutState.COLLAPSED) {
mFloatingActionButton.hide();
state = CollapsingToolbarLayoutState.COLLAPSED; // 修改状态标记为折叠
// 修改状态标记为折叠
state = CollapsingToolbarLayoutState.COLLAPSED;
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams();
layoutParams.height = DisplayUtils.dp2px(240, HomeActivity.this);
mAppBarLayout.setLayoutParams(layoutParams);
Expand All @@ -161,7 +179,8 @@ public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (state == CollapsingToolbarLayoutState.COLLAPSED) {
mFloatingActionButton.show();
}
state = CollapsingToolbarLayoutState.INTERNEDIATE; // 修改状态标记为中间
// 修改状态标记为中间
state = CollapsingToolbarLayoutState.INTERNEDIATE;
}
}
}
Expand All @@ -180,6 +199,7 @@ public void showBannerFail(String failMessage) {

@Override
public void setBanner(String imgUrl) {
mImgUrl = imgUrl;
Picasso.with(this).load(imgUrl)
.into(mIvHomeBanner,
PicassoPalette.with(imgUrl, mIvHomeBanner)
Expand Down Expand Up @@ -262,6 +282,18 @@ public void goSetting() {
startActivityForResult(new Intent(HomeActivity.this, SettingActivity.class), SETTING_REQUEST_CODE);
}

@OnClick(R.id.iv_home_banner)
public void goBigImg() {
if (TextUtils.isEmpty(mImgUrl)) {
return;
}
Intent intent = new Intent();
intent.setClass(this, BigimgActivity.class);
intent.putExtra(BigimgActivity.MEIZI_TITLE, "");
intent.putExtra(BigimgActivity.MEIZI_URL, mImgUrl);
startActivity(intent);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Expand All @@ -284,6 +316,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
case 5:
resFragment.onActivityResult(requestCode, resultCode, data);
break;
default:
break;
}
}
}
Expand Up @@ -6,13 +6,16 @@
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatImageView;
import android.text.TextUtils;

import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import me.bakumon.ugank.R;
import me.bakumon.ugank.module.bigimg.BigimgActivity;
import me.bakumon.ugank.module.home.HomeActivity;

/**
Expand All @@ -26,6 +29,7 @@ public class LauncherActivity extends AppCompatActivity implements LauncherContr

// 记录该 Activity 是否在前台显示
private boolean isResume;
private String mUrl;

private LauncherContract.Presenter mLauncherPresenter = new LauncherPresenter(this);

Expand All @@ -40,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void loadImg(String url) {
mUrl = url;
try {
Picasso.with(this)
.load(url)
Expand Down Expand Up @@ -90,6 +95,19 @@ public void goHomeActivity() {
finish();
}

@OnClick(R.id.img_launcher_welcome)
public void goBigImg(){
if (TextUtils.isEmpty(mUrl)) {
return;
}
goHomeActivity();
Intent intent = new Intent();
intent.setClass(this, BigimgActivity.class);
intent.putExtra(BigimgActivity.MEIZI_TITLE, "");
intent.putExtra(BigimgActivity.MEIZI_URL, mUrl);
startActivity(intent);
}

@Override
public void onBackPressed() {
// 禁掉返回键
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
@@ -1,7 +1,7 @@
<resources>
<string name="app_name">有干货</string>
<string name="home_search">搜索干货(日期数字有福利哦(。◕∀◕。))</string>
<string name="search_tip">搜索“12”试试(。◕∀◕。))</string>
<string name="home_search">搜索干货(。◕∀◕。)</string>
<string name="search_tip">搜索</string>
<string name="menu_share">分享干货</string>
<string name="menu_copy_link">复制链接</string>
<string name="menu_open_with">用浏览器打开</string>
Expand Down

0 comments on commit 6c63fbf

Please sign in to comment.