Search in sources :

Example 1 with ItemWithDetailsAdapter

use of nodomain.freeyourgadget.gadgetbridge.adapter.ItemWithDetailsAdapter in project Gadgetbridge by Freeyourgadget.

the class FwAppInstallerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_appinstaller);
    GBDevice dev = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
    if (dev != null) {
        device = dev;
    }
    if (savedInstanceState != null) {
        mDetails = savedInstanceState.getParcelableArrayList(ITEM_DETAILS);
        if (mDetails == null) {
            mDetails = new ArrayList<>();
        }
    }
    mayConnect = true;
    itemListView = (ListView) findViewById(R.id.itemListView);
    mItemAdapter = new ItemWithDetailsAdapter(this, mItems);
    itemListView.setAdapter(mItemAdapter);
    fwAppInstallTextView = (TextView) findViewById(R.id.infoTextView);
    installButton = (Button) findViewById(R.id.installButton);
    mProgressBar = (ProgressBar) findViewById(R.id.installProgressBar);
    detailsListView = (ListView) findViewById(R.id.detailsListView);
    mDetailsItemAdapter = new ItemWithDetailsAdapter(this, mDetails);
    mDetailsItemAdapter.setSize(ItemWithDetailsAdapter.SIZE_SMALL);
    detailsListView.setAdapter(mDetailsItemAdapter);
    setInstallEnabled(false);
    IntentFilter filter = new IntentFilter();
    filter.addAction(GBApplication.ACTION_QUIT);
    filter.addAction(GBDevice.ACTION_DEVICE_CHANGED);
    filter.addAction(GB.ACTION_DISPLAY_MESSAGE);
    LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filter);
    installButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            setInstallEnabled(false);
            installHandler.onStartInstall(device);
            GBApplication.deviceService().onInstallApp(uri);
        }
    });
    uri = getIntent().getData();
    if (uri == null) {
        //for "share" intent
        uri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
    }
    installHandler = findInstallHandlerFor(uri);
    if (installHandler == null) {
        setInfoText(getString(R.string.installer_activity_unable_to_find_handler));
    } else {
        setInfoText(getString(R.string.installer_activity_wait_while_determining_status));
        // needed to get the device
        if (device == null || !device.isConnected()) {
            connect();
        } else {
            GBApplication.deviceService().requestDeviceInfo();
        }
    }
}
Also used : IntentFilter(android.content.IntentFilter) ItemWithDetailsAdapter(nodomain.freeyourgadget.gadgetbridge.adapter.ItemWithDetailsAdapter) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) GBDevice(nodomain.freeyourgadget.gadgetbridge.impl.GBDevice)

Aggregations

IntentFilter (android.content.IntentFilter)1 View (android.view.View)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 ItemWithDetailsAdapter (nodomain.freeyourgadget.gadgetbridge.adapter.ItemWithDetailsAdapter)1 GBDevice (nodomain.freeyourgadget.gadgetbridge.impl.GBDevice)1