Skip to content

Commit

Permalink
2.2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
HuanTanSheng committed Jan 30, 2018
1 parent d702b09 commit 031d6e3
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public class AlbumModel {
private static final String TAG = "AlbumModel";
public static AlbumModel instance;
public Album album;
private CallBack callBack;


/**
* AlbumModel构造方法
*
* @param act 调用专辑的活动实体类
* @param callBack 初始化全部专辑后的回调
*/
private AlbumModel(final Activity act, AlbumModel.CallBack callBack) {
album = new Album();
this.callBack = callBack;
init(act);
init(act, callBack);
}

public static AlbumModel getInstance(final Activity act, AlbumModel.CallBack callBack) {
Expand All @@ -57,12 +57,13 @@ public static void clear() {
instance = null;
}

private void init(final Activity act) {
private void init(final Activity act, final CallBack callBack) {
new Thread(new Runnable() {
@Override
public void run() {
initAlbum(act);
callBack.onAlbumWorkedCallBack();
if (null != callBack)
callBack.onAlbumWorkedCallBack();
}
}).start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
Expand Down Expand Up @@ -61,7 +60,7 @@
import java.util.Date;
import java.util.Locale;

public class EasyPhotosActivity extends AppCompatActivity implements AlbumModel.CallBack, AlbumItemsAdapter.OnClickListener, PhotosAdapter.OnClickListener, AdListener, View.OnClickListener {
public class EasyPhotosActivity extends AppCompatActivity implements AlbumItemsAdapter.OnClickListener, PhotosAdapter.OnClickListener, AdListener, View.OnClickListener {

private boolean isShowCamera, onlyStartCamera;

Expand Down Expand Up @@ -97,6 +96,8 @@ public class EasyPhotosActivity extends AppCompatActivity implements AlbumModel.
private TextView tvPermission;
private View mBottomBar;

AlbumModel.CallBack albumModelCallBack;

public static void start(Activity activity, int requestCode) {
Intent intent = new Intent(activity, EasyPhotosActivity.class);
activity.startActivityForResult(intent, requestCode);
Expand All @@ -118,7 +119,7 @@ protected void onCreate(Bundle savedInstanceState) {
permissionView = (RelativeLayout) findViewById(R.id.rl_permissions_view);
tvPermission = (TextView) findViewById(R.id.tv_permission);
rootViewAlbumItems = (RelativeLayout) findViewById(R.id.root_view_album_items);

setClick(R.id.iv_back);
if (PermissionUtil.checkAndRequestPermissionsInActivity(this, getNeedPermissions())) {
hasPermissions();
}
Expand All @@ -132,7 +133,18 @@ private void hasPermissions() {
}
permissionView.setVisibility(View.GONE);
AlbumModel.clear();
albumModel = AlbumModel.getInstance(this, this);
albumModelCallBack = new AlbumModel.CallBack() {
@Override
public void onAlbumWorkedCallBack() {
runOnUiThread(new Runnable() {
@Override
public void run() {
onAlbumWorkedDo();
}
});
}
};
albumModel = AlbumModel.getInstance(this, albumModelCallBack);
}

protected String[] getNeedPermissions() {
Expand Down Expand Up @@ -395,15 +407,6 @@ private void onCameraResult() {

}

@Override
public void onAlbumWorkedCallBack() {
runOnUiThread(new Runnable() {
@Override
public void run() {
onAlbumWorkedDo();
}
});
}

private void onAlbumWorkedDo() {
initView();
Expand Down Expand Up @@ -468,7 +471,7 @@ public int getSpanSize(int position) {

initAlbumItems();
shouldShowMenuDone();
setClick(R.id.tv_album_items, R.id.iv_album_items, R.id.root_view_album_items, R.id.iv_back, R.id.tv_done, R.id.tv_clear, R.id.tv_original, R.id.tv_preview, R.id.fab_camera, R.id.iv_second_menu, R.id.tv_puzzle);
setClick(R.id.tv_album_items, R.id.iv_album_items, R.id.root_view_album_items, R.id.tv_done, R.id.tv_clear, R.id.tv_original, R.id.tv_preview, R.id.fab_camera, R.id.iv_second_menu, R.id.tv_puzzle);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ private void doBack() {
}

private void initView() {
findViewById(R.id.iv_back).setOnClickListener(this);
mRootView = (FrameLayout) findViewById(R.id.m_root_view);
mToolBar = (FrameLayout) findViewById(R.id.m_top_bar_layout);
if (!SystemUtils.getInstance().hasNavigationBar(this)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ protected void onCreate(Bundle savedInstanceState) {
}

private void initView() {
setClick(R.id.iv_back);
tvAlbumItems = (PressedTextView) findViewById(R.id.tv_album_items);
tvAlbumItems.setText(albumModel.getAlbumItems().get(0).name);
rootSelectorView = (RelativeLayout) findViewById(R.id.m_selector_root);
tvDone = (PressedTextView) findViewById(R.id.tv_done);
tvDone.setOnClickListener(this);
tvAlbumItems.setOnClickListener(this);
initAlbumItems();
initPhotos();
initPreview();
Expand Down Expand Up @@ -109,6 +112,8 @@ private void initPhotos() {

private void initAlbumItems() {
rootViewAlbumItems = (RelativeLayout) findViewById(R.id.root_view_album_items);
rootViewAlbumItems.setOnClickListener(this);
setClick(R.id.iv_album_items);
rvAlbumItems = (RecyclerView) findViewById(R.id.rv_album_items);
LinearLayoutManager lm = new LinearLayoutManager(this);
ArrayList<Object> list = new ArrayList<Object>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.huantansheng.easyphotos.ui.widget;

import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.support.annotation.Nullable;
import android.util.AttributeSet;

Expand All @@ -12,36 +10,38 @@
*/

public class PressedImageView extends android.support.v7.widget.AppCompatImageView {
private int filterColor;//按压颜色
private float scaleSize;//按压颜色

public PressedImageView(Context context) {
super(context);
this.filterColor = Color.GRAY;
this.scaleSize = 0.97f;
}

public PressedImageView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
this.filterColor = Color.GRAY;
this.scaleSize = 0.97f;

}

public PressedImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.filterColor = Color.GRAY;
this.scaleSize = 0.97f;

}

@Override
public void setPressed(boolean pressed) {
super.setPressed(pressed);
if (isPressed()) {
setColorFilter(filterColor, PorterDuff.Mode.MULTIPLY);
setScaleX(this.scaleSize);
setScaleY(this.scaleSize);
} else {
clearColorFilter();
setScaleX(1.0f);
setScaleY(1.0f);
}
}

public void setPressedColor(int pressedColor) {
filterColor = pressedColor;
public void setScaleSize(float scaleSize) {
this.scaleSize = scaleSize;
}
}
52 changes: 26 additions & 26 deletions easyPhotos/src/main/res/layout/activity_easy_photos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,32 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/m_tool_bar_bottom_line" />


<RelativeLayout
android:id="@+id/root_view_album_items"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/easy_photos_bar_primary_translation"
android:paddingEnd="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingStart="8dp"
android:paddingTop="50dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/m_bottom_bar"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/m_tool_bar">

<android.support.v7.widget.RecyclerView
android:id="@+id/rv_album_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:background="@drawable/bg_dialog_album_items_background_easy_photos"
android:scrollbars="vertical" />
</RelativeLayout>

<LinearLayout
android:id="@+id/m_second_level_menu"
android:layout_width="wrap_content"
Expand Down Expand Up @@ -86,31 +112,6 @@
android:textColor="@color/easy_photos_fg_primary" />
</LinearLayout>

<RelativeLayout
android:id="@+id/root_view_album_items"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/easy_photos_bar_primary_translation"
android:paddingEnd="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingStart="8dp"
android:paddingTop="50dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/m_bottom_bar"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/m_tool_bar">

<android.support.v7.widget.RecyclerView
android:id="@+id/rv_album_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:background="@drawable/bg_dialog_album_items_background_easy_photos"
android:scrollbars="vertical" />
</RelativeLayout>

<View
android:id="@+id/m_bottom_bar"
android:layout_width="0dp"
Expand Down Expand Up @@ -197,7 +198,6 @@
android:id="@+id/iv_back"
android:layout_width="42dp"
android:layout_height="42dp"
android:onClick="onClick"
android:padding="10dp"
app:layout_constraintLeft_toLeftOf="@+id/m_tool_bar"
app:layout_constraintTop_toTopOf="@+id/m_tool_bar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:onClick="onClick"
android:padding="10dp"
app:srcCompat="@drawable/ic_arrow_back_easy_photos" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
android:layout_marginRight="8dp"
android:background="@drawable/bg_menu_done_easy_photos"
android:gravity="center"
android:onClick="onClick"
android:padding="6dp"
android:textColor="@color/menu_text_easy_photos"
android:textSize="12sp"
Expand All @@ -81,7 +80,6 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/easy_photos_bar_primary_translation"
android:onClick="onClick"
android:paddingEnd="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
Expand Down Expand Up @@ -109,7 +107,6 @@
android:layout_height="0dp"
android:gravity="center"
android:minWidth="70dp"
android:onClick="onClick"
android:paddingEnd="6dp"
android:paddingLeft="16dp"
android:paddingRight="6dp"
Expand All @@ -123,7 +120,6 @@
android:id="@+id/iv_album_items"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:onClick="onClick"
android:paddingTop="8dp"
app:layout_constraintBottom_toBottomOf="@+id/tv_album_items"
app:layout_constraintLeft_toRightOf="@+id/tv_album_items"
Expand Down Expand Up @@ -153,7 +149,6 @@
android:id="@+id/iv_back"
android:layout_width="42dp"
android:layout_height="42dp"
android:onClick="onClick"
android:padding="10dp"
app:layout_constraintLeft_toLeftOf="@+id/m_tool_bar"
app:layout_constraintTop_toTopOf="@+id/m_tool_bar"
Expand Down
7 changes: 5 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.huantansheng.easyphotos.sample"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down Expand Up @@ -37,4 +37,7 @@ dependencies {
exclude group: "com.android.support"
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'
//检测内存泄漏
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
}
1 change: 1 addition & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:name=".MyApplication"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.huantansheng.easyphotos.sample;

import android.app.Application;

import com.squareup.leakcanary.LeakCanary;

/**
* 主要用于检测内存泄漏
* Created by huan on 2018/1/30.
*/

public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
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);
}
}

0 comments on commit 031d6e3

Please sign in to comment.