Android Open Source - Android-App-Project___Stay-Anonymous Second Activity






From Project

Back to project page Android-App-Project___Stay-Anonymous.

License

The source code is released under:

Apache License

If you think the Android project Android-App-Project___Stay-Anonymous 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 mobile_final;
/*from  w  ww.j  a v a 2  s.com*/
import java.io.IOException;
import java.util.*;

import com.google.cloud.backend.*;
import com.google.cloud.backend.core.CloudBackend;
import com.google.cloud.backend.core.CloudEntity;
import com.google.cloud.backend.core.CloudQuery;
import com.google.cloud.backend.core.CloudQuery.Scope;
import com.google.cloud.backend.core.Filter;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class SecondActivity extends Activity {

  private EditText numPswd; //
  private TextView titleText; //
  private EditText joinTitle; // id: editText1


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

    // attaching id to components
    joinTitle = (EditText) findViewById(R.id.editText1);
    Button addButton = (Button) findViewById(R.id.button1);
    Button enterButton = (Button) findViewById(R.id.button2);
    
    // enter a room (NON-instructor)
    enterButton.setOnClickListener(new OnClickListener() {
      public void onClick(View v)  {

        // execute the Cloud Query to check if the room exists or not
        // Cloud Query
        boolean isValidRoom = false;
        
        CloudQuery cq = new CloudQuery("Guestbook");
        String titleString = joinTitle.getText().toString();
        
            
        cq.setFilter(Filter.eq("room_title", titleString));
        cq.setScope(Scope.FUTURE_AND_PAST);
        
        CloudBackend cb = new CloudBackend();
        try {
          List<CloudEntity> results = cb.list(cq);
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        
        
        // if the room exist, then send the intent
        if(isValidRoom)  {
        
          Intent intent = new Intent(
              SecondActivity.this,
              ChattingRoomActivity.class);
          intent.putExtra("joinTitle", joinTitle
              .getText().toString());
          intent.putExtra("isInstructor", "no");
    
          startActivity(intent);
        }  else {
          
          AlertDialog.Builder builder = new AlertDialog.Builder(SecondActivity.this);
          LayoutInflater inflater = SecondActivity.this.getLayoutInflater();
          View contentView = inflater.inflate(R.layout.noroom, null);
          builder.setView(contentView).setPositiveButton("Got it!", new DialogInterface.OnClickListener() {
            
            @Override
            public void onClick(DialogInterface dialog, int which) {
              // I got it!
            }
          });  
          builder.create();
          builder.show();
        }
        
        
      }
    });
    
    
    // add a new room (for instructor)
    addButton.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        // TODO Auto-generated method stub
        AlertDialog.Builder builder = new AlertDialog.Builder(
            SecondActivity.this);

        // Get the layout inflater
        LayoutInflater inflater = SecondActivity.this
            .getLayoutInflater();
        final View contentView = inflater.inflate(R.layout.dialog_chatroom, null);
        builder.setView(contentView)
            .setPositiveButton("create",
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog,int which) {

                    // if press "confirm", go to the room
                    // with this name

  
                    Intent intent = new Intent(
                        SecondActivity.this,
                        ChattingRoomActivity.class);
                    
                    // dffdfdfdf
                    EditText editPassword = (EditText) contentView.findViewById(R.id.password);
                    EditText editTitle = (EditText) contentView.findViewById(R.id.title);
                    
                    intent.putExtra("password", Integer.parseInt(editPassword.getText().toString()));
                    intent.putExtra("joinTitle", joinTitle
                        .getText().toString());

                    intent.putExtra("isInstructor", "yes");
                    startActivity(intent);

                  }
                })
            .setNegativeButton("Cancel",
                new DialogInterface.OnClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog,
                      int which) {
                  }
                });

        builder.create();
        builder.show();
      }

    });

    // 1. Instantiate an AlertDialog.Builder with its constructor
    // AlertDialog.Builder builder = new AlertDialog.Builder(this);
    //
    // // 2. Chain together various setter methods to set the dialog
    // characteristics
    // builder.setMessage("abc")
    // .setTitle("def");
    //
    // // 3. Get the AlertDialog from create()
    // AlertDialog dialog = builder.create();
    // dialog.show();

  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
//    getMenuInflater().inflate(R.menu.second, menu);
    return true;
  }

}




Java Source Code List

com.google.cloud.backend.GCMBroadcastReceiver.java
com.google.cloud.backend.GCMIntentService.java
com.google.cloud.backend.android.mobilebackend.MobilebackendRequestInitializer.java
com.google.cloud.backend.android.mobilebackend.MobilebackendRequest.java
com.google.cloud.backend.android.mobilebackend.Mobilebackend.java
com.google.cloud.backend.android.mobilebackend.model.BlobAccess.java
com.google.cloud.backend.android.mobilebackend.model.EntityDto.java
com.google.cloud.backend.android.mobilebackend.model.EntityListDto.java
com.google.cloud.backend.android.mobilebackend.model.FilterDto.java
com.google.cloud.backend.android.mobilebackend.model.Filter.java
com.google.cloud.backend.android.mobilebackend.model.QueryDto.java
com.google.cloud.backend.core.CloudBackendAsync.java
com.google.cloud.backend.core.CloudBackendFragment.java
com.google.cloud.backend.core.CloudBackendMessaging.java
com.google.cloud.backend.core.CloudBackend.java
com.google.cloud.backend.core.CloudCallbackHandler.java
com.google.cloud.backend.core.CloudEndpointUtils.java
com.google.cloud.backend.core.CloudEntity.java
com.google.cloud.backend.core.CloudQuery.java
com.google.cloud.backend.core.Consts.java
com.google.cloud.backend.core.Filter.java
mobile_final.ChattingRoomActivity.java
mobile_final.EventListAdaptor.java
mobile_final.PostAdapter.java
mobile_final.SecondActivity.java
mobile_final.SplashFragment.java
mobile_final.StartingActivity.java
mobile_final.TestActivity.java
mobile_final.VoteHandler.java