| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.keyCabinet.utils.update; |
| | | |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.view.View; |
| | | import android.view.Window; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.doumee.keyCabinet.R; |
| | | import com.yanzhenjie.permission.runtime.Permission; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class UpdateDialog extends Dialog { |
| | | private UpdialogListener lister; |
| | | private TextView update; |
| | | private TextView not_update; |
| | | private TextView update_text; |
| | | private TextView tv_version; |
| | | |
| | | public UpdateDialog(Context context) { |
| | | super(context, R.style.update_dialog_style); |
| | | this.requestWindowFeature(Window.FEATURE_NO_TITLE); |
| | | initView(context); |
| | | //isneedupdate(NetWorkUtil.isWifiConnected(context)); |
| | | } |
| | | |
| | | public void setText(String text,String version) { |
| | | update_text.setText(text); |
| | | tv_version.setText("æ´æ°çæ¬"+version); |
| | | } |
| | | |
| | | private void initView(Context context) { |
| | | setContentView(R.layout.ui_update_dialog); |
| | | update = findViewById(R.id.layout_update); |
| | | not_update = findViewById(R.id.layout_not_update); |
| | | update_text = findViewById(R.id.update_text); |
| | | tv_version = findViewById(R.id.tv_version); |
| | | |
| | | update.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | getWritePermision(); |
| | | } |
| | | }); |
| | | not_update.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (lister != null) { |
| | | lister.setOnclickNoUpdate(); |
| | | } |
| | | } |
| | | }); |
| | | //getWritePermision(); |
| | | } |
| | | |
| | | public void setOnOtemListener(UpdialogListener lister) { |
| | | this.lister = lister; |
| | | } |
| | | |
| | | /** |
| | | * æé®æ¥å£çå¬ |
| | | * |
| | | * @author yuan |
| | | * |
| | | */ |
| | | public interface UpdialogListener { |
| | | void setOnclickUpdate(); |
| | | |
| | | void setOnclickNoUpdate(); |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦å¼ºå¶å级 |
| | | */ |
| | | public void isneedupdate(boolean flag) { |
| | | if (flag) {//æ¯ |
| | | not_update.setVisibility(View.GONE); |
| | | /* |
| | | * LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) |
| | | * update.getLayoutParams(); // params.leftMargin = 100; |
| | | * params.gravity = Gravity.CENTER_HORIZONTAL; |
| | | * update.setLayoutParams(params); |
| | | */ |
| | | } |
| | | } |
| | | |
| | | private void getWritePermision(){ |
| | | PermissionUtils.getPermission2(getContext(), new PermissionUtils.CallBack() { |
| | | @Override |
| | | public void sucess() { |
| | | if (lister != null) { |
| | | lister.setOnclickUpdate(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void fail(List<String> permissions) { |
| | | //showNoPermissionTip(); |
| | | PermissionUtils.gotoPermission(getContext()); |
| | | dismiss(); |
| | | } |
| | | }, Permission.Group.STORAGE); |
| | | } |
| | | |
| | | |
| | | |
| | | private PermissiondDialog permissiondDialog; |
| | | /** |
| | | * 没ææéçæé |
| | | * |
| | | */ |
| | | private void showNoPermissionTip() { |
| | | try { |
| | | Toast.makeText(getContext(), getContext().getString(R.string.guide_permiss_1), Toast.LENGTH_LONG).show(); |
| | | if(permissiondDialog==null){ |
| | | permissiondDialog=new PermissiondDialog(getContext(), getContext().getString(R.string.help), |
| | | getContext().getString(R.string.guide_permiss_2), getContext().getString(R.string.cancel), |
| | | getContext().getString(R.string.empower), new PermissiondDialog.OnClickListener() { |
| | | @Override |
| | | public void clickOk() { |
| | | permissiondDialog.dismiss(); |
| | | PermissionUtils.gotoPermission(getContext()); |
| | | } |
| | | |
| | | @Override |
| | | public void clickNo() { |
| | | permissiondDialog.dismiss(); |
| | | } |
| | | }); |
| | | } |
| | | if(!permissiondDialog.isShowing()){ |
| | | permissiondDialog.show(); |
| | | } |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | } |
| | | } |