Search in sources :

Example 1 with WPViewPagerTransformer

use of org.wordpress.android.widgets.WPViewPagerTransformer in project WordPress-Android by wordpress-mobile.

the class NotificationsDetailActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    AppLog.i(AppLog.T.NOTIFS, "Creating NotificationsDetailActivity");
    setContentView(R.layout.notifications_detail_activity);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    if (savedInstanceState == null) {
        mNoteId = getIntent().getStringExtra(NotificationsListFragment.NOTE_ID_EXTRA);
    } else {
        if (savedInstanceState.containsKey(ARG_TITLE) && getSupportActionBar() != null) {
            getSupportActionBar().setTitle(StringUtils.notNullStr(savedInstanceState.getString(ARG_TITLE)));
        }
        mNoteId = savedInstanceState.getString(NotificationsListFragment.NOTE_ID_EXTRA);
    }
    if (mNoteId == null) {
        showErrorToastAndFinish();
        return;
    }
    final Note note = NotificationsTable.getNoteById(mNoteId);
    if (note == null) {
        showErrorToastAndFinish();
        return;
    }
    // If `note.getTimestamp()` is not the most recent seen note, the server will discard the value.
    NotificationsActions.updateSeenTimestamp(note);
    Map<String, String> properties = new HashMap<>();
    properties.put("notification_type", note.getType());
    AnalyticsTracker.track(AnalyticsTracker.Stat.NOTIFICATIONS_OPENED_NOTIFICATION_DETAILS, properties);
    //set up the viewpager and adapter for lateral navigation
    mViewPager = (WPViewPager) findViewById(R.id.viewpager);
    mViewPager.setPageTransformer(false, new WPViewPagerTransformer(WPViewPagerTransformer.TransformType.SLIDE_OVER));
    NotesAdapter.FILTERS filter = NotesAdapter.FILTERS.FILTER_ALL;
    if (getIntent().hasExtra(NotificationsListFragment.NOTE_CURRENT_LIST_FILTER_EXTRA)) {
        filter = (NotesAdapter.FILTERS) getIntent().getSerializableExtra(NotificationsListFragment.NOTE_CURRENT_LIST_FILTER_EXTRA);
    }
    mAdapter = buildNoteListAdapterAndSetPosition(note, filter);
    //set title
    setActionBarTitleForNote(note);
    markNoteAsRead(note);
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            AnalyticsTracker.track(AnalyticsTracker.Stat.NOTIFICATION_SWIPE_PAGE_CHANGED);
            AppPrefs.setNotificationsSwipeToNavigateShown(true);
            //change the action bar title for the current note
            Note currentNote = mAdapter.getNoteAtPosition(position);
            if (currentNote != null) {
                setActionBarTitleForNote(currentNote);
                markNoteAsRead(currentNote);
            }
        }
    });
    // Hide the keyboard, unless we arrived here from the 'Reply' action in a push notification
    if (!getIntent().getBooleanExtra(NotificationsListFragment.NOTE_INSTANT_REPLY_EXTRA, false)) {
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    }
}
Also used : NotesAdapter(org.wordpress.android.ui.notifications.adapters.NotesAdapter) WPViewPagerTransformer(org.wordpress.android.widgets.WPViewPagerTransformer) HashMap(java.util.HashMap) Note(org.wordpress.android.models.Note) ViewPager(android.support.v4.view.ViewPager) WPViewPager(org.wordpress.android.widgets.WPViewPager) ActionBar(android.support.v7.app.ActionBar)

Example 2 with WPViewPagerTransformer

use of org.wordpress.android.widgets.WPViewPagerTransformer in project WordPress-Android by wordpress-mobile.

the class ReaderPhotoViewerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.reader_activity_photo_viewer);
    mViewPager = (WPViewPager) findViewById(R.id.viewpager);
    mTxtTitle = (TextView) findViewById(R.id.text_title);
    // title is hidden until we know we can show it
    mTxtTitle.setVisibility(View.GONE);
    if (savedInstanceState != null) {
        mInitialImageUrl = savedInstanceState.getString(ReaderConstants.ARG_IMAGE_URL);
        mIsPrivate = savedInstanceState.getBoolean(ReaderConstants.ARG_IS_PRIVATE);
        mIsGallery = savedInstanceState.getBoolean(ReaderConstants.ARG_IS_GALLERY);
        mContent = savedInstanceState.getString(ReaderConstants.ARG_CONTENT);
    } else if (getIntent() != null) {
        mInitialImageUrl = getIntent().getStringExtra(ReaderConstants.ARG_IMAGE_URL);
        mIsPrivate = getIntent().getBooleanExtra(ReaderConstants.ARG_IS_PRIVATE, false);
        mIsGallery = getIntent().getBooleanExtra(ReaderConstants.ARG_IS_GALLERY, false);
        mContent = getIntent().getStringExtra(ReaderConstants.ARG_CONTENT);
    }
    mViewPager.setPageTransformer(false, new WPViewPagerTransformer(TransformType.FLOW));
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            updateTitle(position);
        }
    });
    mViewPager.setAdapter(getAdapter());
    loadImageList();
}
Also used : WPViewPagerTransformer(org.wordpress.android.widgets.WPViewPagerTransformer) ViewPager(android.support.v4.view.ViewPager) WPViewPager(org.wordpress.android.widgets.WPViewPager)

Example 3 with WPViewPagerTransformer

use of org.wordpress.android.widgets.WPViewPagerTransformer in project WordPress-Android by wordpress-mobile.

the class ReaderPostPagerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    setContentView(R.layout.reader_activity_post_pager);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    mViewPager = (WPViewPager) findViewById(R.id.viewpager);
    mProgress = (ProgressBar) findViewById(R.id.progress_loading);
    if (savedInstanceState != null) {
        mIsFeed = savedInstanceState.getBoolean(ReaderConstants.ARG_IS_FEED);
        mBlogId = savedInstanceState.getLong(ReaderConstants.ARG_BLOG_ID);
        mPostId = savedInstanceState.getLong(ReaderConstants.ARG_POST_ID);
        mDirectOperation = (DirectOperation) savedInstanceState.getSerializable(ReaderConstants.ARG_DIRECT_OPERATION);
        mCommentId = savedInstanceState.getInt(ReaderConstants.ARG_COMMENT_ID);
        mIsSinglePostView = savedInstanceState.getBoolean(ReaderConstants.ARG_IS_SINGLE_POST);
        mIsRelatedPostView = savedInstanceState.getBoolean(ReaderConstants.ARG_IS_RELATED_POST);
        mInterceptedUri = savedInstanceState.getString(ReaderConstants.ARG_INTERCEPTED_URI);
        if (savedInstanceState.containsKey(ReaderConstants.ARG_POST_LIST_TYPE)) {
            mPostListType = (ReaderPostListType) savedInstanceState.getSerializable(ReaderConstants.ARG_POST_LIST_TYPE);
        }
        if (savedInstanceState.containsKey(ReaderConstants.ARG_TAG)) {
            mCurrentTag = (ReaderTag) savedInstanceState.getSerializable(ReaderConstants.ARG_TAG);
        }
        mPostSlugsResolutionUnderway = savedInstanceState.getBoolean(ReaderConstants.KEY_POST_SLUGS_RESOLUTION_UNDERWAY);
        if (savedInstanceState.containsKey(ReaderConstants.KEY_TRACKED_POSITIONS)) {
            Serializable positions = savedInstanceState.getSerializable(ReaderConstants.KEY_TRACKED_POSITIONS);
            if (positions instanceof HashSet) {
                mTrackedPositions.addAll((HashSet<Integer>) positions);
            }
        }
    } else {
        mIsFeed = getIntent().getBooleanExtra(ReaderConstants.ARG_IS_FEED, false);
        mBlogId = getIntent().getLongExtra(ReaderConstants.ARG_BLOG_ID, 0);
        mPostId = getIntent().getLongExtra(ReaderConstants.ARG_POST_ID, 0);
        mDirectOperation = (DirectOperation) getIntent().getSerializableExtra(ReaderConstants.ARG_DIRECT_OPERATION);
        mCommentId = getIntent().getIntExtra(ReaderConstants.ARG_COMMENT_ID, 0);
        mIsSinglePostView = getIntent().getBooleanExtra(ReaderConstants.ARG_IS_SINGLE_POST, false);
        mIsRelatedPostView = getIntent().getBooleanExtra(ReaderConstants.ARG_IS_RELATED_POST, false);
        mInterceptedUri = getIntent().getStringExtra(ReaderConstants.ARG_INTERCEPTED_URI);
        if (getIntent().hasExtra(ReaderConstants.ARG_POST_LIST_TYPE)) {
            mPostListType = (ReaderPostListType) getIntent().getSerializableExtra(ReaderConstants.ARG_POST_LIST_TYPE);
        }
        if (getIntent().hasExtra(ReaderConstants.ARG_TAG)) {
            mCurrentTag = (ReaderTag) getIntent().getSerializableExtra(ReaderConstants.ARG_TAG);
        }
    }
    if (mPostListType == null) {
        mPostListType = ReaderPostListType.TAG_FOLLOWED;
    }
    // back button will navigate through related posts
    if (mIsRelatedPostView) {
        mToolbar.setNavigationIcon(R.drawable.ic_cross_white_24dp);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            onShowHideToolbar(true);
            trackPostAtPositionIfNeeded(position);
            if (mLastSelectedPosition > -1 && mLastSelectedPosition != position) {
                // pause the previous web view - important because otherwise embedded content
                // will continue to play
                ReaderPostDetailFragment lastFragment = getDetailFragmentAtPosition(mLastSelectedPosition);
                if (lastFragment != null) {
                    lastFragment.pauseWebView();
                }
                // don't show the swipe indicator in the future since the user knows how to swipe
                AppPrefs.setReaderSwipeToNavigateShown(true);
            }
            // resume the newly active webView if it was previously paused
            ReaderPostDetailFragment thisFragment = getDetailFragmentAtPosition(position);
            if (thisFragment != null) {
                thisFragment.resumeWebViewIfPaused();
            }
            mLastSelectedPosition = position;
            updateTitle(position);
        }
    });
    mViewPager.setPageTransformer(false, new WPViewPagerTransformer(WPViewPagerTransformer.TransformType.SLIDE_OVER));
}
Also used : Serializable(java.io.Serializable) WPViewPagerTransformer(org.wordpress.android.widgets.WPViewPagerTransformer) View(android.view.View) ViewPager(android.support.v4.view.ViewPager) WPViewPager(org.wordpress.android.widgets.WPViewPager) ActionBar(android.support.v7.app.ActionBar) HashSet(java.util.HashSet)

Aggregations

ViewPager (android.support.v4.view.ViewPager)3 WPViewPager (org.wordpress.android.widgets.WPViewPager)3 WPViewPagerTransformer (org.wordpress.android.widgets.WPViewPagerTransformer)3 ActionBar (android.support.v7.app.ActionBar)2 View (android.view.View)1 Serializable (java.io.Serializable)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Note (org.wordpress.android.models.Note)1 NotesAdapter (org.wordpress.android.ui.notifications.adapters.NotesAdapter)1