Search in sources :

Example 91 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Space-Station-Tracker by Kiarasht.

the class Locations method onCreate.

/**
     * Assign simple widgets while also use the Google API to get user's location.
     *
     * @param savedInstanceState on create method
     */
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.locations_layout);
    mActivity = this;
    LinearLayoutManager layoutManager = new LinearLayoutManager(mActivity, LinearLayoutManager.VERTICAL, false);
    mRecyclerView = (ObservableRecyclerView) findViewById(R.id.recycler);
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    // Show an ad, or hide it if its disabled
    if (!sharedPreferences.getBoolean("advertisement", false)) {
        adView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().addTestDevice(getString(R.string.test_device)).build();
        if (adView != null) {
            adView.loadAd(adRequest);
            adView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

                @Override
                public void onGlobalLayout() {
                    if (!mPaddingOnce) {
                        mPaddingOnce = true;
                        mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(), mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom() + adView.getHeight());
                    }
                }
            });
        }
    } else {
        findViewById(R.id.adView).setVisibility(View.GONE);
    }
    mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    mActionBarSize = getActionBarSize();
    mImageView = (ImageView) findViewById(R.id.image);
    mOverlayView = findViewById(R.id.overlay);
    mTitleView = (TextView) findViewById(R.id.title);
    mTitleView.setText(getTitle());
    setTitle(null);
    mRecyclerView.setScrollViewCallbacks(this);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setNestedScrollingEnabled(true);
    // mRecyclerViewBackground makes RecyclerView's background except header view.
    mRecyclerViewBackground = findViewById(R.id.list_background);
    //since you cannot programmatically add a header view to a RecyclerView we added an empty view as the header
    // in the adapter and then are shifting the views OnCreateView to compensate
    final float scale = 1 + MAX_TEXT_SCALE_DELTA;
    mRecyclerViewBackground.post(new Runnable() {

        @Override
        public void run() {
            ViewHelper.setTranslationY(mRecyclerViewBackground, mFlexibleSpaceImageHeight);
        }
    });
    ViewHelper.setTranslationY(mOverlayView, mFlexibleSpaceImageHeight);
    mTitleView.post(new Runnable() {

        @Override
        public void run() {
            ViewHelper.setTranslationY(mTitleView, (int) (mFlexibleSpaceImageHeight - mTitleView.getHeight() * scale));
            ViewHelper.setPivotX(mTitleView, 0);
            ViewHelper.setPivotY(mTitleView, 0);
            ViewHelper.setScaleX(mTitleView, scale);
            ViewHelper.setScaleY(mTitleView, scale);
        }
    });
    requestQueue = Volley.newRequestQueue(this);
    Connected();
}
Also used : AdRequest(com.google.android.gms.ads.AdRequest) SharedPreferences(android.content.SharedPreferences) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ViewTreeObserver(android.view.ViewTreeObserver)

Example 92 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project recyclerview-animators by wasabeef.

the class AnimatorSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_animator_sample);
    Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    if (getIntent().getBooleanExtra("GRID", true)) {
        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    } else {
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
    }
    recyclerView.setItemAnimator(new SlideInLeftAnimator());
    final MainAdapter adapter = new MainAdapter(this, new ArrayList<>(Arrays.asList(data)));
    recyclerView.setAdapter(adapter);
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
    for (Type type : Type.values()) {
        spinnerAdapter.add(type.name());
    }
    spinner.setAdapter(spinnerAdapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            recyclerView.setItemAnimator(Type.values()[position].getAnimator());
            recyclerView.getItemAnimator().setAddDuration(500);
            recyclerView.getItemAnimator().setRemoveDuration(500);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            adapter.add("newly added item", 1);
        }
    });
    findViewById(R.id.del).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            adapter.remove(1);
        }
    });
}
Also used : Spinner(android.widget.Spinner) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) GridLayoutManager(android.support.v7.widget.GridLayoutManager) SlideInLeftAnimator(jp.wasabeef.recyclerview.animators.SlideInLeftAnimator) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) Toolbar(android.support.v7.widget.Toolbar)

Example 93 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project wire-android by wireapp.

the class OnItemClickListener method onCreateDialog.

@NonNull
@Override
@SuppressLint("InflateParams")
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final LayoutInflater inflater = LayoutInflater.from(getActivity());
    final View view = inflater.inflate(R.layout.preference_dialog_accent_color, null);
    final RecyclerView recyclerView = ViewUtils.getView(view, R.id.rv__accent_color);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
    AccentColorAdapter adapter = new AccentColorAdapter(getContext(), getArguments().getInt(ARG_COLOR));
    adapter.setOnItemClickListener(this);
    recyclerView.setAdapter(adapter);
    return new AlertDialog.Builder(getActivity()).setView(view).setCancelable(true).create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) NonNull(android.support.annotation.NonNull) SuppressLint(android.annotation.SuppressLint)

Example 94 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project HumaneApp by Ganesh1010.

the class NeedDetailsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_need_details);
    toolbar = (Toolbar) findViewById(R.id.toolbar_need_details);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("");
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    needDetails = new NeedDetails();
    needItemDetails = new NeedItemDetails();
    needItemResult = new ArrayList<>();
    donatedDetailsList = new ArrayList<>();
    need = new NeedDetails();
    itemslist = new ArrayList();
    //   needDetails.setNeed_id(8);
    needListData = new ArrayList();
    needCardData = new ArrayList();
    //needViewData();
    //needCardViewData();
    progressBar = (CircularProgressBar) findViewById(R.id.circularProgressBar_ReceivalPage);
    percentage = (TextView) findViewById(R.id.circularProgressPercentageTextVIew_ReceivalPage);
    // 2500ms = 2,5s
    int animationDuration = 1000;
    progressBar.setProgressWithAnimation(80, animationDuration);
    percentage.setText("80%");
    showlistButton = (Button) findViewById(R.id.showListButton_ReceivalPage);
    needrecyclerView = (RecyclerView) findViewById(R.id.needListRecyclerView_ReceivalPage);
    receivalCardView = (RecyclerView) findViewById(R.id.donorListRecyclerView_ReceivalPage);
    needListLayout = (LinearLayout) findViewById(R.id.needListDivider_ReceivalPage);
    headingLayout = (LinearLayout) findViewById(R.id.listHeadingLinearLayout_ReceivalPage);
    new NeedAndDonatedDetails().execute();
// Toast.makeText(this,"after caardd adapter",Toast.LENGTH_LONG).show();
}
Also used : ArrayList(java.util.ArrayList) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 95 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter 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)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)688 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)612 View (android.view.View)593 TextView (android.widget.TextView)245 ArrayList (java.util.ArrayList)179 Intent (android.content.Intent)148 ImageView (android.widget.ImageView)132 Toolbar (android.support.v7.widget.Toolbar)118 GridLayoutManager (android.support.v7.widget.GridLayoutManager)111 AdapterView (android.widget.AdapterView)109 ViewGroup (android.view.ViewGroup)97 AlertDialog (android.support.v7.app.AlertDialog)91 Bundle (android.os.Bundle)85 ListView (android.widget.ListView)85 BindView (butterknife.BindView)85 Nullable (android.support.annotation.Nullable)78 DialogInterface (android.content.DialogInterface)71 Context (android.content.Context)65 ArrayAdapter (android.widget.ArrayAdapter)65 LayoutInflater (android.view.LayoutInflater)64