Skip to content

Commit

Permalink
Update version to 1.0.4, Improve performance when resume
Browse files Browse the repository at this point in the history
  • Loading branch information
hearsilent committed May 31, 2018
1 parent a1e8c83 commit 854561e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 49 deletions.
28 changes: 14 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "hearsilent.amazingavatar"
minSdkVersion 16
targetSdkVersion 25
versionCode 103
versionName "1.0.3"
targetSdkVersion 27
versionCode 104
versionName "1.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -20,15 +20,15 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
testCompile 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
testImplementation 'junit:junit:4.12'
}
44 changes: 20 additions & 24 deletions app/src/main/java/hearsilent/amazingavatar/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.design.widget.AppBarLayout;
import android.support.v4.widget.Space;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.DividerItemDecoration;
Expand All @@ -15,6 +15,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Space;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
Expand Down Expand Up @@ -59,13 +60,13 @@ protected void onCreate(Bundle savedInstanceState) {
}

private void findViews() {
mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
mAvatarImageView = (CircleImageView) findViewById(R.id.imageView_avatar);
mToolbarTextView = (TextView) findViewById(R.id.toolbar_title);
mTitleTextView = (TextView) findViewById(R.id.textView_title);
mSpace = (Space) findViewById(R.id.space);
mToolBar = (Toolbar) findViewById(R.id.toolbar);
mRecyclerView = (RecyclerView) findViewById(recyclerView);
mAppBarLayout = findViewById(R.id.app_bar);
mAvatarImageView = findViewById(R.id.imageView_avatar);
mToolbarTextView = findViewById(R.id.toolbar_title);
mTitleTextView = findViewById(R.id.textView_title);
mSpace = findViewById(R.id.space);
mToolBar = findViewById(R.id.toolbar);
mRecyclerView = findViewById(recyclerView);
}

private void setUpViews() {
Expand Down Expand Up @@ -155,28 +156,22 @@ public void run() {
});
}

private void clearAnim() {
mAvatarImageView.setTranslationX(0);
mAvatarImageView.setTranslationY(0);
mTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTitleTextSize);
mTitleTextView.setTranslationX(0);
mTitleTextView.setTranslationY(0);
}

private void resetPoints() {
clearAnim();

int avatarSize = Utils.convertDpToPixelSize(EXPAND_AVATAR_SIZE_DP, this);
mAvatarImageView.getLocationOnScreen(mAvatarPoint);
mAvatarPoint[0] -= (avatarSize - mAvatarImageView.getWidth()) / 2;
mAvatarPoint[0] -= mAvatarImageView.getTranslationX() +
(avatarSize - mAvatarImageView.getWidth()) / 2f;
mAvatarPoint[1] -= mAvatarImageView.getTranslationY();
mSpace.getLocationOnScreen(mSpacePoint);
mToolbarTextView.getLocationOnScreen(mToolbarTextPoint);
mToolbarTextPoint[0] += Utils.convertDpToPixelSize(16, this);
mTitleTextView.post(new Runnable() {
mTitleTextView.getLocationOnScreen(mTitleTextViewPoint);
mTitleTextViewPoint[0] -= mTitleTextView.getTranslationX();
mTitleTextViewPoint[1] -= mTitleTextView.getTranslationY();
new Handler().post(new Runnable() {

@Override
public void run() {
mTitleTextView.getLocationOnScreen(mTitleTextViewPoint);
translationView(mAppBarStateChangeListener.getCurrentOffset());
}
});
Expand All @@ -200,18 +195,19 @@ private class DemoViewHolder extends RecyclerView.ViewHolder {
private DemoViewHolder(View view) {
super(view);

textView = (TextView) view.findViewById(R.id.textView);
textView = view.findViewById(R.id.textView);
}
}

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new DemoViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_demo, parent, false));
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
((DemoViewHolder) holder).textView
.setText(String.format(Locale.getDefault(), "HearSilent %d", position));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ public class AvatarCallback {
public void onSuccess(AvatarModel avatarModel) {
}

public void onFail(String errorMessage) {
}

public void onFail() {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hearsilent.amazingavatar.libs;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.widget.RecyclerView;
Expand All @@ -20,8 +21,9 @@ public FlingBehavior(Context context, AttributeSet attrs) {
}

@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child,
View target, float velocityX, float velocityY, boolean consumed) {
public boolean onNestedFling(@NonNull CoordinatorLayout coordinatorLayout,
@NonNull AppBarLayout child, @NonNull View target, float velocityX,
float velocityY, boolean consumed) {
if (velocityY > 0 && !isPositive || velocityY < 0 && isPositive) {
velocityY = velocityY * -1;
}
Expand All @@ -37,8 +39,8 @@ public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout c

@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child,
View target, int dx, int dy, int[] consumed) {
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
View target, int dx, int dy, int[] consumed, int type) {
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
isPositive = dy > 0;
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="1">

<android.support.v4.widget.Space
<Space
android:id="@+id/space"
android:layout_width="32dp"
android:layout_height="32dp"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:3.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Mar 08 14:56:05 GMT+08:00 2017
#Thu May 31 15:54:33 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

0 comments on commit 854561e

Please sign in to comment.