Search in sources :

Example 1 with RiseNumberTextView

use of com.nightonke.saver.ui.RiseNumberTextView in project CoCoin by Nightonke.

the class AccountBookTodayViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account_book_today_view);
    SuperToast.cancelAllSuperToasts();
    mContext = this;
    mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
    userName = (TextView) findViewById(R.id.user_name);
    userEmail = (TextView) findViewById(R.id.user_email);
    userName.setTypeface(CoCoinUtil.typefaceLatoRegular);
    userEmail.setTypeface(CoCoinUtil.typefaceLatoLight);
    User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
    if (user != null) {
        userName.setText(user.getUsername());
        userEmail.setText(user.getEmail());
    }
    setFonts();
    View view = mViewPager.getRootView();
    title = (TextView) view.findViewById(R.id.logo_white);
    title.setTypeface(CoCoinUtil.typefaceLatoLight);
    title.setText(SettingManager.getInstance().getAccountBookName());
    mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.GetTypeface(), Typeface.NORMAL);
    setTitle("");
    toolbar = mViewPager.getToolbar();
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    custom = (MaterialRippleLayout) mDrawer.findViewById(R.id.custom_layout);
    tags = (MaterialRippleLayout) mDrawer.findViewById(R.id.tag_layout);
    months = (MaterialRippleLayout) mDrawer.findViewById(R.id.month_layout);
    list = (MaterialRippleLayout) mDrawer.findViewById(R.id.list_layout);
    report = (MaterialRippleLayout) mDrawer.findViewById(R.id.report_layout);
    sync = (MaterialRippleLayout) mDrawer.findViewById(R.id.sync_layout);
    settings = (MaterialRippleLayout) mDrawer.findViewById(R.id.settings_layout);
    help = (MaterialRippleLayout) mDrawer.findViewById(R.id.help_layout);
    feedback = (MaterialRippleLayout) mDrawer.findViewById(R.id.feedback_layout);
    about = (MaterialRippleLayout) mDrawer.findViewById(R.id.about_layout);
    syncIcon = (MaterialIconView) mDrawer.findViewById(R.id.sync_icon);
    setIconEnable(syncIcon, SettingManager.getInstance().getLoggenOn());
    monthExpenseTip = (TextView) mDrawer.findViewById(R.id.month_expense_tip);
    monthExpenseTip.setTypeface(CoCoinUtil.GetTypeface());
    monthExpense = (RiseNumberTextView) mDrawer.findViewById(R.id.month_expense);
    monthExpense.setTypeface(CoCoinUtil.typefaceLatoLight);
    if (SettingManager.getInstance().getIsMonthLimit()) {
        monthExpenseTip.setVisibility(View.VISIBLE);
        monthExpense.setText("0");
    } else {
        monthExpenseTip.setVisibility(View.INVISIBLE);
        monthExpense.setVisibility(View.INVISIBLE);
    }
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setHomeButtonEnabled(true);
        }
    }
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, 0, 0) {

        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            monthExpense.setText("0");
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            monthExpense.withNumber(RecordManager.getCurrentMonthExpense()).setDuration(500).start();
        }
    };
    mDrawer.setDrawerListener(mDrawerToggle);
    View logo = findViewById(R.id.logo_white);
    if (logo != null) {
        logo.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mViewPager.notifyHeaderChanged();
            }
        });
    }
    todayModeAdapter = new TodayViewFragmentAdapter(getSupportFragmentManager());
    mViewPager.getViewPager().setOffscreenPageLimit(todayModeAdapter.getCount());
    mViewPager.getViewPager().setAdapter(todayModeAdapter);
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
    mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {

        @Override
        public HeaderDesign getHeaderDesign(int page) {
            return HeaderDesign.fromColorAndDrawable(CoCoinUtil.GetTagColor(page - 2), CoCoinUtil.GetTagDrawable(-3));
        }
    });
    setListeners();
    profileImage = (CircleImageView) mDrawer.findViewById(R.id.profile_image);
    profileImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (SettingManager.getInstance().getLoggenOn()) {
                CoCoinUtil.showToast(mContext, R.string.change_logo_tip);
            } else {
                CoCoinUtil.showToast(mContext, R.string.login_tip);
            }
        }
    });
    mDemoSlider = (SliderLayout) findViewById(R.id.slider);
    HashMap<String, Integer> urls = CoCoinUtil.GetDrawerTopUrl();
    for (String name : urls.keySet()) {
        CustomSliderView customSliderView = new CustomSliderView(this);
        // initialize a SliderLayout
        customSliderView.image(urls.get(name)).setScaleType(BaseSliderView.ScaleType.Fit);
        mDemoSlider.addSlider(customSliderView);
    }
    mDemoSlider.setPresetTransformer(SliderLayout.Transformer.ZoomOut);
    mDemoSlider.setCustomAnimation(new DescriptionAnimation());
    mDemoSlider.setDuration(4000);
    mDemoSlider.setCustomIndicator((PagerIndicator) findViewById(R.id.custom_indicator));
    loadLogo();
}
Also used : MaterialViewPager(com.github.florent37.materialviewpager.MaterialViewPager) BmobUser(cn.bmob.v3.BmobUser) User(com.nightonke.saver.model.User) HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) CustomSliderView(com.nightonke.saver.ui.CustomSliderView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) RiseNumberTextView(com.nightonke.saver.ui.RiseNumberTextView) View(android.view.View) TextView(android.widget.TextView) BaseSliderView(com.daimajia.slider.library.SliderTypes.BaseSliderView) CustomSliderView(com.nightonke.saver.ui.CustomSliderView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView) TodayViewFragmentAdapter(com.nightonke.saver.adapter.TodayViewFragmentAdapter) DescriptionAnimation(com.daimajia.slider.library.Animations.DescriptionAnimation) ActionBar(android.support.v7.app.ActionBar)

Example 2 with RiseNumberTextView

use of com.nightonke.saver.ui.RiseNumberTextView in project CoCoin by Nightonke.

the class AccountBookSettingActivity method init.

// Init the setting activity////////////////////////////////////////////////////////////////////////
private void init() {
    back = (MaterialIconView) findViewById(R.id.icon_left);
    back.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    logo = (CircleImageView) findViewById(R.id.profile_image);
    logo.setOnClickListener(this);
    profileLayout = (MaterialRippleLayout) findViewById(R.id.profile_layout);
    userNameIcon = (MaterialIconView) findViewById(R.id.user_name_icon);
    userEmailIcon = (MaterialIconView) findViewById(R.id.user_email_icon);
    userName = (TextView) findViewById(R.id.user_name);
    userName.setTypeface(CoCoinUtil.typefaceLatoLight);
    userEmail = (TextView) findViewById(R.id.user_email);
    userEmail.setTypeface(CoCoinUtil.typefaceLatoLight);
    loginButton = (TextView) findViewById(R.id.login_button);
    loginButton.setTypeface(CoCoinUtil.typefaceLatoLight);
    loginButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            userOperator();
        }
    });
    expense = (RiseNumberTextView) findViewById(R.id.expense);
    expense.setTypeface(CoCoinUtil.typefaceLatoLight);
    records = (RiseNumberTextView) findViewById(R.id.records);
    records.setTypeface(CoCoinUtil.typefaceLatoLight);
    expenseTV = (TextView) findViewById(R.id.expense_text);
    expenseTV.setTypeface(CoCoinUtil.GetTypeface());
    recordsTV = (TextView) findViewById(R.id.records_text);
    recordsTV.setTypeface(CoCoinUtil.GetTypeface());
    expense.withNumber(RecordManager.SUM).setDuration(1500).start();
    records.withNumber(RecordManager.RECORDS.size()).setDuration(1500).start();
    monthLayout = (MaterialRippleLayout) findViewById(R.id.month_layout);
    monthIcon = (MaterialIconView) findViewById(R.id.month_limit_icon);
    monthMaxExpenseIcon = (MaterialIconView) findViewById(R.id.month_expense_icon);
    monthColorRemindIcon = (MaterialIconView) findViewById(R.id.month_color_icon);
    monthWarningIcon = (MaterialIconView) findViewById(R.id.warning_expense_icon);
    monthColorRemindTypeIcon = (MaterialIconView) findViewById(R.id.month_color_type_icon);
    monthColorRemindSelect = (MaterialIconView) findViewById(R.id.month_color_type);
    monthColorRemindSelect.setColor(SettingManager.getInstance().getRemindColor());
    monthForbiddenIcon = (MaterialIconView) findViewById(R.id.month_forbidden_icon);
    monthSB = (Switch) findViewById(R.id.month_limit_enable_button);
    monthSB.setOnCheckedChangeListener(this);
    monthColorRemindSB = (Switch) findViewById(R.id.month_color_remind_button);
    monthColorRemindSB.setOnCheckedChangeListener(this);
    monthForbiddenSB = (Switch) findViewById(R.id.month_forbidden_button);
    monthForbiddenSB.setOnCheckedChangeListener(this);
    monthMaxExpense = (RiseNumberTextView) findViewById(R.id.month_expense);
    if (SettingManager.getInstance().getIsMonthLimit())
        monthMaxExpense.withNumber(SettingManager.getInstance().getMonthLimit()).setDuration(1000).start();
    // change the month limit///////////////////////////////////////////////////////////////////////////
    monthMaxExpense.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (SettingManager.getInstance().getIsMonthLimit()) {
                new MaterialDialog.Builder(mContext).theme(Theme.LIGHT).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).title(R.string.set_month_expense_dialog_title).inputType(InputType.TYPE_CLASS_NUMBER).positiveText(R.string.submit).inputRange(3, 5).input(SettingManager.getInstance().getMonthLimit().toString(), null, new MaterialDialog.InputCallback() {

                    @Override
                    public void onInput(MaterialDialog dialog, CharSequence input) {
                        int newExpense = SettingManager.getInstance().getMonthLimit();
                        if (input.length() != 0) {
                            newExpense = Integer.parseInt(input.toString());
                        }
                        // the month limit must be smaller than the month warning
                        if (newExpense < SettingManager.getInstance().getMonthWarning()) {
                            SettingManager.getInstance().setMonthWarning(((int) (newExpense * 0.8) / 100 * 100));
                            if (SettingManager.getInstance().getMonthWarning() < 100) {
                                SettingManager.getInstance().setMonthWarning(100);
                            }
                            updateSettingsToServer(UPDATE_MONTH_WARNING);
                            SettingManager.getInstance().setMainViewRemindColorShouldChange(true);
                            monthWarning.setText(SettingManager.getInstance().getMonthWarning().toString());
                        }
                        SettingManager.getInstance().setMonthLimit(newExpense);
                        updateSettingsToServer(UPDATE_MONTH_LIMIT);
                        SettingManager.getInstance().setTodayViewMonthExpenseShouldChange(true);
                        SettingManager.getInstance().setMainViewMonthExpenseShouldChange(true);
                        monthMaxExpense.withNumber(SettingManager.getInstance().getMonthLimit()).setDuration(1000).start();
                    }
                }).show();
            }
        }
    });
    monthWarning = (RiseNumberTextView) findViewById(R.id.warning_expense);
    monthWarning.setText(SettingManager.getInstance().getMonthWarning().toString());
    if (SettingManager.getInstance().getIsMonthLimit() && SettingManager.getInstance().getIsColorRemind())
        monthWarning.withNumber(SettingManager.getInstance().getMonthWarning()).setDuration(1000).start();
    // change month warning/////////////////////////////////////////////////////////////////////////////
    monthWarning.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (SettingManager.getInstance().getIsMonthLimit() && SettingManager.getInstance().getIsColorRemind()) {
                new MaterialDialog.Builder(mContext).theme(Theme.LIGHT).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).title(R.string.set_month_expense_dialog_title).inputType(InputType.TYPE_CLASS_NUMBER).positiveText(R.string.submit).alwaysCallInputCallback().input(null, null, new MaterialDialog.InputCallback() {

                    @Override
                    public void onInput(final MaterialDialog dialog, final CharSequence input) {
                        if (input.length() == 0) {
                            dialog.setContent(mContext.getResources().getString(R.string.set_warning_expense_dialog_title));
                            dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
                        } else if (Integer.parseInt(input.toString()) < 100) {
                            dialog.setContent("≥ 100");
                            dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
                        } else if (Integer.parseInt(input.toString()) > SettingManager.getInstance().getMonthLimit()) {
                            dialog.setContent("≤ " + SettingManager.getInstance().getMonthLimit().toString());
                            dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
                        } else {
                            dialog.setContent(mContext.getResources().getString(R.string.set_warning_expense_dialog_title));
                            dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
                        }
                        dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(new View.OnClickListener() {

                            @Override
                            public void onClick(View v) {
                                SettingManager.getInstance().setMonthWarning(Integer.parseInt(input.toString()));
                                updateSettingsToServer(UPDATE_MONTH_WARNING);
                                SettingManager.getInstance().setMainViewRemindColorShouldChange(true);
                                monthWarning.withNumber(SettingManager.getInstance().getMonthWarning()).setDuration(1000).start();
                                dialog.dismiss();
                            }
                        });
                    }
                }).show();
            }
        }
    });
    // change month remind color////////////////////////////////////////////////////////////////////////
    monthColorRemindSelect.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            SettingManager.getInstance().setMainViewRemindColorShouldChange(true);
            remindColorSelectDialog.show((AppCompatActivity) mContext);
        }
    });
    monthMaxExpense.setTypeface(CoCoinUtil.typefaceLatoLight);
    monthWarning.setTypeface(CoCoinUtil.typefaceLatoLight);
    monthLimitTV = (TextView) findViewById(R.id.month_limit_text);
    monthLimitTV.setTypeface(CoCoinUtil.GetTypeface());
    monthWarningTV = (TextView) findViewById(R.id.warning_expense_text);
    monthWarningTV.setTypeface(CoCoinUtil.GetTypeface());
    monthMaxExpenseTV = (TextView) findViewById(R.id.month_expense_text);
    monthMaxExpenseTV.setTypeface(CoCoinUtil.GetTypeface());
    monthColorRemindTV = (TextView) findViewById(R.id.month_color_remind_text);
    monthColorRemindTV.setTypeface(CoCoinUtil.GetTypeface());
    monthColorRemindTypeTV = (TextView) findViewById(R.id.month_color_type_text);
    monthColorRemindTypeTV.setTypeface(CoCoinUtil.GetTypeface());
    monthForbiddenTV = (TextView) findViewById(R.id.month_forbidden_text);
    monthForbiddenTV.setTypeface(CoCoinUtil.GetTypeface());
    accountBookNameLayout = (MaterialRippleLayout) findViewById(R.id.account_book_name_layout);
    accountBookNameLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            changeAccountBookName();
        }
    });
    accountBookName = (TextView) findViewById(R.id.account_book_name);
    accountBookName.setTypeface(CoCoinUtil.GetTypeface());
    accountBookName.setText(SettingManager.getInstance().getAccountBookName());
    accountBookNameTV = (TextView) findViewById(R.id.account_book_name_text);
    accountBookNameTV.setTypeface(CoCoinUtil.GetTypeface());
    changePasswordLayout = (MaterialRippleLayout) findViewById(R.id.change_password_layout);
    changePasswordLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            changePassword();
        }
    });
    changePasswordTV = (TextView) findViewById(R.id.change_password_text);
    changePasswordTV.setTypeface(CoCoinUtil.GetTypeface());
    sortTagsLayout = (MaterialRippleLayout) findViewById(R.id.sort_tags_layout);
    sortTagsLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            sortTags();
        }
    });
    sortTagsTV = (TextView) findViewById(R.id.sort_tags_text);
    sortTagsTV.setTypeface(CoCoinUtil.GetTypeface());
    showPictureLayout = (MaterialRippleLayout) findViewById(R.id.whether_show_picture_layout);
    showPictureIcon = (MaterialIconView) findViewById(R.id.whether_show_picture_icon);
    showPictureSB = (Switch) findViewById(R.id.whether_show_picture_button);
    showPictureSB.setOnCheckedChangeListener(this);
    showPictureTV = (TextView) findViewById(R.id.whether_show_picture_text);
    showPictureTV.setTypeface(CoCoinUtil.GetTypeface());
    hollowLayout = (MaterialRippleLayout) findViewById(R.id.whether_show_circle_layout);
    hollowIcon = (MaterialIconView) findViewById(R.id.whether_show_circle_icon);
    hollowSB = (Switch) findViewById(R.id.whether_show_circle_button);
    hollowSB.setOnCheckedChangeListener(this);
    hollowTV = (TextView) findViewById(R.id.whether_show_circle_text);
    hollowTV.setTypeface(CoCoinUtil.GetTypeface());
    updateLayout = (MaterialRippleLayout) findViewById(R.id.update_layout);
    updateLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            CoCoinUtil.showToast(mContext, mContext.getResources().getString(R.string.checking_update), SuperToast.Background.BLUE);
            AppUpdateManager appUpdateManager = new AppUpdateManager(mContext);
            appUpdateManager.checkUpdateInfo(true);
        }
    });
    currentVersionTV = (TextView) findViewById(R.id.update_text);
    currentVersionTV.setTypeface(CoCoinUtil.GetTypeface());
    currentVersionTV.setText(mContext.getResources().getString(R.string.current_version) + CoCoinUtil.GetCurrentVersion());
    canBeUpdatedTV = (TextView) findViewById(R.id.update_tag);
    canBeUpdatedTV.setTypeface(CoCoinUtil.GetTypeface());
    if (SettingManager.getInstance().getCanBeUpdated()) {
        canBeUpdatedTV.setVisibility(View.VISIBLE);
    } else {
        canBeUpdatedTV.setVisibility(View.GONE);
    }
    boolean loggenOn = SettingManager.getInstance().getLoggenOn();
    if (loggenOn) {
        // is logged on, set the user name and email
        userName.setText(SettingManager.getInstance().getUserName());
        userEmail.setText(SettingManager.getInstance().getUserEmail());
        loginButton.setText(mContext.getResources().getText(R.string.logout_button));
        loginButton.setBackgroundResource(R.drawable.button_logout);
    } else {
        userName.setText("");
        userEmail.setText("");
        loginButton.setText(getResourceString(R.string.login_button));
    }
    setIconEnable(userNameIcon, loggenOn);
    setIconEnable(userEmailIcon, loggenOn);
    loadLogo();
    monthSB.setCheckedImmediately(SettingManager.getInstance().getIsMonthLimit());
    setMonthState();
    showPictureSB.setCheckedImmediately(SettingManager.getInstance().getShowPicture());
    setShowPictureState(SettingManager.getInstance().getShowPicture());
    hollowSB.setCheckedImmediately(SettingManager.getInstance().getIsHollow());
    setHollowState(SettingManager.getInstance().getIsHollow());
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) AppCompatActivity(android.support.v7.app.AppCompatActivity) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) RiseNumberTextView(com.nightonke.saver.ui.RiseNumberTextView) View(android.view.View) TextView(android.widget.TextView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView) AppUpdateManager(com.nightonke.saver.model.AppUpdateManager)

Aggregations

View (android.view.View)2 TextView (android.widget.TextView)2 RiseNumberTextView (com.nightonke.saver.ui.RiseNumberTextView)2 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)2 MaterialIconView (net.steamcrafted.materialiconlib.MaterialIconView)2 ActionBar (android.support.v7.app.ActionBar)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 BmobUser (cn.bmob.v3.BmobUser)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 DescriptionAnimation (com.daimajia.slider.library.Animations.DescriptionAnimation)1 BaseSliderView (com.daimajia.slider.library.SliderTypes.BaseSliderView)1 MaterialViewPager (com.github.florent37.materialviewpager.MaterialViewPager)1 HeaderDesign (com.github.florent37.materialviewpager.header.HeaderDesign)1 TodayViewFragmentAdapter (com.nightonke.saver.adapter.TodayViewFragmentAdapter)1 AppUpdateManager (com.nightonke.saver.model.AppUpdateManager)1 User (com.nightonke.saver.model.User)1 CustomSliderView (com.nightonke.saver.ui.CustomSliderView)1