Android Open Source - PlayTogether User Info Activity






From Project

Back to project page PlayTogether.

License

The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project PlayTogether listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.rockylearnstodevelop.playtogether;
//from   w w w  . j  av  a  2 s. c  o m
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public class UserInfoActivity extends Activity {

  public static final String TAG = UserInfoActivity.class.getSimpleName();
  private Button mReject;
  private Button mAccept;
  private TextView mSport;
  private TextView mTime;
  private TextView mLevel;
  private TextView mName;
  
  private String objectId;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_info);
    // Show the Up button in the action bar.
    setupActionBar();
    
    Intent intent = getIntent();
    String sport = intent.getExtras().getString(ParseConstants.KEY_SPORT);
    String time = intent.getExtras().getString(ParseConstants.KEY_TIME);
    String level = intent.getExtras().getString(ParseConstants.KEY_LEVEL);
    String name = intent.getExtras().getString(ParseConstants.KEY_SENDERNAME);
    objectId = intent.getExtras().getString(ParseConstants.KEY_OBJECTID);
    
    mReject = (Button) findViewById(R.id.reject);
    mAccept = (Button) findViewById(R.id.playButton);
    mSport = (TextView) findViewById(R.id.sportName);
    mTime = (TextView) findViewById(R.id.sportTime);
    mLevel = (TextView) findViewById(R.id.sportLevel);
    mName = (TextView) findViewById(R.id.userName);
    
    
    mSport.setText(sport);
    mTime.setText(time);
    mLevel.setText(level);
    mName.setText(name);
    
    mReject.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
        Intent intent = new Intent(UserInfoActivity.this, MainActivity.class);
        startActivity(intent);
        Log.d(TAG, "objectId: " + objectId);
        deletRequest(objectId);
      }
    });
    
    mAccept.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
        Intent intent = new Intent(UserInfoActivity.this, MainActivity.class);
        startActivity(intent);
        //feed back on the activity
        
        //delete the request
        
        Toast.makeText(UserInfoActivity.this, "You have accepted the request", Toast.LENGTH_LONG).show();
      }
    });
  }

  protected void deletRequest(String objectId) {
    ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseConstants.CLASS_ACTIVITYREQUEST);
    query.getInBackground(objectId, new GetCallback<ParseObject>() {

      @Override
      public void done(ParseObject request, ParseException e) {
        if(e == null){
          try {
            request.delete();
          } catch (ParseException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        }
        else{
          Log.d(TAG, e.getMessage());
        }
      }
    });
  }

  /**
   * Set up the {@link android.app.ActionBar}.
   */
  private void setupActionBar() {

    getActionBar().setDisplayHomeAsUpEnabled(true);

  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.user_info, menu);
    return true;
  }

  @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;
    }
    return super.onOptionsItemSelected(item);
  }

}




Java Source Code List

com.rockylearnstodevelop.playtogether.ActivitiesFragment.java
com.rockylearnstodevelop.playtogether.ActivityAdapter.java
com.rockylearnstodevelop.playtogether.FileHelper.java
com.rockylearnstodevelop.playtogether.ImageResizer.java
com.rockylearnstodevelop.playtogether.LoginActivity.java
com.rockylearnstodevelop.playtogether.MainActivity.java
com.rockylearnstodevelop.playtogether.MatchActivity.java
com.rockylearnstodevelop.playtogether.NoMatchActivity.java
com.rockylearnstodevelop.playtogether.ParseConstants.java
com.rockylearnstodevelop.playtogether.PlayWithMe2Application.java
com.rockylearnstodevelop.playtogether.RequestAdapter.java
com.rockylearnstodevelop.playtogether.RequestFragment.java
com.rockylearnstodevelop.playtogether.SectionsPagerAdapter.java
com.rockylearnstodevelop.playtogether.SignupActivity.java
com.rockylearnstodevelop.playtogether.UserInfoActivity.java
com.rockylearnstodevelop.playtogether.WannaPlayFragment.java