Search in sources :

Example 1 with GBDeviceAppAdapter

use of nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAppAdapter 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

Intent (android.content.Intent)1 View (android.view.View)1 ItemTouchHelper (androidx.recyclerview.widget.ItemTouchHelper)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)1 GBDeviceAppAdapter (nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAppAdapter)1