Search in sources :

Example 21 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project Rashr by DsLNeXuS.

the class FlashFragment method showUnifiedBuildsDialog.

/**
     * Check if Device uses a Unified base like some Galaxy S4: htle, htltespr htltexx uses the same
     * sources so they can use the unified kernels and recoveries. Let the User choice which one is
     * the correct for him. PLEASE BE CAREFUL!
     */
public void showUnifiedBuildsDialog() {
    final AppCompatDialog UnifiedBuildsDialog = new AppCompatDialog(mContext);
    UnifiedBuildsDialog.setTitle(R.string.make_choice);
    final ArrayList<String> DevName = new ArrayList<>();
    ArrayList<String> DevNamesCarriers = new ArrayList<>();
    UnifiedBuildsDialog.setContentView(R.layout.dialog_unified_build);
    ListView UnifiedList = (ListView) UnifiedBuildsDialog.findViewById(R.id.lvUnifiedList);
    ArrayAdapter<String> UnifiedAdapter = new ArrayAdapter<>(mContext, android.R.layout.simple_list_item_1, DevNamesCarriers);
    if (UnifiedList != null) {
        UnifiedList.setAdapter(UnifiedAdapter);
        UnifiedList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
                UnifiedBuildsDialog.dismiss();
                final ProgressDialog reloading = new ProgressDialog(mContext);
                reloading.setMessage(mContext.getString(R.string.reloading));
                reloading.setCancelable(false);
                reloading.show();
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        Common.setBooleanPref(mContext, Const.PREF_NAME, Const.PREF_KEY_SHOW_UNIFIED, false);
                        RashrApp.DEVICE.setName(DevName.get(position));
                        RashrApp.DEVICE.loadRecoveryList();
                        mActivity.runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                reloading.dismiss();
                                mActivity.switchTo(FlashFragment.newInstance(mActivity));
                            }
                        });
                    }
                }).start();
            }
        });
    }
    if (RashrApp.DEVICE.getManufacture().equals("samsung")) {
        String[] unifiedGalaxyS3 = { "d2lte", "d2att", "d2cri", "d2mtr", "d2spr", "d2tmo", "d2usc", "d2vzw" };
        String[] unifiedGalaxyNote3 = { "hlte", "hltespr", "hltetmo", "hltevzw", "htlexx" };
        String[] unifiedGalaxyS4 = { "jflte", "jflteatt", "jfltecan", "jfltecri", "jfltecsp", "jfltespr", "jfltetmo", "jflteusc", "jfltevzw", "jfltexx", "jgedlte" };
        String[] unifiedGalaxyNote4 = { "trlte", "trltecan", "trltedt", "trltexx", "trltespr", "trltetmo", "trltevzw", "trlteusc" };
        if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyS3)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyS3));
        } else if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyS3)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyNote3));
        } else if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyS4)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyS4));
        } else if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyNote4)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyNote4));
        }
    }
    if (RashrApp.DEVICE.getManufacture().equals("motorola")) {
        String[] unifiedMsm8960 = { "moto_msm8960" };
        if (RashrApp.DEVICE.getBOARD().equals("msm8960")) {
            DevName.addAll(Arrays.asList(unifiedMsm8960));
        }
    }
    for (String i : DevName) {
        if (i.contains("att")) {
            DevNamesCarriers.add(i + " (AT&T Mobility)");
        } else if (i.contains("can")) {
            DevNamesCarriers.add(i + " (Canada)");
        } else if (i.contains("cri")) {
            DevNamesCarriers.add(i + " (Cricket Wireless)");
        } else if (i.contains("csp")) {
            DevNamesCarriers.add(i + " (C Spire Wireless)");
        } else if (i.contains("mtr")) {
            DevNamesCarriers.add(i + " (MetroPCS)");
        } else if (i.contains("spr")) {
            DevNamesCarriers.add(i + " (Sprint Corporation)");
        } else if (i.contains("tmo")) {
            DevNamesCarriers.add(i + " (T-Mobile US)");
        } else if (i.contains("usc")) {
            DevNamesCarriers.add(i + " (U.S. Cellular)");
        } else if (i.contains("vzw")) {
            DevNamesCarriers.add(i + " (Verizon Wireless)");
        } else if (i.contains("xx")) {
            DevNamesCarriers.add(i + " (International)");
        } else if (i.contains("ged")) {
            DevNamesCarriers.add(i + " (Google Play Edition)");
        } else if (i.contains("dt")) {
            DevNamesCarriers.add(i + " (India)");
        } else {
            DevNamesCarriers.add(i + " (Unified)");
        }
    }
    AppCompatButton KeepCurrent = (AppCompatButton) UnifiedBuildsDialog.findViewById(R.id.bKeepCurrent);
    if (KeepCurrent != null) {
        KeepCurrent.setText(String.format(getString(R.string.keep_current_name), RashrApp.DEVICE.getName()));
        KeepCurrent.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Common.setBooleanPref(mContext, Const.PREF_NAME, Const.PREF_KEY_SHOW_UNIFIED, false);
                UnifiedBuildsDialog.dismiss();
            }
        });
    }
    if (DevName.size() > 0) {
        UnifiedBuildsDialog.show();
        UnifiedBuildsDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                Common.setBooleanPref(mContext, Const.PREF_NAME, Const.PREF_KEY_SHOW_UNIFIED, false);
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) ProgressDialog(android.app.ProgressDialog) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) AppCompatButton(android.support.v7.widget.AppCompatButton) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) AppCompatDialog(android.support.v7.app.AppCompatDialog) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 22 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project Tusky by Vavassor.

the class ComposeActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_compose);
    ButterKnife.bind(this);
    // Setup the toolbar.
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(null);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        Drawable closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp);
        ThemeUtils.setDrawableTint(this, closeIcon, R.attr.compose_close_button_tint);
        actionBar.setHomeAsUpIndicator(closeIcon);
    }
    // Setup the interface buttons.
    floatingBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onSendClicked();
        }
    });
    pickBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onMediaPick();
        }
    });
    takeBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            initiateCameraApp();
        }
    });
    nsfwBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            toggleNsfw();
        }
    });
    visibilityBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showComposeOptions();
        }
    });
    /* Initialise all the state, or restore it from a previous run, to determine a "starting"
         * state. */
    SharedPreferences preferences = getPrivatePreferences();
    String startingVisibility;
    boolean startingHideText;
    String startingContentWarning = null;
    ArrayList<SavedQueuedMedia> savedMediaQueued = null;
    if (savedInstanceState != null) {
        showMarkSensitive = savedInstanceState.getBoolean("showMarkSensitive");
        startingVisibility = savedInstanceState.getString("statusVisibility");
        statusMarkSensitive = savedInstanceState.getBoolean("statusMarkSensitive");
        startingHideText = savedInstanceState.getBoolean("statusHideText");
        // Keep these until everything needed to put them in the queue is finished initializing.
        savedMediaQueued = savedInstanceState.getParcelableArrayList("savedMediaQueued");
        // These are for restoring an in-progress commit content operation.
        InputContentInfoCompat previousInputContentInfo = InputContentInfoCompat.wrap(savedInstanceState.getParcelable("commitContentInputContentInfo"));
        int previousFlags = savedInstanceState.getInt("commitContentFlags");
        if (previousInputContentInfo != null) {
            onCommitContentInternal(previousInputContentInfo, previousFlags);
        }
    } else {
        showMarkSensitive = false;
        startingVisibility = preferences.getString("rememberedVisibility", "public");
        statusMarkSensitive = false;
        startingHideText = false;
    }
    /* If the composer is started up as a reply to another post, override the "starting" state
         * based on what the intent from the reply request passes. */
    Intent intent = getIntent();
    String[] mentionedUsernames = null;
    inReplyToId = null;
    if (intent != null) {
        inReplyToId = intent.getStringExtra("in_reply_to_id");
        String replyVisibility = intent.getStringExtra("reply_visibility");
        if (replyVisibility != null && startingVisibility != null) {
            // Lowest possible visibility setting in response
            if (startingVisibility.equals("direct") || replyVisibility.equals("direct")) {
                startingVisibility = "direct";
            } else if (startingVisibility.equals("private") || replyVisibility.equals("private")) {
                startingVisibility = "private";
            } else if (startingVisibility.equals("unlisted") || replyVisibility.equals("unlisted")) {
                startingVisibility = "unlisted";
            } else {
                startingVisibility = replyVisibility;
            }
        }
        mentionedUsernames = intent.getStringArrayExtra("mentioned_usernames");
        if (inReplyToId != null) {
            startingHideText = !intent.getStringExtra("content_warning").equals("");
            if (startingHideText) {
                startingContentWarning = intent.getStringExtra("content_warning");
            }
        }
    }
    /* If the currently logged in account is locked, its posts should default to private. This
         * should override even the reply settings, so this must be done after those are set up. */
    if (preferences.getBoolean("loggedInAccountLocked", false)) {
        startingVisibility = "private";
    }
    // After the starting state is finalised, the interface can be set to reflect this state.
    setStatusVisibility(startingVisibility);
    postProgress.setVisibility(View.INVISIBLE);
    updateNsfwButtonColor();
    final ParserUtils parser = new ParserUtils(this);
    // Setup the main text field.
    // new String[] { "image/gif", "image/webp" }
    setEditTextMimeTypes(null);
    final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color);
    SpanUtils.highlightSpans(textEditor.getText(), mentionColour);
    textEditor.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            updateVisibleCharactersLeft();
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            SpanUtils.highlightSpans(editable, mentionColour);
        }
    });
    textEditor.addOnPasteListener(new EditTextTyped.OnPasteListener() {

        @Override
        public void onPaste() {
            parser.getPastedURLText(ComposeActivity.this);
        }
    });
    // Add any mentions to the text field when a reply is first composed.
    if (mentionedUsernames != null) {
        StringBuilder builder = new StringBuilder();
        for (String name : mentionedUsernames) {
            builder.append('@');
            builder.append(name);
            builder.append(' ');
        }
        textEditor.setText(builder);
        textEditor.setSelection(textEditor.length());
    }
    // Initialise the content warning editor.
    contentWarningEditor.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            updateVisibleCharactersLeft();
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    showContentWarning(startingHideText);
    if (startingContentWarning != null) {
        contentWarningEditor.setText(startingContentWarning);
    }
    // Initialise the empty media queue state.
    mediaQueued = new ArrayList<>();
    waitForMediaLatch = new CountUpDownLatch();
    statusAlreadyInFlight = false;
    // These can only be added after everything affected by the media queue is initialized.
    if (savedMediaQueued != null) {
        for (SavedQueuedMedia item : savedMediaQueued) {
            addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize);
        }
    } else if (intent != null && savedInstanceState == null) {
        /* Get incoming images being sent through a share action from another app. Only do this
             * when savedInstanceState is null, otherwise both the images from the intent and the
             * instance state will be re-queued. */
        String type = intent.getType();
        if (type != null) {
            if (type.startsWith("image/")) {
                List<Uri> uriList = new ArrayList<>();
                switch(intent.getAction()) {
                    case Intent.ACTION_SEND:
                        {
                            Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
                            if (uri != null) {
                                uriList.add(uri);
                            }
                            break;
                        }
                    case Intent.ACTION_SEND_MULTIPLE:
                        {
                            ArrayList<Uri> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
                            if (list != null) {
                                for (Uri uri : list) {
                                    if (uri != null) {
                                        uriList.add(uri);
                                    }
                                }
                            }
                            break;
                        }
                }
                for (Uri uri : uriList) {
                    long mediaSize = getMediaSize(getContentResolver(), uri);
                    pickMedia(uri, mediaSize);
                }
            } else if (type.equals("text/plain")) {
                String action = intent.getAction();
                if (action != null && action.equals(Intent.ACTION_SEND)) {
                    String text = intent.getStringExtra(Intent.EXTRA_TEXT);
                    if (text != null) {
                        int start = Math.max(textEditor.getSelectionStart(), 0);
                        int end = Math.max(textEditor.getSelectionEnd(), 0);
                        int left = Math.min(start, end);
                        int right = Math.max(start, end);
                        textEditor.getText().replace(left, right, text, 0, text.length());
                        parser.putInClipboardManager(this, text);
                        textEditor.onPaste();
                    }
                }
            }
        }
    }
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) CountUpDownLatch(com.keylesspalace.tusky.util.CountUpDownLatch) StringUtils.randomAlphanumericString(com.keylesspalace.tusky.util.StringUtils.randomAlphanumericString) Uri(android.net.Uri) InputContentInfoCompat(android.support.v13.view.inputmethod.InputContentInfoCompat) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) List(java.util.List) ArrayList(java.util.ArrayList) ParserUtils(com.keylesspalace.tusky.util.ParserUtils) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar) SharedPreferences(android.content.SharedPreferences) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Intent(android.content.Intent) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) EditTextTyped(com.keylesspalace.tusky.view.EditTextTyped)

Example 23 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project android_frameworks_base by ResurrectionRemix.

the class RecentPanelView method setupItemTouchHelper.

private void setupItemTouchHelper() {
    ItemTouchHelper touchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() {

        RecentCard card;

        int taskid;

        int initPos;

        int finalPos;

        boolean isSwipe;

        boolean unwantedDrag = true;

        @Override
        public boolean onMove(RecyclerView recyclerView, ViewHolder viewHolder, ViewHolder target) {
            /* We'll start multiwindow action in the clearView void, when the drag action
                and all animations are completed. Otherwise we'd do a loop action
                till the drag is completed for each onMove (wasting resources and making
                the drag not smooth).*/
            ExpandableCardAdapter.ViewHolder vh = (ExpandableCardAdapter.ViewHolder) viewHolder;
            vh.hideOptions(-1, -1);
            initPos = viewHolder.getAdapterPosition();
            card = (RecentCard) mCardAdapter.getCard(initPos);
            taskid = card.task.persistentTaskId;
            unwantedDrag = false;
            return true;
        }

        @Override
        public void onMoved(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, int fromPos, RecyclerView.ViewHolder target, int toPos, int x, int y) {
            finalPos = toPos;
            isSwipe = false;
        }

        @Override
        public float getMoveThreshold(RecyclerView.ViewHolder viewHolder) {
            // if less then this we consider it as unwanted drag
            return 0.2f;
        }

        @Override
        public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            super.clearView(recyclerView, viewHolder);
            if (isSwipe) {
                //don't start multiwindow on swipe
                return;
            }
            if (unwantedDrag) {
                /*this means MoveThreshold is less than needed, so onMove
                    has not been considered, so we don't consider the action as wanted drag*/
                return;
            }
            //restore the drag check
            unwantedDrag = true;
            boolean wasDocked = false;
            int dockSide = WindowManagerProxy.getInstance().getDockSide();
            if (dockSide != WindowManager.DOCKED_INVALID) {
                try {
                    //resize the docked stack to fullscreen to disable current multiwindow mode
                    ActivityManagerNative.getDefault().resizeStack(ActivityManager.StackId.DOCKED_STACK_ID, null, true, true, false, -1);
                } catch (RemoteException e) {
                }
                wasDocked = true;
            }
            ActivityOptions options = ActivityOptions.makeBasic();
            //0 means dock app to top, 1 to bottom
            options.setDockCreateMode(0);
            options.setLaunchStackId(ActivityManager.StackId.DOCKED_STACK_ID);
            Handler mHandler = new Handler();
            mHandler.postDelayed(new Runnable() {

                public void run() {
                    try {
                        card = (RecentCard) mCardAdapter.getCard(finalPos);
                        int newTaskid = card.task.persistentTaskId;
                        ActivityManagerNative.getDefault().startActivityFromRecents((finalPos > initPos) ? taskid : newTaskid, options.toBundle());
                        /*after we docked our main app, on the other side of the screen we
                            open the app we dragged the main app over*/
                        mController.openOnDraggedApptoOtherSide((finalPos > initPos) ? newTaskid : taskid);
                    } catch (RemoteException e) {
                    }
                }
            }, wasDocked ? 100 : 0);
        }

        @Override
        public boolean isLongPressDragEnabled() {
            return true;
        }

        @Override
        public void onSwiped(ViewHolder viewHolder, int direction) {
            int pos = viewHolder.getAdapterPosition();
            RecentCard card = (RecentCard) mCardAdapter.getCard(pos);
            mCardAdapter.removeCard(pos);
            removeApplication(card.task);
            isSwipe = true;
        }

        @Override
        public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            // Set movement flags based on the layout manager
            final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
            final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
            return makeMovementFlags(dragFlags, swipeFlags);
        }
    });
    touchHelper.attachToRecyclerView(mCardRecyclerView);
}
Also used : Handler(android.os.Handler) Paint(android.graphics.Paint) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) RecyclerView(android.support.v7.widget.RecyclerView) RemoteException(android.os.RemoteException) ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) ActivityOptions(android.app.ActivityOptions)

Example 24 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ManageAccountsSettings method updatePreferenceIntents.

/**
     * Filters through the preference list provided by GoogleLoginService.
     *
     * This method removes all the invalid intent from the list, adds account name as extra into the
     * intent, and hack the location settings to start it as a fragment.
     */
private void updatePreferenceIntents(PreferenceScreen prefs) {
    final PackageManager pm = getActivity().getPackageManager();
    for (int i = 0; i < prefs.getPreferenceCount(); ) {
        Preference pref = prefs.getPreference(i);
        Intent intent = pref.getIntent();
        if (intent != null) {
            // preference click event here directly.
            if (intent.getAction().equals(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)) {
                // The OnPreferenceClickListener overrides the click event completely. No intent
                // will get fired.
                pref.setOnPreferenceClickListener(new FragmentStarter(LocationSettings.class.getName(), R.string.location_settings_title));
            } else {
                ResolveInfo ri = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, mUserHandle.getIdentifier());
                if (ri == null) {
                    prefs.removePreference(pref);
                    continue;
                } else {
                    intent.putExtra(ACCOUNT_KEY, mFirstAccount);
                    intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
                    pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                        @Override
                        public boolean onPreferenceClick(Preference preference) {
                            Intent prefIntent = preference.getIntent();
                            /*
                                 * Check the intent to see if it resolves to a exported=false
                                 * activity that doesn't share a uid with the authenticator.
                                 *
                                 * Otherwise the intent is considered unsafe in that it will be
                                 * exploiting the fact that settings has system privileges.
                                 */
                            if (isSafeIntent(pm, prefIntent)) {
                                getActivity().startActivityAsUser(prefIntent, mUserHandle);
                            } else {
                                Log.e(TAG, "Refusing to launch authenticator intent because" + "it exploits Settings permissions: " + prefIntent);
                            }
                            return true;
                        }
                    });
                }
            }
        }
        i++;
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) PackageManager(android.content.pm.PackageManager) AccountPreference(com.android.settings.AccountPreference) Preference(android.support.v7.preference.Preference) Intent(android.content.Intent)

Example 25 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project EasyRecyclerView by Jude95.

the class DividerDecoration method onDrawOver.

public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (parent.getAdapter() == null) {
        return;
    }
    int orientation = 0;
    int headerCount = 0, footerCount = 0, dataCount;
    if (parent.getAdapter() instanceof RecyclerArrayAdapter) {
        headerCount = ((RecyclerArrayAdapter) parent.getAdapter()).getHeaderCount();
        footerCount = ((RecyclerArrayAdapter) parent.getAdapter()).getFooterCount();
        dataCount = ((RecyclerArrayAdapter) parent.getAdapter()).getCount();
    } else {
        dataCount = parent.getAdapter().getItemCount();
    }
    int dataStartPosition = headerCount;
    int dataEndPosition = headerCount + dataCount;
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof StaggeredGridLayoutManager) {
        orientation = ((StaggeredGridLayoutManager) layoutManager).getOrientation();
    } else if (layoutManager instanceof GridLayoutManager) {
        orientation = ((GridLayoutManager) layoutManager).getOrientation();
    } else if (layoutManager instanceof LinearLayoutManager) {
        orientation = ((LinearLayoutManager) layoutManager).getOrientation();
    }
    int start, end;
    if (orientation == OrientationHelper.VERTICAL) {
        start = parent.getPaddingLeft() + mPaddingLeft;
        end = parent.getWidth() - parent.getPaddingRight() - mPaddingRight;
    } else {
        start = parent.getPaddingTop() + mPaddingLeft;
        end = parent.getHeight() - parent.getPaddingBottom() - mPaddingRight;
    }
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        int position = parent.getChildAdapterPosition(child);
        if (//数据项除了最后一项
        position >= dataStartPosition && position < dataEndPosition - 1 || //数据项最后一项
        (position == dataEndPosition - 1 && mDrawLastItem) || //header&footer且可绘制
        (!(position >= dataStartPosition && position < dataEndPosition) && mDrawHeaderFooter)) {
            if (orientation == OrientationHelper.VERTICAL) {
                RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
                int top = child.getBottom() + params.bottomMargin;
                int bottom = top + mHeight;
                mColorDrawable.setBounds(start, top, end, bottom);
                mColorDrawable.draw(c);
            } else {
                RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
                int left = child.getRight() + params.rightMargin;
                int right = left + mHeight;
                mColorDrawable.setBounds(left, start, right, end);
                mColorDrawable.draw(c);
            }
        }
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerArrayAdapter(com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter) RecyclerView(android.support.v7.widget.RecyclerView) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

View (android.view.View)367 RecyclerView (android.support.v7.widget.RecyclerView)271 TextView (android.widget.TextView)175 Intent (android.content.Intent)109 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)84 Toolbar (android.support.v7.widget.Toolbar)77 TextWatcher (android.text.TextWatcher)77 Editable (android.text.Editable)76 ImageView (android.widget.ImageView)76 ArrayList (java.util.ArrayList)68 Bundle (android.os.Bundle)48 DialogInterface (android.content.DialogInterface)47 AlertDialog (android.support.v7.app.AlertDialog)47 AdapterView (android.widget.AdapterView)46 EditText (android.widget.EditText)42 SuppressLint (android.annotation.SuppressLint)39 Button (android.widget.Button)39 ActionBar (android.support.v7.app.ActionBar)34 List (java.util.List)34 ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)33