Skip to content

Commit

Permalink
Merge branch 'release/0.8.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
sangcomz committed Mar 9, 2019
2 parents 2c91d62 + fbb99a0 commit 4c360b6
Show file tree
Hide file tree
Showing 20 changed files with 75 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sangcomz.fishbun.adapter.image;

import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

Expand All @@ -9,6 +8,6 @@
*/

public interface ImageAdapter {
void loadImage(Context context, ImageView target, Uri loadUrl);
void loadDetailImage(Context context, ImageView target, Uri loadUrl);
void loadImage(ImageView target, Uri loadUrl);
void loadDetailImage(ImageView target, Uri loadUrl);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sangcomz.fishbun.adapter.image.impl;

import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

Expand All @@ -14,24 +13,20 @@

public class GlideAdapter implements ImageAdapter {
@Override
public void loadImage(Context context,
ImageView target,
Uri loadUrl) {
RequestOptions options = new RequestOptions();
options.centerCrop();
public void loadImage(ImageView target, Uri loadUrl) {
RequestOptions options = new RequestOptions().centerCrop();
Glide
.with(context)
.with(target.getContext())
.load(loadUrl)
.apply(options)
.into(target);
}

@Override
public void loadDetailImage(Context context, ImageView target, Uri loadUrl) {
RequestOptions options = new RequestOptions();
options.centerInside();
public void loadDetailImage(ImageView target, Uri loadUrl) {
RequestOptions options = new RequestOptions().centerInside();
Glide
.with(context)
.with(target.getContext())
.load(loadUrl)
.apply(options)
.into(target);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sangcomz.fishbun.adapter.image.impl;

import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

Expand All @@ -13,19 +12,18 @@

public class PicassoAdapter implements ImageAdapter {
@Override
public void loadImage(Context context, ImageView target, Uri loadUrl) {
public void loadImage(ImageView target, Uri loadUrl) {
Picasso
.with(context)
.get()
.load(loadUrl)
.fit()
.centerCrop()
.into(target);
}

@Override
public void loadDetailImage(Context context, ImageView target, Uri loadUrl) {
Picasso
.with(context)
public void loadDetailImage(ImageView target, Uri loadUrl) {
Picasso.get()
.load(loadUrl)
.fit()
.centerInside()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -45,12 +46,14 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
}

@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
public void onBindViewHolder(@NonNull final ViewHolder holder, final int position) {
holder.imgAlbumThumb.setImageDrawable(null);
Fishton.getInstance().imageAdapter
.loadImage(holder.imgAlbumThumb.getContext(),
holder.imgAlbumThumb,
Uri.parse(albumList.get(position).thumbnailPath));

Uri loadUrl = Uri.parse(albumList.get(position).thumbnailPath);

if (holder.imgAlbumThumb != null && loadUrl != null)
Fishton.getInstance().imageAdapter
.loadImage(holder.imgAlbumThumb, loadUrl);

holder.view.setTag(albumList.get(position));
Album a = (Album) holder.view.getTag();
Expand Down Expand Up @@ -95,7 +98,7 @@ public ViewHolder(View view, int albumSize) {
imgAlbumThumb.setLayoutParams(new LinearLayout.LayoutParams(albumSize, albumSize));

txtAlbumName = view.findViewById(R.id.txt_album_name);
txtAlbumCount = view.findViewById(R.id.txt_album_count);
txtAlbumCount = view.findViewById(R.id.txt_album_count);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sangcomz.fishbun.adapter.view;

import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.constraint.ConstraintLayout;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
Expand Down Expand Up @@ -29,19 +30,20 @@ public DetailViewPagerAdapter(LayoutInflater inflater, Uri[] images) {
}


@NonNull
@Override
public Object instantiateItem(ViewGroup container, int position) {
public Object instantiateItem(@NonNull ViewGroup container, int position) {

View itemView = inflater.inflate(R.layout.detail_item, container, false);
container.addView(itemView);

TouchImageView imageView = itemView.findViewById(R.id.img_detail_image);

fishton
.imageAdapter
.loadDetailImage(itemView.getContext(),
imageView,
images[position]);
if (imageView != null
&& images[position] != null)
fishton
.imageAdapter
.loadDetailImage(imageView, images[position]);

return itemView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ public void onClick(View v) {
vh.btnThumbCount.setTextColor(fishton.colorActionBarTitle);

initState(fishton.selectedImages.indexOf(image), vh);
if (image != null)
if (image != null
&& vh.imgThumbImage != null)
Fishton.getInstance().imageAdapter
.loadImage(vh.imgThumbImage.getContext(),
vh.imgThumbImage,
image);
.loadImage(vh.imgThumbImage, image);


vh.btnThumbCount.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -257,7 +256,7 @@ public ViewHolderImage(View view) {
super(view);
item = view;
imgThumbImage = view.findViewById(R.id.img_thumb_image);
btnThumbCount = view.findViewById(R.id.btn_thumb_count);
btnThumbCount = view.findViewById(R.id.btn_thumb_count);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
import android.support.v4.content.ContextCompat;
import android.widget.Toast;

import com.sangcomz.fishbun.R;
import com.sangcomz.fishbun.define.Define;


/**
* Created by sangc on 2015-10-12.
*/
public class PermissionCheck {
Context context;
private Context context;

public PermissionCheck(Context context) {
this.context = context;
Expand All @@ -42,7 +43,6 @@ public boolean CheckStoragePermission() {
define.PERMISSION_STORAGE);
} else {
// No explanation needed, we can request the permission.

ActivityCompat.requestPermissions((Activity) context,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
define.PERMISSION_STORAGE);
Expand All @@ -58,7 +58,7 @@ public boolean CheckStoragePermission() {


public void showPermissionDialog() {
Toast.makeText(context, "permission deny", Toast.LENGTH_SHORT).show();
Toast.makeText(context, R.string.msg_permission, Toast.LENGTH_SHORT).show();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.view.View;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.Toast;

import com.sangcomz.fishbun.BaseActivity;
import com.sangcomz.fishbun.R;
Expand Down Expand Up @@ -73,6 +74,12 @@ private void initToolBar() {
}

private void initAdapter() {
if (fishton.pickerImages == null) {
Toast.makeText(this, R.string.msg_error, Toast.LENGTH_SHORT).show();
finish();
return;
}

onCheckStateChange(fishton.pickerImages[initPosition]);

DetailViewPagerAdapter adapter = new DetailViewPagerAdapter(getLayoutInflater(), fishton.pickerImages);
Expand Down
4 changes: 2 additions & 2 deletions FishBun/src/main/res/layout/detail_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
android:id="@+id/img_detail_image"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
Expand Down
4 changes: 3 additions & 1 deletion FishBun/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<string name="done">완료</string>
<string name="msg_no_selected">선택된 이미지가 없습니다.</string>
<string name="str_all_view">전체사진</string>
<string name="msg_permission">권한 거부</string>
<string name="msg_permission">권한이 거부 됐습니다.</string>
<string name="msg_no_image">앨범이 없습니다.\n사진을 찍어보세요!</string>
<string name="msg_full_image">더 이상 선택할 수 없습니다.</string>
<string name="msg_error">일시적인 오류가 발생했습니다. 잠시후에 다시 시도해주세요.</string>

</resources>
4 changes: 3 additions & 1 deletion FishBun/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
<string name="done">done</string>
<string name="msg_no_selected">There is no selected image.</string>
<string name="str_all_view">All view</string>
<string name="msg_permission">permission deny</string>
<string name="msg_permission">Permission denied.</string>
<string name="msg_no_image">There is no album.\nTake a Picture!</string>
<string name="msg_full_image">Selection full. Deselect an image to choose another.</string>
<string name="msg_loading_image">Loading...</string>
<string name="image">image</string>

<string name="msg_error">There was a temporary error. Please try again in a few minutes.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
public void onBindViewHolder(final ViewHolder holder, final int position) {
final Uri imagePath = imagePaths.get(position);
Picasso
.with(context)
.get()
.load(imagePath)
.fit()
.centerCrop()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sangcomz.fishbundemo;

import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

Expand All @@ -10,17 +9,15 @@
* Created by sangc on 2015-11-06.
*/
class ImageController {
Context context;
ImageView imgMain;

ImageController(Context context, ImageView imgMain) {
this.context = context;
ImageController(ImageView imgMain) {
this.imgMain = imgMain;
}

void setImgMain(Uri path) {
Picasso
.with(context)
.get()
.load(path)
.fit()
.centerCrop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
btnAddImages = (Button) rootView.findViewById(R.id.btn_add_images);
linearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
withActivityController = new ImageController(getActivity(), imgMain);
withActivityController = new ImageController(imgMain);
imageAdapter = new ImageAdapter(getActivity(), withActivityController, path);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(imageAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.widget.ImageView;

import com.sangcomz.fishbun.FishBun;
import com.sangcomz.fishbun.FishBunCreator;
import com.sangcomz.fishbun.adapter.image.impl.GlideAdapter;
import com.sangcomz.fishbun.adapter.image.impl.PicassoAdapter;
import com.sangcomz.fishbun.define.Define;
Expand All @@ -38,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
imgMain = findViewById(R.id.img_main);
recyclerView = findViewById(R.id.recyclerview);
linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
mainController = new ImageController(this, imgMain);
mainController = new ImageController(imgMain);
imageAdapter = new ImageAdapter(this, mainController, path);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(imageAdapter);
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ _FishBun_ is a highly customizable image picker for Android.
<img src="/pic/fishbuns.png">


## What's New in _FishBun_ 0.8.7?
## What's New in _FishBun_ 0.8.8?

- Fix fishton
- Fix Bug (#138, #137)
- Update Glide / Picasso (#139)



Expand Down Expand Up @@ -110,18 +111,18 @@ Setting up _FishBun_ requires to add this Gradle configuration:

dependencies {
// Under the Android Plugin 3.0.0.
compile 'com.sangcomz:FishBun:0.8.6'
compile 'com.sangcomz:FishBun:0.8.8'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.picasso:picasso:2.71828'
or
compile 'com.github.bumptech.glide:glide:4.5.0'
compile 'com.github.bumptech.glide:glide:4.9.0'
// Android plugin 3.0.0 or higher.
implementation 'com.sangcomz:FishBun:0.8.6'
implementation 'com.sangcomz:FishBun:0.8.8'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.picasso:picasso:2.71828'
or
implementation 'com.github.bumptech.glide:glide:4.5.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'

}

Expand Down
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
buildscript {
ext {
support_version = '28.0.0'
picasso_version = '2.5.2'
glide_version = '4.8.0'
fresco_version = '1.3.0'
picasso_version = '2.71828'
glide_version = '4.9.0'
constraint_version = '1.1.3'
}
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
Loading

0 comments on commit 4c360b6

Please sign in to comment.