Search in sources :

Example 16 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project stillStanding by katsik.

the class GraphActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTheme(R.style.AppTheme);
    setContentView(R.layout.activity_graph);
    // Get a support ActionBar corresponding to this toolbar
    ActionBar ab = getSupportActionBar();
    // Enable the Up button
    ab.setDisplayHomeAsUpEnabled(true);
    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    GraphView graph = (GraphView) findViewById(R.id.graph);
    series = new LineGraphSeries<>();
    series.setColor(Color.BLUE);
    series.setThickness(10);
    graph.addSeries(series);
    series.setDrawBackground(true);
    // activate horizontal zooming and scrolling
    graph.getViewport().setScalable(true);
    // activate horizontal scrolling
    graph.getViewport().setScrollable(true);
    // activate horizontal and vertical zooming and scrolling
    graph.getViewport().setScalableY(true);
    // activate vertical scrolling
    graph.getViewport().setScrollableY(true);
    // To set a fixed manual viewport use this:
    // set manual X bounds
    graph.getViewport().setXAxisBoundsManual(true);
    graph.getViewport().setMinX(0.5);
    graph.getViewport().setMaxX(6.5);
    // set manual Y bounds
    graph.getViewport().setYAxisBoundsManual(true);
    graph.getViewport().setMinY(0);
    graph.getViewport().setMaxY(20);
    graph.setTitle(getString(R.string.graph_title));
    currentX = 0;
    // Start chart thread
    liveChartExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(1);
    if (liveChartExecutor != null)
        liveChartExecutor.execute(new AccelerationChart(new AccelerationChartHandler()));
}
Also used : GraphView(com.jjoe64.graphview.GraphView) ActionBar(android.support.v7.app.ActionBar)

Example 17 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project agera by google.

the class NotesFragment method onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    notesStore = notesStore(getContext().getApplicationContext());
    pool = new RecycledViewPool();
    final RowHandler<NoteGroup> rowHandler = rowBinder(pool, (r) -> new LinearLayoutManager(getContext(), HORIZONTAL, false), NoteGroup::getId, (r) -> dataBindingRepositoryPresenterOf(Note.class).layout(R.layout.text_layout).itemId(BR.note).handler(BR.click, (Receiver<Note>) (note) -> {
        final EditText editText = new EditText(getContext());
        editText.setId(R.id.edit);
        editText.setText(note.getNote());
        new AlertDialog.Builder(getContext()).setTitle(R.string.edit_note).setView(editText).setPositiveButton(R.string.edit, (d, i) -> notesStore.updateNote(note, editText.getText().toString())).create().show();
    }).handler(BR.longClick, (Receiver<Note>) notesStore::deleteNote).stableIdForItem(Note::getId).collectionId(BR.noteGroup).forCollection(NoteGroup::getNotes));
    adapter = repositoryAdapter().addLayout(layout(R.layout.header)).add(notesStore.getNotesRepository(), repositoryPresenterOf(NoteGroup.class).layout(R.layout.note_group_layout).stableIdForItem(NoteGroup::getId).bindWith(rowHandler).recycleWith(rowHandler).forList()).addItem(getInstance().format(new Date()), dataBindingRepositoryPresenterOf(String.class).layout(R.layout.footer).itemId(BR.string).forItem()).build();
    adapter.setHasStableIds(true);
    final DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    backgroundRepository = repositoryWithInitialValue(Result.<Bitmap>absent()).observe().onUpdatesPerLoop().goTo(networkExecutor).getFrom(() -> "http://www.gravatar.com/avatar/4df6f4fe5976df17deeea19443d4429d?s=" + Math.max(displayMetrics.heightPixels, displayMetrics.widthPixels)).transform(url -> httpGetRequest(url).compile()).attemptTransform(httpFunction()).orEnd(Result::failure).goTo(calculationExecutor).thenTransform(input -> {
        final byte[] body = input.getBody();
        return absentIfNull(decodeByteArray(body, 0, body.length));
    }).onDeactivation(SEND_INTERRUPT).compile();
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) Bundle(android.os.Bundle) RepositoryAdapter.repositoryAdapter(com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter) Date(java.util.Date) HttpFunctions.httpFunction(com.google.android.agera.net.HttpFunctions.httpFunction) LayoutPresenters.layout(com.google.android.agera.rvadapter.LayoutPresenters.layout) ImageView(android.widget.ImageView) Result(com.google.android.agera.Result) NonNull(android.support.annotation.NonNull) Repository(com.google.android.agera.Repository) RecycledViewPool(android.support.v7.widget.RecyclerView.RecycledViewPool) NotesStore.notesStore(com.google.android.agera.testapp.NotesStore.notesStore) RowHandler.rowBinder(com.google.android.agera.testapp.RowHandler.rowBinder) Result.absentIfNull(com.google.android.agera.Result.absentIfNull) DateFormat.getInstance(java.text.DateFormat.getInstance) View(android.view.View) Updatable(com.google.android.agera.Updatable) RepositoryAdapter(com.google.android.agera.rvadapter.RepositoryAdapter) Receiver(com.google.android.agera.Receiver) NoteGroupToID.noteGroupToID(com.google.android.agera.testapp.NoteGroupToID.noteGroupToID) Executor(java.util.concurrent.Executor) DataBindingRepositoryPresenters.dataBindingRepositoryPresenterOf(com.google.android.agera.rvdatabinding.DataBindingRepositoryPresenters.dataBindingRepositoryPresenterOf) LayoutInflater(android.view.LayoutInflater) Fragment(android.support.v4.app.Fragment) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Repositories.repositoryWithInitialValue(com.google.android.agera.Repositories.repositoryWithInitialValue) DisplayMetrics(android.util.DisplayMetrics) ViewGroup(android.view.ViewGroup) RepositoryPresenters.repositoryPresenterOf(com.google.android.agera.rvadapter.RepositoryPresenters.repositoryPresenterOf) AlertDialog(android.app.AlertDialog) RecyclerView(android.support.v7.widget.RecyclerView) Function(com.google.android.agera.Function) BitmapFactory.decodeByteArray(android.graphics.BitmapFactory.decodeByteArray) Bitmap(android.graphics.Bitmap) SEND_INTERRUPT(com.google.android.agera.RepositoryConfig.SEND_INTERRUPT) HttpRequests.httpGetRequest(com.google.android.agera.net.HttpRequests.httpGetRequest) Nullable(android.support.annotation.Nullable) HORIZONTAL(android.support.v7.widget.LinearLayoutManager.HORIZONTAL) EditText(android.widget.EditText) RecycledViewPool(android.support.v7.widget.RecyclerView.RecycledViewPool) Receiver(com.google.android.agera.Receiver) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DisplayMetrics(android.util.DisplayMetrics) Date(java.util.Date)

Example 18 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project AwesomeRecyclerView by forceLain.

the class AwesomeLayoutManager method fill.

private void fill(RecyclerView.Recycler recycler) {
    View anchorView = getAnchorView();
    viewCache.clear();
    for (int i = 0, cnt = getChildCount(); i < cnt; i++) {
        View view = getChildAt(i);
        int pos = getPosition(view);
        viewCache.put(pos, view);
    }
    for (int i = 0; i < viewCache.size(); i++) {
        detachView(viewCache.valueAt(i));
    }
    switch(orientation) {
        case VERTICAL:
            fillUp(anchorView, recycler);
            fillDown(anchorView, recycler);
            break;
        case HORIZONTAL:
            fillLeft(anchorView, recycler);
            fillRight(anchorView, recycler);
            break;
    }
    for (int i = 0; i < viewCache.size(); i++) {
        recycler.recycleView(viewCache.valueAt(i));
    }
    updateViewScale();
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 19 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project AndroidSwipeLayout by daimajia.

the class DividerItemDecoration method onDrawOver.

@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (mDivider == null) {
        super.onDrawOver(c, parent, state);
        return;
    }
    // Initialization needed to avoid compiler warning
    int left = 0, right = 0, top = 0, bottom = 0, size;
    int orientation = getOrientation(parent);
    int childCount = parent.getChildCount();
    if (orientation == LinearLayoutManager.VERTICAL) {
        size = mDivider.getIntrinsicHeight();
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
    } else {
        // horizontal
        size = mDivider.getIntrinsicWidth();
        top = parent.getPaddingTop();
        bottom = parent.getHeight() - parent.getPaddingBottom();
    }
    for (int i = mShowFirstDivider ? 0 : 1; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        if (orientation == LinearLayoutManager.VERTICAL) {
            top = child.getTop() - params.topMargin;
            bottom = top + size;
        } else {
            // horizontal
            left = child.getLeft() - params.leftMargin;
            right = left + size;
        }
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
    // show last divider
    if (mShowLastDivider && childCount > 0) {
        View child = parent.getChildAt(childCount - 1);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        if (orientation == LinearLayoutManager.VERTICAL) {
            top = child.getBottom() + params.bottomMargin;
            bottom = top + size;
        } else {
            // horizontal
            left = child.getRight() + params.rightMargin;
            right = left + size;
        }
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 20 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project android-advancedrecyclerview by h6ah4i.

the class RecyclerViewDragDropManager method handleScrollOnDragging.

/*package*/
void handleScrollOnDragging() {
    final RecyclerView rv = mRecyclerView;
    boolean horizontal;
    switch(CustomRecyclerViewUtils.getOrientation(rv)) {
        case CustomRecyclerViewUtils.ORIENTATION_VERTICAL:
            horizontal = false;
            break;
        case CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL:
            horizontal = true;
            break;
        default:
            return;
    }
    if (mNestedScrollView != null) {
        handleScrollOnDraggingInternalWithNestedScrollView(rv, horizontal);
    } else {
        handleScrollOnDraggingInternalWithRecyclerView(rv, horizontal);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)33 View (android.view.View)31 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)6 TextView (android.widget.TextView)5 ImageView (android.widget.ImageView)4 Context (android.content.Context)3 ViewGroup (android.view.ViewGroup)3 LayoutParams (com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams)3 Intent (android.content.Intent)2 Bitmap (android.graphics.Bitmap)2 Drawable (android.graphics.drawable.Drawable)2 Bundle (android.os.Bundle)2 NonNull (android.support.annotation.NonNull)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 AlertDialog (android.app.AlertDialog)1 PendingIntent (android.app.PendingIntent)1