Skip to content

Commit

Permalink
查看大图片
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfusheng committed Jun 17, 2018
1 parent b9161cf commit d27d042
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 90 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
Expand Down Expand Up @@ -83,7 +82,7 @@ protected GlideImageLoader loadImage(Object obj, @DrawableRes int placeholder, T
glideRequest = glideRequest.transform(transformation);
}

glideRequest = glideRequest.diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true);
// glideRequest = glideRequest.diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true);

glideRequest.listener(new RequestListener<Drawable>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -11,6 +13,7 @@
import com.sunfusheng.glideimageview.GlideImageView;
import com.sunfusheng.glideimageview.progress.CircleProgressView;
import com.sunfusheng.glideimageview.sample.about.AboutActivity;
import com.sunfusheng.glideimageview.sample.image.SingleImageActivity;

/**
* @author by sunfusheng on 2017/6/3.
Expand Down Expand Up @@ -73,6 +76,22 @@ protected void onCreate(Bundle savedInstanceState) {
draggableView1.setOnClickListener(v -> startActivity(new Intent(mContext, RecyclerViewActivity.class)));
draggableView2.setOnClickListener(v -> startActivity(new Intent(mContext, NineImageViewActivity.class)));

image31.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, SingleImageActivity.class);
intent.putExtra(SingleImageActivity.KEY_IMAGE_URL, girl);
intent.putExtra(SingleImageActivity.KEY_IMAGE_URL_THUMBNAIL, girl_thumbnail);
ActivityOptionsCompat compat = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this, image31, getString(R.string.transitional_image));
ActivityCompat.startActivity(MainActivity.this, intent, compat.toBundle());
});

image32.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, SingleImageActivity.class);
intent.putExtra(SingleImageActivity.KEY_IMAGE_URL, cat);
intent.putExtra(SingleImageActivity.KEY_IMAGE_URL_THUMBNAIL, cat_thumbnail);
ActivityOptionsCompat compat = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this, image32, getString(R.string.transitional_image));
ActivityCompat.startActivity(MainActivity.this, intent, compat.toBundle());
});

line1();
line2();
line3();
Expand Down Expand Up @@ -104,7 +123,6 @@ private void line3() {
});

image32.load(cat, R.color.placeholder, (percentage, bytesRead, totalBytes) -> {
Log.d("--->", "【load cat】percentage: " + percentage + " totalBytes: " + totalBytes + " bytesRead: " + bytesRead);
if (percentage >= 100) {
progressView2.setVisibility(View.GONE);
} else {
Expand All @@ -114,13 +132,6 @@ private void line3() {
});
}

// Intent intent = new Intent(MainActivity.this, SingleImageActivity.class);
// intent.putExtra(KEY_IMAGE_URL, cat);
// intent.putExtra(KEY_IMAGE_URL_THUMBNAIL, cat_thumbnail);
// ActivityOptionsCompat compat = ActivityOptionsCompat
// .makeSceneTransitionAnimation(MainActivity.this, image41, getString(R.string.transitional_image));
// ActivityCompat.startActivity(MainActivity.this, intent, compat.toBundle());

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,17 @@
import com.sunfusheng.glideimageview.progress.CircleProgressView;
import com.sunfusheng.glideimageview.sample.R;

import java.util.Random;

/**
* Created by sunfusheng on 2017/6/15.
* @author by sunfusheng on 2017/6/15.
*/
public class SingleImageActivity extends AppCompatActivity {

GlideImageView glideImageView;
CircleProgressView progressView;

CircleProgressView progressView1;
CircleProgressView progressView2;
CircleProgressView progressView3;
View maskView;

public static final String KEY_IMAGE_URL = "image_url";
public static final String KEY_IMAGE_URL_THUMBNAIL = "image_url_thumbnail";

GlideImageView glideImageView;
CircleProgressView progressView;

String image_url;
String image_url_thumbnail;

Expand All @@ -35,40 +28,24 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image);

glideImageView = findViewById(R.id.glideImageView);
progressView1 = findViewById(R.id.progressView1);
progressView2 = findViewById(R.id.progressView2);
progressView3 = findViewById(R.id.progressView3);
maskView = findViewById(R.id.maskView);

image_url = getIntent().getStringExtra(KEY_IMAGE_URL);
image_url_thumbnail = getIntent().getStringExtra(KEY_IMAGE_URL_THUMBNAIL);

initProgressView();
loadImage();
}
glideImageView = findViewById(R.id.glideImageView);
progressView = findViewById(R.id.progressView);
glideImageView.setOnClickListener(v -> onBackPressed());

private void initProgressView() {
int randomNum = new Random().nextInt(3);
switch (randomNum) {
case 1:
progressView = progressView2;
break;
case 2:
progressView = progressView3;
break;
case 0:
default:
progressView = progressView1;
break;
}
progressView1.setVisibility(View.GONE);
progressView2.setVisibility(View.GONE);
progressView3.setVisibility(View.GONE);
progressView.setVisibility(View.VISIBLE);
loadImage();
}

private void loadImage() {

glideImageView.load(image_url, R.color.transparent, (percentage, bytesRead, totalBytes) -> {
if (percentage >= 100) {
progressView.setVisibility(View.GONE);
} else {
progressView.setVisibility(View.VISIBLE);
progressView.setProgress(percentage);
}
});
}
}
43 changes: 3 additions & 40 deletions Sample/src/main/res/layout/activity_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,60 +18,23 @@
android:id="@+id/glideImageView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:transitionName="@string/transitional_image"
app:layout_aspectRatio="178%"
app:layout_widthPercent="100%"/>
</android.support.percent.PercentRelativeLayout>

<View
android:id="@+id/maskView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/prl_image"
android:layout_alignTop="@+id/prl_image"
android:background="@color/transparent10"
android:visibility="visible"/>

<com.sunfusheng.glideimageview.progress.CircleProgressView
android:id="@+id/progressView1"
android:id="@+id/progressView"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:progress="0"
android:visibility="gone"
app:cpv_innerPadding="2dp"
app:cpv_outerColor="@color/transparent90_white"
app:cpv_outerSize="1dp"
app:cpv_progressNormalColor="@color/transparent"
app:cpv_progressReachColor="@color/transparent90_white"
app:cpv_progressStyle="FillInnerArc"/>

<com.sunfusheng.glideimageview.progress.CircleProgressView
android:id="@+id/progressView2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:progress="0"
android:visibility="gone"
app:cpv_progressNormalColor="@color/transparent10"
app:cpv_progressReachColor="@color/transparent90_white"
app:cpv_progressStyle="FillInner"
app:cpv_progressTextColor="@color/red"
app:cpv_progressTextSize="13sp"
app:cpv_progressTextVisible="true"/>

<com.sunfusheng.glideimageview.progress.CircleProgressView
android:id="@+id/progressView3"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:progress="0"
android:visibility="gone"
app:cpv_outerColor="@color/transparent90_white"
app:cpv_outerSize="2dp"
app:cpv_progressNormalColor="@color/transparent10"
app:cpv_progressReachColor="@color/transparent90_white"
app:cpv_progressStyle="Normal"
app:cpv_progressTextColor="@color/transparent90_white"
app:cpv_progressTextSize="13sp"/>
</RelativeLayout>
2 changes: 2 additions & 0 deletions Sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
android:layout_width="50dp"
android:layout_height="50dp"
android:progress="0"
android:visibility="gone"
app:cpv_innerPadding="2dp"
app:cpv_outerColor="@color/transparent90_white"
app:cpv_outerSize="1dp"
Expand Down Expand Up @@ -157,6 +158,7 @@
android:layout_height="50dp"
android:layout_margin="10dp"
android:progress="0"
android:visibility="gone"
app:cpv_progressNormalColor="@color/transparent10"
app:cpv_progressReachColor="@color/transparent90_white"
app:cpv_progressStyle="FillInner"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.novoda:bintray-release:0.8.0'
}
}
Expand Down

0 comments on commit d27d042

Please sign in to comment.