diff --git a/AndroidProject.apk b/AndroidProject.apk index e39a5d25..c98532ad 100644 Binary files a/AndroidProject.apk and b/AndroidProject.apk differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2dfb2623..b05ebbe1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -107,7 +107,7 @@ android:label="@string/web_title" /> - + diff --git a/app/src/main/java/com/hjq/demo/ui/activity/LauncherActivity.java b/app/src/main/java/com/hjq/demo/ui/activity/LauncherActivity.java index dcbd8ca7..4680a303 100644 --- a/app/src/main/java/com/hjq/demo/ui/activity/LauncherActivity.java +++ b/app/src/main/java/com/hjq/demo/ui/activity/LauncherActivity.java @@ -81,7 +81,7 @@ private void initStartAnim() { mTextView.startAnimation(ra); } - private void requestFilePermission() { + private void requestPermission() { XXPermissions.with(this) .permission(Permission.Group.STORAGE) .request(this); @@ -102,14 +102,14 @@ public void noPermission(List denied, boolean quick) { if (quick) { toast("没有权限访问文件,请手动授予权限"); XXPermissions.gotoPermissionSettings(LauncherActivity.this, true); - }else { + } else { toast("请先授予文件读写权限"); - getWindow().getDecorView().postDelayed(new Runnable() { + postDelayed(new Runnable() { @Override public void run() { - requestFilePermission(); + requestPermission(); } - }, 2000); + }, 1000); } } @@ -125,7 +125,7 @@ protected void onRestart() { if (XXPermissions.isHasPermission(LauncherActivity.this, Permission.Group.STORAGE)) { hasPermission(null, true); }else { - requestFilePermission(); + requestPermission(); } } @@ -144,7 +144,7 @@ public void onAnimationStart(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { - requestFilePermission(); + requestPermission(); } @Override diff --git a/app/src/main/java/com/hjq/demo/ui/activity/PersonalDataActivity.java b/app/src/main/java/com/hjq/demo/ui/activity/PersonalDataActivity.java index 4ca73cc6..8e8f44cc 100644 --- a/app/src/main/java/com/hjq/demo/ui/activity/PersonalDataActivity.java +++ b/app/src/main/java/com/hjq/demo/ui/activity/PersonalDataActivity.java @@ -17,7 +17,7 @@ * author : Android 轮子哥 * github : https://github.com/getActivity/AndroidProject * time : 2019/04/20 - * desc : 个人资料界面 + * desc : 个人资料 */ public final class PersonalDataActivity extends MyActivity { diff --git a/app/src/main/java/com/hjq/demo/ui/activity/ImageActivity.java b/app/src/main/java/com/hjq/demo/ui/activity/PhotoActivity.java similarity index 76% rename from app/src/main/java/com/hjq/demo/ui/activity/ImageActivity.java rename to app/src/main/java/com/hjq/demo/ui/activity/PhotoActivity.java index 517341ee..faf6e70b 100644 --- a/app/src/main/java/com/hjq/demo/ui/activity/ImageActivity.java +++ b/app/src/main/java/com/hjq/demo/ui/activity/PhotoActivity.java @@ -1,52 +1,52 @@ -package com.hjq.demo.ui.activity; - -import android.support.v4.view.ViewPager; - -import com.hjq.demo.R; -import com.hjq.demo.common.MyActivity; -import com.hjq.demo.ui.adapter.ImagePagerAdapter; - -import java.util.ArrayList; - -import butterknife.BindView; - -/** - * author : Android 轮子哥 - * github : https://github.com/getActivity/AndroidProject - * time : 2019/03/05 - * desc : 查看大图 - */ -public final class ImageActivity extends MyActivity { - - @BindView(R.id.vp_image_pager) - ViewPager mViewPager; - - @Override - protected int getLayoutId() { - return R.layout.activity_image; - } - - @Override - protected int getTitleId() { - return 0; - } - - @Override - protected void initView() { - - } - - @Override - protected void initData() { - ArrayList data = new ArrayList<>(); - data.add("https://www.baidu.com/img/bd_logo.png"); - data.add("https://www.baidu.com/img/bd_logo.png"); - data.add("https://www.baidu.com/img/bd_logo.png"); - mViewPager.setAdapter(new ImagePagerAdapter(this, data)); - } - - @Override - public boolean statusBarDarkFont() { - return !super.statusBarDarkFont(); - } +package com.hjq.demo.ui.activity; + +import android.support.v4.view.ViewPager; + +import com.hjq.demo.R; +import com.hjq.demo.common.MyActivity; +import com.hjq.demo.ui.adapter.PhotoPagerAdapter; + +import java.util.ArrayList; + +import butterknife.BindView; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/AndroidProject + * time : 2019/03/05 + * desc : 查看大图 + */ +public final class PhotoActivity extends MyActivity { + + @BindView(R.id.vp_photo_pager) + ViewPager mViewPager; + + @Override + protected int getLayoutId() { + return R.layout.activity_photo; + } + + @Override + protected int getTitleId() { + return 0; + } + + @Override + protected void initView() { + + } + + @Override + protected void initData() { + ArrayList data = new ArrayList<>(); + data.add("https://www.baidu.com/img/bd_logo.png"); + data.add("https://www.baidu.com/img/bd_logo.png"); + data.add("https://www.baidu.com/img/bd_logo.png"); + mViewPager.setAdapter(new PhotoPagerAdapter(this, data)); + } + + @Override + public boolean statusBarDarkFont() { + return !super.statusBarDarkFont(); + } } \ No newline at end of file diff --git a/app/src/main/java/com/hjq/demo/ui/activity/SettingActivity.java b/app/src/main/java/com/hjq/demo/ui/activity/SettingActivity.java index 2c7d6b19..a3a5a7ff 100644 --- a/app/src/main/java/com/hjq/demo/ui/activity/SettingActivity.java +++ b/app/src/main/java/com/hjq/demo/ui/activity/SettingActivity.java @@ -6,8 +6,8 @@ import com.hjq.demo.common.MyActivity; import com.hjq.demo.helper.ActivityStackManager; import com.hjq.demo.helper.CacheDataManager; -import com.hjq.widget.SettingBar; import com.hjq.image.ImageLoader; +import com.hjq.widget.SettingBar; import com.hjq.widget.SwitchButton; import butterknife.BindView; diff --git a/app/src/main/java/com/hjq/demo/ui/activity/WebActivity.java b/app/src/main/java/com/hjq/demo/ui/activity/WebActivity.java index 28de3e14..5120c2fa 100644 --- a/app/src/main/java/com/hjq/demo/ui/activity/WebActivity.java +++ b/app/src/main/java/com/hjq/demo/ui/activity/WebActivity.java @@ -67,7 +67,7 @@ protected void initView() { } // 加快HTML网页加载完成的速度,等页面finish再加载图片 - if(Build.VERSION.SDK_INT >= 19) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { settings.setLoadsImagesAutomatically(true); } else { settings.setLoadsImagesAutomatically(false); diff --git a/app/src/main/java/com/hjq/demo/ui/adapter/ImagePagerAdapter.java b/app/src/main/java/com/hjq/demo/ui/adapter/PhotoPagerAdapter.java similarity index 90% rename from app/src/main/java/com/hjq/demo/ui/adapter/ImagePagerAdapter.java rename to app/src/main/java/com/hjq/demo/ui/adapter/PhotoPagerAdapter.java index d6cd009f..7840e1de 100644 --- a/app/src/main/java/com/hjq/demo/ui/adapter/ImagePagerAdapter.java +++ b/app/src/main/java/com/hjq/demo/ui/adapter/PhotoPagerAdapter.java @@ -1,71 +1,71 @@ -package com.hjq.demo.ui.adapter; - -import android.app.Activity; -import android.support.annotation.NonNull; -import android.support.v4.view.PagerAdapter; -import android.view.View; -import android.view.ViewGroup; - -import com.github.chrisbanes.photoview.PhotoView; -import com.hjq.image.ImageLoader; - -import java.util.List; - -/** - * author : Android 轮子哥 - * github : https://github.com/getActivity/AndroidProject - * time : 2019/03/05 - * desc : 图片加载适配器 - */ -public final class ImagePagerAdapter extends PagerAdapter implements View.OnClickListener { - - private Activity mActivity; - private List mData; - - public ImagePagerAdapter(Activity activity, List data) { - mActivity = activity; - mData = data; - } - - // 加载数量,自动回调 - @Override - public int getCount() { - return mData.size(); - } - - // 返回真表示不会重新创建,使用缓存加载。返回假则重新创建 - @Override - public boolean isViewFromObject(@NonNull View view, @NonNull Object object) { - return view == object; - } - - /** - * 实例化条目 - * ViewPager预加载机制:最多保存3个page,超过的将需要被销毁掉 - * 由于最多3个page,所以不需要设置ViewHolder - * 用于将数据设置给ViewItem - */ - - @NonNull - @Override - public Object instantiateItem(@NonNull ViewGroup container, int position) { - PhotoView view = new PhotoView(mActivity); - view.setOnClickListener(this); - ImageLoader.loadImage(view, mData.get(position)); - // 将View添加到ViewPager - container.addView(view); - return view; - } - - // 销毁条目 - @Override - public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { - container.removeView((View) object); - } - - @Override - public void onClick(View v) { - // 点击退出当前的 Activity - mActivity.finish(); - } +package com.hjq.demo.ui.adapter; + +import android.app.Activity; +import android.support.annotation.NonNull; +import android.support.v4.view.PagerAdapter; +import android.view.View; +import android.view.ViewGroup; + +import com.github.chrisbanes.photoview.PhotoView; +import com.hjq.image.ImageLoader; + +import java.util.List; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/AndroidProject + * time : 2019/03/05 + * desc : 图片加载适配器 + */ +public final class PhotoPagerAdapter extends PagerAdapter implements View.OnClickListener { + + private Activity mActivity; + private List mData; + + public PhotoPagerAdapter(Activity activity, List data) { + mActivity = activity; + mData = data; + } + + // 加载数量,自动回调 + @Override + public int getCount() { + return mData.size(); + } + + // 返回真表示不会重新创建,使用缓存加载。返回假则重新创建 + @Override + public boolean isViewFromObject(@NonNull View view, @NonNull Object object) { + return view == object; + } + + /** + * 实例化条目 + * ViewPager预加载机制:最多保存3个page,超过的将需要被销毁掉 + * 由于最多3个page,所以不需要设置ViewHolder + * 用于将数据设置给ViewItem + */ + + @NonNull + @Override + public Object instantiateItem(@NonNull ViewGroup container, int position) { + PhotoView view = new PhotoView(mActivity); + view.setOnClickListener(this); + ImageLoader.loadImage(view, mData.get(position)); + // 将View添加到ViewPager + container.addView(view); + return view; + } + + // 销毁条目 + @Override + public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { + container.removeView((View) object); + } + + @Override + public void onClick(View v) { + // 点击退出当前的 Activity + mActivity.finish(); + } } \ No newline at end of file diff --git a/app/src/main/java/com/hjq/demo/ui/fragment/TestFragmentA.java b/app/src/main/java/com/hjq/demo/ui/fragment/TestFragmentA.java index e0a02b96..a05c18c4 100644 --- a/app/src/main/java/com/hjq/demo/ui/fragment/TestFragmentA.java +++ b/app/src/main/java/com/hjq/demo/ui/fragment/TestFragmentA.java @@ -2,7 +2,6 @@ import android.support.design.widget.AppBarLayout; import android.support.v7.widget.Toolbar; -import android.view.KeyEvent; import android.widget.TextView; import com.gyf.barlibrary.ImmersionBar; diff --git a/app/src/main/java/com/hjq/demo/ui/fragment/TestFragmentD.java b/app/src/main/java/com/hjq/demo/ui/fragment/TestFragmentD.java index f607a7d7..2e578a6a 100644 --- a/app/src/main/java/com/hjq/demo/ui/fragment/TestFragmentD.java +++ b/app/src/main/java/com/hjq/demo/ui/fragment/TestFragmentD.java @@ -10,7 +10,7 @@ import com.hjq.demo.ui.activity.AboutActivity; import com.hjq.demo.ui.activity.DialogActivity; import com.hjq.demo.ui.activity.HomeActivity; -import com.hjq.demo.ui.activity.ImageActivity; +import com.hjq.demo.ui.activity.PhotoActivity; import com.hjq.demo.ui.activity.LoginActivity; import com.hjq.demo.ui.activity.PasswordForgetActivity; import com.hjq.demo.ui.activity.PasswordResetActivity; @@ -99,7 +99,7 @@ public void onClick(View v) { startActivity(WebActivity.class); break; case R.id.btn_test_image: - startActivity(ImageActivity.class); + startActivity(PhotoActivity.class); break; case R.id.btn_test_pay: new MessageDialog.Builder(getBindingActivity()) diff --git a/app/src/main/java/com/hjq/demo/widget/PhotoViewPager.java b/app/src/main/java/com/hjq/demo/widget/PhotoViewPager.java new file mode 100644 index 00000000..556f545a --- /dev/null +++ b/app/src/main/java/com/hjq/demo/widget/PhotoViewPager.java @@ -0,0 +1,34 @@ +package com.hjq.demo.widget; + +import android.content.Context; +import android.support.v4.view.ViewPager; +import android.util.AttributeSet; +import android.view.MotionEvent; + +/** + * author : Android 轮子哥 + * github : https://github.com/getActivity/AndroidProject + * time : 2019/05/07 + * desc : ViewPager 中使用 PhotoView 时出现 pointerIndex out of range 异常 + */ +public final class PhotoViewPager extends ViewPager { + + public PhotoViewPager(Context context) { + super(context); + } + + public PhotoViewPager(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + // 当PhotoView 和 ViewPager 组合时 ,用双指进行放大时 是没有问题的,但是用双指进行缩小的时候,程序就会崩掉 + // 并且抛出java.lang.IllegalArgumentException: pointerIndex out of range + try { + return super.onInterceptTouchEvent(ev); + } catch (IllegalArgumentException | ArrayIndexOutOfBoundsException ignored) { + return false; + } + } +} \ No newline at end of file diff --git a/app/src/main/res/mipmap/bg_launcher.jpg b/app/src/main/res/drawable-xxhdpi/bg_launcher.jpg similarity index 100% rename from app/src/main/res/mipmap/bg_launcher.jpg rename to app/src/main/res/drawable-xxhdpi/bg_launcher.jpg diff --git a/app/src/main/res/mipmap/ic_logo.png b/app/src/main/res/drawable-xxhdpi/ic_logo.png similarity index 100% rename from app/src/main/res/mipmap/ic_logo.png rename to app/src/main/res/drawable-xxhdpi/ic_logo.png diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 43c9c1f3..ce38912e 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -19,7 +19,7 @@ android:layout_height="@dimen/space_200" android:layout_marginTop="@dimen/space_80" android:layout_marginBottom="@dimen/space_80" - android:src="@mipmap/ic_logo" /> + android:src="@drawable/ic_logo" /> + android:src="@drawable/bg_launcher" /> + android:src="@drawable/ic_logo" /> + android:src="@drawable/ic_logo" /> - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_test_a.xml b/app/src/main/res/layout/fragment_test_a.xml index b0478c88..c58fca13 100644 --- a/app/src/main/res/layout/fragment_test_a.xml +++ b/app/src/main/res/layout/fragment_test_a.xml @@ -27,7 +27,7 @@ android:layout_height="wrap_content" android:paddingTop="@dimen/space_300" android:scaleType="centerCrop" - android:src="@mipmap/bg_launcher" + android:src="@drawable/bg_launcher" app:layout_collapseMode="parallax" /> + android:src="@drawable/bg_launcher" /> @@ -47,7 +47,7 @@ android:layout_width="@dimen/space_180" android:layout_height="@dimen/space_180" android:layout_marginLeft="@dimen/space_40" - android:src="@mipmap/ic_logo" + android:src="@drawable/ic_logo" app:civ_border_color="@color/black60" app:civ_border_width="@dimen/space_2" /> @@ -210,7 +210,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:scaleType="centerCrop" - android:src="@mipmap/bg_launcher" /> + android:src="@drawable/bg_launcher" /> diff --git a/dialog/src/main/java/com/hjq/dialog/InputDialog.java b/dialog/src/main/java/com/hjq/dialog/InputDialog.java index c1599b25..e8fb832f 100644 --- a/dialog/src/main/java/com/hjq/dialog/InputDialog.java +++ b/dialog/src/main/java/com/hjq/dialog/InputDialog.java @@ -2,7 +2,6 @@ import android.app.Dialog; import android.content.Context; -import android.content.DialogInterface; import android.support.v4.app.FragmentActivity; import android.view.Gravity; import android.view.View; diff --git a/dialog/src/main/java/com/hjq/dialog/MenuDialog.java b/dialog/src/main/java/com/hjq/dialog/MenuDialog.java index acf6b40e..a7adf3e6 100644 --- a/dialog/src/main/java/com/hjq/dialog/MenuDialog.java +++ b/dialog/src/main/java/com/hjq/dialog/MenuDialog.java @@ -29,7 +29,8 @@ public final class MenuDialog { public static final class Builder extends BaseDialogFragment.Builder - implements View.OnClickListener, BaseRecyclerViewAdapter.OnItemClickListener { + implements View.OnClickListener, + BaseRecyclerViewAdapter.OnItemClickListener { private OnListener mListener; private boolean mAutoDismiss = true; diff --git a/dialog/src/main/java/com/hjq/dialog/PayPasswordDialog.java b/dialog/src/main/java/com/hjq/dialog/PayPasswordDialog.java index 606c6d53..90558a16 100644 --- a/dialog/src/main/java/com/hjq/dialog/PayPasswordDialog.java +++ b/dialog/src/main/java/com/hjq/dialog/PayPasswordDialog.java @@ -30,7 +30,8 @@ public final class PayPasswordDialog { public static final class Builder extends BaseDialogFragment.Builder - implements BaseRecyclerViewAdapter.OnItemClickListener, View.OnClickListener { + implements BaseRecyclerViewAdapter.OnItemClickListener, + View.OnClickListener { // 输入键盘文本 private static final String[] KEYBOARD_TEXT = new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9", "", "0", ""}; diff --git a/umeng/src/main/java/com/hjq/umeng/WeChatActivity.java b/umeng/src/main/java/com/hjq/umeng/WeChatActivity.java deleted file mode 100644 index 6d9bcb99..00000000 --- a/umeng/src/main/java/com/hjq/umeng/WeChatActivity.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hjq.umeng; - -import android.os.Bundle; - -import com.umeng.socialize.weixin.view.WXCallbackActivity; - -/** - * author : Android 轮子哥 - * github : https://github.com/getActivity/AndroidProject - * time : 2019/04/29 - * desc : 微信回调 Activity - */ -public class WeChatActivity extends WXCallbackActivity { - -} \ No newline at end of file diff --git a/widget/src/main/java/com/hjq/widget/ClearEditText.java b/widget/src/main/java/com/hjq/widget/ClearEditText.java index e7f8f561..427d3cf1 100644 --- a/widget/src/main/java/com/hjq/widget/ClearEditText.java +++ b/widget/src/main/java/com/hjq/widget/ClearEditText.java @@ -2,14 +2,12 @@ import android.annotation.SuppressLint; import android.content.Context; -import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.support.v4.content.ContextCompat; import android.support.v4.graphics.drawable.DrawableCompat; -import android.support.v4.view.ViewCompat; import android.text.Editable; import android.text.TextWatcher; import android.util.AttributeSet; diff --git a/widget/src/main/java/com/hjq/widget/HintLayout.java b/widget/src/main/java/com/hjq/widget/HintLayout.java index 93b41367..4738bd7a 100644 --- a/widget/src/main/java/com/hjq/widget/HintLayout.java +++ b/widget/src/main/java/com/hjq/widget/HintLayout.java @@ -12,7 +12,6 @@ import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.MotionEvent; -import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView;