Java源码示例:org.angmarch.views.NiceSpinner

示例1
private void initNicespinner(){//创建一个筛选器
    niceSpinner=(NiceSpinner)findViewById(R.id.chart_spinner);
    List<String> data=new LinkedList<>(Arrays.asList("饼状图","柱状图"));
    niceSpinner.attachDataSource(data);
    niceSpinner.addOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            switch (i){
                case 0:
                    relativeLayout.removeAllViews();
                    initPieChart();
                    break;
                case 1:
                    relativeLayout.removeAllViews();
                    initColumnChart();
                    break;
                default:
                    break;
            }
        }
    });
}
 
示例2
private void initdropView(){
    niceSpinner=(NiceSpinner)findViewById(R.id.list_spinner);
    List<String> data=new LinkedList<>(Arrays.asList("全部","工作","学习","生活","日记","旅行"));
    niceSpinner.attachDataSource(data);
    niceSpinner.addOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            switch (i){
                case 0:
                    prestenerImp_list.readNotefromDatatoList(0);
                    break;
                case 1:
                    prestenerImp_list.readNotefromDatatoList(1);
                    break;
                case 2:
                    prestenerImp_list.readNotefromDatatoList(2);
                    break;
                case 3:
                    prestenerImp_list.readNotefromDatatoList(3);
                    break;
                case 4:
                    prestenerImp_list.readNotefromDatatoList(4);
                    break;
                case 5:
                    prestenerImp_list.readNotefromDatatoList(5);
                    break;
                case 6:
                    prestenerImp_list.readNotefromDatatoList(6);
                    break;
                default:
                    break;
            }
        }
    });
}
 
示例3
private void initBackgroundcolorview(){//颜色选择
    niceSpinner=(NiceSpinner)this.findViewById(R.id.spiner_color_set);
    List<String>data=new LinkedList<>(Arrays.asList("默认","珊瑚朱","樱草紫","霓虹绿","绅士黑"));
    niceSpinner.attachDataSource(data);
    niceSpinner.addOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            switch (i){
                case 0:
                    prestenerImp_about.putcurrentcolorOnSeting(0);
                    prestenerImp_about.setBackgroundcolorfromSeting();
                    break;
                case 1:
                    prestenerImp_about.putcurrentcolorOnSeting(1);
                    prestenerImp_about.setBackgroundcolorfromSeting();
                    break;
                case 2:
                    prestenerImp_about.putcurrentcolorOnSeting(2);
                    prestenerImp_about.setBackgroundcolorfromSeting();
                    break;
                case 3:
                    prestenerImp_about.putcurrentcolorOnSeting(3);
                    prestenerImp_about.setBackgroundcolorfromSeting();
                    break;
                case 4:
                    prestenerImp_about.putcurrentcolorOnSeting(4);
                    prestenerImp_about.setBackgroundcolorfromSeting();
                    break;
                default:
                        break;

            }
            EventBus.getDefault().post(new MessageEvent(MessageEvent.UPDATA_COLOR));
        }
    });
}
 
示例4
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 初始化界面
    loginAlertDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE);
    loginAlertDialog.getProgressHelper().setBarColor(Color.parseColor("#A5DC86"));
    loginAlertDialog.setTitleText("正在登录,请稍候...");
    loginAlertDialog.setCancelable(false);
    // 透明
    setContentView(R.layout.activity_login);
    // 设置标题栏
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // 读取帐号密码
    EditText ed_username = findViewById(R.id.ed_username);
    EditText ed_pwd = findViewById(R.id.ed_pwd);
    SharedPreferences preferences = getSharedPreferences("login", MODE_PRIVATE);
    ed_username.setText(preferences.getString("username", ""));
    ed_pwd.setText(preferences.getString("pwd", ""));

    // 设置按钮事件
    Button actionButton = findViewById(R.id.bt_login);
    actionButton.setOnClickListener((v -> firstLogin()));
    // 设置服务器
    NiceSpinner sp_server = findViewById(R.id.sp_server);
    sp_server.attachDataSource(Arrays.asList("安卓", "IOS", "台服", "国际"));
    sp_server.setSelectedIndex(preferences.getInt("server", 0));
    // 连接更新服务器
    final CheckVersionCallBack callBack = new CheckVersionCallBack() {
        @Override
        public void onFinish() {
        }

        @Override
        public void onUpgrade(String newVersion, String newData) {
            if (Config.hasLogin) {
                return;
            }
            Looper.prepare();
            new SweetAlertDialog(LoginActivity.this, SweetAlertDialog.WARNING_TYPE)
                    .setTitleText("发现新版本")
                    .setContentText(String.format("新版本:%s\n更新日志:\n%s", newVersion, newData))
                    .setConfirmText("去下载")
                    .setCancelText("下次再说")
                    .setCancelClickListener(SweetAlertDialog::cancel)
                    .setConfirmClickListener((sweetAlertDialog) -> {
                        Uri uri = Uri.parse("https://github.com/ProtectorMoe/pe-protector-moe/releases");
                        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                        startActivity(intent);
                        sweetAlertDialog.cancel();
                        setResult(RESULT_CANCELED);
                        finish();
                    })
                    .show();
            Looper.loop();
        }

        @Override
        public void onError(String errMsg) {
            if (Config.hasLogin) {
                return;
            }
            Looper.prepare();
            new SweetAlertDialog(LoginActivity.this, SweetAlertDialog.ERROR_TYPE)
                    .setTitleText("错误")
                    .setContentText("连接更新服务器失败")
                    .setConfirmText("确定")
                    .setConfirmClickListener(SweetAlertDialog::cancel)
                    .show();
            Looper.loop();
        }
    };

    // 检测软件更新
    new Thread(() -> {
        try {
            PackageManager manager = getApplicationContext().getPackageManager();
            PackageInfo info = manager.getPackageInfo(getApplicationContext().getPackageName(), 0);
            int versionCode = info.versionCode;
            CheckVersionBean bean = NetSender.getInstance().checkVersion();
            if (bean.versionCode > versionCode) {
                callBack.onUpgrade(bean.versionName, bean.history.get(String.valueOf(bean.versionCode)));
            } else {
                callBack.onFinish();
            }
        } catch (Exception e) {
            callBack.onError(e.getMessage() + e.getLocalizedMessage());
        }
    }).start();
}