SaveBundleUtils.java 8.42 KB
package com.wd.foundation.bean.utils;

import java.io.Serializable;

import android.os.Bundle;
import android.os.Parcelable;

/**
 * 描述:
 *
 * @author : lvjinhui
 * @since: 2022/12/16
 */
public final class SaveBundleUtils {
    private SaveBundleUtils() {
    }

    public static String getString(Bundle bundle, String key, String defaultValue) {
        if (null != bundle && null != key) {
            try {
                return bundle.getString(key, defaultValue);
            } catch (Exception var4) {
                return defaultValue;
            }
        } else {
            return defaultValue;
        }
    }

    public static int getInt(Bundle bundle, String key, int defaultValue) {
        if (null != bundle && null != key) {
            try {
                return bundle.getInt(key, defaultValue);
            } catch (Exception var4) {
                return defaultValue;
            }
        } else {
            return defaultValue;
        }
    }

    public static long getLong(Bundle bundle, String key, long defaultValue) {
        if (null != bundle && null != key) {
            try {
                return bundle.getLong(key, defaultValue);
            } catch (Exception var5) {
                return defaultValue;
            }
        } else {
            return defaultValue;
        }
    }

    public static float getFloat(Bundle bundle, String key, float defaultValue) {
        if (null != bundle && null != key) {
            try {
                return bundle.getFloat(key, defaultValue);
            } catch (Exception var4) {
                return defaultValue;
            }
        } else {
            return defaultValue;
        }
    }

    public static double getDouble(Bundle bundle, String key, double defaultValue) {
        if (null != bundle && null != key) {
            try {
                return bundle.getDouble(key, defaultValue);
            } catch (Exception var5) {
                return defaultValue;
            }
        } else {
            return defaultValue;
        }
    }

    public static boolean getBoolean(Bundle bundle, String key, boolean defaultValue) {
        if (null != bundle && null != key) {
            try {
                return bundle.getBoolean(key, defaultValue);
            } catch (Exception var4) {
                return defaultValue;
            }
        } else {
            return defaultValue;
        }
    }

    public static byte getByte(Bundle bundle, String key, byte defaultValue) {
        if (null != bundle && null != key) {
            try {
                return bundle.getByte(key, defaultValue);
            } catch (Exception var4) {
                return defaultValue;
            }
        } else {
            return defaultValue;
        }
    }

    public static short getShort(Bundle bundle, String key, short defaultValue) {
        if (null != bundle && null != key) {
            try {
                return bundle.getShort(key, defaultValue);
            } catch (Exception var4) {
                return defaultValue;
            }
        } else {
            return defaultValue;
        }
    }

    public static char getChar(Bundle bundle, String key, char defaultValue) {
        if (null != bundle && null != key) {
            try {
                return bundle.getChar(key, defaultValue);
            } catch (Exception var4) {
                return defaultValue;
            }
        } else {
            return defaultValue;
        }
    }

    public static CharSequence getCharSequence(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getCharSequence(key);
            } catch (Exception var3) {
                return null;
            }
        } else {
            return null;
        }
    }

    public static Serializable getSerializable(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getSerializable(key);
            } catch (Exception var3) {
                return null;
            }
        } else {
            return null;
        }
    }

    public static <T extends Parcelable> T getParcelable(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getParcelable(key);
            } catch (Exception var3) {
                return null;
            }
        } else {
            return null;
        }
    }

    public static Parcelable[] getParcelableArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getParcelableArray(key);
            } catch (Exception var3) {
                return new Parcelable[0];
            }
        } else {
            return new Parcelable[0];
        }
    }

    public static boolean[] getBooleanArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getBooleanArray(key);
            } catch (Exception var3) {
                return new boolean[0];
            }
        } else {
            return new boolean[0];
        }
    }

    public static byte[] getByteArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getByteArray(key);
            } catch (Exception var3) {
                return new byte[0];
            }
        } else {
            return new byte[0];
        }
    }

    public static short[] getShortArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getShortArray(key);
            } catch (Exception var3) {
                return new short[0];
            }
        } else {
            return new short[0];
        }
    }

    public static char[] getCharArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getCharArray(key);
            } catch (Exception var3) {
                return new char[0];
            }
        } else {
            return new char[0];
        }
    }

    public static int[] getIntArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getIntArray(key);
            } catch (Exception var3) {
                return new int[0];
            }
        } else {
            return new int[0];
        }
    }

    public static long[] getLongArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getLongArray(key);
            } catch (Exception var3) {
                return new long[0];
            }
        } else {
            return new long[0];
        }
    }

    public static float[] getFloatArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getFloatArray(key);
            } catch (Exception var3) {
                return new float[0];
            }
        } else {
            return new float[0];
        }
    }

    public static double[] getDoubleArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getDoubleArray(key);
            } catch (Exception var3) {
                return new double[0];
            }
        } else {
            return new double[0];
        }
    }

    public static String[] getStringArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getStringArray(key);
            } catch (Exception var3) {
                return new String[0];
            }
        } else {
            return new String[0];
        }
    }

    public static CharSequence[] getCharSequenceArray(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getCharSequenceArray(key);
            } catch (Exception var3) {
                return new CharSequence[0];
            }
        } else {
            return new CharSequence[0];
        }
    }

    public static Bundle getBundle(Bundle bundle, String key) {
        if (null != bundle && null != key) {
            try {
                return bundle.getBundle(key);
            } catch (Exception var3) {
                return null;
            }
        } else {
            return null;
        }
    }
}