use of com.lguipeng.notes.adpater.MaterialSimpleListAdapter in project Notes by lguipeng.
the class AboutActivity method showShareDialog.
private void showShareDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.ShareDialog);
builder.setTitle(getString(R.string.share));
final MaterialSimpleListAdapter adapter = new MaterialSimpleListAdapter(this);
String[] array = getResources().getStringArray(R.array.share_dialog_text);
adapter.add(new ShareListItem.Builder(this).content(array[0]).icon(R.drawable.ic_wx_logo).build());
adapter.add(new ShareListItem.Builder(this).content(array[1]).icon(R.drawable.ic_wx_moments).build());
adapter.add(new ShareListItem.Builder(this).content(array[2]).icon(R.drawable.ic_wx_collect).build());
adapter.add(new ShareListItem.Builder(this).content(array[3]).icon(R.drawable.ic_sina_logo).build());
adapter.add(new ShareListItem.Builder(this).content(array[4]).icon(R.drawable.ic_share_more).build());
builder.setAdapter(adapter, (dialog, which) -> {
switch(which) {
case 0:
shareToWeChatSession();
break;
case 1:
shareToWeChatTimeline();
break;
case 2:
shareToWeChatFavorite();
break;
case 3:
shareToWeibo();
break;
default:
share("", null);
}
});
AlertDialog dialog = builder.create();
Window window = dialog.getWindow();
window.setGravity(Gravity.BOTTOM);
WindowManager.LayoutParams lp = window.getAttributes();
Display display = getWindowManager().getDefaultDisplay();
Point out = new Point();
display.getSize(out);
lp.width = out.x;
window.setAttributes(lp);
View decorView = window.getDecorView();
decorView.setBackgroundColor(getResources().getColor(R.color.window_background));
dialog.setOnShowListener((dialog1 -> {
Animator animator = ObjectAnimator.ofFloat(decorView, "translationY", decorView.getMeasuredHeight() / 1.5F, 0);
animator.setDuration(200);
animator.start();
}));
dialog.show();
}
Aggregations