Search in sources :

Example 71 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project SR-Tracker-for-Overwatch by Rexios80.

the class StatsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.stats_fragment, container, false);
    if (dpWidth() > 750) {
        LinearLayout llStats = (LinearLayout) v.findViewById(R.id.ll_stats);
        int cardBackground = ContextCompat.getColor(getActivity(), R.color.cardBackground);
        llStats.setBackgroundColor(cardBackground);
    }
    lvStats = (ListView) v.findViewById(R.id.lv_stats);
    adapter = new StatsListViewAdapter(getActivity(), new DatabaseParser(getContext()).getStatsList(), getContext());
    lvStats.setAdapter(adapter);
    lvStats.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> a, View v, int position, long arg3) {
            String timeString = ((HashMap<String, String>) adapter.getItem(position)).get("time");
            String snackbarText;
            if (timeString == null || timeString.equals("0")) {
                snackbarText = "No time recorded";
            } else {
                long time = Long.parseLong(timeString);
                SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yy  -  h:mm a");
                Date date = new Date(time);
                snackbarText = dateFormat.format(date);
            }
            Snackbar.make(getActivity().findViewById(android.R.id.content), snackbarText, Snackbar.LENGTH_LONG).show();
        }
    });
    lvStats.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> a, View v, int position, long arg3) {
            String noteString = ((HashMap<String, String>) adapter.getItem(position)).get("note");
            if (noteString == null || noteString.equals("")) {
                Snackbar.make(getActivity().findViewById(android.R.id.content), "No note recorded", Snackbar.LENGTH_LONG).show();
                return true;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), R.style.AlertDialogCustom);
            builder.setMessage(noteString).show();
            return true;
        }
    });
    return v;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Date(java.util.Date) AdapterView(android.widget.AdapterView) SimpleDateFormat(java.text.SimpleDateFormat) LinearLayout(android.widget.LinearLayout)

Example 72 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ConditionAdapterUtils method addDismiss.

public static void addDismiss(final RecyclerView recyclerView) {
    ItemTouchHelper.SimpleCallback callback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.START | ItemTouchHelper.END) {

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            return true;
        }

        @Override
        public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            return viewHolder.getItemViewType() == R.layout.condition_card ? super.getSwipeDirs(recyclerView, viewHolder) : 0;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            DashboardAdapter adapter = (DashboardAdapter) recyclerView.getAdapter();
            Object item = adapter.getItem(viewHolder.getItemId());
            if (item instanceof Condition) {
                ((Condition) item).silence();
            }
        }
    };
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) RecyclerView(android.support.v7.widget.RecyclerView) DashboardAdapter(com.android.settings.dashboard.DashboardAdapter)

Example 73 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    player = (VideoView) findViewById(R.id.player);
    if (player != null) {
        player.setOnDragListener(this);
        player.setOnHoverListener(this);
        player.setOnLongClickListener(this);
    }
    thumbnailLarge = (ImageView) findViewById(R.id.thumbnail_large);
    if (thumbnailLarge != null) {
        thumbnailLarge.setOnDragListener(this);
        thumbnailLarge.setOnHoverListener(this);
        thumbnailLarge.setOnLongClickListener(this);
    }
    setLayoutManager(new LinearLayoutManager(this));
    adapter = new VideoAdapter(getRecyclerView());
    setAdapter(adapter);
    getRecyclerView().requestFocus();
    if (icicle != null) {
        isInPermission = icicle.getBoolean(STATE_IN_PERMISSION, false);
    }
    if (hasFilesPermission()) {
        loadVideos();
    } else if (!isInPermission) {
        isInPermission = true;
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_PERMS);
    }
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 74 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final RecyclerView pager = (RecyclerView) findViewById(R.id.pager);
    final LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
    pager.setLayoutManager(layoutManager);
    snapperCarr.attachToRecyclerView(pager);
    adapter = new PageAdapter(pager, getLayoutInflater());
    pager.setAdapter(adapter);
    final TabLayout tabs = (TabLayout) findViewById(R.id.tabs);
    for (int i = 0; i < adapter.getItemCount(); i++) {
        tabs.addTab(tabs.newTab().setText(adapter.getTabText(this, i)));
    }
    tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            pager.smoothScrollToPosition(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        // unused
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
        // unused
        }
    });
    pager.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            int tab = layoutManager.findFirstCompletelyVisibleItemPosition();
            if (tab >= 0 && tab < tabs.getTabCount()) {
                tabs.getTabAt(tab).select();
            }
        }
    });
}
Also used : TabLayout(com.commonsware.cwac.crossport.design.widget.TabLayout) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 75 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setLayoutManager(new LinearLayoutManager(this));
    adapter = new IconicAdapter(getRecyclerView());
    setAdapter(adapter);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

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