admin
2021-12-27 b53262049f3c856cff0e181cc667322a29dfeabb
加载动画
2个文件已添加
2个文件已修改
125 ■■■■■ 已修改文件
app/build.gradle 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/res/layout/dialog_loading.xml 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/com/hanju/video/app/ui/dialog/LoadingDialogUtil.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/com/hanju/video/app/ui/login/PersonInfoActivity.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/build.gradle
@@ -69,8 +69,10 @@
    //indicator
    implementation 'com.github.hackware1993:MagicIndicator:1.7.0'
    //加载动画库
    implementation 'com.github.ybq:Android-SpinKit:1.4.0'
}
android {
    signingConfigs {
        debug {
app/res/layout/dialog_loading.xml
New file
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:gravity="center"
    android:orientation="vertical">
    <com.github.ybq.android.spinkit.SpinKitView
        android:id="@+id/spin_kit"
        style="@style/SpinKitView.Large.Circle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:SpinKit_Color="@color/colorLoading" />
    <TextView
        android:id="@+id/tv_msg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:textColor="@color/colorLoading"></TextView>
</LinearLayout>
app/src/com/hanju/video/app/ui/dialog/LoadingDialogUtil.java
New file
@@ -0,0 +1,94 @@
package com.hanju.video.app.ui.dialog;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.lcjian.library.util.common.StringUtils;
import com.weikou.beibeivideo.R;
/**
 * 用户协议弹框
 */
public class LoadingDialogUtil {
    private static Dialog pd;
    public static void show(Context context) {
        show(context, "", false);
    }
    public static void show(Context context, String msg, boolean cancelable) {
        try {
            dismiss();
            //拿到dialog
            pd = getLoadingDialog(context, msg);
            //设置点击外围是否消失
            pd.setCancelable(cancelable);
            pd.show();
        } catch (Exception e) {
        }
    }
    //这里的加载效果自己随意定义
    public static Dialog getLoadingDialog(Context context, String msg) {
        Dialog loading_dialog = new Dialog(context, R.style.Dialog);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null);
        TextView tv_msg = view.findViewById(R.id.tv_msg);
        if (StringUtils.isEmpty(msg)) {
            tv_msg.setVisibility(View.GONE);
        } else {
            tv_msg.setText(msg);
            tv_msg.setVisibility(View.VISIBLE);
        }
        loading_dialog.setContentView(view);
        loading_dialog.getWindow().setBackgroundDrawableResource(R.color.transparent);
        loading_dialog.setCancelable(false);
        return loading_dialog;
    }
    //在这里直接做了判断,大胆的放心的使用,保证不会出现空指针
    public static void dismiss() {
        try {
            if (pd != null && pd.isShowing()) {
                pd.dismiss();
            }
            pd = null;
        } catch (Exception e) {
            // TODO: handle exception
        } finally {
            pd = null;
        }
    }
    public static boolean isShowing() {
        try {
            if (pd != null) {
                return pd.isShowing();
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
        return false;
    }
    /**
     * 设置dialog点击外部是否可以消失
     */
    public static void setCanceledOnTouchOutside(boolean b) {
        try {
            if (pd != null && pd.isShowing()) {
                pd.setCanceledOnTouchOutside(b);
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
}
app/src/com/hanju/video/app/ui/login/PersonInfoActivity.java
@@ -161,6 +161,7 @@
                    File f = new File(uriClipUri.getPath());//获取图片
                    Bitmap bitmap = crop.compressPhto(f);
                    if (crop.compressPhto(f, false)) {//压缩并保存成功
                        Toast.makeText(getApplicationContext(), "压缩保存成功", Toast.LENGTH_SHORT).show();
                        if (bitmap != null) {
                            if (bitmap.getByteCount() / 1024 > maxSize) {
                                bitmap = compressImage(bitmap);