115 lines
2.9 KiB
Java
115 lines
2.9 KiB
Java
package com.gh.base.fragment;
|
|
|
|
import android.os.Bundle;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.TextView;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
import com.gh.gamecenter.R;
|
|
|
|
/**
|
|
* @author CsHeng
|
|
* @Date 17/05/2017
|
|
* @Time 4:27 PM
|
|
*/
|
|
public class WaitingDialogFragment extends BaseDialogFragment {
|
|
|
|
public static final String KEY_MSG = "msg";
|
|
|
|
private OnDialogBackListener mBackListener;
|
|
|
|
private TextView message;
|
|
|
|
public static WaitingDialogFragment newInstance(String message) {
|
|
Bundle args = new Bundle();
|
|
args.putString(KEY_MSG, message);
|
|
WaitingDialogFragment fragment = new WaitingDialogFragment();
|
|
fragment.setArguments(args);
|
|
return fragment;
|
|
}
|
|
|
|
public static WaitingDialogFragment newInstance(String message, boolean isCancelable) {
|
|
Bundle args = new Bundle();
|
|
args.putString(KEY_MSG, message);
|
|
WaitingDialogFragment fragment = new WaitingDialogFragment();
|
|
fragment.setArguments(args);
|
|
fragment.setCancelable(isCancelable);
|
|
return fragment;
|
|
}
|
|
|
|
|
|
@Nullable
|
|
@Override
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
final View view = inflater.inflate(R.layout.set_wait_dialog, null);
|
|
message = view.findViewById(R.id.set_wait_message);
|
|
message.setText(getArguments().getString(KEY_MSG));
|
|
return view;
|
|
}
|
|
|
|
@Override
|
|
public void show(FragmentManager manager, String tag) {
|
|
try {
|
|
super.show(manager, tag);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void show(FragmentManager manager, String tag, OnDialogBackListener backListener) {
|
|
show(manager, tag);
|
|
this.mBackListener = backListener;
|
|
}
|
|
|
|
public void uploadWaitingHint(String hint) {
|
|
if (message != null) message.setText(hint);
|
|
}
|
|
|
|
@Override
|
|
public boolean onBack() {
|
|
if (mBackListener != null) {
|
|
mBackListener.onBack();
|
|
return true;
|
|
}
|
|
return super.onBack();
|
|
}
|
|
|
|
@Override
|
|
public void dismiss() {
|
|
mBackListener = null;
|
|
super.dismiss();
|
|
}
|
|
|
|
public static class WaitingDialogData {
|
|
private String msg;
|
|
|
|
private boolean isShow;
|
|
|
|
public WaitingDialogData(String msg, boolean isShow) {
|
|
this.msg = msg;
|
|
this.isShow = isShow;
|
|
}
|
|
|
|
public String getMsg() {
|
|
return msg;
|
|
}
|
|
|
|
public void setMsg(String msg) {
|
|
this.msg = msg;
|
|
}
|
|
|
|
public boolean isShow() {
|
|
return isShow;
|
|
}
|
|
|
|
public void setShow(boolean show) {
|
|
isShow = show;
|
|
}
|
|
}
|
|
}
|