Search in sources :

Example 1 with LiveSdkSampleApplication

use of com.microsoft.live.sample.LiveSdkSampleApplication in project LiveSDK-for-Android by liveservices.

the class ContactsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_contacts);
    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Contact contact = (Contact) parent.getItemAtPosition(position);
            ViewContactDialog dialog = new ViewContactDialog(ContactsActivity.this, contact);
            dialog.setOwnerActivity(ContactsActivity.this);
            dialog.show();
        }
    });
    LinearLayout layout = new LinearLayout(this);
    Button newCalendarButton = new Button(this);
    newCalendarButton.setText("New Contact");
    newCalendarButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            CreateContactDialog dialog = new CreateContactDialog(ContactsActivity.this);
            dialog.setOwnerActivity(ContactsActivity.this);
            dialog.show();
        }
    });
    layout.addView(newCalendarButton);
    lv.addHeaderView(layout);
    mAdapter = new ContactsListAdapter(this);
    setListAdapter(mAdapter);
    LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication();
    mClient = app.getConnectClient();
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ListView(android.widget.ListView) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) LiveSdkSampleApplication(com.microsoft.live.sample.LiveSdkSampleApplication) LinearLayout(android.widget.LinearLayout)

Example 2 with LiveSdkSampleApplication

use of com.microsoft.live.sample.LiveSdkSampleApplication in project LiveSDK-for-Android by liveservices.

the class SkyDriveActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.skydrive);
    mPrevFolderIds = new Stack<String>();
    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SkyDriveObject skyDriveObj = (SkyDriveObject) parent.getItemAtPosition(position);
            skyDriveObj.accept(new Visitor() {

                @Override
                public void visit(SkyDriveAlbum album) {
                    mPrevFolderIds.push(mCurrentFolderId);
                    loadFolder(album.getId());
                }

                @Override
                public void visit(SkyDrivePhoto photo) {
                    ViewPhotoDialog dialog = new ViewPhotoDialog(SkyDriveActivity.this, photo);
                    dialog.setOwnerActivity(SkyDriveActivity.this);
                    dialog.show();
                }

                @Override
                public void visit(SkyDriveFolder folder) {
                    mPrevFolderIds.push(mCurrentFolderId);
                    loadFolder(folder.getId());
                }

                @Override
                public void visit(SkyDriveFile file) {
                    Bundle b = new Bundle();
                    b.putString(JsonKeys.ID, file.getId());
                    b.putString(JsonKeys.NAME, file.getName());
                    showDialog(DIALOG_DOWNLOAD_ID, b);
                }

                @Override
                public void visit(SkyDriveVideo video) {
                    PlayVideoDialog dialog = new PlayVideoDialog(SkyDriveActivity.this, video);
                    dialog.setOwnerActivity(SkyDriveActivity.this);
                    dialog.show();
                }

                @Override
                public void visit(SkyDriveAudio audio) {
                    PlayAudioDialog audioDialog = new PlayAudioDialog(SkyDriveActivity.this, audio);
                    audioDialog.show();
                }
            });
        }
    });
    LinearLayout layout = new LinearLayout(this);
    Button newFolderButton = new Button(this);
    newFolderButton.setText("New Folder");
    newFolderButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            NewFolderDialog dialog = new NewFolderDialog(SkyDriveActivity.this);
            dialog.setOwnerActivity(SkyDriveActivity.this);
            dialog.show();
        }
    });
    layout.addView(newFolderButton);
    Button uploadFileButton = new Button(this);
    uploadFileButton.setText("Upload File");
    uploadFileButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getApplicationContext(), FilePicker.class);
            startActivityForResult(intent, FilePicker.PICK_FILE_REQUEST);
        }
    });
    layout.addView(uploadFileButton);
    lv.addHeaderView(layout);
    mPhotoAdapter = new SkyDriveListAdapter(this);
    setListAdapter(mPhotoAdapter);
    LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication();
    mClient = app.getConnectClient();
}
Also used : Visitor(com.microsoft.live.sample.skydrive.SkyDriveObject.Visitor) ListView(android.widget.ListView) Button(android.widget.Button) LiveSdkSampleApplication(com.microsoft.live.sample.LiveSdkSampleApplication) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Bundle(android.os.Bundle) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) VideoView(android.widget.VideoView) OnClickListener(android.view.View.OnClickListener) LinearLayout(android.widget.LinearLayout) FilePicker(com.microsoft.live.sample.util.FilePicker)

Example 3 with LiveSdkSampleApplication

use of com.microsoft.live.sample.LiveSdkSampleApplication in project LiveSDK-for-Android by liveservices.

the class ViewProfileActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_profile);
    mNameTextView = (TextView) findViewById(R.id.nameTextView);
    final LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication();
    findViewById(R.id.signOutButton).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            LiveAuthClient authClient = app.getAuthClient();
            authClient.logout(new LiveAuthListener() {

                @Override
                public void onAuthError(LiveAuthException exception, Object userState) {
                    showToast(exception.getMessage());
                }

                @Override
                public void onAuthComplete(LiveStatus status, LiveConnectSession session, Object userState) {
                    app.setSession(null);
                    app.setConnectClient(null);
                    getParent().finish();
                }
            });
        }
    });
    final LiveConnectClient connectClient = app.getConnectClient();
    connectClient.getAsync("me", new LiveOperationListener() {

        @Override
        public void onError(LiveOperationException exception, LiveOperation operation) {
            showToast(exception.getMessage());
        }

        @Override
        public void onComplete(LiveOperation operation) {
            JSONObject result = operation.getResult();
            if (result.has(JsonKeys.ERROR)) {
                JSONObject error = result.optJSONObject(JsonKeys.ERROR);
                String code = error.optString(JsonKeys.CODE);
                String message = error.optString(JsonKeys.MESSAGE);
                showToast(code + ": " + message);
            } else {
                User user = new User(result);
                mNameTextView.setText("Hello, " + user.getName() + "!");
            }
        }
    });
    connectClient.getAsync("me/picture", new LiveOperationListener() {

        @Override
        public void onError(LiveOperationException exception, LiveOperation operation) {
            showToast(exception.getMessage());
        }

        @Override
        public void onComplete(LiveOperation operation) {
            JSONObject result = operation.getResult();
            if (result.has(JsonKeys.ERROR)) {
                JSONObject error = result.optJSONObject(JsonKeys.ERROR);
                String code = error.optString(JsonKeys.CODE);
                String message = error.optString(JsonKeys.MESSAGE);
                showToast(code + ": " + message);
                return;
            }
            String location = result.optString(JsonKeys.LOCATION);
            connectClient.downloadAsync(location, new LiveDownloadOperationListener() {

                @Override
                public void onDownloadProgress(int totalBytes, int bytesRemaining, LiveDownloadOperation operation) {
                }

                @Override
                public void onDownloadFailed(LiveOperationException exception, LiveDownloadOperation operation) {
                    showToast(exception.getMessage());
                }

                @Override
                public void onDownloadCompleted(LiveDownloadOperation operation) {
                    DownloadProfilePictureAsyncTask task = new DownloadProfilePictureAsyncTask();
                    task.execute(operation);
                }
            });
        }
    });
}
Also used : LiveConnectClient(com.microsoft.live.LiveConnectClient) LiveConnectSession(com.microsoft.live.LiveConnectSession) LiveAuthException(com.microsoft.live.LiveAuthException) LiveOperation(com.microsoft.live.LiveOperation) LiveDownloadOperationListener(com.microsoft.live.LiveDownloadOperationListener) LiveOperationException(com.microsoft.live.LiveOperationException) TextView(android.widget.TextView) View(android.view.View) LiveAuthListener(com.microsoft.live.LiveAuthListener) LiveStatus(com.microsoft.live.LiveStatus) LiveDownloadOperation(com.microsoft.live.LiveDownloadOperation) JSONObject(org.json.JSONObject) LiveOperationListener(com.microsoft.live.LiveOperationListener) LiveAuthClient(com.microsoft.live.LiveAuthClient) OnClickListener(android.view.View.OnClickListener) LiveSdkSampleApplication(com.microsoft.live.sample.LiveSdkSampleApplication) JSONObject(org.json.JSONObject)

Aggregations

View (android.view.View)3 OnClickListener (android.view.View.OnClickListener)3 TextView (android.widget.TextView)3 LiveSdkSampleApplication (com.microsoft.live.sample.LiveSdkSampleApplication)3 AdapterView (android.widget.AdapterView)2 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)2 Button (android.widget.Button)2 LinearLayout (android.widget.LinearLayout)2 ListView (android.widget.ListView)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 ImageView (android.widget.ImageView)1 VideoView (android.widget.VideoView)1 LiveAuthClient (com.microsoft.live.LiveAuthClient)1 LiveAuthException (com.microsoft.live.LiveAuthException)1 LiveAuthListener (com.microsoft.live.LiveAuthListener)1 LiveConnectClient (com.microsoft.live.LiveConnectClient)1 LiveConnectSession (com.microsoft.live.LiveConnectSession)1 LiveDownloadOperation (com.microsoft.live.LiveDownloadOperation)1 LiveDownloadOperationListener (com.microsoft.live.LiveDownloadOperationListener)1