Search in sources :

Example 1 with SlidingPaneLayout

use of android.support.v4.widget.SlidingPaneLayout in project UltimateAndroid by cymcsg.

the class ParallaxSwipeBackActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    //通过反射来改变SlidingPanelayout的值
    try {
        slidingPaneLayout = new SlidingPaneLayout(this);
        Field f_overHang = SlidingPaneLayout.class.getDeclaredField("mOverhangSize");
        f_overHang.setAccessible(true);
        f_overHang.set(slidingPaneLayout, 0);
        slidingPaneLayout.setPanelSlideListener(this);
        slidingPaneLayout.setSliderFadeColor(getResources().getColor(android.R.color.transparent));
    } catch (Exception e) {
        e.printStackTrace();
    }
    super.onCreate(savedInstanceState);
    mFileTemp = new File(getCacheDir(), WINDOWBITMAP);
    defaultTranslationX = dip2px(defaultTranslationX);
    shadowWidth = dip2px(shadowWidth);
    //behindframeLayout
    FrameLayout behindframeLayout = new FrameLayout(this);
    behindImageView = new ImageView(this);
    behindImageView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    behindframeLayout.addView(behindImageView, 0);
    //containerLayout
    LinearLayout containerLayout = new LinearLayout(this);
    containerLayout.setOrientation(LinearLayout.HORIZONTAL);
    containerLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    containerLayout.setLayoutParams(new ViewGroup.LayoutParams(getWindowManager().getDefaultDisplay().getWidth() + shadowWidth, ViewGroup.LayoutParams.MATCH_PARENT));
    //you view container
    frameLayout = new FrameLayout(this);
    frameLayout.setBackgroundColor(getResources().getColor(android.R.color.white));
    frameLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    //add shadow
    shadowImageView = new ImageView(this);
    shadowImageView.setBackgroundResource(R.drawable.parallax_swipe_back_shadow);
    shadowImageView.setLayoutParams(new LinearLayout.LayoutParams(shadowWidth, LinearLayout.LayoutParams.MATCH_PARENT));
    containerLayout.addView(shadowImageView);
    containerLayout.addView(frameLayout);
    containerLayout.setTranslationX(-shadowWidth);
    //添加两个view
    slidingPaneLayout.addView(behindframeLayout, 0);
    slidingPaneLayout.addView(containerLayout, 1);
}
Also used : Field(java.lang.reflect.Field) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) SlidingPaneLayout(android.support.v4.widget.SlidingPaneLayout) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Example 2 with SlidingPaneLayout

use of android.support.v4.widget.SlidingPaneLayout in project Conversations by siacs.

the class ConversationActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mOpenConversation = savedInstanceState.getString(STATE_OPEN_CONVERSATION, null);
        mPanelOpen = savedInstanceState.getBoolean(STATE_PANEL_OPEN, true);
        int pos = savedInstanceState.getInt(STATE_FIRST_VISIBLE, -1);
        int offset = savedInstanceState.getInt(STATE_OFFSET_FROM_TOP, 1);
        if (pos >= 0 && offset <= 0) {
            Log.d(Config.LOGTAG, "retrieved scroll position from instanceState " + pos + ":" + offset);
            mScrollPosition = new Pair<>(pos, offset);
        } else {
            mScrollPosition = null;
        }
        String pending = savedInstanceState.getString(STATE_PENDING_URI, null);
        if (pending != null) {
            Log.d(Config.LOGTAG, "ConversationsActivity.onCreate() - restoring pending image uri");
            mPendingImageUris.clear();
            mPendingImageUris.add(Uri.parse(pending));
        }
    }
    setContentView(R.layout.fragment_conversations_overview);
    this.mConversationFragment = new ConversationFragment();
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.selected_conversation, this.mConversationFragment, "conversation");
    transaction.commit();
    listView = (EnhancedListView) findViewById(R.id.list);
    this.listAdapter = new ConversationAdapter(this, conversationList);
    listView.setAdapter(this.listAdapter);
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE);
    }
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View clickedView, int position, long arg3) {
            if (getSelectedConversation() != conversationList.get(position)) {
                setSelectedConversation(conversationList.get(position));
                ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation());
                conversationWasSelectedByKeyboard = false;
            }
            hideConversationsOverview();
            openConversation();
        }
    });
    listView.setDismissCallback(new EnhancedListView.OnDismissCallback() {

        @Override
        public EnhancedListView.Undoable onDismiss(final EnhancedListView enhancedListView, final int position) {
            final int index = listView.getFirstVisiblePosition();
            View v = listView.getChildAt(0);
            final int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
            try {
                swipedConversation = listAdapter.getItem(position);
            } catch (IndexOutOfBoundsException e) {
                return null;
            }
            listAdapter.remove(swipedConversation);
            xmppConnectionService.markRead(swipedConversation);
            final boolean formerlySelected = (getSelectedConversation() == swipedConversation);
            if (position == 0 && listAdapter.getCount() == 0) {
                endConversation(swipedConversation, false, true);
                return null;
            } else if (formerlySelected) {
                setSelectedConversation(listAdapter.getItem(0));
                ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation());
            }
            return new EnhancedListView.Undoable() {

                @Override
                public void undo() {
                    listAdapter.insert(swipedConversation, position);
                    if (formerlySelected) {
                        setSelectedConversation(swipedConversation);
                        ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation());
                    }
                    swipedConversation = null;
                    listView.setSelectionFromTop(index + (listView.getChildCount() < position ? 1 : 0), top);
                }

                @Override
                public void discard() {
                    if (!swipedConversation.isRead() && swipedConversation.getMode() == Conversation.MODE_SINGLE) {
                        swipedConversation = null;
                        return;
                    }
                    endConversation(swipedConversation, false, false);
                    swipedConversation = null;
                }

                @Override
                public String getTitle() {
                    if (swipedConversation.getMode() == Conversation.MODE_MULTI) {
                        return getResources().getString(R.string.title_undo_swipe_out_muc);
                    } else {
                        return getResources().getString(R.string.title_undo_swipe_out_conversation);
                    }
                }
            };
        }
    });
    listView.enableSwipeToDismiss();
    listView.setSwipingLayout(R.id.swipeable_item);
    listView.setUndoStyle(EnhancedListView.UndoStyle.SINGLE_POPUP);
    listView.setUndoHideDelay(5000);
    listView.setRequireTouchBeforeDismiss(false);
    mContentView = findViewById(R.id.content_view_spl);
    if (mContentView == null) {
        mContentView = findViewById(R.id.content_view_ll);
    }
    if (mContentView instanceof SlidingPaneLayout) {
        SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView;
        mSlidingPaneLayout.setShadowResource(R.drawable.es_slidingpane_shadow);
        mSlidingPaneLayout.setSliderFadeColor(0);
        mSlidingPaneLayout.setPanelSlideListener(new PanelSlideListener() {

            @Override
            public void onPanelOpened(View arg0) {
                mShouldPanelBeOpen.set(true);
                updateActionBarTitle();
                invalidateOptionsMenu();
                hideKeyboard();
                if (xmppConnectionServiceBound) {
                    xmppConnectionService.getNotificationService().setOpenConversation(null);
                }
                closeContextMenu();
            }

            @Override
            public void onPanelClosed(View arg0) {
                mShouldPanelBeOpen.set(false);
                listView.discardUndo();
                openConversation();
            }

            @Override
            public void onPanelSlide(View arg0, float arg1) {
            // TODO Auto-generated method stub
            }
        });
    }
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) PanelSlideListener(android.support.v4.widget.SlidingPaneLayout.PanelSlideListener) ConversationAdapter(eu.siacs.conversations.ui.adapter.ConversationAdapter) SlidingPaneLayout(android.support.v4.widget.SlidingPaneLayout) View(android.view.View) AdapterView(android.widget.AdapterView) EnhancedListView(de.timroes.android.listview.EnhancedListView) SuppressLint(android.annotation.SuppressLint) FragmentTransaction(android.app.FragmentTransaction) EnhancedListView(de.timroes.android.listview.EnhancedListView) ActionBar(android.app.ActionBar)

Example 3 with SlidingPaneLayout

use of android.support.v4.widget.SlidingPaneLayout in project Conversations by siacs.

the class ConversationActivity method hideConversationsOverview.

public void hideConversationsOverview() {
    if (mContentView instanceof SlidingPaneLayout) {
        SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView;
        mShouldPanelBeOpen.set(false);
        mSlidingPaneLayout.closePane();
    }
}
Also used : SlidingPaneLayout(android.support.v4.widget.SlidingPaneLayout)

Example 4 with SlidingPaneLayout

use of android.support.v4.widget.SlidingPaneLayout in project Rocket.Chat.Android by RocketChat.

the class MainActivity method setupSidebar.

private void setupSidebar() {
    SlidingPaneLayout pane = (SlidingPaneLayout) findViewById(R.id.sliding_pane);
    if (pane == null) {
        return;
    }
    final SlidingPaneLayout subPane = (SlidingPaneLayout) findViewById(R.id.sub_sliding_pane);
    pane.setPanelSlideListener(new SlidingPaneLayout.SimplePanelSlideListener() {

        @Override
        public void onPanelClosed(View panel) {
            super.onPanelClosed(panel);
            if (subPane != null) {
                subPane.closePane();
            }
        }
    });
    final DrawerArrowDrawable drawerArrowDrawable = new DrawerArrowDrawable(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
    toolbar.setNavigationIcon(drawerArrowDrawable);
    toolbar.setNavigationOnClickListener(view -> {
        if (pane.isSlideable() && !pane.isOpen()) {
            pane.openPane();
        }
    });
    //ref: ActionBarDrawerToggle#setProgress
    pane.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {

        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            drawerArrowDrawable.setProgress(slideOffset);
        }

        @Override
        public void onPanelOpened(View panel) {
            drawerArrowDrawable.setVerticalMirror(true);
        }

        @Override
        public void onPanelClosed(View panel) {
            drawerArrowDrawable.setVerticalMirror(false);
        }
    });
}
Also used : DrawerArrowDrawable(android.support.v7.graphics.drawable.DrawerArrowDrawable) SlidingPaneLayout(android.support.v4.widget.SlidingPaneLayout) View(android.view.View) RoomToolbar(chat.rocket.android.widget.RoomToolbar) Toolbar(android.support.v7.widget.Toolbar)

Example 5 with SlidingPaneLayout

use of android.support.v4.widget.SlidingPaneLayout in project wire-android by wireapp.

the class RootFragment method onBackPressed.

@Override
public boolean onBackPressed() {
    Fragment fragment = getChildFragmentManager().findFragmentByTag(ParticipantsDialogFragment.TAG);
    if (fragment instanceof OnBackPressedListener && ((OnBackPressedListener) fragment).onBackPressed()) {
        return true;
    }
    fragment = getChildFragmentManager().findFragmentById(R.id.fl__root__right_view);
    if (fragment instanceof OnBackPressedListener && ((OnBackPressedListener) fragment).onBackPressed()) {
        return true;
    }
    fragment = getChildFragmentManager().findFragmentById(R.id.fl__root__camera);
    if (fragment instanceof CameraFragment) {
        //TODO: https://wearezeta.atlassian.net/browse/AN-2311 Refactor camera into one view
        getControllerFactory().getCameraController().closeCamera(((CameraFragment) fragment).getCameraContext());
        return true;
    } else if (fragment instanceof OnBackPressedListener) {
        ((OnBackPressedListener) fragment).onBackPressed();
        return true;
    }
    fragment = getChildFragmentManager().findFragmentById(R.id.fl__root__giphy);
    if (fragment instanceof GiphySharingPreviewFragment) {
        if (!((GiphySharingPreviewFragment) fragment).onBackPressed()) {
            getControllerFactory().getGiphyController().cancel();
        }
        return true;
    }
    fragment = getChildFragmentManager().findFragmentById(R.id.fl__root__sketch);
    if (fragment instanceof OnBackPressedListener) {
        ((OnBackPressedListener) fragment).onBackPressed();
        return true;
    }
    if (getControllerFactory().getPickUserController().isShowingPickUser(IPickUserController.Destination.CONVERSATION_LIST)) {
        getControllerFactory().getPickUserController().hidePickUser(IPickUserController.Destination.CONVERSATION_LIST, true);
        return true;
    }
    if (slidingPaneLayout != null && !slidingPaneLayout.isOpen()) {
        slidingPaneLayout.openPane();
        return true;
    }
    return false;
}
Also used : OnBackPressedListener(com.waz.zclient.OnBackPressedListener) CameraFragment(com.waz.zclient.pages.main.profile.camera.CameraFragment) DrawingFragment(com.waz.zclient.pages.main.drawing.DrawingFragment) LocationFragment(com.waz.zclient.pages.main.conversation.LocationFragment) CollectionFragment(com.waz.zclient.conversation.CollectionFragment) Fragment(android.support.v4.app.Fragment) GiphySharingPreviewFragment(com.waz.zclient.pages.main.giphy.GiphySharingPreviewFragment) ConversationFragment(com.waz.zclient.pages.main.conversation.ConversationFragment) ParticipantsDialogFragment(com.waz.zclient.pages.main.participants.dialog.ParticipantsDialogFragment) PendingConnectRequestManagerFragment(com.waz.zclient.pages.main.connect.PendingConnectRequestManagerFragment) CameraFragment(com.waz.zclient.pages.main.profile.camera.CameraFragment) ConversationListManagerFragment(com.waz.zclient.pages.main.conversationlist.ConversationListManagerFragment) TabbedParticipantBodyFragment(com.waz.zclient.pages.main.participants.TabbedParticipantBodyFragment) ConnectRequestInboxManagerFragment(com.waz.zclient.pages.main.connect.ConnectRequestInboxManagerFragment) BaseFragment(com.waz.zclient.pages.BaseFragment) GiphySharingPreviewFragment(com.waz.zclient.pages.main.giphy.GiphySharingPreviewFragment)

Aggregations

SlidingPaneLayout (android.support.v4.widget.SlidingPaneLayout)8 View (android.view.View)3 ViewGroup (android.view.ViewGroup)2 FrameLayout (android.widget.FrameLayout)2 Manifest (android.Manifest)1 SuppressLint (android.annotation.SuppressLint)1 ActionBar (android.app.ActionBar)1 Activity (android.app.Activity)1 FragmentTransaction (android.app.FragmentTransaction)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 Snackbar (android.support.design.widget.Snackbar)1 InputConnectionCompat (android.support.v13.view.inputmethod.InputConnectionCompat)1 InputContentInfoCompat (android.support.v13.view.inputmethod.InputContentInfoCompat)1 DialogFragment (android.support.v4.app.DialogFragment)1 Fragment (android.support.v4.app.Fragment)1 BuildCompat (android.support.v4.os.BuildCompat)1