Search in sources :

Example 16 with NetworkDevice

use of com.genonbeta.TrebleShot.object.NetworkDevice in project TrebleShot by genonbeta.

the class ShareActivity method onRequestReady.

protected void onRequestReady() {
    if (getIntent().hasExtra(EXTRA_DEVICE_ID)) {
        String deviceId = getIntent().getStringExtra(EXTRA_DEVICE_ID);
        NetworkDevice chosenDevice = new NetworkDevice(deviceId);
        try {
            mDatabase.reconstruct(chosenDevice);
            showChooserDialog(chosenDevice);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : NetworkDevice(com.genonbeta.TrebleShot.object.NetworkDevice) JSONException(org.json.JSONException) FileNotFoundException(java.io.FileNotFoundException) ConnectException(java.net.ConnectException) IOException(java.io.IOException)

Example 17 with NetworkDevice

use of com.genonbeta.TrebleShot.object.NetworkDevice in project TrebleShot by genonbeta.

the class NetworkDeviceListFragment method onListItemClick.

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    final NetworkDevice device = (NetworkDevice) getAdapter().getItem(position);
    if (mClickListener != null) {
        if (device.versionNumber != -1 && device.versionNumber < AppConfig.SUPPORTED_MIN_VERSION)
            createSnackbar(R.string.mesg_versionNotSupported).show();
        else
            mClickListener.onItemClick(l, v, position, id);
    } else if (device instanceof NetworkDeviceListAdapter.HotspotNetwork) {
        final NetworkDeviceListAdapter.HotspotNetwork hotspotNetwork = (NetworkDeviceListAdapter.HotspotNetwork) device;
        AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
        builder.setTitle(hotspotNetwork.nickname);
        builder.setMessage(R.string.text_trebleshotHotspotDescription);
        builder.setNegativeButton(R.string.butn_close, null);
        builder.setPositiveButton(isConnectedToNetwork(hotspotNetwork) ? R.string.butn_disconnect : R.string.butn_connect, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                toggleConnection(hotspotNetwork);
            }
        });
        builder.show();
    } else if (device.brand != null && device.model != null)
        new DeviceInfoDialog(getActivity(), getAdapter().getDatabase(), device).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) DeviceInfoDialog(com.genonbeta.TrebleShot.dialog.DeviceInfoDialog) NetworkDevice(com.genonbeta.TrebleShot.object.NetworkDevice) NetworkDeviceListAdapter(com.genonbeta.TrebleShot.adapter.NetworkDeviceListAdapter)

Aggregations

NetworkDevice (com.genonbeta.TrebleShot.object.NetworkDevice)17 JSONException (org.json.JSONException)5 AccessDatabase (com.genonbeta.TrebleShot.database.AccessDatabase)4 IOException (java.io.IOException)4 ConnectException (java.net.ConnectException)4 View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 TextDrawable (com.amulyakhare.textdrawable.TextDrawable)3 ArrayList (java.util.ArrayList)3 Intent (android.content.Intent)2 ServiceConnection (android.content.ServiceConnection)2 NavigationView (android.support.design.widget.NavigationView)2 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)2 Toolbar (android.support.v7.widget.Toolbar)2 NetworkDeviceListAdapter (com.genonbeta.TrebleShot.adapter.NetworkDeviceListAdapter)2 DeviceInfoDialog (com.genonbeta.TrebleShot.dialog.DeviceInfoDialog)2 WorkerService (com.genonbeta.TrebleShot.service.WorkerService)2 PowerfulActionMode (com.genonbeta.TrebleShot.widget.PowerfulActionMode)2 PendingIntent (android.app.PendingIntent)1