Android Open Source - CloudPaste-Android Share To Cloud Paste Activity






From Project

Back to project page CloudPaste-Android.

License

The source code is released under:

MIT License

If you think the Android project CloudPaste-Android 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.alwaysallthetime.cloudpaste;
/*  w  w w  .j  av a 2  s .  c o  m*/
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Toast;

import com.alwaysallthetime.adnlib.data.Message;
import com.alwaysallthetime.adnlib.response.MessageResponseHandler;
import com.alwaysallthetime.messagebeast.ADNSharedPreferences;

public class ShareToCloudPasteActivity extends BaseCloudPasteActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final Handler handler = new Handler();

        Intent intent = getIntent();
        String action = intent.getAction();
        String type = intent.getType();

        showProgress(R.string.share_progress);

        if(Intent.ACTION_SEND.equals(action) && "text/plain".equals(type)) {
            if(ADNSharedPreferences.isLoggedIn()) {
                String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
                if(sharedText != null) {
                    CloudPaste.pasteToCloud(sharedText, MessageManagerInstance.getInstance(), new MessageResponseHandler() {
                        @Override
                        public void onSuccess(Message responseData) {
                            handler.post(new Runnable() {
                                @Override
                                public void run() {
                                    Toast.makeText(ShareToCloudPasteActivity.this, R.string.saved_toast, Toast.LENGTH_LONG).show();
                                    finish();
                                }
                            });
                        }

                        @Override
                        public void onError(Exception error) {
                            super.onError(error);
                            handler.post(new Runnable() {
                                @Override
                                public void run() {
                                    Toast.makeText(ShareToCloudPasteActivity.this, R.string.generic_error, Toast.LENGTH_LONG).show();
                                    finish();
                                }
                            });
                        }
                    });
                }
            } else {
                Toast.makeText(this, R.string.login_error, Toast.LENGTH_LONG).show();
                finish();
            }
        } else {
            Toast.makeText(this, R.string.generic_error, Toast.LENGTH_LONG).show();
            finish();
        }
    }
}




Java Source Code List

com.alwaysallthetime.cloudpaste.BaseCloudPasteActivity.java
com.alwaysallthetime.cloudpaste.BaseLoginActivity.java
com.alwaysallthetime.cloudpaste.CloudPaste.java
com.alwaysallthetime.cloudpaste.LaunchActivity.java
com.alwaysallthetime.cloudpaste.LoginWebViewActivity.java
com.alwaysallthetime.cloudpaste.MainActivity.java
com.alwaysallthetime.cloudpaste.MessageManagerInstance.java
com.alwaysallthetime.cloudpaste.ShareToCloudPasteActivity.java
com.alwaysallthetime.cloudpaste.adapter.MainListViewAdapter.java
com.alwaysallthetime.cloudpaste.client.CloudPasteADNClient.java