Skip to content

Commit

Permalink
friends can be added, friends list will be retrieved
Browse files Browse the repository at this point in the history
  • Loading branch information
puntubabu committed Jul 16, 2014
1 parent 75e1888 commit 3d8fa2c
Show file tree
Hide file tree
Showing 63 changed files with 173 additions and 40 deletions.
13 changes: 10 additions & 3 deletions Quizdom/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
Binary file modified Quizdom/bin/Quizdom.apk
Binary file not shown.
8 changes: 5 additions & 3 deletions Quizdom/bin/R.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ int id action_context_bar 0x7f05001d
int id action_menu_divider 0x7f050016
int id action_menu_presenter 0x7f050017
int id action_mode_close_button 0x7f050024
int id action_settings 0x7f050051
int id action_settings 0x7f050052
int id activity_chooser_view_content 0x7f050025
int id always 0x7f05000b
int id beginning 0x7f050011
Expand Down Expand Up @@ -293,7 +293,7 @@ int id imgLogo 0x7f050050
int id listMode 0x7f050001
int id list_item 0x7f050029
int id loginbutton 0x7f050045
int id lvFriends 0x7f05003d
int id lvFriendsList 0x7f05003d
int id middle 0x7f050012
int id msgView 0x7f05004a
int id never 0x7f050009
Expand All @@ -303,6 +303,7 @@ int id progress_circular 0x7f050018
int id progress_horizontal 0x7f050019
int id radio 0x7f05002f
int id regButton 0x7f05004b
int id rowTextView 0x7f050051
int id search_badge 0x7f050032
int id search_bar 0x7f050031
int id search_button 0x7f050033
Expand Down Expand Up @@ -361,7 +362,8 @@ int layout activity_signup 0x7f03001e
int layout activity_splash 0x7f03001f
int layout fragment_friends_list 0x7f030020
int layout fragment_main 0x7f030021
int layout support_simple_spinner_dropdown_item 0x7f030022
int layout friendrow 0x7f030022
int layout support_simple_spinner_dropdown_item 0x7f030023
int menu friends_list 0x7f0c0000
int menu main 0x7f0c0001
int string abc_action_bar_home_description 0x7f0a0001
Expand Down
Binary file modified Quizdom/bin/classes.dex
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R$anim.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R$attr.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R$bool.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R$color.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R$dimen.class
Binary file not shown.
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R$id.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R$integer.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R$layout.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R$string.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R$style.class
Binary file not shown.
Binary file not shown.
Binary file modified Quizdom/bin/classes/android/support/v7/appcompat/R.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/BuildConfig.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/HomeScreen.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/JSONParser.class
Binary file not shown.
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/Login.class
Binary file not shown.
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/MainActivity.class
Binary file not shown.
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/Manifest.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/Names.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/PlayerInfo.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$anim.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$attr.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$bool.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$color.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$dimen.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$drawable.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$id.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$integer.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$layout.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$menu.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$string.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$style.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R$styleable.class
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/R.class
Binary file not shown.
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/SignUp.class
Binary file not shown.
Binary file not shown.
Binary file modified Quizdom/bin/classes/com/breanawiggins/quizdom/SplashScreen.class
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions Quizdom/bin/proguard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
# view AndroidManifest.xml #generated:36
-keep class com.google.android.gcm.GCMBroadcastReceiver { <init>(...); }

# onClick res/layout/activity_friends_list.xml #generated:21
# onClick res/layout/activity_home.xml #generated:37
-keepclassmembers class * { *** onClick(...); }

Binary file modified Quizdom/bin/resources.ap_
Binary file not shown.
2 changes: 1 addition & 1 deletion Quizdom/gen/android/support/v7/appcompat/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public static final class layout {
public static final int abc_search_dropdown_item_icons_2line = 0x7f030015;
public static final int abc_search_view = 0x7f030016;
public static final int abc_simple_decor = 0x7f030017;
public static final int support_simple_spinner_dropdown_item = 0x7f030022;
public static final int support_simple_spinner_dropdown_item = 0x7f030023;
}
public static final class string {
public static final int abc_action_bar_home_description = 0x7f0a0001;
Expand Down
8 changes: 5 additions & 3 deletions Quizdom/gen/com/breanawiggins/quizdom/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ public static final class id {
public static final int action_menu_divider=0x7f050016;
public static final int action_menu_presenter=0x7f050017;
public static final int action_mode_close_button=0x7f050024;
public static final int action_settings=0x7f050051;
public static final int action_settings=0x7f050052;
public static final int activity_chooser_view_content=0x7f050025;
public static final int always=0x7f05000b;
public static final int beginning=0x7f050011;
Expand Down Expand Up @@ -1138,7 +1138,7 @@ public static final class id {
public static final int listMode=0x7f050001;
public static final int list_item=0x7f050029;
public static final int loginbutton=0x7f050045;
public static final int lvFriends=0x7f05003d;
public static final int lvFriendsList=0x7f05003d;
public static final int middle=0x7f050012;
public static final int msgView=0x7f05004a;
public static final int never=0x7f050009;
Expand All @@ -1148,6 +1148,7 @@ public static final class id {
public static final int progress_horizontal=0x7f050019;
public static final int radio=0x7f05002f;
public static final int regButton=0x7f05004b;
public static final int rowTextView=0x7f050051;
public static final int search_badge=0x7f050032;
public static final int search_bar=0x7f050031;
public static final int search_button=0x7f050033;
Expand Down Expand Up @@ -1232,7 +1233,8 @@ public static final class layout {
public static final int activity_splash=0x7f03001f;
public static final int fragment_friends_list=0x7f030020;
public static final int fragment_main=0x7f030021;
public static final int support_simple_spinner_dropdown_item=0x7f030022;
public static final int friendrow=0x7f030022;
public static final int support_simple_spinner_dropdown_item=0x7f030023;
}
public static final class menu {
public static final int friends_list=0x7f0c0000;
Expand Down
2 changes: 1 addition & 1 deletion Quizdom/res/layout/activity_friends_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:layout_height="match_parent"
android:background="@drawable/loginback" >
<ListView
android:id="@+id/lvFriends"
android:id="@+id/lvFriendsList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btnAddFriend"
Expand Down
7 changes: 7 additions & 0 deletions Quizdom/res/layout/friendrow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
160 changes: 140 additions & 20 deletions Quizdom/src/com/breanawiggins/quizdom/FriendsListActivity.java
Original file line number Diff line number Diff line change
@@ -1,57 +1,133 @@
package com.breanawiggins.quizdom;

import java.util.ArrayList;
import java.util.HashMap;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.ProgressDialog;
import android.app.ListActivity;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ListView;
import android.widget.Toast;

public class FriendsListActivity extends ActionBarActivity {
public class FriendsListActivity extends ListActivity {

//Edit Textbox
private EditText etFriend;

// Progress Dialog
private ProgressDialog pDialog;
//Friends List
private ListView lvFriendsList;

// JSON parser class
JSONParser jsonParser = new JSONParser();

//testing from a real server:
private static final String ADD_FRIEND_URL = "http://www.quizdom.comoj.com/addfriend.php";
private static final String ADD_FRIEND_URL = "http://pradeepkeshary.com/webservice/addfriend.php";
private static final String GET_FRIENDS_LIST_URL = "http://pradeepkeshary.com/webservice/getfriendslist.php";

//ids
private static final String TAG_SUCCESS = "success";
private static final String TAG_MESSAGE = "message";
private static final String TAG_FRIEND_NAME = "friend_name";
private String username;

// An array of all of our friends
private JSONArray mFriends = null;
// manages all of our friends in a list.
private ArrayList<String> mFriendsList;

private ArrayAdapter<String> listAdapter ;

SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(FriendsListActivity.this);


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

username = sp.getString("username", "ERROR");
etFriend = (EditText)findViewById(R.id.etFriend);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
lvFriendsList = (ListView)findViewById(R.id.lvFriendsList);

}

@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
// loading the comments via AsyncTask
new LoadFriends().execute();
}

/**
* Inserts the parsed data into the listview.
*/
private void updateList() {
mFriendsList.add("test1");
mFriendsList.add("test2");
mFriendsList.add("test3");
ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("username", username));

listAdapter = new ArrayAdapter<String>(this, R.layout.friendrow, mFriendsList);


lvFriendsList.setAdapter(listAdapter);

// when the user clicks a list item we
//could do something. However, we will choose
//to do nothing...
ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {

// This method is triggered if an item is click within our
// list. For our example we won't be using this, but
// it is useful to know in real life applications.

}
});
}

public class LoadFriends extends AsyncTask<Void, Void, Boolean> {

@Override
protected void onPreExecute() {
super.onPreExecute();
}

@Override
protected Boolean doInBackground(Void... arg0) {
updateJSONdata();
return null;

}

@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
updateList();
}
}

Expand All @@ -60,11 +136,6 @@ class AddFriend extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// pDialog = new ProgressDialog(AddComment.this);
// pDialog.setMessage("Posting Comment...");
// pDialog.setIndeterminate(false);
// pDialog.setCancelable(true);
// pDialog.show();
}

@Override
Expand All @@ -77,8 +148,6 @@ protected String doInBackground(String... args) {
String user = sp.getString("username", "");
String friend = etFriend.getText().toString();



try {
// Building Parameters
ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
Expand Down Expand Up @@ -114,8 +183,6 @@ protected String doInBackground(String... args) {
}

protected void onPostExecute(String file_url) {
// dismiss the dialog once product deleted
//pDialog.dismiss();
if (file_url != null){
Toast.makeText(FriendsListActivity.this, file_url, Toast.LENGTH_LONG).show();
}
Expand All @@ -132,6 +199,59 @@ public void onClick(View v){
}
}

/**
* Retrieves recent post data from the server.
*/
public void updateJSONdata() {

// Instantiate the arraylist to contain all the JSON data.
// we are going to use a bunch of key-value pairs, referring
// to the json element name, and the content, for example,
// message it the tag, and "I'm awesome" as the content..

mFriendsList = new ArrayList<String>();

// Bro, it's time to power up the J parser
JSONParser jParser = new JSONParser();
// Feed the beast our comments url, and it spits us
// back a JSON object.
JSONObject json = jParser.getJSONFromUrl(GET_FRIENDS_LIST_URL);

// when parsing JSON stuff, we should probably
// try to catch any exceptions:
try {

// I know I said we would check if "Posts were Avail." (success==1)
// before we tried to read the individual posts, but I lied...
// mFriends will tell us how many "posts" or comments are
// available
mFriends = json.getJSONArray(TAG_FRIEND_NAME);

// looping through all posts according to the json object returned
for (int i = 0; i < mFriends.length(); i++) {
JSONObject c = mFriends.getJSONObject(i);

// gets each friend
String friendname = c.getString(TAG_FRIEND_NAME);

// // creating new HashMap
// HashMap<String, String> map = new HashMap<String, String>();

//map.put(TAG_FRIEND_NAME, friendname);

// adding HashList to ArrayList
mFriendsList.add(friendname);

// annndddd, our JSON data is up to date same with our array
// list
}

} catch (JSONException e) {
e.printStackTrace();
}
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {

Expand Down
8 changes: 1 addition & 7 deletions Quizdom/src/com/breanawiggins/quizdom/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Login extends Activity implements OnClickListener {
JSONParser jsonParser = new JSONParser();

//testing from a real server:
private static final String LOGIN_URL = "http://quizdom.comoj.com/login.php";
private static final String LOGIN_URL = "http://pradeepkeshary.com/webservice/login.php";

//JSON element ids from response of php script:
private static final String TAG_SUCCESS = "success";
Expand Down Expand Up @@ -67,12 +67,6 @@ class AttemptLogin extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
// super.onPreExecute();
// pDialog = new ProgressDialog(Login.this);
// pDialog.setMessage("Attempting login...");
// pDialog.setIndeterminate(false);
// pDialog.setCancelable(true);
// pDialog.show();
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions Quizdom/src/com/breanawiggins/quizdom/SignUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class SignUp extends Activity implements OnClickListener {
JSONParser jsonParser = new JSONParser();

//testing from a real server:
private static final String LOGIN_URL = "http://quizdom.comoj.com/register.php";
private static final String LOGIN_URL = "http://pradeepkeshary.com/webservice/register.php";

//ids
private static final String TAG_SUCCESS = "success";
Expand Down Expand Up @@ -75,7 +75,7 @@ protected String doInBackground(String... args) {
LOGIN_URL, "POST", params);

// full json response
Log.d("Login attempt", json.toString());
//Log.d("Login attempt", json.toString());

// json success element
success = json.getInt(TAG_SUCCESS);
Expand Down
Binary file modified appcompat_v7/bin/android-support-v7-appcompat.jar
Binary file not shown.
Binary file modified google-play-services_lib/bin/google-play-services_lib.jar
Binary file not shown.

0 comments on commit 3d8fa2c

Please sign in to comment.