Skip to content

Commit

Permalink
update ui
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie_lee committed Sep 8, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent f911be8 commit 41f2bdc
Showing 42 changed files with 687 additions and 616 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.novoda:bintray-release:0.5.0'
}
}
8 changes: 4 additions & 4 deletions matisse/build.gradle
Original file line number Diff line number Diff line change
@@ -52,12 +52,12 @@ dependencies {
// jcenter configuration for novoda's bintray-release
// $ ./gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME -PbintrayKey=BINTRAY_KEY -PdryRun=false
publish {
userOrg = 'zhihu'
groupId = 'com.zhihu.android'
userOrg = 'exacloud'
groupId = 'com.exacloud'
artifactId = 'matisse'
publishVersion = '0.5.0-alpha4'
publishVersion = '0.5.0-alpha5'
desc = 'A well-designed local image selector for Android'
website = 'https://www.zhihu.com/'
website = 'https://www.kujiale.com/'
}

task checkstyle(type:Checkstyle) {
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@
import java.util.Set;

public final class SelectionSpec {

public Set<MimeType> mimeTypeSet;
public boolean mediaTypeExclusive;
public boolean showSingleMediaType;
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@

@SuppressWarnings("unused")
public class SelectedItemCollection {

public static final String STATE_SELECTION = "state_selection";
public static final String STATE_COLLECTION_TYPE = "state_collection_type";
/**
@@ -137,7 +136,6 @@ public void overwrite(ArrayList<Item> items, int collectionType) {
mItems.addAll(items);
}


public List<Item> asList() {
return new ArrayList<>(mItems);
}
@@ -172,9 +170,8 @@ public IncapableCause isAcceptable(Item item) {
String cause;

try {
cause = mContext.getResources().getQuantityString(
R.plurals.error_over_count,
maxSelectable,
cause = mContext.getResources().getString(
R.string.error_over_count,
maxSelectable
);
} catch (Resources.NotFoundException e) {
@@ -217,13 +214,16 @@ private void refineCollectionType() {
}

/**
* Determine whether there will be conflict media types. A user can only select images and videos at the same time
* Determine whether there will be conflict media types. A user can only select images and
* videos at the same time
* while {@link SelectionSpec#mediaTypeExclusive} is set to false.
*/
public boolean typeConflict(Item item) {
return SelectionSpec.getInstance().mediaTypeExclusive
&& ((item.isImage() && (mCollectionType == COLLECTION_VIDEO || mCollectionType == COLLECTION_MIXED))
|| (item.isVideo() && (mCollectionType == COLLECTION_IMAGE || mCollectionType == COLLECTION_MIXED)));
&& ((item.isImage() && (mCollectionType == COLLECTION_VIDEO || mCollectionType ==
COLLECTION_MIXED))
|| (item.isVideo() && (mCollectionType == COLLECTION_IMAGE || mCollectionType ==
COLLECTION_MIXED)));
}

public int count() {
Original file line number Diff line number Diff line change
@@ -37,22 +37,17 @@

public abstract class BasePreviewActivity extends AppCompatActivity implements View.OnClickListener,
ViewPager.OnPageChangeListener {

public static final String EXTRA_DEFAULT_BUNDLE = "extra_default_bundle";
public static final String EXTRA_RESULT_BUNDLE = "extra_result_bundle";
public static final String EXTRA_RESULT_APPLY = "extra_result_apply";

protected final SelectedItemCollection mSelectedCollection = new SelectedItemCollection(this);
protected SelectionSpec mSpec;
protected ViewPager mPager;

protected PreviewPagerAdapter mAdapter;

protected CheckView mCheckView;
protected TextView mButtonBack;
protected View mButtonBack;
protected TextView mButtonApply;
protected TextView mSize;

protected int mPreviousPos = -1;

@Override
@@ -75,7 +70,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mSelectedCollection.onCreate(savedInstanceState);
}

mButtonBack = (TextView) findViewById(R.id.button_back);
mButtonBack = findViewById(R.id.button_back);
mButtonApply = (TextView) findViewById(R.id.button_apply);
mSize = (TextView) findViewById(R.id.size);
mButtonBack.setOnClickListener(this);
@@ -89,7 +84,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mCheckView.setCountable(mSpec.countable);

mCheckView.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
Item item = mAdapter.getMediaItem(mPager.getCurrentItem());
@@ -179,16 +173,9 @@ public void onPageScrollStateChanged(int state) {

private void updateApplyButton() {
int selectedCount = mSelectedCollection.count();
if (selectedCount == 0) {
mButtonApply.setText(R.string.button_apply_default);
mButtonApply.setEnabled(false);
} else if (selectedCount == 1 && mSpec.singleSelectionModeEnabled()) {
mButtonApply.setText(R.string.button_apply_default);
mButtonApply.setEnabled(true);
} else {
mButtonApply.setEnabled(true);
mButtonApply.setText(getString(R.string.button_apply, selectedCount));
}
mButtonApply.setText(getString(R.string.button_apply, selectedCount, SelectionSpec
.getInstance().maxSelectable));
mButtonApply.setOnClickListener(this);
}

protected void updateSize(Item item) {
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -34,8 +35,8 @@
import java.io.File;

public class AlbumsAdapter extends CursorAdapter {

private final Drawable mPlaceholder;
private int mSelectedPosition = 0;

public AlbumsAdapter(Context context, Cursor c, boolean autoRequery) {
super(context, c, autoRequery);
@@ -62,13 +63,41 @@ public View newView(Context context, Cursor cursor, ViewGroup parent) {

@Override
public void bindView(View view, Context context, Cursor cursor) {
final int position = cursor.getPosition();

Album album = Album.valueOf(cursor);
((TextView) view.findViewById(R.id.album_name)).setText(album.getDisplayName(context));
((TextView) view.findViewById(R.id.album_media_count)).setText(String.valueOf(album.getCount()));
((TextView) view.findViewById(R.id.album_media_count)).setText(String.valueOf(album
.getCount()));

Log.d("position", "cPos:" + position + " ,sPos" + mSelectedPosition + ",name:" + album
.getDisplayName(context));
view.findViewById(R.id.selector).setVisibility(position == mSelectedPosition ? View
.VISIBLE : View.INVISIBLE);

// do not need to load animated Gif
SelectionSpec.getInstance().imageEngine.loadThumbnail(context, context.getResources().getDimensionPixelSize(R
.dimen.media_grid_size), mPlaceholder,
(ImageView) view.findViewById(R.id.album_cover), Uri.fromFile(new File(album.getCoverPath())));
SelectionSpec.getInstance().imageEngine.loadThumbnail(context, context.getResources()
.getDimensionPixelSize(R
.dimen.media_grid_size), mPlaceholder,
(ImageView) view.findViewById(R.id.album_cover), Uri.fromFile(new File(album
.getCoverPath())));
}

/**
* 设置选择的position
*
* @param position 当前选择的position
*/
public void setSelectedPosition(int position) {
mSelectedPosition = position;
}

/**
* 获得选择的position
*
* @return 选择的position
*/
public int getSelectedPosition() {
return mSelectedPosition;
}
}
Loading

0 comments on commit 41f2bdc

Please sign in to comment.