Android Open Source - APO-Theta-Upsilon-App News






From Project

Back to project page APO-Theta-Upsilon-App.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project APO-Theta-Upsilon-App 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

/*
 * Copyright 2011 Devin Schwab, Umang Banugaria
 *//from  w  w  w  .j  a v a  2s .c om
 * This file is part of the APO Theta Upsilon App for Case Western Reserve University's Alpha Phi Omega Theta Upsilon Chapter.
 *
 * The APO Theta Upsilon program is free software: you can redistribute it and/or modify
 * it under the terms of the Lesser GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Lesser GNU General Public License for more details.
 *
 * You should have received a copy of the Lesser GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package edu.cwru.apo;

import org.json.JSONException;
import org.json.JSONObject;

import edu.cwru.apo.API.Methods;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

// displays most recent news from website
// will have a news ticker with latest twitter updates
public class News extends Activity implements AsyncRestRequestListener<Methods, JSONObject>{
  
  TextView text;
  
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.news);
    text = (TextView)findViewById(R.id.newsText);
    
    API api = new API(this);
    if(!api.callMethod(Methods.checkCredentials, this, (String[])null))
    {
      Toast msg = Toast.makeText(getApplicationContext(), "Error: Calling checkCredentials", Toast.LENGTH_LONG);
      msg.show();
    }
  }
  
  public void onRestRequestComplete(Methods method, JSONObject result)
  {
    if(method == Methods.checkCredentials)
    {
      if(result != null)
      {
        String requestStatus;
        try {
          requestStatus = result.getString("requestStatus");
          if(requestStatus.compareTo("valid") == 0)
          {
            // put message here
            Toast msg = Toast.makeText(getApplicationContext(), "Success!", Toast.LENGTH_LONG);
            msg.show();
          }
          else
          {
            Toast msg = Toast.makeText(getApplicationContext(), "Failure", Toast.LENGTH_LONG);
            msg.show();
          }
        } catch (JSONException e) {
          // TODO Auto-generated catch block
          // put invalid JSON message here
          Toast msg = Toast.makeText(getApplicationContext(), "JSON Error: Invalid element", Toast.LENGTH_LONG);
          msg.show();
          e.printStackTrace();
        }

      }
      else
      {
        Toast msg = Toast.makeText(getApplicationContext(), "Error: result is null", Toast.LENGTH_LONG);
        msg.show();
      }
    }
    else
    {
      Toast msg = Toast.makeText(getApplicationContext(), "Invalid method called", Toast.LENGTH_LONG);
      msg.show();
    }
  }
  
  /*@Override
  protected void onPause()
  {
    Auth.saveKeys(getSharedPreferences(APO.PREF_FILE_NAME, MODE_PRIVATE));
  }
  
  @Override
  protected void onResume()
  {
    Auth.loadKeys(getSharedPreferences(APO.PREF_FILE_NAME, MODE_PRIVATE));
  }*/

}




Java Source Code List

edu.cwru.apo.API.java
edu.cwru.apo.APO.java
edu.cwru.apo.AsyncRestRequestListener.java
edu.cwru.apo.Auth.java
edu.cwru.apo.Contract.java
edu.cwru.apo.Directory.java
edu.cwru.apo.DynamicHmac.java
edu.cwru.apo.ForgotPassword.java
edu.cwru.apo.Hex.java
edu.cwru.apo.Hmac.java
edu.cwru.apo.Home.java
edu.cwru.apo.ImageAdapter.java
edu.cwru.apo.Installation.java
edu.cwru.apo.Login.java
edu.cwru.apo.News.java
edu.cwru.apo.PhoneOpenHelper.java
edu.cwru.apo.Profile.java
edu.cwru.apo.Report.java
edu.cwru.apo.RestClient.java
edu.cwru.apo.TrustAPOHttpClient.java