Search in sources :

Example 1 with SuperToast

use of com.github.johnpersano.supertoasts.SuperToast in project AnimeTaste by daimajia.

the class PlayActivity method setMaxSize.

@SuppressLint("InlinedApi")
private void setMaxSize() {
    if (Build.VERSION.SDK_INT >= 9) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    if (Build.MODEL.equals("M040")) {
        if (!mSharedPreferences.getBoolean("Meizu", false)) {
            SuperToast superToast = new SuperToast(this);
            superToast.setDuration(12000);
            superToast.setText("魅族某些版本固件可能存在兼容性问题,建议您升级到最新固件");
            superToast.setIcon(SuperToast.Icon.Dark.INFO, SuperToast.IconPosition.LEFT);
            superToast.show();
            mSharedPreferences.edit().putBoolean("Meizu", true).apply();
        }
    }
    getSupportActionBar().hide();
    RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(Screen.getScreenWidth(getWindowManager()), Screen.getScreenHeight(getWindowManager()));
    mHeaderWrapper.setLayoutParams(param);
    mVV.setLayoutParams(param);
    mZoomButton.setBackgroundResource(R.drawable.screensize_zoomin_button);
    mCurrentScape = OrientationHelper.LANDSCAPE;
}
Also used : SuperToast(com.github.johnpersano.supertoasts.SuperToast) RelativeLayout(android.widget.RelativeLayout) SuppressLint(android.annotation.SuppressLint)

Example 2 with SuperToast

use of com.github.johnpersano.supertoasts.SuperToast in project CoCoin by Nightonke.

the class ShowActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show);
    mContext = this;
    title = (TextView) findViewById(R.id.title);
    CoCoinUtil.init(mContext);
    title.setTypeface(CoCoinUtil.typefaceLatoLight);
    title.setText(mContext.getResources().getString(R.string.app_name));
    mViewPager = (SCViewPager) findViewById(R.id.viewpager_main_activity);
    mDotsView = (DotsView) findViewById(R.id.dotsview_main);
    mDotsView.setDotRessource(R.drawable.dot_selected, R.drawable.dot_unselected);
    mDotsView.setNumberOfPage(NUM_PAGES);
    mPageAdapter = new SCViewPagerAdapter(getSupportFragmentManager());
    mPageAdapter.setNumberOfPage(NUM_PAGES);
    mPageAdapter.setFragmentBackgroundColor(R.color.my_blue);
    mViewPager.setAdapter(mPageAdapter);
    mViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            mDotsView.selectDot(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    final Point size = SCViewAnimationUtil.getDisplaySize(this);
    int iconOffsetX = CoCoinUtil.getInstance().dpToPx(28);
    int iconOffsetY = CoCoinUtil.getInstance().dpToPx(28);
    SCViewAnimation sc0 = new SCViewAnimation(findViewById(R.id.icon_4));
    sc0.startToPosition(size.x / 4 - iconOffsetX, size.y * 2 / 7 - iconOffsetY);
    sc0.addPageAnimation(new SCPositionAnimation(this, 0, 0, size.y));
    mViewPager.addAnimation(sc0);
    SCViewAnimation sc1 = new SCViewAnimation(findViewById(R.id.icon_11));
    sc1.startToPosition(size.x * 3 / 4 - iconOffsetX, size.y * 3 / 7 - iconOffsetY);
    sc1.addPageAnimation(new SCPositionAnimation(this, 0, -size.x, 0));
    mViewPager.addAnimation(sc1);
    SCViewAnimation sc2 = new SCViewAnimation(findViewById(R.id.icon_12));
    sc2.startToPosition(size.x / 4 - iconOffsetX, size.y * 4 / 7 - iconOffsetY);
    sc2.addPageAnimation(new SCPositionAnimation(this, 0, size.x, 0));
    mViewPager.addAnimation(sc2);
    SCViewAnimation sc3 = new SCViewAnimation(findViewById(R.id.icon_19));
    sc3.startToPosition(size.x * 3 / 4 - iconOffsetX, size.y * 5 / 7 - iconOffsetY);
    sc3.addPageAnimation(new SCPositionAnimation(this, 0, 0, -size.y));
    mViewPager.addAnimation(sc3);
    ((TextView) findViewById(R.id.text_0)).setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    SCViewAnimation sc4 = new SCViewAnimation(findViewById(R.id.text_0));
    sc4.addPageAnimation(new SCPositionAnimation(this, 0, -size.x, 0));
    mViewPager.addAnimation(sc4);
    PieChartView pie = (PieChartView) findViewById(R.id.pie);
    List<SliceValue> values = new ArrayList<SliceValue>();
    for (int i = 0; i < 5; ++i) {
        SliceValue sliceValue = new SliceValue((float) Math.random() * 30 + 15, ContextCompat.getColor(CoCoinApplication.getAppContext(), R.color.white));
        values.add(sliceValue);
    }
    PieChartData pieData = new PieChartData(values);
    pieData.setHasLabels(false);
    pieData.setHasLabelsOnlyForSelected(false);
    pieData.setHasLabelsOutside(false);
    pieData.setHasCenterCircle(true);
    pie.setPieChartData(pieData);
    pie.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);
    SCViewAnimation sc5 = new SCViewAnimation(pie);
    sc5.startToPosition(size.x / 2, size.y / 9 - size.y);
    sc5.addPageAnimation(new SCPositionAnimation(this, 0, 0, size.y));
    sc5.addPageAnimation(new SCPositionAnimation(this, 1, 0, size.y));
    mViewPager.addAnimation(sc5);
    LineChartView line = (LineChartView) findViewById(R.id.line);
    List<Line> lines = new ArrayList<Line>();
    for (int i = 0; i < 1; ++i) {
        List<PointValue> pointValues = new ArrayList<PointValue>();
        pointValues.add(new PointValue(0, 50));
        pointValues.add(new PointValue(1, 100));
        pointValues.add(new PointValue(2, 20));
        pointValues.add(new PointValue(3, 0));
        pointValues.add(new PointValue(4, 10));
        pointValues.add(new PointValue(5, 15));
        pointValues.add(new PointValue(6, 40));
        pointValues.add(new PointValue(7, 60));
        pointValues.add(new PointValue(8, 100));
        Line aLine = new Line(pointValues);
        aLine.setColor(ContextCompat.getColor(CoCoinApplication.getAppContext(), R.color.white));
        aLine.setShape(ValueShape.CIRCLE);
        aLine.setCubic(false);
        aLine.setFilled(false);
        aLine.setHasLabels(false);
        aLine.setHasLabelsOnlyForSelected(false);
        aLine.setHasLines(true);
        aLine.setHasPoints(true);
        lines.add(aLine);
    }
    LineChartData linedata = new LineChartData(lines);
    linedata.setBaseValue(Float.NEGATIVE_INFINITY);
    line.setLineChartData(linedata);
    line.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);
    SCViewAnimation sc6 = new SCViewAnimation(line);
    sc6.startToPosition(-size.x, null);
    sc6.addPageAnimation(new SCPositionAnimation(this, 0, size.x, 0));
    sc6.addPageAnimation(new SCPositionAnimation(this, 1, size.x, 0));
    mViewPager.addAnimation(sc6);
    ColumnChartView histogram = (ColumnChartView) findViewById(R.id.histogram);
    List<Column> columns = new ArrayList<Column>();
    List<SubcolumnValue> subcolumnValues;
    for (int i = 0; i < 5; ++i) {
        subcolumnValues = new ArrayList<SubcolumnValue>();
        for (int j = 0; j < 1; ++j) {
            subcolumnValues.add(new SubcolumnValue((float) Math.random() * 50f + 5, ContextCompat.getColor(CoCoinApplication.getAppContext(), R.color.white)));
        }
        Column column = new Column(subcolumnValues);
        column.setHasLabels(false);
        column.setHasLabelsOnlyForSelected(false);
        columns.add(column);
    }
    ColumnChartData histogramData = new ColumnChartData(columns);
    histogram.setColumnChartData(histogramData);
    histogram.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);
    SCViewAnimation sc7 = new SCViewAnimation(histogram);
    sc7.startToPosition(size.x / 2 - CoCoinUtil.getInstance().dpToPx(140), size.y * 8 / 9 - CoCoinUtil.getInstance().dpToPx(140) + size.y);
    sc7.addPageAnimation(new SCPositionAnimation(this, 0, 0, -size.y));
    sc7.addPageAnimation(new SCPositionAnimation(this, 1, 0, size.y));
    mViewPager.addAnimation(sc7);
    ((TextView) findViewById(R.id.text_1)).setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    SCViewAnimation sc8 = new SCViewAnimation(findViewById(R.id.text_1));
    sc8.startToPosition(size.x, null);
    sc8.addPageAnimation(new SCPositionAnimation(this, 0, -size.x, 0));
    sc8.addPageAnimation(new SCPositionAnimation(this, 1, -size.x, 0));
    mViewPager.addAnimation(sc8);
    SCViewAnimation sc9 = new SCViewAnimation(findViewById(R.id.cloud));
    sc9.startToPosition(size.x / 2 - CoCoinUtil.getInstance().dpToPx(100) + size.x, size.y / 7);
    sc9.addPageAnimation(new SCPositionAnimation(this, 1, -size.x, 0));
    sc9.addPageAnimation(new SCPositionAnimation(this, 2, 0, size.y));
    mViewPager.addAnimation(sc9);
    SCViewAnimation sc10 = new SCViewAnimation(findViewById(R.id.mobile));
    sc10.startToPosition(size.x / 2 - size.x, size.y * 6 / 7 - CoCoinUtil.getInstance().dpToPx(100));
    sc10.addPageAnimation(new SCPositionAnimation(this, 1, size.x, 0));
    sc10.addPageAnimation(new SCPositionAnimation(this, 2, 0, -size.y));
    mViewPager.addAnimation(sc10);
    ((TextView) findViewById(R.id.text_2)).setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    SCViewAnimation sc11 = new SCViewAnimation(findViewById(R.id.text_2));
    sc11.startToPosition(size.x, null);
    sc11.addPageAnimation(new SCPositionAnimation(this, 1, -size.x, 0));
    sc11.addPageAnimation(new SCPositionAnimation(this, 2, -size.x, 0));
    mViewPager.addAnimation(sc11);
    ImageView remind1 = (ImageView) findViewById(R.id.remind_1);
    remind1.getLayoutParams().width = size.x / 3;
    remind1.getLayoutParams().height = size.x / 3 * 653 / 320;
    SCViewAnimation sc12 = new SCViewAnimation(findViewById(R.id.remind_1));
    sc12.startToPosition(size.x / 2 - size.x, size.y / 11);
    sc12.addPageAnimation(new SCPositionAnimation(this, 2, size.x, 0));
    sc12.addPageAnimation(new SCPositionAnimation(this, 3, size.x, 0));
    mViewPager.addAnimation(sc12);
    ImageView remind2 = (ImageView) findViewById(R.id.remind_2);
    remind2.getLayoutParams().width = size.x / 3;
    remind2.getLayoutParams().height = size.x / 3 * 653 / 320;
    SCViewAnimation sc13 = new SCViewAnimation(findViewById(R.id.remind_2));
    sc13.startToPosition(size.x / 2 + size.x - size.x / 3, size.y * 10 / 11 - remind1.getLayoutParams().height);
    sc13.addPageAnimation(new SCPositionAnimation(this, 2, -size.x, 0));
    sc13.addPageAnimation(new SCPositionAnimation(this, 3, -size.x, 0));
    mViewPager.addAnimation(sc13);
    ((TextView) findViewById(R.id.text_3)).setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    SCViewAnimation sc14 = new SCViewAnimation(findViewById(R.id.text_3));
    sc14.startToPosition(size.x, null);
    sc14.addPageAnimation(new SCPositionAnimation(this, 2, -size.x, 0));
    sc14.addPageAnimation(new SCPositionAnimation(this, 3, -size.x, 0));
    mViewPager.addAnimation(sc14);
    View statusBar = findViewById(R.id.status_bar);
    statusBar.setLayoutParams(new RelativeLayout.LayoutParams(statusBar.getLayoutParams().width, getStatusBarHeight()));
    SCViewAnimation statusBarAnimation = new SCViewAnimation(statusBar);
    statusBarAnimation.startToPosition(null, -getStatusBarHeight());
    statusBarAnimation.addPageAnimation(new SCPositionAnimation(this, 3, 0, getStatusBarHeight()));
    mViewPager.addAnimation(statusBarAnimation);
    toolbarLayout = findViewById(R.id.toolbar_layout);
    SCViewAnimation toolbarLayoutAnimation = new SCViewAnimation(toolbarLayout);
    toolbarLayoutAnimation.startToPosition(null, -size.y / 2);
    toolbarLayoutAnimation.addPageAnimation(new SCPositionAnimation(this, 3, 0, size.y / 2));
    mViewPager.addAnimation(toolbarLayoutAnimation);
    passwordAdapter = new PasswordChangeFragmentAdapter(getSupportFragmentManager());
    viewPager = (ViewPager) findViewById(R.id.viewpager);
    viewPager.setScrollBarFadeDuration(700);
    viewPager.setAdapter(passwordAdapter);
    myGridView = (MyGridView) findViewById(R.id.gridview);
    myGridViewAdapter = new PasswordChangeButtonGridViewAdapter(this);
    myGridView.setAdapter(myGridViewAdapter);
    myGridView.setOnItemClickListener(gridViewClickListener);
    myGridView.setOnItemLongClickListener(gridViewLongClickListener);
    myGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            myGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            View lastChild = myGridView.getChildAt(myGridView.getChildCount() - 1);
            RelativeLayout.LayoutParams relativeLayout = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, lastChild.getBottom());
            relativeLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            myGridView.setLayoutParams(relativeLayout);
            DisplayMetrics displaymetrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
            int height = displaymetrics.heightPixels;
            RelativeLayout.LayoutParams viewPagerLayoutParams = new RelativeLayout.LayoutParams(viewPager.getLayoutParams().width, 800);
            viewPagerLayoutParams.topMargin = getStatusBarHeight() + CoCoinUtil.getToolBarHeight(mContext) / 2;
            viewPager.setLayoutParams(viewPagerLayoutParams);
        }
    });
    superToast = new SuperToast(this);
    SCViewAnimation gridViewAnimation = new SCViewAnimation(myGridView);
    gridViewAnimation.startToPosition(null, size.y);
    gridViewAnimation.addPageAnimation(new SCPositionAnimation(this, 3, 0, -size.y));
    mViewPager.addAnimation(gridViewAnimation);
    SCViewAnimation viewpagerAnimation = new SCViewAnimation(viewPager);
    viewpagerAnimation.startToPosition(null, -size.y);
    viewpagerAnimation.addPageAnimation(new SCPositionAnimation(this, 3, 0, size.y));
    mViewPager.addAnimation(viewpagerAnimation);
    View background = findViewById(R.id.background);
    SCViewAnimation backgroundAnimation = new SCViewAnimation(background);
    backgroundAnimation.startToPosition(null, -size.y - 100);
    backgroundAnimation.addPageAnimation(new SCPositionAnimation(this, 3, 0, size.y + 100));
    mViewPager.addAnimation(backgroundAnimation);
}
Also used : SuperToast(com.github.johnpersano.supertoasts.SuperToast) ArrayList(java.util.ArrayList) SliceValue(lecho.lib.hellocharts.model.SliceValue) SCViewPagerAdapter(com.dev.sacot41.scviewpager.SCViewPagerAdapter) DisplayMetrics(android.util.DisplayMetrics) PasswordChangeButtonGridViewAdapter(com.nightonke.saver.adapter.PasswordChangeButtonGridViewAdapter) Column(lecho.lib.hellocharts.model.Column) LineChartData(lecho.lib.hellocharts.model.LineChartData) SubcolumnValue(lecho.lib.hellocharts.model.SubcolumnValue) TextView(android.widget.TextView) LineChartView(lecho.lib.hellocharts.view.LineChartView) ImageView(android.widget.ImageView) ViewTreeObserver(android.view.ViewTreeObserver) SCViewAnimation(com.dev.sacot41.scviewpager.SCViewAnimation) PointValue(lecho.lib.hellocharts.model.PointValue) PieChartView(lecho.lib.hellocharts.view.PieChartView) PieChartData(lecho.lib.hellocharts.model.PieChartData) Point(android.graphics.Point) SCViewPager(com.dev.sacot41.scviewpager.SCViewPager) ViewPager(android.support.v4.view.ViewPager) ImageView(android.widget.ImageView) View(android.view.View) MyGridView(com.nightonke.saver.ui.MyGridView) PieChartView(lecho.lib.hellocharts.view.PieChartView) AdapterView(android.widget.AdapterView) DotsView(com.dev.sacot41.scviewpager.DotsView) TextView(android.widget.TextView) LineChartView(lecho.lib.hellocharts.view.LineChartView) ColumnChartView(lecho.lib.hellocharts.view.ColumnChartView) Point(android.graphics.Point) Line(lecho.lib.hellocharts.model.Line) PasswordChangeFragmentAdapter(com.nightonke.saver.adapter.PasswordChangeFragmentAdapter) SCPositionAnimation(com.dev.sacot41.scviewpager.SCPositionAnimation) RelativeLayout(android.widget.RelativeLayout) ColumnChartData(lecho.lib.hellocharts.model.ColumnChartData) ColumnChartView(lecho.lib.hellocharts.view.ColumnChartView)

Example 3 with SuperToast

use of com.github.johnpersano.supertoasts.SuperToast in project CoCoin by Nightonke.

the class AccountBookSettingActivity method showToast.

// Show toast///////////////////////////////////////////////////////////////////////////////////////
private void showToast(int toastType, String msg) {
    Log.d("CoCoin", msg);
    SuperToast.cancelAllSuperToasts();
    SuperToast superToast = new SuperToast(mContext);
    superToast.setAnimations(CoCoinUtil.TOAST_ANIMATION);
    superToast.setDuration(SuperToast.Duration.LONG);
    superToast.setTextColor(Color.parseColor("#ffffff"));
    superToast.setTextSize(SuperToast.TextSize.SMALL);
    String tip = "";
    switch(toastType) {
        case 0:
            // the new account book name is updated to server successfully
            superToast.setText(CoCoinApplication.getAppContext().getResources().getString(R.string.change_and_update_account_book_name_successfully));
            superToast.setBackground(SuperToast.Background.BLUE);
            break;
        case 1:
            // the new account book name is failed to updated to server
            superToast.setText(CoCoinApplication.getAppContext().getResources().getString(R.string.change_and_update_account_book_name_fail));
            superToast.setBackground(SuperToast.Background.RED);
            break;
        case 2:
            // the new account book name is changed successfully
            superToast.setText(CoCoinApplication.getAppContext().getResources().getString(R.string.change_account_book_name_successfully));
            superToast.setBackground(SuperToast.Background.BLUE);
            break;
        case 3:
            // the new account book name is failed to change
            superToast.setText(CoCoinApplication.getAppContext().getResources().getString(R.string.change_account_book_name_fail));
            superToast.setBackground(SuperToast.Background.RED);
            break;
        case 4:
            // register successfully
            tip = msg;
            superToast.setText(getResourceString(R.string.register_successfully) + tip);
            superToast.setBackground(SuperToast.Background.BLUE);
            break;
        case 5:
            // register failed
            tip = getResourceString(R.string.network_disconnection);
            if (msg.charAt(1) == 's')
                tip = getResourceString(R.string.user_name_exist);
            if (msg.charAt(0) == 'e')
                tip = getResourceString(R.string.user_email_exist);
            if (msg.charAt(1) == 'n')
                tip = getResourceString(R.string.user_mobile_exist);
            superToast.setText(getResourceString(R.string.register_fail) + tip);
            superToast.setBackground(SuperToast.Background.RED);
            break;
        case 6:
            // login successfully
            tip = msg;
            superToast.setText(getResourceString(R.string.login_successfully) + tip);
            superToast.setBackground(SuperToast.Background.BLUE);
            break;
        case 7:
            // login failed
            tip = getResourceString(R.string.network_disconnection);
            if (msg.charAt(0) == 'u')
                tip = getResourceString(R.string.user_name_or_password_incorrect);
            if (msg.charAt(1) == 'n')
                tip = getResourceString(R.string.user_mobile_exist);
            superToast.setText(getResourceString(R.string.login_fail) + tip);
            superToast.setBackground(SuperToast.Background.RED);
            break;
        case 8:
            // log out successfully
            superToast.setText(getResourceString(R.string.log_out_successfully));
            superToast.setBackground(SuperToast.Background.BLUE);
            break;
        case 9:
            // sync settings successfully
            superToast.setText(getResourceString(R.string.sync_to_server_successfully));
            superToast.setBackground(SuperToast.Background.BLUE);
            break;
        case 10:
            // sync settings failed
            tip = getResourceString(R.string.network_disconnection);
            superToast.setText(getResourceString(R.string.sync_to_server_failed) + tip);
            superToast.setBackground(SuperToast.Background.RED);
            break;
    }
    superToast.getTextView().setTypeface(CoCoinUtil.GetTypeface());
    superToast.show();
}
Also used : SuperToast(com.github.johnpersano.supertoasts.SuperToast)

Example 4 with SuperToast

use of com.github.johnpersano.supertoasts.SuperToast in project CoCoin by Nightonke.

the class EditRecordActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_record);
    overridePendingTransition(R.anim.trans_left_in, R.anim.trans_left_out);
    mContext = this;
    superToast = new SuperToast(this);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        position = extras.getInt("POSITION");
        CoCoinUtil.editRecordPosition = RecordManager.SELECTED_RECORDS.size() - 1 - position;
    } else {
        CoCoinUtil.editRecordPosition = -1;
    }
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion >= Build.VERSION_CODES.LOLLIPOP) {
        // Do something for lollipop and above versions
        Window window = this.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(ContextCompat.getColor(mContext, R.color.statusBarColor));
    } else {
    // do something for phones running an SDK before lollipop
    }
    // edit viewpager///////////////////////////////////////////////////////////////////////////////////
    editViewPager = (CoCoinScrollableViewPager) findViewById(R.id.edit_pager);
    editViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
    editAdapter = new EditMoneyRemarkFragmentAdapter(getSupportFragmentManager(), CoCoinFragmentManager.EDIT_RECORD_ACTIVITY_FRAGMENT);
    editViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (position == 1) {
                CoCoinFragmentManager.editRecordActivityEditRemarkFragment.editRequestFocus();
            } else {
                CoCoinFragmentManager.editRecordActivityEditMoneyFragment.editRequestFocus();
            }
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    editViewPager.setAdapter(editAdapter);
    // tag viewpager////////////////////////////////////////////////////////////////////////////////////
    tagViewPager = (ViewPager) findViewById(R.id.viewpager);
    tagViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
    if (RecordManager.TAGS.size() % 8 == 0)
        tagAdapter = new TagChooseFragmentAdapter(getSupportFragmentManager(), RecordManager.TAGS.size() / 8);
    else
        tagAdapter = new TagChooseFragmentAdapter(getSupportFragmentManager(), RecordManager.TAGS.size() / 8 + 1);
    tagViewPager.setAdapter(tagAdapter);
    myGridView = (MyGridView) findViewById(R.id.gridview);
    myGridViewAdapter = new ButtonGridViewAdapter(this);
    myGridView.setAdapter(myGridViewAdapter);
    myGridView.setOnItemClickListener(gridViewClickListener);
    myGridView.setOnItemLongClickListener(gridViewLongClickListener);
    myGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            myGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            View lastChild = myGridView.getChildAt(myGridView.getChildCount() - 1);
            myGridView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, lastChild.getBottom()));
        }
    });
    back = (MaterialIconView) findViewById(R.id.back);
    back.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
}
Also used : Window(android.view.Window) Bundle(android.os.Bundle) SuperToast(com.github.johnpersano.supertoasts.SuperToast) ViewPager(android.support.v4.view.ViewPager) CoCoinUnscrollableViewPager(com.nightonke.saver.ui.CoCoinUnscrollableViewPager) CoCoinScrollableViewPager(com.nightonke.saver.ui.CoCoinScrollableViewPager) View(android.view.View) MyGridView(com.nightonke.saver.ui.MyGridView) AdapterView(android.widget.AdapterView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView) EditMoneyRemarkFragmentAdapter(com.nightonke.saver.adapter.EditMoneyRemarkFragmentAdapter) ButtonGridViewAdapter(com.nightonke.saver.adapter.ButtonGridViewAdapter) ViewTreeObserver(android.view.ViewTreeObserver) TagChooseFragmentAdapter(com.nightonke.saver.adapter.TagChooseFragmentAdapter)

Example 5 with SuperToast

use of com.github.johnpersano.supertoasts.SuperToast in project CoCoin by Nightonke.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mContext = this;
    //        Bmob.initialize(CoCoinApplication.getAppContext(), CoCoin.APPLICATION_ID);
    //        CrashReport.initCrashReport(CoCoinApplication.getAppContext(), "900016815", false);
    //        RecordManager.getInstance(CoCoinApplication.getAppContext());
    //        CoCoinUtil.init(CoCoinApplication.getAppContext());
    appUpdateManager = new AppUpdateManager(mContext);
    appUpdateManager.checkUpdateInfo(false);
    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    Sensor magneticSensor = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    Sensor accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    sensorManager.registerListener(listener, magneticSensor, SensorManager.SENSOR_DELAY_GAME);
    sensorManager.registerListener(listener, accelerometerSensor, SensorManager.SENSOR_DELAY_GAME);
    superToast = new SuperToast(this);
    superActivityToast = new SuperActivityToast(this, SuperToast.Type.PROGRESS_HORIZONTAL);
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    Log.d("Saver", "Version number: " + currentapiVersion);
    if (currentapiVersion >= Build.VERSION_CODES.LOLLIPOP) {
        // Do something for lollipop and above versions
        Window window = this.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(ContextCompat.getColor(mContext, R.color.statusBarColor));
    } else {
    // do something for phones running an SDK before lollipop
    }
    User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
    if (user != null) {
        SettingManager.getInstance().setLoggenOn(true);
        SettingManager.getInstance().setUserName(user.getUsername());
        SettingManager.getInstance().setUserEmail(user.getEmail());
        showToast(WELCOME_BACK);
    // 允许用户使用应用
    } else {
        SettingManager.getInstance().setLoggenOn(false);
    //缓存用户对象为空时, 可打开用户注册界面…
    }
    guillotineBackground = findViewById(R.id.guillotine_background);
    toolBarTitle = (TextView) findViewById(R.id.guillotine_title);
    toolBarTitle.setTypeface(CoCoinUtil.typefaceLatoLight);
    toolBarTitle.setText(SettingManager.getInstance().getAccountBookName());
    // edit viewpager///////////////////////////////////////////////////////////////////////////////////
    editViewPager = (CoCoinScrollableViewPager) findViewById(R.id.edit_pager);
    editAdapter = new EditMoneyRemarkFragmentAdapter(getSupportFragmentManager(), CoCoinFragmentManager.MAIN_ACTIVITY_FRAGMENT);
    editViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (position == 1) {
                if (CoCoinFragmentManager.mainActivityEditRemarkFragment != null)
                    CoCoinFragmentManager.mainActivityEditRemarkFragment.editRequestFocus();
            } else {
                if (CoCoinFragmentManager.mainActivityEditMoneyFragment != null)
                    CoCoinFragmentManager.mainActivityEditMoneyFragment.editRequestFocus();
            }
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    editViewPager.setAdapter(editAdapter);
    // tag viewpager////////////////////////////////////////////////////////////////////////////////////
    tagViewPager = (ViewPager) findViewById(R.id.viewpager);
    if (RecordManager.getInstance(mContext).TAGS.size() % 8 == 0)
        tagAdapter = new TagChooseFragmentAdapter(getSupportFragmentManager(), RecordManager.TAGS.size() / 8);
    else
        tagAdapter = new TagChooseFragmentAdapter(getSupportFragmentManager(), RecordManager.TAGS.size() / 8 + 1);
    tagViewPager.setAdapter(tagAdapter);
    // button grid view/////////////////////////////////////////////////////////////////////////////////
    myGridView = (MyGridView) findViewById(R.id.gridview);
    myGridViewAdapter = new ButtonGridViewAdapter(this);
    myGridView.setAdapter(myGridViewAdapter);
    myGridView.setOnItemClickListener(gridViewClickListener);
    myGridView.setOnItemLongClickListener(gridViewLongClickListener);
    myGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            myGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            View lastChild = myGridView.getChildAt(myGridView.getChildCount() - 1);
            myGridView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, lastChild.getBottom()));
            ViewGroup.LayoutParams params = transparentLy.getLayoutParams();
            params.height = myGridView.getMeasuredHeight();
        }
    });
    ButterKnife.inject(this);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        getSupportActionBar().setTitle(null);
    }
    toolbar.hideOverflowMenu();
    guillotineMenu = LayoutInflater.from(this).inflate(R.layout.guillotine, null);
    root.addView(guillotineMenu);
    transparentLy = (LinearLayout) guillotineMenu.findViewById(R.id.transparent_ly);
    guillotineColorLy = (LinearLayout) guillotineMenu.findViewById(R.id.guillotine_color_ly);
    guillotineToolBar = (Toolbar) guillotineMenu.findViewById(R.id.toolbar);
    menuToolBarTitle = (TextView) guillotineMenu.findViewById(R.id.guillotine_title);
    menuToolBarTitle.setTypeface(CoCoinUtil.typefaceLatoLight);
    menuToolBarTitle.setText(SettingManager.getInstance().getAccountBookName());
    radioButton0 = (RadioButton) guillotineMenu.findViewById(R.id.radio_button_0);
    radioButton1 = (RadioButton) guillotineMenu.findViewById(R.id.radio_button_1);
    radioButton2 = (RadioButton) guillotineMenu.findViewById(R.id.radio_button_2);
    radioButton3 = (RadioButton) guillotineMenu.findViewById(R.id.radio_button_3);
    passwordTip = (TextView) guillotineMenu.findViewById(R.id.password_tip);
    passwordTip.setText(mContext.getResources().getString(R.string.password_tip));
    passwordTip.setTypeface(CoCoinUtil.typefaceLatoLight);
    radioButtonLy = (LinearLayout) guillotineMenu.findViewById(R.id.radio_button_ly);
    statusButton = (MaterialMenuView) guillotineMenu.findViewById(R.id.status_button);
    statusButton.setState(MaterialMenuDrawable.IconState.ARROW);
    statusButton.setOnClickListener(statusButtonOnClickListener);
    animation = new GuillotineAnimation.GuillotineBuilder(guillotineMenu, guillotineMenu.findViewById(R.id.guillotine_hamburger), contentHamburger).setStartDelay(RIPPLE_DURATION).setActionBarViewForAnimation(toolbar).setClosedOnStart(true).setGuillotineListener(new GuillotineListener() {

        @Override
        public void onGuillotineOpened() {
            isPassword = true;
        }

        @Override
        public void onGuillotineClosed() {
            isPassword = false;
            CoCoinFragmentManager.mainActivityEditMoneyFragment.editRequestFocus();
            radioButton0.setChecked(false);
            radioButton1.setChecked(false);
            radioButton2.setChecked(false);
            radioButton3.setChecked(false);
            inputPassword = "";
            statusButton.setState(MaterialMenuDrawable.IconState.ARROW);
        }
    }).build();
    toolbar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            animation.open();
        }
    });
    if (SettingManager.getInstance().getFirstTime()) {
        Intent intent = new Intent(mContext, ShowActivity.class);
        startActivity(intent);
    }
    if (SettingManager.getInstance().getShowMainActivityGuide()) {
        boolean wrapInScrollView = true;
        new MaterialDialog.Builder(this).title(R.string.guide).typeface(CoCoinUtil.GetTypeface(), CoCoinUtil.GetTypeface()).customView(R.layout.main_activity_guide, wrapInScrollView).positiveText(R.string.ok).show();
        SettingManager.getInstance().setShowMainActivityGuide(false);
    }
}
Also used : BmobUser(cn.bmob.v3.BmobUser) User(com.nightonke.saver.model.User) SuperToast(com.github.johnpersano.supertoasts.SuperToast) ButtonGridViewAdapter(com.nightonke.saver.adapter.ButtonGridViewAdapter) ViewTreeObserver(android.view.ViewTreeObserver) TagChooseFragmentAdapter(com.nightonke.saver.adapter.TagChooseFragmentAdapter) Window(android.view.Window) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) SuperActivityToast(com.github.johnpersano.supertoasts.SuperActivityToast) Intent(android.content.Intent) ViewPager(android.support.v4.view.ViewPager) CoCoinScrollableViewPager(com.nightonke.saver.ui.CoCoinScrollableViewPager) InjectView(butterknife.InjectView) View(android.view.View) MyGridView(com.nightonke.saver.ui.MyGridView) AdapterView(android.widget.AdapterView) MaterialMenuView(com.balysv.materialmenu.MaterialMenuView) TextView(android.widget.TextView) AppUpdateManager(com.nightonke.saver.model.AppUpdateManager) EditMoneyRemarkFragmentAdapter(com.nightonke.saver.adapter.EditMoneyRemarkFragmentAdapter) GuillotineListener(com.nightonke.saver.ui.guillotine.interfaces.GuillotineListener) Sensor(android.hardware.Sensor)

Aggregations

SuperToast (com.github.johnpersano.supertoasts.SuperToast)15 ViewPager (android.support.v4.view.ViewPager)5 View (android.view.View)5 ViewTreeObserver (android.view.ViewTreeObserver)5 AdapterView (android.widget.AdapterView)5 TextView (android.widget.TextView)5 MyGridView (com.nightonke.saver.ui.MyGridView)5 Window (android.view.Window)4 PasswordChangeButtonGridViewAdapter (com.nightonke.saver.adapter.PasswordChangeButtonGridViewAdapter)3 PasswordChangeFragmentAdapter (com.nightonke.saver.adapter.PasswordChangeFragmentAdapter)3 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)2 Interpolator (android.view.animation.Interpolator)2 RelativeLayout (android.widget.RelativeLayout)2 ButtonGridViewAdapter (com.nightonke.saver.adapter.ButtonGridViewAdapter)2 EditMoneyRemarkFragmentAdapter (com.nightonke.saver.adapter.EditMoneyRemarkFragmentAdapter)2 TagChooseFragmentAdapter (com.nightonke.saver.adapter.TagChooseFragmentAdapter)2 CoCoinScrollableViewPager (com.nightonke.saver.ui.CoCoinScrollableViewPager)2 FixedSpeedScroller (com.nightonke.saver.ui.FixedSpeedScroller)2 Field (java.lang.reflect.Field)2 MaterialIconView (net.steamcrafted.materialiconlib.MaterialIconView)2