Search in sources :

Example 46 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project quickstart-android by firebase.

the class PostDetailFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // Get post key from arguments
    mPostKey = requireArguments().getString(EXTRA_POST_KEY);
    if (mPostKey == null) {
        throw new IllegalArgumentException("Must pass EXTRA_POST_KEY");
    }
    // Initialize Database
    mPostReference = FirebaseDatabase.getInstance().getReference().child("posts").child(mPostKey);
    mCommentsReference = FirebaseDatabase.getInstance().getReference().child("post-comments").child(mPostKey);
    binding.buttonPostComment.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            postComment();
        }
    });
    binding.recyclerPostComments.setLayoutManager(new LinearLayoutManager(getContext()));
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 47 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project ExoPlayer by google.

the class MainActivity method onCreate.

// Activity lifecycle methods.
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Getting the cast context later than onStart can cause device discovery not to take place.
    try {
        castContext = CastContext.getSharedInstance(this);
    } catch (RuntimeException e) {
        Throwable cause = e.getCause();
        while (cause != null) {
            if (cause instanceof DynamiteModule.LoadingException) {
                setContentView(R.layout.cast_context_error);
                return;
            }
            cause = cause.getCause();
        }
        // Unknown error. We propagate it.
        throw e;
    }
    setContentView(R.layout.main_activity);
    playerView = findViewById(R.id.player_view);
    playerView.requestFocus();
    mediaQueueList = findViewById(R.id.sample_list);
    ItemTouchHelper helper = new ItemTouchHelper(new RecyclerViewCallback());
    helper.attachToRecyclerView(mediaQueueList);
    mediaQueueList.setLayoutManager(new LinearLayoutManager(this));
    mediaQueueList.setHasFixedSize(true);
    mediaQueueListAdapter = new MediaQueueListAdapter();
    findViewById(R.id.add_sample_button).setOnClickListener(this);
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) DynamiteModule(com.google.android.gms.dynamite.DynamiteModule) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 48 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Gadgetbridge by Freeyourgadget.

the class ConfigureAlarms method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_configure_alarms);
    IntentFilter filterLocal = new IntentFilter();
    filterLocal.addAction(DeviceService.ACTION_SAVE_ALARMS);
    LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
    gbDevice = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
    mGBAlarmListAdapter = new GBAlarmListAdapter(this);
    RecyclerView alarmsRecyclerView = findViewById(R.id.alarm_list);
    alarmsRecyclerView.setHasFixedSize(true);
    alarmsRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    alarmsRecyclerView.setAdapter(mGBAlarmListAdapter);
    updateAlarmsFromDB();
}
Also used : IntentFilter(android.content.IntentFilter) RecyclerView(androidx.recyclerview.widget.RecyclerView) GBAlarmListAdapter(nodomain.freeyourgadget.gadgetbridge.adapter.GBAlarmListAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 49 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Gadgetbridge by Freeyourgadget.

the class ControlCenterv2 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    AbstractGBActivity.init(this, AbstractGBActivity.NO_ACTIONBAR);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_controlcenterv2);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.controlcenter_navigation_drawer_open, R.string.controlcenter_navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    // end of material design boilerplate
    deviceManager = ((GBApplication) getApplication()).getDeviceManager();
    deviceListView = findViewById(R.id.deviceListView);
    deviceListView.setHasFixedSize(true);
    deviceListView.setLayoutManager(new LinearLayoutManager(this));
    deviceList = deviceManager.getDevices();
    mGBDeviceAdapter = new GBDeviceAdapterv2(this, deviceList, deviceActivityHashMap);
    // get activity data asynchronously, this fills the deviceActivityHashMap
    // and calls refreshPairedDevices() → notifyDataSetChanged
    createRefreshTask("get activity data", getApplication()).execute();
    deviceListView.setAdapter(this.mGBDeviceAdapter);
    fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            launchDiscoveryActivity();
        }
    });
    showFabIfNeccessary();
    /* uncomment to enable fixed-swipe to reveal more actions

        ItemTouchHelper swipeToDismissTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(
                ItemTouchHelper.LEFT , ItemTouchHelper.RIGHT) {
            @Override
            public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
                if(dX>50)
                    dX = 50;
                super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);

            }

            @Override
            public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                GB.toast(getBaseContext(), "onMove", Toast.LENGTH_LONG, GB.ERROR);

                return false;
            }

            @Override
            public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
                GB.toast(getBaseContext(), "onSwiped", Toast.LENGTH_LONG, GB.ERROR);

            }

            @Override
            public void onChildDrawOver(Canvas c, RecyclerView recyclerView,
                                        RecyclerView.ViewHolder viewHolder, float dX, float dY,
                                        int actionState, boolean isCurrentlyActive) {
            }
        });

        swipeToDismissTouchHelper.attachToRecyclerView(deviceListView);
        */
    registerForContextMenu(deviceListView);
    IntentFilter filterLocal = new IntentFilter();
    filterLocal.addAction(GBApplication.ACTION_LANGUAGE_CHANGE);
    filterLocal.addAction(GBApplication.ACTION_QUIT);
    filterLocal.addAction(GBApplication.ACTION_NEW_DATA);
    filterLocal.addAction(DeviceManager.ACTION_DEVICES_CHANGED);
    filterLocal.addAction(DeviceService.ACTION_REALTIME_SAMPLES);
    LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
    refreshPairedDevices();
    /*
         * Ask for permission to intercept notifications on first run.
         */
    Prefs prefs = GBApplication.getPrefs();
    pesterWithPermissions = prefs.getBoolean("permission_pestering", true);
    Set<String> set = NotificationManagerCompat.getEnabledListenerPackages(this);
    if (pesterWithPermissions) {
        if (!set.contains(this.getPackageName())) {
            // If notification listener access hasn't been granted
            Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
            startActivity(enableIntent);
        }
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        checkAndRequestPermissions();
    }
    ChangeLog cl = createChangeLog();
    if (cl.isFirstRun()) {
        try {
            cl.getLogDialog().show();
        } catch (Exception ignored) {
            GB.toast(getBaseContext(), "Error showing Changelog", Toast.LENGTH_LONG, GB.ERROR);
        }
    }
    GBApplication.deviceService().start();
    if (GB.isBluetoothEnabled() && deviceList.isEmpty() && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        startActivity(new Intent(this, DiscoveryActivity.class));
    } else {
        GBApplication.deviceService().requestDeviceInfo();
    }
}
Also used : IntentFilter(android.content.IntentFilter) NavigationView(com.google.android.material.navigation.NavigationView) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) GBDeviceAdapterv2(nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAdapterv2) Intent(android.content.Intent) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NavigationView(com.google.android.material.navigation.NavigationView) ChangeLog(de.cketti.library.changelog.ChangeLog) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) Toolbar(androidx.appcompat.widget.Toolbar)

Example 50 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Gadgetbridge by Freeyourgadget.

the class AbstractAppManagerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mGBDevice = ((AppManagerActivity) getActivity()).getGBDevice();
    mCoordinator = DeviceHelper.getInstance().getCoordinator(mGBDevice);
    final FloatingActionButton appListFab = ((FloatingActionButton) getActivity().findViewById(R.id.fab));
    final FloatingActionButton appListFabNew = ((FloatingActionButton) getActivity().findViewById(R.id.fab_new));
    watchfaceDesignerActivity = mCoordinator.getWatchfaceDesignerActivity();
    View rootView = inflater.inflate(R.layout.activity_appmanager, container, false);
    RecyclerView appListView = (RecyclerView) (rootView.findViewById(R.id.appListView));
    appListView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (dy > 0) {
                appListFab.hide();
                appListFabNew.hide();
            } else if (dy < 0) {
                appListFab.show();
                if (watchfaceDesignerActivity != null) {
                    appListFabNew.show();
                }
            }
        }
    });
    appListView.setLayoutManager(new LinearLayoutManager(getActivity()));
    mGBDeviceAppAdapter = new GBDeviceAppAdapter(appList, R.layout.item_pebble_watchapp, this);
    appListView.setAdapter(mGBDeviceAppAdapter);
    ItemTouchHelper.Callback appItemTouchHelperCallback = new AppItemTouchHelperCallback(mGBDeviceAppAdapter);
    appManagementTouchHelper = new ItemTouchHelper(appItemTouchHelperCallback);
    appManagementTouchHelper.attachToRecyclerView(appListView);
    if ((watchfaceDesignerActivity != null) && (appListFabNew != null)) {
        appListFabNew.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent startIntent = new Intent(getContext(), watchfaceDesignerActivity);
                startIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice);
                getContext().startActivity(startIntent);
            }
        });
        appListFabNew.show();
    }
    return rootView;
}
Also used : GBDeviceAppAdapter(nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAppAdapter) Intent(android.content.Intent) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)502 RecyclerView (androidx.recyclerview.widget.RecyclerView)301 View (android.view.View)197 TextView (android.widget.TextView)75 ArrayList (java.util.ArrayList)44 Bundle (android.os.Bundle)43 Nullable (androidx.annotation.Nullable)41 Intent (android.content.Intent)36 ImageView (android.widget.ImageView)34 Toolbar (androidx.appcompat.widget.Toolbar)34 List (java.util.List)33 NonNull (androidx.annotation.NonNull)31 Context (android.content.Context)28 ViewGroup (android.view.ViewGroup)27 AlertDialog (androidx.appcompat.app.AlertDialog)24 Test (org.junit.Test)24 LayoutInflater (android.view.LayoutInflater)23 ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)20 MenuItem (android.view.MenuItem)18 DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)17