Search in sources :

Example 1 with MaterialSimpleListAdapter

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Window(android.view.Window) Context(android.content.Context) SnackbarUtils(com.lguipeng.notes.utils.SnackbarUtils) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) Uri(android.net.Uri) WindowManager(android.view.WindowManager) Intent(android.content.Intent) BitmapFactory(android.graphics.BitmapFactory) Animator(android.animation.Animator) WXUtils(com.lguipeng.notes.utils.WXUtils) PackageInfo(android.content.pm.PackageInfo) OnClick(butterknife.OnClick) MenuItem(android.view.MenuItem) SendMessageToWX(com.tencent.mm.sdk.modelmsg.SendMessageToWX) IWXAPI(com.tencent.mm.sdk.openapi.IWXAPI) WXMediaMessage(com.tencent.mm.sdk.modelmsg.WXMediaMessage) Menu(android.view.Menu) Display(android.view.Display) View(android.view.View) Bind(butterknife.Bind) TimeUtils(com.lguipeng.notes.utils.TimeUtils) WXWebpageObject(com.tencent.mm.sdk.modelmsg.WXWebpageObject) MaterialSimpleListAdapter(com.lguipeng.notes.adpater.MaterialSimpleListAdapter) WXAPIFactory(com.tencent.mm.sdk.openapi.WXAPIFactory) ShareListItem(com.lguipeng.notes.model.ShareListItem) ObjectAnimator(android.animation.ObjectAnimator) Point(android.graphics.Point) TextUtils(android.text.TextUtils) R(com.lguipeng.notes.R) Gravity(android.view.Gravity) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) BuildConfig(com.lguipeng.notes.BuildConfig) Toolbar(android.support.v7.widget.Toolbar) ActivityNotFoundException(android.content.ActivityNotFoundException) Bitmap(android.graphics.Bitmap) Window(android.view.Window) MaterialSimpleListAdapter(com.lguipeng.notes.adpater.MaterialSimpleListAdapter) Point(android.graphics.Point) View(android.view.View) TextView(android.widget.TextView) WindowManager(android.view.WindowManager) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) Display(android.view.Display)

Aggregations

Animator (android.animation.Animator)1 ObjectAnimator (android.animation.ObjectAnimator)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Context (android.content.Context)1 Intent (android.content.Intent)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 Point (android.graphics.Point)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 AlertDialog (android.support.v7.app.AlertDialog)1 Toolbar (android.support.v7.widget.Toolbar)1 TextUtils (android.text.TextUtils)1 Display (android.view.Display)1 Gravity (android.view.Gravity)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1