|
|
@@ -4,8 +4,10 @@ import android.annotation.TargetApi;
|
|
|
import android.app.ActivityManager;
|
|
|
import android.app.AlertDialog;
|
|
|
import android.app.ProgressDialog;
|
|
|
+import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.net.Uri;
|
|
|
import android.os.AsyncTask;
|
|
|
import android.os.Build;
|
|
|
@@ -17,6 +19,8 @@ import android.view.LayoutInflater;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.view.WindowManager;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.PopupWindow;
|
|
|
@@ -24,6 +28,8 @@ import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
+import com.afollestad.materialdialogs.GravityEnum;
|
|
|
+import com.afollestad.materialdialogs.MaterialDialog;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baidu.android.pushservice.PushManager;
|
|
|
import com.baidu.autoupdatesdk.AppUpdateInfo;
|
|
|
@@ -58,6 +64,7 @@ import com.me.network.app.http.HttpClient;
|
|
|
import com.me.network.app.http.Method;
|
|
|
import com.me.network.app.http.rx.ResultListener;
|
|
|
import com.me.network.app.http.rx.ResultSubscriber;
|
|
|
+import com.scwang.smartrefresh.layout.util.DensityUtil;
|
|
|
import com.uas.appme.R;
|
|
|
import com.uas.appme.pedometer.view.NewStepActivity;
|
|
|
import com.uas.appme.pedometer.view.StepSplashActivity;
|
|
|
@@ -112,7 +119,6 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_setting);
|
|
|
- //getSupportActionBar().setTitle(getString(R.string.user_setting));
|
|
|
super.setTitle(getString(R.string.user_setting));
|
|
|
initView();
|
|
|
}
|
|
|
@@ -177,7 +183,8 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
|
|
|
mExitBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- showExitDialog();
|
|
|
+ // showExitDialog();
|
|
|
+ showExitPop();
|
|
|
}
|
|
|
});
|
|
|
mCacheTv = (TextView) findViewById(R.id.cache_tv);
|
|
|
@@ -335,17 +342,35 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
|
|
|
}
|
|
|
|
|
|
private void showExitDialog() {
|
|
|
- new AlertDialog.Builder(mContext).setTitle(R.string.app_name).setMessage(R.string.exit_tips).setNegativeButton(R.string.common_cancel, null)
|
|
|
- .setPositiveButton(R.string.common_sure, new DialogInterface.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
- UserSp.getInstance(mContext).clearUserInfo();
|
|
|
- ViewUtil.clearAccount(mContext);
|
|
|
- LoginHelper.broadcastLogout(mContext);
|
|
|
- SettingActivity.this.finish();
|
|
|
-
|
|
|
- }
|
|
|
- }).create().show();
|
|
|
+ new MaterialDialog.Builder(this)
|
|
|
+ .title(R.string.app_name)
|
|
|
+ .titleGravity(GravityEnum.CENTER)
|
|
|
+
|
|
|
+ .content(R.string.exit_tips)
|
|
|
+ .positiveText(R.string.common_sure)
|
|
|
+ .positiveColorRes(R.color.white)
|
|
|
+ .btnSelector(R.drawable.btn_dialog_selector)
|
|
|
+ .btnStackedGravity(GravityEnum.CENTER)
|
|
|
+ .itemsGravity(GravityEnum.CENTER)
|
|
|
+ .buttonsGravity(GravityEnum.CENTER)
|
|
|
+ .negativeText(R.string.common_cancel)
|
|
|
+ .negativeColorRes(R.color.white)
|
|
|
+ .show();
|
|
|
+
|
|
|
+// new AlertDialog.Builder(mContext)
|
|
|
+// .setTitle(R.string.app_name)
|
|
|
+// .setMessage(R.string.exit_tips)
|
|
|
+// .setNegativeButton(R.string.common_cancel, null)
|
|
|
+// .setPositiveButton(R.string.common_sure, new DialogInterface.OnClickListener() {
|
|
|
+// @Override
|
|
|
+// public void onClick(DialogInterface dialog, int which) {
|
|
|
+// UserSp.getInstance(mContext).clearUserInfo();
|
|
|
+// ViewUtil.clearAccount(mContext);
|
|
|
+// LoginHelper.broadcastLogout(mContext);
|
|
|
+// SettingActivity.this.finish();
|
|
|
+//
|
|
|
+// }
|
|
|
+// }).create().show();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -624,4 +649,51 @@ public class SettingActivity extends SupportToolBarActivity implements View.OnCl
|
|
|
setWindow.dismiss();
|
|
|
DisplayUtil.backgroundAlpha(this, 1f);
|
|
|
}
|
|
|
+
|
|
|
+ private PopupWindow popupWindow;
|
|
|
+ public void showExitPop() {
|
|
|
+ View view = null;
|
|
|
+ WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
|
|
+ if (popupWindow == null) {
|
|
|
+ LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
+ view = layoutInflater.inflate(R.layout.pop_simple_dialog, null);
|
|
|
+ TextView tv_title= view.findViewById(R.id.tv_title);
|
|
|
+ TextView tv_content= view.findViewById(R.id.tv_content);
|
|
|
+ TextView tv_cancel=view.findViewById(R.id.tv_cancel);
|
|
|
+ TextView tv_sure= view.findViewById(R.id.tv_sure);
|
|
|
+ tv_content.setText(R.string.exit_tips);
|
|
|
+ popupWindow = new PopupWindow(view, windowManager.getDefaultDisplay().getWidth()- DensityUtil.dp2px(50), LinearLayout.LayoutParams.MATCH_PARENT);
|
|
|
+ tv_sure.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ UserSp.getInstance(mContext).clearUserInfo();
|
|
|
+ ViewUtil.clearAccount(mContext);
|
|
|
+ LoginHelper.broadcastLogout(mContext);
|
|
|
+ SettingActivity.this.finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tv_cancel.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ popupWindow.setFocusable(true);
|
|
|
+ popupWindow.setOutsideTouchable(true);
|
|
|
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ DisplayUtil.backgroundAlpha(activity, 1f);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ DisplayUtil.backgroundAlpha(this, 0.5f);
|
|
|
+ popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
+ popupWindow.showAtLocation(activity.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
}
|