Android Open Source - rsmonitor-heartrate F Q L Query






From Project

Back to project page rsmonitor-heartrate.

License

The source code is released under:

GNU General Public License

If you think the Android project rsmonitor-heartrate 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.facebook.android;
/*  w  w  w  .j  av  a 2 s  .c o m*/
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.renaultsport.heartrate.R;

import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class FQLQuery extends Dialog {

    private EditText mFQLQuery;
    private TextView mFQLOutput;
    private Button mSubmitButton;
    private Activity activity;
    private Handler mHandler;
    private ProgressDialog dialog;

    public FQLQuery(Activity activity) {
        super(activity);
        this.activity = activity;
        setTitle(R.string.fqlquery);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mHandler = new Handler();

        setContentView(R.layout.fql_query);
        LayoutParams params = getWindow().getAttributes();
        params.width = LayoutParams.FILL_PARENT;
        params.height = LayoutParams.FILL_PARENT;
        getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

        mFQLQuery = (EditText) findViewById(R.id.fqlquery);
        mFQLOutput = (TextView) findViewById(R.id.fqlOutput);
        mSubmitButton = (Button) findViewById(R.id.submit_button);

        mSubmitButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .hideSoftInputFromWindow(mFQLQuery.getWindowToken(), 0);
                dialog = ProgressDialog.show(FQLQuery.this.activity, "",
                        FQLQuery.this.activity.getString(R.string.please_wait), true, true);
                /*
                 * Source tag: fql_query_tag
                 */
                String query = mFQLQuery.getText().toString();
                Bundle params = new Bundle();
                params.putString("method", "fql.query");
                params.putString("query", query);
                Utility.mAsyncRunner.request(null, params, new FQLRequestListener());
            }
        });
    }

    public class FQLRequestListener extends BaseRequestListener {

        @Override
        public void onComplete(final String response, final Object state) {
            dialog.dismiss();
            /*
             * Output can be a JSONArray or a JSONObject.
             * Try JSONArray and if there's a JSONException, parse to JSONObject
             */
            try {
                JSONArray json = new JSONArray(response);
                setText(json.toString(2));
            } catch (JSONException e) {
                try {
                    /*
                     * JSONObject probably indicates there was some error
                     * Display that error, but for end user you should parse the
                     * error and show appropriate message
                     */
                    JSONObject json = new JSONObject(response);
                    setText(json.toString(2));
                } catch (JSONException e1) {
                    setText(activity.getString(R.string.exception) + e1.getMessage());
                }
            }
        }

        public void onFacebookError(FacebookError error) {
            dialog.dismiss();
            setText(activity.getString(R.string.facebook_error) + error.getMessage());
        }
    }

    public void setText(final String txt) {
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                mFQLOutput.setText(txt);
                mFQLOutput.setVisibility(View.VISIBLE);
            }
        });
    }
}




Java Source Code List

com.facebook.android.AsyncFacebookRunner.java
com.facebook.android.BaseDialogListener.java
com.facebook.android.BaseRequestListener.java
com.facebook.android.DialogError.java
com.facebook.android.FQLQuery.java
com.facebook.android.FacebookError.java
com.facebook.android.FacebookFunctions.java
com.facebook.android.Facebook.java
com.facebook.android.FbDialog.java
com.facebook.android.FieldsConnectionsDialog.java
com.facebook.android.FriendsGetProfilePics.java
com.facebook.android.FriendsList.java
com.facebook.android.GraphExplorer.java
com.facebook.android.IntentUriHandler.java
com.facebook.android.LoginButton.java
com.facebook.android.PermissionsDialog.java
com.facebook.android.Places.java
com.facebook.android.SessionEvents.java
com.facebook.android.SessionStore.java
com.facebook.android.TokenRefreshDialog.java
com.facebook.android.UpdateStatusResultDialog.java
com.facebook.android.UploadPhotoResultDialog.java
com.facebook.android.Util.java
com.facebook.android.Utility.java
com.googlecode.android.widgets.DateSlider.AlternativeDateSlider.java
com.googlecode.android.widgets.DateSlider.CustomDateSlider.java
com.googlecode.android.widgets.DateSlider.DateSlider.java
com.googlecode.android.widgets.DateSlider.DateTimeSlider.java
com.googlecode.android.widgets.DateSlider.DefaultDateSlider.java
com.googlecode.android.widgets.DateSlider.MonthYearDateSlider.java
com.googlecode.android.widgets.DateSlider.ScrollLayout.java
com.googlecode.android.widgets.DateSlider.TimeSlider.java
com.googlecode.android.widgets.DateSlider.TimeView.java
com.renaultsport.heartrate.ActivityMain.java
com.renaultsport.heartrate.ActivityRecord.java
com.renaultsport.heartrate.ActivitySplash.java
com.renaultsport.heartrate.ActivityUpload.java
com.renaultsport.heartrate.ActivityVideoReader.java
com.renaultsport.heartrate.ActivityWarning.java
com.renaultsport.heartrate.MainApplication.java
com.renaultsport.heartrate.utils.CaptureCamera.java
com.renaultsport.heartrate.utils.ClientThread.java
com.renaultsport.heartrate.utils.Constants.java
com.renaultsport.heartrate.utils.RunEncoder.java
team.stride.tabs.TabGroupActivity.java