This commit is contained in:
@ -10,6 +10,7 @@ import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
@ -76,12 +77,12 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
|
||||
@BindView(R.id.image_detail_page)
|
||||
Gh_ViewPager mViewPager;
|
||||
@BindView(R.id.image_detail_slide)
|
||||
View mSlideLine;
|
||||
@BindView(R.id.image_detail_progress)
|
||||
TextView mProgressHint;
|
||||
|
||||
private RelativeLayout.LayoutParams rparams;
|
||||
@BindView(R.id.image_mask)
|
||||
View mIndicatorMask;
|
||||
@BindView(R.id.image_indicator_tv)
|
||||
TextView mIndicatorTv;
|
||||
|
||||
private ViewImageAdapter adapter;
|
||||
|
||||
@ -95,7 +96,6 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
private HashSet<Integer> mViewedSet; // 让调用者知道该图片是否被看过了
|
||||
private Map<String, ImageInfoEntity> mImageInfoMap;
|
||||
|
||||
private int width;
|
||||
private int mLimitWidth;
|
||||
|
||||
private boolean isOrientation;
|
||||
@ -108,7 +108,6 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
return checkIntent;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_viewimage;
|
||||
@ -117,8 +116,8 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mViewedSet = new HashSet();
|
||||
mImageInfoMap = new HashMap();
|
||||
mViewedSet = new HashSet<>();
|
||||
mImageInfoMap = new HashMap<>();
|
||||
|
||||
// init data
|
||||
int current = 0;
|
||||
@ -133,6 +132,9 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
isOrientation = savedInstanceState.getBoolean("isOrientation");
|
||||
}
|
||||
|
||||
if (urls.size() > 1) mIndicatorMask.setVisibility(View.VISIBLE);
|
||||
mIndicatorTv.setText(String.format("%d/%d", current + 1, urls.size()));
|
||||
|
||||
mImagePipeline = Fresco.getImagePipeline();
|
||||
|
||||
// init slide
|
||||
@ -144,13 +146,6 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
} else {
|
||||
mLimitWidth = widthPixels;
|
||||
}
|
||||
width = widthPixels / urls.size();
|
||||
rparams = new RelativeLayout.LayoutParams(width, DisplayUtils.dip2px(getApplicationContext(), 1));
|
||||
rparams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
||||
rparams.bottomMargin = DisplayUtils.dip2px(getApplicationContext(), 10);
|
||||
rparams.leftMargin = width * current;
|
||||
mSlideLine.setLayoutParams(rparams);
|
||||
|
||||
// init viewPage
|
||||
adapter = new ViewImageAdapter();
|
||||
mViewPager.setAdapter(adapter);
|
||||
@ -212,8 +207,6 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
public void onPageScrolled(int position, float positionOffset,
|
||||
int positionOffsetPixels) {
|
||||
if (positionOffset != 0) {
|
||||
rparams.leftMargin = (int) (width * (positionOffset + position));
|
||||
mSlideLine.setLayoutParams(rparams);
|
||||
mProgressHint.setVisibility(View.GONE);
|
||||
} else {
|
||||
String url = urls.get(position);
|
||||
@ -249,6 +242,7 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
zoomDraweeView.reset(); // 重置矩阵,还原图片
|
||||
}
|
||||
}
|
||||
mIndicatorTv.setText(String.format("%d/%d", position + 1, urls.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -286,7 +280,6 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
} else {
|
||||
imageView.setImageURI(url); // 加载原图
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ViewImageAdapter extends PagerAdapter implements OnSingleTapListener {
|
||||
@ -299,8 +292,9 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
return urls.size();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
||||
String url = urls.get(position);
|
||||
|
||||
Gh_RelativeLayout view = (Gh_RelativeLayout) View.inflate(container.getContext(), R.layout.viewimage_normal_item, null);
|
||||
@ -435,18 +429,18 @@ public class ViewImageActivity extends BaseActivity implements OnPageChangeListe
|
||||
MessageShareUtils.refreshImage(new File(savePath), ViewImageActivity.this);
|
||||
} catch (IOException e) {
|
||||
Utils.log("图片保存失败:" + e.toString());
|
||||
System.out.println(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
||||
container.removeView((View) object);
|
||||
object = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user