Search in sources :

Example 1 with IAction

use of org.aisen.android.support.action.IAction in project AisenWeiBo by wangdan.

the class PictureFragment method downloadImage.

private void downloadImage() {
    new IAction(getActivity(), new SdcardPermissionAction((BaseActivity) getActivity(), null)) {

        @Override
        public void doAction() {
            new WorkTask<Void, Void, String>() {

                @Override
                protected void onPrepare() {
                    super.onPrepare();
                    ViewUtils.createProgressDialog(getActivity(), getString(R.string.msg_save_pic_loading), ThemeUtils.getThemeColor()).show();
                }

                private void notifyFileSys(File file) {
                    SystemUtils.scanPhoto(getActivity(), file);
                }

                @Override
                public String workInBackground(Void... params) throws TaskException {
                    File file = origFile;
                    if (!file.exists())
                        file = BitmapLoader.getInstance().getCacheFile(getImage());
                    String path = SystemUtils.getSdcardPath() + File.separator + AppSettings.getImageSavePath() + File.separator + file.getName();
                    File newFile = new File(path);
                    if (!newFile.exists()) {
                        if (!newFile.getParentFile().exists())
                            newFile.getParentFile().mkdirs();
                        try {
                            FileUtils.copyFile(file, newFile);
                            notifyFileSys(newFile);
                            return newFile.getParentFile().getAbsolutePath();
                        } catch (Exception e) {
                        }
                    } else {
                        notifyFileSys(newFile);
                        return newFile.getParentFile().getAbsolutePath();
                    }
                    return null;
                }

                @Override
                protected void onSuccess(String aBoolean) {
                    super.onSuccess(aBoolean);
                    if (!TextUtils.isEmpty(aBoolean)) {
                        showMessage(String.format(getString(R.string.msg_save_pic_success), aBoolean));
                    } else {
                        showMessage(R.string.msg_save_pic_faild);
                    }
                }

                @Override
                protected void onFinished() {
                    super.onFinished();
                    ViewUtils.dismissProgressDialog();
                }
            }.execute();
        }
    }.run();
}
Also used : IAction(org.aisen.android.support.action.IAction) SdcardPermissionAction(org.aisen.weibo.sina.support.permissions.SdcardPermissionAction) WorkTask(org.aisen.android.network.task.WorkTask) File(java.io.File) TaskException(org.aisen.android.network.task.TaskException)

Example 2 with IAction

use of org.aisen.android.support.action.IAction in project AisenWeiBo by wangdan.

the class MainActivity method onMenuClicked.

/**
     * 选择了侧边栏,切换侧边栏菜单
     *
     * @param item
     * @return
     */
@Override
public void onMenuClicked(MenuFragment.NavMenuItem item, boolean closeDrawer) {
    invalidateOptionsMenu();
    ABaseFragment fragment = null;
    // 切换ContentFragment,或者跳转到新的界面
    switch(item.id) {
        // 首页
        case MenuFragment.MENU_MAIN:
            fabGroupsFragment.triggerLastPosition();
            break;
        // 通知
        case MenuFragment.MENU_NOTIFICATION:
            fragment = NotificationPagerFragment.newInstance(newIntentNotificationIndex);
            newIntentNotificationIndex = -1;
            break;
        // 提及
        case MenuFragment.MENU_MENTION:
            fragment = MentionPagerFragment.newInstance();
            break;
        // 评论
        case MenuFragment.MENU_CMT:
            fragment = CommentPagerFragment.newInstance();
            break;
        // 私信
        case MenuFragment.MENU_MD:
            new IAction(MainActivity.this, new WebLoginAction(MainActivity.this, BizFragment.createBizFragment(this))) {

                @Override
                public void doAction() {
                    WeiboClientActivity.launchDM(MainActivity.this);
                }
            }.run();
            MobclickAgent.onEvent(MainActivity.this, "md");
            break;
        // 热门微博
        case MenuFragment.MENU_HOT_STATUS:
            WeiboClientActivity.launchHotStatuses(this);
            MobclickAgent.onEvent(MainActivity.this, "hot_status");
            break;
        // 草稿箱
        case MenuFragment.MENU_DRAT:
            fragment = DraftFragment.newInstance();
            break;
        // 设置
        case MenuFragment.MENU_SETTINGS:
            SettingsPagerFragment.launch(this);
            break;
        // 轻松一刻
        case MenuFragment.MENU_JOKE:
            fragment = JokesPagerFragment.newInstance();
            MobclickAgent.onEvent(this, "menu_joke");
            break;
        // 精美壁纸
        case MenuFragment.MENU_WALLPAPER:
            fragment = WallpaperFragment.newInstance();
            MobclickAgent.onEvent(this, "menu_wallpaper");
            break;
    }
    if (fragment != null) {
        setFragemnt(fragment, getString(item.toolbarRes));
    }
    // 隐藏Fab按钮
    if (item.id == 1) {
        fabBtn.setVisibility(View.VISIBLE);
        // 显示Fab
        BizFragment.createBizFragment(this).getFabAnimator().show();
    } else {
        fabBtn.setVisibility(View.GONE);
    }
    // 关闭侧边栏
    if (closeDrawer) {
        mHandler.postDelayed(new Runnable() {

            @Override
            public void run() {
                closeDrawer();
            }
        }, 300);
    }
}
Also used : ABaseFragment(org.aisen.android.ui.fragment.ABaseFragment) IAction(org.aisen.android.support.action.IAction) WebLoginAction(org.aisen.weibo.sina.support.action.WebLoginAction)

Example 3 with IAction

use of org.aisen.android.support.action.IAction in project AisenWeiBo by wangdan.

the class MainActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (drawerToggle != null && drawerToggle.onOptionsItemSelected(item))
        return true;
    if (android.R.id.home == item.getItemId()) {
        if (mDrawerLayout.isDrawerVisible(GravityCompat.START))
            mDrawerLayout.closeDrawers();
        else
            mDrawerLayout.openDrawer(GravityCompat.START);
        return true;
    }
    // 退出
    if (item.getItemId() == R.id.exitapp) {
        finish();
        MobclickAgent.onEvent(this, "exitapp");
    } else // 新微博
    if (item.getItemId() == R.id.publish)
        PublishActivity.publishStatus(this, null);
    else // 开始离线
    if (item.getItemId() == R.id.toggle_offline) {
        OfflineUtils.toggleOffline(this);
        MobclickAgent.onEvent(this, "toggle_offline");
    } else // 停止离线
    if (item.getItemId() == R.id.stop_offline) {
        OfflineService.stopOffline();
        MobclickAgent.onEvent(this, "stop_offline");
    } else // 通知设置
    if (item.getItemId() == R.id.notification_settings)
        NotificationSettingsFragment.launch(this);
    else // 搜索
    if (item.getItemId() == R.id.search) {
        new IAction(MainActivity.this, new WebLoginAction(MainActivity.this, BizFragment.createBizFragment(this))) {

            @Override
            public void doAction() {
                SearchFragment.launch(MainActivity.this, "");
                MobclickAgent.onEvent(MainActivity.this, "toggle_search");
            }
        }.run();
    }
    return super.onOptionsItemSelected(item);
}
Also used : IAction(org.aisen.android.support.action.IAction) WebLoginAction(org.aisen.weibo.sina.support.action.WebLoginAction)

Example 4 with IAction

use of org.aisen.android.support.action.IAction in project AisenWeiBo by wangdan.

the class OtherItemFragment method checkPhotoPermission.

//	private void setLanguage(int value) {
//		String[] valueTitleArr = getResources().getStringArray(R.array.pLanguage);
//
//		pLanguage.setSummary(valueTitleArr[value]);
//	}
public static void checkPhotoPermission(final BaseActivity activity, final boolean shownever) {
    APermissionsAction permissionsAction = new APermissionsAction(activity, null, activity.getActivityHelper(), Manifest.permission.CALL_PHONE) {

        @Override
        protected void onPermissionDenied(boolean alwaysDenied) {
            if (alwaysDenied) {
                if (shownever && ActivityHelper.getBooleanShareData(GlobalContext.getInstance(), "donot_crash_remind", false)) {
                    return;
                }
                MaterialDialog.Builder builder = new MaterialDialog.Builder(activity).forceStacking(true).content(R.string.crash_hint).negativeText(R.string.crash_settings).onPositive(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        ActivityHelper.putBooleanShareData(GlobalContext.getInstance(), "donot_crash_remind", true);
                    }
                }).onNegative(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        AisenUtils.gotoSettings(activity);
                    }
                });
                if (shownever)
                    builder.positiveText(R.string.donnot_remind);
                builder.show();
            }
        }
    };
    // 开启日志上报
    new IAction(activity, permissionsAction) {

        @Override
        public void doAction() {
            Log.d("Main", "setupCrash");
            ((MyApplication) GlobalContext.getInstance()).setupCrash();
        }
    }.run();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) IAction(org.aisen.android.support.action.IAction) DialogAction(com.afollestad.materialdialogs.DialogAction) APermissionsAction(org.aisen.android.support.permissions.APermissionsAction)

Aggregations

IAction (org.aisen.android.support.action.IAction)4 WebLoginAction (org.aisen.weibo.sina.support.action.WebLoginAction)2 DialogAction (com.afollestad.materialdialogs.DialogAction)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 File (java.io.File)1 TaskException (org.aisen.android.network.task.TaskException)1 WorkTask (org.aisen.android.network.task.WorkTask)1 APermissionsAction (org.aisen.android.support.permissions.APermissionsAction)1 ABaseFragment (org.aisen.android.ui.fragment.ABaseFragment)1 SdcardPermissionAction (org.aisen.weibo.sina.support.permissions.SdcardPermissionAction)1