public void rateStory(View view) {

    RatingBar ratingBar = (RatingBar) findViewById(R.id.rating_bar);
    int rating = (int) Math.round(ratingBar.getRating());
    System.out.println(rating);

    // Update rating if user hit like button
    try {
      // Store json object with value of user rating
      JSONObject storyRate = getStoryObj();
      storyRate.put("rating", rating);

      System.out.println(storyRate.toString());

      // Post json data with rating to server
      Utility.postJsonData(
          storyRate.toString(), getResources().getString(R.string.server_rate_story));

    } catch (Exception e) {
      getResources().getString(R.string.server_error);
      e.printStackTrace();
    }
    // Go back to main activity after sending rating
    NavUtils.navigateUpFromSameTask(this);
  }
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();
    if (id == R.id.nav_home) {
      Intent intent = new Intent(getApplicationContext(), MainActivity.class);
      startActivity(intent);
    } else if (id == R.id.nav_house) {
      // Handle the home action
      NavUtils.navigateUpFromSameTask(
          this); // GOES UP FROM THIS ACTIVITY TO THE PARENT ACTIVITY - PROPERTYACTIVITY. This
                 // should make navigation faster
    } /*else if (id == R.id.nav_gallery) {

      } else if (id == R.id.nav_slideshow) {

      } else if (id == R.id.nav_manage) {

      } else if (id == R.id.nav_share) {

      } else if (id == R.id.nav_send) {

      }*/

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout_property_list);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
Esempio n. 3
0
 /*
  * Wird aufgerufen, wenn auf einen ActionBar Knopf gedrückt wird
  */
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       // This ID represents the Home or Up button. In the case of this
       // activity, the Up button is shown. Use NavUtils to allow users
       // to navigate up one level in the application structure. For
       // more details, see the Navigation pattern on Android Design:
       //
       // http://developer.android.com/design/patterns/navigation.html#up-vs-back
       //
       NavUtils.navigateUpFromSameTask(this);
       return true;
     case R.id.action_search:
       openSearch();
       return true;
     case R.id.action_settings:
       openSettings();
       return true;
     case R.id.action_map:
       openLiveKarte();
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
  private void selectItem(int position) {

    Activity activity = null;

    switch (position) {
        // Campus Select
      case 0:
        // startActivity(new Intent(this, CamSelTest.class));
        NavUtils.navigateUpFromSameTask(this);
        mDrawerLayout.closeDrawer(mDrawerList);

        break;
        // Help
      case 1:
        startActivity(new Intent(this, Help.class));
        mDrawerLayout.closeDrawer(mDrawerList);
        break;
        // About Us
      case 2:
        startActivity(new Intent(this, AboutUs.class));
        mDrawerLayout.closeDrawer(mDrawerList);
        break;

      default:
        break;
    }
  }
Esempio n. 5
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
      Toast.makeText(
              getApplicationContext(),
              "Sept 17,18,19 @\n"
                  + "SJCET, Choondacherry P.O,\n"
                  + "Palai-686 579, \n"
                  + "Kottayam DISTRICT\n"
                  + "Kerala,India",
              Toast.LENGTH_LONG)
          .show();
    }

    if (id == android.R.id.home) {
      NavUtils.navigateUpFromSameTask(this);
    }

    return super.onOptionsItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        NavUtils.navigateUpFromSameTask(this);
        return true;

      case R.id.menu_sign_out:
        try {
          dbAdapter.clearAllTables();
        } catch (Exception e) {
          e.printStackTrace();
        }
        finish();
        Intent intent = new Intent(this.getApplicationContext(), LoginActivity.class);
        startActivity(intent);
        break;
      default:
        break;
    }

    return super.onOptionsItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        NavUtils.navigateUpFromSameTask(this);
        return true;

      case R.id.action_send:
        ParseObject message = createMessage();

        if (message == null) {
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
          builder
              .setMessage(R.string.error_file_selected)
              .setTitle(R.string.error_title)
              .setPositiveButton(android.R.string.ok, null);
          AlertDialog dialog = builder.create();
          dialog.show();

        } else {
          send(message);
          finish();
        }

        return true;
    }
    return super.onOptionsItemSelected(item);
  }
Esempio n. 8
0
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       NavUtils.navigateUpFromSameTask(this);
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public boolean onOptionsItemSelected(android.view.MenuItem item) {
   if (item.getItemId() == android.R.id.home) {
     NavUtils.navigateUpFromSameTask(this);
     return true;
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public void onBackPressed() {
   super.onBackPressed();
   String value = emailLogin.getText().toString();
   ActivityManager.setSharedStringValue(
       ForgetPasswordActivity.this, SELECTED_EMAIL, (null == value ? "" : value));
   NavUtils.navigateUpFromSameTask(this);
   overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       if (NavUtils.getParentActivityName(getActivity()) != null) {
         NavUtils.navigateUpFromSameTask(getActivity());
       }
       return true;
     case R.id.menu_item_delete_single_crime:
       CrimeLab.get(getActivity()).deleteCrime(mCrime);
       if (NavUtils.getParentActivityName(getActivity()) != null) {
         NavUtils.navigateUpFromSameTask(getActivity());
       }
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Esempio n. 12
0
 /* (non-Javadoc)
  * @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
  */
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
       // Respond to the action bar's Up/Home button
     case android.R.id.home:
       NavUtils.navigateUpFromSameTask(this);
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Esempio n. 13
0
  @Override
  public void customOnNavigateUp() {
    final FragmentManager manager = getSupportFragmentManager();
    if (manager.getBackStackEntryCount() == 0) {
      NavUtils.navigateUpFromSameTask(this);
      return;
    }

    manager.popBackStack();
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       NavUtils.navigateUpFromSameTask(getActivity());
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Esempio n. 15
0
 @Override
 public boolean onMenuItemSelected(int featureId, MenuItem item) {
   int id = item.getItemId();
   if (id == android.R.id.home) {
     if (!super.onMenuItemSelected(featureId, item)) {
       NavUtils.navigateUpFromSameTask(this);
     }
     return true;
   }
   return super.onMenuItemSelected(featureId, item);
 }
Esempio n. 16
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   // TODO Auto-generated method stub
   switch (item.getItemId()) {
     case android.R.id.home:
       NavUtils.navigateUpFromSameTask(this);
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Esempio n. 17
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       NavUtils.navigateUpFromSameTask(this);
       return true;
     case R.id.menu_settings:
       startActivity(new Intent(LogicActivity.this, SettingsActivity.class));
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       NavUtils.navigateUpFromSameTask(this);
       return true;
     case MENU_OVERFLOW:
       mMenuDrawer.toggleMenu();
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Esempio n. 19
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       if (NavUtils.getParentActivityName(this) != null) {
         NavUtils.navigateUpFromSameTask(this);
       }
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Esempio n. 20
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;

      case R.id.action_save:
        saveNote();
        break;
    }
    return super.onOptionsItemSelected(item);
  }
Esempio n. 21
0
  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {

    System.out.println(item.getItemId());
    switch (item.getItemId()) {
      case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       Intent destIntent = new Intent(this, MainActivity.class);
       if (NavUtils.shouldUpRecreateTask(this, destIntent)) {
         startActivity(destIntent);
       } else {
         NavUtils.navigateUpFromSameTask(this);
       }
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   // Handle presses on the action bar items
   switch (item.getItemId()) {
     case R.id.action_person:
       //     openProfile();
       return true;
     case android.R.id.home:
       NavUtils.navigateUpFromSameTask(this);
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Esempio n. 24
0
  // Called by onCreate()
  // Get item data from intent and show
  private void showIntentItem(Bundle savedInstanceState) {
    // Get item in JSON format
    String itemJson = getIntent().getStringExtra(EXTRA_PARAM_ITEM);
    if (itemJson == null) {
      Log.e(LOG_TAG, "Get null item from intent");
      NavUtils.navigateUpFromSameTask(this);
    }

    // Transform JSON to item
    try {
      mItem = new Gson().fromJson(itemJson, Item2.class);
    } catch (Exception e) {
      e.printStackTrace();
      Log.e(LOG_TAG, "Wrong JSON format in transforming item");
      NavUtils.navigateUpFromSameTask(this);
    }

    if (savedInstanceState == null) {
      showItem();
    } else {
      initiateRefresh();
    }
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    switch (item.getItemId()) {
        // Respond to the action bar's Up/Home button
      case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
Esempio n. 26
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == android.R.id.home) {
      NavUtils.navigateUpFromSameTask(this);
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    // Handle item selection
    switch (item.getItemId()) {
      case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
      case R.id.action_settings:
        botonSettingsActividadClick();
        return true;

      default:
        return super.onOptionsItemSelected(item);
    }
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
      case R.id.menu_settings:
        this.onSettingsClick(item);

      case R.id.add_place_to_db:
        this.onAddToDBClick(item);

        return true;
    }
    return super.onOptionsItemSelected(item);
  }
Esempio n. 29
0
  // Show detail information
  private void showItem() {
    // Show attendants.
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    String userId = sharedPreferences.getString(MyConstants.USER_ID, "");
    if (userId.isEmpty()) {
      Log.d(LOG_TAG, "Got empty user ID. Go to main activity.");
      Toast.makeText(
              this, getString(R.string.data_is_out_of_date_reload_automatically), Toast.LENGTH_LONG)
          .show();
      NavUtils.navigateUpFromSameTask(this);
    }
    for (Item2.ItemMember member : mItem.getMembers()) {
      if (member.getUserkey().equals(userId)) {
        myAttendant = member.getAttendant();
        Log.d(LOG_TAG, "I attended " + myAttendant + " in item " + mItem.getId());
      }
    }
    mHeaderTitle.setText("(" + myAttendant + ") " + mItem.getAttendant() + "/" + mItem.getPeople());

    // Transform time format and show
    SimpleDateFormat sdf1 = new SimpleDateFormat(RFC3339FORMAT, Locale.US); // in format
    DateFormat sdf2 = DateFormat.getDateTimeInstance(); // out format
    String timeString = mItem.getCreatetime();
    sdf1.setTimeZone(TimeZone.getTimeZone("UTC")); // Get UTC time from server
    try {
      Date d = sdf1.parse(timeString);
      timeString = sdf2.format(d);
    } catch (ParseException e) {
      e.printStackTrace();
      Log.d(LOG_TAG, "Wrong format CreateTime from server. Show it directory");
    }
    mTextViewIntroduction.setText(timeString);

    // Show the image
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && addTransitionListener()) {
      // If we're running on Lollipop and we have added a listener to the shared element
      // transition, load the thumbnail. The listener will load the full-size image when
      // the transition is complete.
      loadThumbnail();
    } else {
      // If all other cases we should just load the full-size image now
      loadFullSizeImage();
    }

    // Show call button
    updatePhoneButtonVisibility();
  }
Esempio n. 30
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
      Intent settingsActivity = new Intent(getBaseContext(), Preferences.class);
      startActivity(settingsActivity);
    }
    if (id == android.R.id.home) {
      NavUtils.navigateUpFromSameTask(this);
    }
    return super.onOptionsItemSelected(item);
  }