Example usage for android.widget Toast LENGTH_LONG

List of usage examples for android.widget Toast LENGTH_LONG

Introduction

In this page you can find the example usage for android.widget Toast LENGTH_LONG.

Prototype

int LENGTH_LONG

To view the source code for android.widget Toast LENGTH_LONG.

Click Source Link

Document

Show the view or text notification for a long period of time.

Usage

From source file:edu.cwru.apo.Contract.java

public void onRestRequestComplete(Methods method, JSONObject result) {
    if (method == Methods.getContract) {
        if (result != null) {
            try {
                String requestStatus = result.getString("requestStatus");
                if (requestStatus.compareTo("success") == 0) {
                    String contract = "";
                    contract += "Status: " + result.getString("status") + "\n";
                    contract += "Dues: " + result.getString("dues") + "\n\n";
                    contract += "Chapter Attendance: \n";
                    contract += "Attended: " + result.getDouble("chaptersAttended") + "\n";
                    contract += "Required: " + result.getDouble("chaptersRequired") + "\n\n";
                    contract += "Pledge Attendance: \n";
                    contract += "Attended: " + result.getDouble("pledgeAttended") + "\n";
                    contract += "Required: " + result.getDouble("pledgeRequired") + "\n\n";
                    contract += "Hours:\n";
                    contract += "Hours towards contract: " + result.getDouble("contractHours") + "/"
                            + result.getDouble("contractHoursRequired") + "\n";
                    contract += "Inside Hours: " + result.getDouble("in") + "/" + result.getDouble("inRequired")
                            + "\n";
                    contract += "Outside Hours: " + result.getDouble("out") + "\n";
                    contract += "Total semester Hours: " + result.getDouble("totalHours");
                    text.setText(contract);
                } else if (requestStatus.compareTo("timestamp invalid") == 0) {
                    Toast msg = Toast.makeText(getApplicationContext(), "Invalid timestamp.  Please try again.",
                            Toast.LENGTH_LONG);
                    msg.show();/*from w  w w .  j  ava  2 s . c  o m*/
                } else if (requestStatus.compareTo("HMAC invalid") == 0) {
                    Auth.loggedIn = false;
                    Toast msg = Toast.makeText(getApplicationContext(),
                            "You have been logged out by the server.  Please log in again.", Toast.LENGTH_LONG);
                    msg.show();
                    finish();
                } else if (requestStatus.compareTo("no contract") == 0) {
                    Toast msg = Toast.makeText(getApplicationContext(), "You have not signed a contract.",
                            Toast.LENGTH_LONG);
                    msg.show();
                } else {
                    Toast msg = Toast.makeText(getApplicationContext(), "Invalid requestStatus",
                            Toast.LENGTH_LONG);
                    msg.show();
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}

From source file:com.ptts.fragments.BusLocation.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bus_location);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    showProgressBar();/* w  ww  .  j  a v  a2s .  c o  m*/

    txtBusId = (TextView) findViewById(R.id.bus_plate);
    txtBusTime = (TextView) findViewById(R.id.time_label);

    Intent in = getIntent();
    cd = new ConnectionDetector(getApplicationContext());

    bus_id = in.getStringExtra(FetchBusTask.getKeyBusid());
    String latitude = in.getStringExtra(FetchBusTask.getKeyLatitude());
    String longitude = in.getStringExtra(FetchBusTask.getKeyLongitude());

    bus_id = bus_id.substring(6).replace("/", "");

    txtBusId.setText("Bus " + bus_id);
    //txtBusTime.setText(latitude);
    if (!cd.isConnectingToInternet()) {
        Toast.makeText(getApplicationContext(), "Connect to Internet First", Toast.LENGTH_LONG).show();
        return;
    } else {
        //to get bus plate number
        ServerConnection connect = new ServerConnection();
        connect.execute(new String[] { bus_id });

    }

    // Getting LocationManager object from System Service LOCATION_SERVICE
    locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    // Getting Google Play availability status
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

    if (status != ConnectionResult.SUCCESS) { // Google Play Services are not available

        int requestCode = 10;
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
        dialog.show();

    } else { // Google Play Services are available

        // Getting reference to the SupportMapFragment
        SupportMapFragment fragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);

        // Getting Google Map
        mGoogleMap = fragment.getMap();

        // Enabling MyLocation in Google Map
        mGoogleMap.setMyLocationEnabled(true);

        // Creating a criteria object to retrieve provider
        Criteria criteria = new Criteria();

        // Getting the name of the best provider
        String provider = locationManager.getBestProvider(criteria, true);

        if (provider != null) {

            // Getting Current Location From GPS
            Location location = locationManager.getLastKnownLocation(provider);

            if (location != null) {
                onLocationChanged(location);
            }

            locationManager.requestLocationUpdates(provider, 20000, 0, this);

        }

    } //end else

    mGoogleMap.addMarker(new MarkerOptions()
            .position(new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude))).title(bus_id)
            .snippet(latitude));

    //find the distance between the two
    LatLng origin = new LatLng(mLatitude, mLongitude);
    LatLng dest = new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude));

    // Getting URL to the Google Directions API
    String url = getDirectionsUrl(origin, dest);

    DownloadTask downloadTask = new DownloadTask();

    // Start downloading json data from Google Directions API
    downloadTask.execute(url);

}

From source file:edu.cwru.apo.Home.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.updateMenuItem:
        if (phoneDB == null)
            phoneDB = new PhoneOpenHelper(this);
        if (database == null)
            database = phoneDB.getWritableDatabase();
        API phoneApi = new API(this);
        String[] params = { "0" };
        if (!phoneApi.callMethod(Methods.phone, this, params)) {
            Toast msg = Toast.makeText(this, "Error: Calling phone", Toast.LENGTH_LONG);
            msg.show();/*from w  w w . ja  v a2  s  . com*/
        }
        return true;
    case R.id.updateApp:
        API updateAppApi = new API(this);
        if (!updateAppApi.callMethod(Methods.checkAppVersion, this)) {
            Toast msg = Toast.makeText(this, "Error: Couldn't get app version", Toast.LENGTH_LONG);
            msg.show();
        }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:pl.bcichecki.rms.client.android.fragments.InboxMessagesListFragment.java

private void downloadArchivedData() {
    if (!showArchivedMessages) {
        return;//from w w  w.j av  a2  s .  c o  m
    }

    Log.d(TAG, "Downloading inbox messages list...");

    if (!AppUtils.checkInternetConnection(getActivity())) {
        Log.d(TAG, "There is NO network connected!");
        return;
    }

    messagesRestClient.getAllArchivedInboxMessages(
            new GsonHttpResponseHandler<List<Message>>(new TypeToken<List<Message>>() {
            }.getType(), true) {

                @Override
                public void onFailure(Throwable error, String content) {
                    Log.d(TAG, "Retrieving archived inbox messages failed. [error=" + error + ", content="
                            + content + "]");
                    if (error instanceof HttpResponseException) {
                        if (((HttpResponseException) error).getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
                            AppUtils.showCenteredToast(getActivity(),
                                    R.string.general_unathorized_error_message_title, Toast.LENGTH_LONG);
                        } else {
                            AppUtils.showCenteredToast(getActivity(),
                                    R.string.general_unknown_error_message_title, Toast.LENGTH_LONG);
                        }
                    } else {
                        AppUtils.showCenteredToast(getActivity(), R.string.general_unknown_error_message_title,
                                Toast.LENGTH_LONG);
                    }
                }

                @Override
                public void onFinish() {
                    inboxMessagesListAdapter.refresh();
                    hideLoadingMessage();
                    Log.d(TAG, "Retrieving archived inbox messages finished.");
                }

                @Override
                public void onStart() {
                    Log.d(TAG, "Retrieving archived inbox messages started.");
                    showLoadingMessage();
                }

                @Override
                public void onSuccess(int statusCode, List<Message> object) {
                    Log.d(TAG, "Retrieving archived inbox messages successful. Retrieved " + object.size()
                            + " objects.");
                    inboxMessages.addAll(object);
                }
            });
}

From source file:pl.bcichecki.rms.client.android.fragments.OutboxMessagesListFragment.java

private void downloadArchivedData() {
    if (!showArchivedMessages) {
        return;/*w  w  w .j  a v a2 s.c o m*/
    }

    Log.d(TAG, "Downloading outbox messages list...");

    if (!AppUtils.checkInternetConnection(getActivity())) {
        Log.d(TAG, "There is NO network connected!");
        return;
    }

    messagesRestClient.getAllArchivedOutboxMessages(
            new GsonHttpResponseHandler<List<Message>>(new TypeToken<List<Message>>() {
            }.getType(), true) {

                @Override
                public void onFailure(Throwable error, String content) {
                    Log.d(TAG, "Retrieving archived outbox messages failed. [error=" + error + ", content="
                            + content + "]");
                    if (error instanceof HttpResponseException) {
                        if (((HttpResponseException) error).getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
                            AppUtils.showCenteredToast(getActivity(),
                                    R.string.general_unathorized_error_message_title, Toast.LENGTH_LONG);
                        } else {
                            AppUtils.showCenteredToast(getActivity(),
                                    R.string.general_unknown_error_message_title, Toast.LENGTH_LONG);
                        }
                    } else {
                        AppUtils.showCenteredToast(getActivity(), R.string.general_unknown_error_message_title,
                                Toast.LENGTH_LONG);
                    }
                }

                @Override
                public void onFinish() {
                    outboxMessagesListAdapter.refresh();
                    hideLoadingMessage();
                    Log.d(TAG, "Retrieving archived outbox messages finished.");
                }

                @Override
                public void onStart() {
                    Log.d(TAG, "Retrieving archived outbox messages started.");
                    showLoadingMessage();
                }

                @Override
                public void onSuccess(int statusCode, List<Message> object) {
                    Log.d(TAG, "Retrieving archived outbox messages successful. Retrieved " + object.size()
                            + " objects.");
                    outboxMessages.addAll(object);
                }
            });
}

From source file:com.gelecekonline.android.uploadornek.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    selectedImageView = (ImageView) findViewById(R.id.selectedImageView);
    selectImageButton = (Button) findViewById(R.id.selectImageButton);
    selectImageButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            try {
                //Resim secen Intent tanimlamasi
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(Intent.createChooser(intent, getString(R.string.select_image)),
                        SELECT_IMAGE_INTENT_ID);
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), getString(R.string.select_image_problem),
                        Toast.LENGTH_LONG).show();
            }//from   w w  w. j  ava  2 s .  co  m
        }
    });

    uploadButton = (Button) findViewById(R.id.uploadButton);
    uploadButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (selectedImageView.getDrawable() == null) {
                Toast.makeText(getApplicationContext(), getString(R.string.please_select_image),
                        Toast.LENGTH_LONG).show();
            } else {
                dialog = ProgressDialog.show(MainActivity.this, getString(R.string.image_uploading),
                        getString(R.string.please_wait), true);
                if (uploadImageTask == null || uploadImageTask.getStatus() == AsyncTask.Status.FINISHED) {
                    uploadImageTask = new UploadImageTask();
                }
                uploadImageTask.execute();
            }
        }
    });
}

From source file:com.grinnellplans.plandroid.SessionService.java

public void LoginResult(String resp) {
    Log.i("SessionService::LoginResult", "Started");
    JSONObject js = null;/*from w w  w . j a va 2 s .co m*/
    try {
        Log.i("SessionService::LoginResult", "parsing");
        js = new JSONObject(resp);
        if (!js.getBoolean("success")) {
            _loginCallback.onLoggedIn(false, js.getString("message"));
        } else {
            JSONArray af = js.getJSONArray("autofingerList");
            _af.refresh(af);
            _loginCallback.onLoggedIn(true, "");
        }

    } catch (JSONException je) {
        Toast.makeText(this, "Unknown login response: " + resp, Toast.LENGTH_LONG).show();
    }
    Log.i("SessionService::LoginResult", "Finished");
}

From source file:org.andrico.andrico.UiHandler.java

void notifyUser(final String statusBarMessage, final Boolean toast) {
    post(new Runnable() {
        public void run() {
            if (toast) {
                Toast.makeText(mContext, statusBarMessage, Toast.LENGTH_LONG).show();
            }/*from   w ww  .j a  va2 s .  com*/
        }
    });
    return;
}

From source file:com.chess.genesis.activity.GameListFrag.java

protected void sendGame(final Bundle gamedata) {
    try {//from  ww  w .j a v  a  2  s  .co  m
        final String gamename = gamedata.containsKey("gameid")
                ? gamedata.getString("white") + " V. " + gamedata.getString("black")
                : gamedata.getString("name");
        final String filename = gamename + ".txt";
        final String gamestr = GameParser.export(gamedata).toString();
        final Uri uri = FileUtils.writeFile(filename, gamestr);
        final Intent intent = new Intent(Intent.ACTION_SEND);

        intent.putExtra(Intent.EXTRA_STREAM, uri);
        intent.setType("application/json");
        startActivity(intent);
    } catch (final JSONException e) {
        Toast.makeText(act, "Corrupt Game Data", Toast.LENGTH_LONG).show();
    } catch (final FileNotFoundException e) {
        Toast.makeText(act, "File Not Found", Toast.LENGTH_LONG).show();
    } catch (final IOException e) {
        Toast.makeText(act, "Error Reading File", Toast.LENGTH_LONG).show();
    }
}

From source file:com.orange.labs.sample.UploadPicture.java

private void showToast(String msg) {
    Toast error = Toast.makeText(mContext, msg, Toast.LENGTH_LONG);
    error.show();
}