Search in sources :

Example 1 with RunnableWithParameter

use of com.trovebox.android.common.util.RunnableWithParameter in project mobile-android by photo.

the class FacebookFragment method init.

void init(View view) {
    try {
        new ShowCurrentlyLoggedInUserTask(view).execute();
        messageEt = (EditText) view.findViewById(R.id.message);
        messageEt.setText(null);
        Button logOutButton = (Button) view.findViewById(R.id.logoutBtn);
        logOutButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                TrackerUtils.trackButtonClickEvent("logoutBtn", FacebookFragment.this);
                performFacebookLogout();
            }
        });
        sendButton = (Button) view.findViewById(R.id.sendBtn);
        sendButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                TrackerUtils.trackButtonClickEvent("sendBtn", FacebookFragment.this);
                if (GuiUtils.checkLoggedInAndOnline()) {
                    postPhoto();
                }
            }
        });
        {
            sendButton.setEnabled(false);
            PhotoUtils.validateShareTokenExistsAsyncAndRunAsync(photo, new RunnableWithParameter<Photo>() {

                @Override
                public void run(Photo parameter) {
                    sendButton.setEnabled(true);
                }
            }, new Runnable() {

                @Override
                public void run() {
                    sendButton.setEnabled(false);
                }
            }, new FBLoadingControl(view));
        }
    } catch (Exception ex) {
        GuiUtils.error(TAG, R.string.errorCouldNotInitFacebookFragment, ex, getActivity());
        dismissAllowingStateLoss();
    }
}
Also used : Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) RunnableWithParameter(com.trovebox.android.common.util.RunnableWithParameter) Photo(com.trovebox.android.common.model.Photo) View(android.view.View) TextView(android.widget.TextView) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with RunnableWithParameter

use of com.trovebox.android.common.util.RunnableWithParameter in project mobile-android by photo.

the class SyncUploadFragment method init.

public void init(View v, Bundle savedInstanceState) {
    final Button uploadBtn = (Button) v.findViewById(R.id.uploadBtn);
    uploadBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TrackerUtils.trackButtonClickEvent("uploadBtn", SyncUploadFragment.this);
            if (!UploadUiFragment.checkAlbumRequiredAndSpecified(albumsWrapper)) {
                return;
            }
            v.setEnabled(false);
            uploadSelectedFiles(true, true);
        }
    });
    uploadBtn.setEnabled(false);
    editTitle = (EditText) v.findViewById(R.id.edit_title);
    editTags = (EditText) v.findViewById(R.id.edit_tags);
    albumsText = ((EditText) v.findViewById(R.id.edit_albums));
    albumsText.setVisibility(Preferences.isLimitedAccountAccessType() ? View.GONE : View.VISIBLE);
    privateSwitch = (Switch) v.findViewById(R.id.private_switch);
    twitterSwitch = (Switch) v.findViewById(R.id.twitter_switch);
    facebookSwitch = (Switch) v.findViewById(R.id.facebook_switch);
    albumsText.setOnClickListener(this);
    if (Preferences.isLimitedAccountAccessType()) {
        privateSwitch.setChecked(true);
        privateSwitch.setEnabled(false);
    }
    privateSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            reinitShareSwitches(!isChecked);
        }
    });
    reinitShareSwitches();
    AccountLimitUtils2.tryToRefreshLimitInformationAndRunInContextAsync(new Runnable() {

        @Override
        public void run() {
            if (!isAdded()) {
                return;
            }
            UploadUiFragment.checkCanUpload(albumsText, uploadBtn, new RunnableWithParameter<StringMapParcelableWrapper>() {

                @Override
                public void run(StringMapParcelableWrapper parameter) {
                    SyncUploadFragment.this.albumsWrapper = parameter;
                }
            });
        }
    }, new Runnable() {

        @Override
        public void run() {
            CommonUtils.debug(TAG, "Limit information refresh failed");
        }
    }, loadingControl);
}
Also used : EditText(android.widget.EditText) StringMapParcelableWrapper(com.trovebox.android.common.util.data.StringMapParcelableWrapper) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) OnClickListener(android.view.View.OnClickListener) RunnableWithParameter(com.trovebox.android.common.util.RunnableWithParameter) View(android.view.View) CompoundButton(android.widget.CompoundButton)

Example 3 with RunnableWithParameter

use of com.trovebox.android.common.util.RunnableWithParameter in project mobile-android by photo.

the class ShareUtils method shareViaEMail.

/**
     * Shares the specified photo via email. The email application should be
     * installed on the user device
     * 
     * @param photo
     * @param context
     * @param loadingControl the loading control for token retrieval operation
     */
public static void shareViaEMail(Photo photo, final Context context, LoadingControl loadingControl) {
    RunnableWithParameter<Photo> runnable = new RunnableWithParameter<Photo>() {

        @Override
        public void run(Photo photo) {
            String mailId = "";
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", mailId, null));
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, CommonUtils.getStringResource(R.string.share_email_default_title));
            String url = PhotoUtils.getShareUrl(photo);
            String bodyText = CommonUtils.getStringResource(R.string.share_email_default_body, url, url);
            emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(bodyText));
            context.startActivity(Intent.createChooser(emailIntent, CommonUtils.getStringResource(R.string.share_email_send_title)));
        }
    };
    PhotoUtils.validateShareTokenExistsAsyncAndRunAsync(photo, runnable, null, loadingControl);
}
Also used : RunnableWithParameter(com.trovebox.android.common.util.RunnableWithParameter) Photo(com.trovebox.android.common.model.Photo) Intent(android.content.Intent)

Example 4 with RunnableWithParameter

use of com.trovebox.android.common.util.RunnableWithParameter in project mobile-android by photo.

the class ShareUtils method shareViaSystem.

/**
     * Shares the specified photo url via system share menu.
     * 
     * @param photo
     * @param context
     * @param loadingControl the loading control for token retrieval operation
     */
public static void shareViaSystem(Photo photo, final Context context, LoadingControl loadingControl) {
    RunnableWithParameter<Photo> runnable = new RunnableWithParameter<Photo>() {

        @Override
        public void run(Photo photo) {
            Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, CommonUtils.getStringResource(R.string.share_system_default_title));
            String url = PhotoUtils.getShareUrl(photo);
            String bodyText = CommonUtils.getStringResource(R.string.share_system_default_body, url, url);
            shareIntent.putExtra(Intent.EXTRA_TEXT, bodyText);
            context.startActivity(Intent.createChooser(shareIntent, CommonUtils.getStringResource(R.string.share_system_send_title)));
        }
    };
    PhotoUtils.validateShareTokenExistsAsyncAndRunAsync(photo, runnable, null, loadingControl);
}
Also used : RunnableWithParameter(com.trovebox.android.common.util.RunnableWithParameter) Photo(com.trovebox.android.common.model.Photo) Intent(android.content.Intent)

Aggregations

RunnableWithParameter (com.trovebox.android.common.util.RunnableWithParameter)4 Photo (com.trovebox.android.common.model.Photo)3 Intent (android.content.Intent)2 View (android.view.View)2 OnClickListener (android.view.View.OnClickListener)2 Button (android.widget.Button)2 CompoundButton (android.widget.CompoundButton)1 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)1 EditText (android.widget.EditText)1 TextView (android.widget.TextView)1 StringMapParcelableWrapper (com.trovebox.android.common.util.data.StringMapParcelableWrapper)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1