Search in sources :

Example 41 with OnClick

use of butterknife.OnClick in project Palm300Heroes by nicolite.

the class UserInfoActivity method onViewClicked.

@OnClick({ R.id.rl_user_avatar, R.id.rl_nickName, R.id.rl_user_pwd, R.id.rl_user_gender, R.id.user_logout })
public void onViewClicked(View view) {
    switch(view.getId()) {
        case R.id.rl_user_avatar:
            Matisse.from(this).choose(MimeType.of(MimeType.PNG, MimeType.JPEG)).countable(true).maxSelectable(1).restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED).thumbnailScale(0.85f).imageEngine(new GlideEngine()).forResult(REQUEST_CODE_CHOOSE_PICTURE);
            break;
        case R.id.rl_nickName:
            LinearLayout editor = (LinearLayout) getLayoutInflater().inflate(R.layout.item_single_eidtor, null, false);
            final EditText edInput = (EditText) editor.findViewById(R.id.ed_input);
            new AlertDialog.Builder(this).setTitle("请输入昵称").setView(editor).setPositiveButton("确定", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    String nickNameText = edInput.getText().toString();
                    if (TextUtils.isEmpty(nickNameText)) {
                        ToastUtils.showToastShort("昵称不能为空");
                        return;
                    }
                    nickName.setText(nickNameText);
                    user.setNickName(nickNameText);
                    saveUserInfo(user);
                }
            }).setNegativeButton("取消", null).show();
            break;
        case R.id.rl_user_pwd:
            LinearLayout changePwd = (LinearLayout) getLayoutInflater().inflate(R.layout.item_change_password, null, false);
            final EditText originPwd = (EditText) changePwd.findViewById(R.id.et_origin_pwd);
            final EditText newPwd = (EditText) changePwd.findViewById(R.id.et_new_pwd);
            final EditText newPwd2 = (EditText) changePwd.findViewById(R.id.et_new_pwd2);
            new AlertDialog.Builder(this).setTitle("修改密码").setView(changePwd).setPositiveButton("确认", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    String originPassword = originPwd.getText().toString();
                    String newPassword = newPwd.getText().toString();
                    String newPassword2 = newPwd2.getText().toString();
                    if (TextUtils.isEmpty(originPassword) || TextUtils.isEmpty(newPassword) || TextUtils.isEmpty(newPassword2)) {
                        ToastUtils.showToastShort("请填写完整");
                        return;
                    } else if (!newPassword.equals(newPassword2)) {
                        ToastUtils.showToastShort("两次输入的密码不一致");
                        return;
                    }
                    BmobUser.updateCurrentUserPassword(originPassword, newPassword, new UpdateListener() {

                        @Override
                        public void done(BmobException e) {
                            if (e == null) {
                                ToastUtils.showToastShort("修改成功!");
                                BmobUser.logOut();
                                UserInfoActivity.this.setResult(2);
                                finish();
                            } else {
                                ToastUtils.showToastShort("修改失败!");
                            }
                        }
                    });
                }
            }).setNegativeButton("取消", null).show();
            break;
        case R.id.rl_user_gender:
            final String[] items = { "男", "女" };
            selected = userData.getGender() == null ? 0 : (userData.getGender() ? 0 : 1);
            new AlertDialog.Builder(this).setTitle("请选择").setSingleChoiceItems(items, selected, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    selected = i;
                }
            }).setPositiveButton("确定", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    userGender.setImageResource(items[selected].equals("男") ? R.drawable.male : R.drawable.female);
                    user.setGender(items[selected].equals("男"));
                    saveUserInfo(user);
                }
            }).setNegativeButton("取消", null).show();
            break;
        case R.id.user_logout:
            BmobUser.logOut();
            UserInfoActivity.this.setResult(2);
            finish();
            break;
    }
}
Also used : EditText(android.widget.EditText) AlertDialog(android.support.v7.app.AlertDialog) BmobException(cn.bmob.v3.exception.BmobException) GlideEngine(com.zhihu.matisse.engine.impl.GlideEngine) DialogInterface(android.content.DialogInterface) UpdateListener(cn.bmob.v3.listener.UpdateListener) LinearLayout(android.widget.LinearLayout) OnClick(butterknife.OnClick)

Example 42 with OnClick

use of butterknife.OnClick in project Palm300Heroes by nicolite.

the class MoreFragment method onViewClick.

@OnClick({ R.id.theme_music, R.id.update, R.id.help, R.id.about, R.id.share, R.id.joinqq, R.id.user_root_view })
public void onViewClick(View view) {
    switch(view.getId()) {
        case R.id.theme_music:
            // Intent intent = new Intent(getActivity(), WebViewActivity.class);
            // Bundle bundle = new Bundle();
            // bundle.putInt("type", WebViewActivity.TYPE_THEME_MUSIC);
            // bundle.putString("url", Constants.MISSEVAN_PLAYLIST_URL);
            // bundle.putString("title", "主题曲");
            // intent.putExtras(bundle);
            // startActivity(intent);
            Intent intent = new Intent(getActivity(), ContainerActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("title", "主题曲");
            bundle.putInt("type", ContainerActivity.TYPE_THEME_MUSIC);
            intent.putExtras(bundle);
            startActivity(intent);
            break;
        case R.id.update:
            Beta.checkUpgrade();
            break;
        case R.id.help:
            Intent help = new Intent(getActivity(), HelpActivity.class);
            startActivity(help);
            break;
        case R.id.about:
            Intent about = new Intent(getActivity(), AboutActivity.class);
            startActivity(about);
            break;
        case R.id.share:
            Intent share = new Intent(Intent.ACTION_SEND);
            share.putExtra(Intent.EXTRA_TEXT, "掌上300英雄\n" + getString(R.string.mainPage));
            share.setType("text/plain");
            startActivity(share);
            break;
        case R.id.joinqq:
            joinQQGroup("wRl6tmw4JNr0iufx47gR2WXCqKyWPIXC");
            break;
        case R.id.user_root_view:
            User currentUser = BmobUser.getCurrentUser(User.class);
            if (currentUser == null) {
                Intent login = new Intent(getActivity(), LoginActivity.class);
                startActivityForResult(login, 200);
            } else {
                Intent userInfo = new Intent(getActivity(), UserInfoActivity.class);
                userInfo.putExtra("user_data", currentUser);
                startActivityForResult(userInfo, 100);
            }
            break;
    }
}
Also used : User(cn.nicolite.palm300heroes.model.bean.User) BmobUser(cn.bmob.v3.BmobUser) Bundle(android.os.Bundle) Intent(android.content.Intent) OnClick(butterknife.OnClick)

Example 43 with OnClick

use of butterknife.OnClick in project GankTouTiao by heqiangflytosky.

the class ArticleDetailActivity method onClick.

@OnClick({ R.id.menu_back, R.id.menu_more, R.id.favorite, R.id.share })
public void onClick(View view) {
    switch(view.getId()) {
        case R.id.menu_back:
            finish();
            break;
        case R.id.menu_more:
            final ListPopupWindow listPopupWindow = new ListPopupWindow(this);
            listPopupWindow.setAdapter(new ArrayAdapter<>(this, R.layout.abc_popup_menu_item_layout, getResources().getStringArray(R.array.article_detail_menu_more)));
            listPopupWindow.setAnchorView(view);
            listPopupWindow.setWidth(getResources().getDimensionPixelOffset(R.dimen.menu_more_pop_width));
            // listPopupWindow.setHorizontalOffset(0 - getResources().getDimensionPixelOffset(R.dimen.menu_more_pop_offset_right));
            listPopupWindow.setModal(true);
            listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
                    switch(position) {
                        case 0:
                            mWebView.clearView();
                            mWebView.reload();
                            break;
                        case 1:
                            AppUtils.copy(ArticleDetailActivity.this, mData.url);
                            break;
                        case 2:
                            AppUtils.startBrowser(ArticleDetailActivity.this, mData.url);
                            break;
                        default:
                            break;
                    }
                    listPopupWindow.dismiss();
                }
            });
            listPopupWindow.show();
            break;
        case R.id.favorite:
            BackgroundHandler.execute(new Runnable() {

                @Override
                public void run() {
                    if (isFavourite) {
                        boolean success = GankProviderHelper.getInstance().deleteFavouriteEntry(mData.gank_id, mData.gank_type);
                        if (success) {
                            if (!isDestroyed()) {
                                runOnUiThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        setFavorite(false);
                                    }
                                });
                            }
                        }
                    } else {
                        boolean success = GankProviderHelper.getInstance().saveFavouriteEntry(mData);
                        if (success) {
                            if (!isDestroyed()) {
                                runOnUiThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        setFavorite(true);
                                    }
                                });
                            }
                        }
                    }
                }
            });
            break;
        case R.id.share:
            AppUtils.share(this, mData.title, mData.url);
            break;
        default:
            break;
    }
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) OnClick(butterknife.OnClick)

Example 44 with OnClick

use of butterknife.OnClick in project GankTouTiao by heqiangflytosky.

the class AboutFragment method onClick.

@OnClick({ R.id.layout_favourite, R.id.layout_read_history, R.id.layout_about_author })
public void onClick(View view) {
    switch(view.getId()) {
        case R.id.layout_favourite:
            Intent favIntent = new Intent(getActivity(), FavouriteHistoryActivity.class);
            favIntent.putExtra(FavouriteHistoryActivity.ACTIVITY_TYPE, FavouriteHistoryActivity.ACTIVITY_TYPE_FAV);
            getActivity().startActivity(favIntent);
            break;
        case R.id.layout_read_history:
            Intent historyIntent = new Intent(getActivity(), FavouriteHistoryActivity.class);
            historyIntent.putExtra(FavouriteHistoryActivity.ACTIVITY_TYPE, FavouriteHistoryActivity.ACTIVITY_TYPE_HISTORY);
            getActivity().startActivity(historyIntent);
            break;
        case R.id.layout_about_author:
            Intent aboutIntent = new Intent(getActivity(), AboutMeActivity.class);
            getActivity().startActivity(aboutIntent);
            break;
    }
}
Also used : Intent(android.content.Intent) OnClick(butterknife.OnClick)

Example 45 with OnClick

use of butterknife.OnClick in project mapbox-plugins-android by mapbox.

the class AutocompleteLauncherActivity method onOverlayFabClick.

@OnClick(R.id.fabCard)
public void onOverlayFabClick(View view) {
    Intent intent = new PlaceAutocomplete.IntentBuilder().accessToken(Mapbox.getAccessToken()).placeOptions(PlaceOptions.builder().backgroundColor(Color.parseColor("#EEEEEE")).addInjectedFeature(home).addInjectedFeature(work).limit(10).build(PlaceOptions.MODE_CARDS)).build(AutocompleteLauncherActivity.this);
    startActivityForResult(intent, REQUEST_CODE_AUTOCOMPLETE);
}
Also used : Intent(android.content.Intent) PlaceAutocomplete(com.mapbox.mapboxsdk.plugins.places.autocomplete.PlaceAutocomplete) OnClick(butterknife.OnClick)

Aggregations

OnClick (butterknife.OnClick)465 Intent (android.content.Intent)206 View (android.view.View)24 AlertDialog (android.support.v7.app.AlertDialog)21 TextView (android.widget.TextView)18 File (java.io.File)18 Bundle (android.os.Bundle)16 BindView (butterknife.BindView)16 DialogInterface (android.content.DialogInterface)15 ArrayList (java.util.ArrayList)15 DialogFragment (com.rey.material.app.DialogFragment)13 SimpleDialog (com.rey.material.app.SimpleDialog)13 Uri (android.net.Uri)11 SimpleDateFormat (java.text.SimpleDateFormat)11 SuppressLint (android.annotation.SuppressLint)10 ImageView (android.widget.ImageView)10 LzyResponse (com.lzy.demo.model.LzyResponse)10 HorizontalChangeHandler (com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler)9 List (java.util.List)9 Animator (android.animation.Animator)8