Skip to content

Commit

Permalink
PolicyLib优化
Browse files Browse the repository at this point in the history
PolicyLib优化
  • Loading branch information
[email protected] committed Dec 18, 2019
1 parent 0260d1c commit 6ad54fe
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
Binary file modified app-debug.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void onClick(int which) {
if (mRationaleCallbacks != null) {
mRationaleCallbacks.onRationaleDenied(requestCode);
}
notifyPermissionDenied();
// notifyPermissionDenied();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.db.policylib.PermissionPolicy;
Expand Down Expand Up @@ -82,11 +83,25 @@ Dialog createSupportDialog(Context context, final RationaleClickListener listene
dialog.setCancelable(false);
dialog.setContentView(R.layout.layout_policy);
dialog.show();
LinearLayout ll_bottom = dialog.findViewById(R.id.ll_bottom);
RecyclerView rv_list = dialog.findViewById(R.id.rv_list);
TextView tv_request = dialog.findViewById(R.id.tv_request);
TextView tv_ok = dialog.findViewById(R.id.tv_ok);
TextView tv_cancel = dialog.findViewById(R.id.tv_cancel);
ll_bottom.setVisibility(View.VISIBLE);
tv_request.setVisibility(View.GONE);
PolicyAdapter adapter = new PolicyAdapter(context, lists);
rv_list.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
rv_list.setAdapter(adapter);
tv_ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
if (listener != null) {
listener.onClick(0);
}
}
});
tv_request.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -96,6 +111,15 @@ public void onClick(View v) {
}
}
});
tv_cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
if (listener != null) {
listener.onClick(1);
}
}
});
return dialog;
}

Expand All @@ -105,8 +129,13 @@ Dialog createFrameworkDialog(Context context, final RationaleClickListener liste
dialog.setCancelable(false);
dialog.setContentView(R.layout.layout_policy);
dialog.show();
LinearLayout ll_bottom = dialog.findViewById(R.id.ll_bottom);
RecyclerView rv_list = dialog.findViewById(R.id.rv_list);
TextView tv_request = dialog.findViewById(R.id.tv_request);
TextView tv_ok = dialog.findViewById(R.id.tv_ok);
TextView tv_cancel = dialog.findViewById(R.id.tv_cancel);
ll_bottom.setVisibility(View.VISIBLE);
tv_request.setVisibility(View.GONE);
PolicyAdapter adapter = new PolicyAdapter(context, lists);
rv_list.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
rv_list.setAdapter(adapter);
Expand All @@ -119,6 +148,24 @@ public void onClick(View v) {
}
}
});
tv_request.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
if (listener != null) {
listener.onClick(0);
}
}
});
tv_cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
if (listener != null) {
listener.onClick(1);
}
}
});
return dialog;
}

Expand Down

0 comments on commit 6ad54fe

Please sign in to comment.