Android Open Source - Paginize Page Activity






From Project

Back to project page Paginize.

License

The source code is released under:

Copyright (c) 2014 neevek <i at neevek.net> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal ...

If you think the Android project Paginize listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.neevek.android.lib.paginize;
//from  www  .  j  a v a 2 s.  c  o  m
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import net.neevek.android.lib.paginize.annotation.InjectPageAnimator;
import net.neevek.android.lib.paginize.exception.InjectFailedException;
import net.neevek.android.lib.paginize.util.AnnotationUtils;
import net.neevek.android.lib.paginize.util.ViewFinder;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by neevek on 12/26/13.
 */
public class PageActivity extends Activity {
    private PageManager mPageManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPageManager = new PageManager((ViewGroup)findViewById(android.R.id.content));

        try {
            initAnnotatedFields();

        } catch (Exception e) {
            e.printStackTrace();
            throw new InjectFailedException(e);
        }
    }

    private void initAnnotatedFields() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException, InstantiationException {
        Class clazz = getClass();

        List<Class> list = new ArrayList<Class>();
        do {
            list.add(clazz);

            if (mPageManager.getPageAnimator() == null) {
                InjectPageAnimator pamAnnotation = (InjectPageAnimator)clazz.getAnnotation(InjectPageAnimator.class);
                if (pamAnnotation != null) {
                    mPageManager.setPageAnimator(pamAnnotation.value().newInstance());
                }
            }
        } while ((clazz = clazz.getSuperclass()) != PageActivity.class);

        ViewFinder viewFinder = new ViewFinder() {
            public View findViewById(int id) { return PageActivity.this.findViewById(id); }
        };
        for (int i = list.size() - 1; i >= 0; --i) {
            AnnotationUtils.initAnnotatedFields(list.get(i), this, viewFinder);
        }
    }

    public PageManager getPageManager() {
        return mPageManager;
    }

    //**************** methods to show a new page ****************//
    public void showPage(Class <? extends Page > pageClass, boolean animated) {
        showPage(pageClass, animated, null);
    }

    public void showPage(Class <? extends Page > pageClass, boolean animated, Object arg) {
        try {
            Page page = pageClass.getConstructor(PageActivity.class).newInstance(this);
            page.show(arg, animated);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void hideTopPage() {
        getPageManager().popPage(false, false);
    }

    public int getPageCount() {
        return mPageManager.getPageCount();
    }

    @Override
    public void onBackPressed() {
        if (!mPageManager.onBackPressed()) {
            finish();
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        mPageManager.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPageManager.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mPageManager.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPageManager.onDestroy();
    }


}




Java Source Code List

net.neevek.android.demo.paginize.activities.MainActivity.java
net.neevek.android.demo.paginize.pages.general.FrameInnerPage.java
net.neevek.android.demo.paginize.pages.general.FramePage.java
net.neevek.android.demo.paginize.pages.main.MainPage.java
net.neevek.android.demo.paginize.pages.main.TabPage1.java
net.neevek.android.demo.paginize.pages.main.TabPage2.java
net.neevek.android.demo.paginize.pages.other.AlertPage.java
net.neevek.android.demo.paginize.pages.other.ListItemPage.java
net.neevek.android.demo.paginize.pages.other.ListPage.java
net.neevek.android.demo.paginize.pages.other.TestPage.java
net.neevek.android.demo.paginize.pages.viewpager.MyViewPagerPage.java
net.neevek.android.demo.paginize.pages.viewpager.ViewPageSubPage1.java
net.neevek.android.demo.paginize.pages.viewpager.ViewPageSubPage2.java
net.neevek.android.lib.paginize.InnerPageContainer.java
net.neevek.android.lib.paginize.InnerPageManager.java
net.neevek.android.lib.paginize.InnerPage.java
net.neevek.android.lib.paginize.PageActivity.java
net.neevek.android.lib.paginize.PageDataCallback.java
net.neevek.android.lib.paginize.PageManager.java
net.neevek.android.lib.paginize.PagePagerAdapter.java
net.neevek.android.lib.paginize.Page.java
net.neevek.android.lib.paginize.ViewPagerInnerPage.java
net.neevek.android.lib.paginize.ViewPagerPage.java
net.neevek.android.lib.paginize.ViewWrapper.java
net.neevek.android.lib.paginize.anim.PageAnimator.java
net.neevek.android.lib.paginize.anim.SlidePageAnimator.java
net.neevek.android.lib.paginize.anim.ZoomPageAnimator.java
net.neevek.android.lib.paginize.annotation.DecoratePageConstructor.java
net.neevek.android.lib.paginize.annotation.InheritPageLayout.java
net.neevek.android.lib.paginize.annotation.InjectPageAnimator.java
net.neevek.android.lib.paginize.annotation.InjectView.java
net.neevek.android.lib.paginize.annotation.InnerPageContainerLayoutResId.java
net.neevek.android.lib.paginize.annotation.PageLayout.java
net.neevek.android.lib.paginize.annotation.SetListeners.java
net.neevek.android.lib.paginize.annotation.ViewPagerResId.java
net.neevek.android.lib.paginize.exception.InjectFailedException.java
net.neevek.android.lib.paginize.exception.NotImplementedInterfaceException.java
net.neevek.android.lib.paginize.util.AnnotationUtils.java
net.neevek.android.lib.paginize.util.ViewFinder.java