Skip to content

Commit

Permalink
Merge pull request #20 from HuanTanSheng/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
HuanTanSheng authored Jan 30, 2018
2 parents 62522ba + d641da8 commit c07d3fd
Show file tree
Hide file tree
Showing 20 changed files with 138 additions and 91 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 All @@ -74,25 +75,27 @@ private void initAlbum(Activity act) {

Uri contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

String sortOrder = MediaStore.Images.Media.DATE_ADDED + " DESC";
String sortOrder = MediaStore.Images.Media.DATE_TAKEN + " DESC";

ContentResolver contentResolver = act.getContentResolver();
String[] projections = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
projections = new String[]{
MediaStore.Images.Media._ID,
MediaStore.Images.Media.DATA,
MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.DATE_ADDED,
MediaStore.Images.Media.DATE_TAKEN,
MediaStore.Images.Media.MIME_TYPE,
MediaStore.Images.Media.WIDTH,
MediaStore.Images.Media.HEIGHT,
MediaStore.Images.Media.SIZE};

} else {
projections = new String[]{
MediaStore.Images.Media._ID,
MediaStore.Images.Media.DATA,
MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.DATE_ADDED,
MediaStore.Images.Media.DATE_TAKEN,
MediaStore.Images.Media.MIME_TYPE,
MediaStore.Images.Media.SIZE};
}
Expand All @@ -103,7 +106,7 @@ private void initAlbum(Activity act) {
String albumItem_all_name = act.getString(R.string.selector_folder_all_easy_photos);
int pathCol = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
int nameCol = cursor.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME);
int DateCol = cursor.getColumnIndex(MediaStore.Images.Media.DATE_ADDED);
int DateCol = cursor.getColumnIndex(MediaStore.Images.Media.DATE_TAKEN);
int mimeType = cursor.getColumnIndex(MediaStore.Images.Media.MIME_TYPE);
int sizeCol = cursor.getColumnIndex(MediaStore.Images.Media.SIZE);
int WidthCol = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Photo implements Parcelable {
public int width;//图片宽度
public int height;//图片高度
public long size;//图片文件大小,单位:Bytes
public long time;//图片最后修改时间戳,单位:
public long time;//图片拍摄的时间戳,单位:毫秒
public boolean selected;//是否被选中,内部使用,无需关心
public boolean selectedOriginal;//用户选择时是否选择了原图选项

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ public void save(Activity act, ViewGroup stickerGroup, View imageGroup, int imag
this.currTextSticker.setUsing(false);
}

for (BitmapSticker bs : bitmapStickers) {
if (bs.isUsing()) {
bs.setUsing(false);
}
}

for (TextSticker ts : textStickers) {
if (ts.isUsing()) {
ts.setUsing(false);
}
}

Bitmap srcBitmap = Bitmap.createBitmap(stickerGroup.getWidth(), stickerGroup.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(srcBitmap);
stickerGroup.draw(canvas);
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
Expand Up @@ -189,7 +189,7 @@ private void updateSelector(TextView tvSelector, boolean selected, Photo photo,
tvSelector.setBackgroundResource(R.drawable.bg_select_true_easy_photos);
if (isSingle) {
singlePosition = position;
tvSelector.setText("");
tvSelector.setText("1");
}
} else {
if (unable) {
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<corners android:radius="100dp" />
<stroke
android:width="1dp"
android:color="@color/white_easy_photos" />
android:color="@color/menu_text_easy_photos" />
<solid android:color="@color/easy_photos_fg_accent"/>
</shape>
4 changes: 2 additions & 2 deletions easyPhotos/src/main/res/drawable/ic_selector_easy_photos.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="12dp"
android:height="12dp"
android:width="20dp"
android:height="20dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="12dp"
android:height="12dp"
android:width="20dp"
android:height="20dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
Expand Down
54 changes: 27 additions & 27 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 Expand Up @@ -226,7 +226,7 @@
android:background="@drawable/bg_menu_done_easy_photos"
android:gravity="center"
android:padding="6dp"
android:textColor="@color/white_easy_photos"
android:textColor="@color/menu_text_easy_photos"
android:textSize="12sp"
android:textStyle="bold"
android:visibility="invisible"
Expand Down
Loading

0 comments on commit c07d3fd

Please sign in to comment.