Android Open Source - mobilib Mbl Data Input Activity






From Project

Back to project page mobilib.

License

The source code is released under:

MIT License

If you think the Android project mobilib 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.datdo.mobilib.imageinput;
//from  ww  w.  j  a v  a  2  s. co m
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.datdo.mobilib.base.MblBaseFragmentActivity;
import com.datdo.mobilib.util.MblUtils;

class MblDataInputActivity extends MblBaseFragmentActivity {

    private static final String EXTRA_CALLBACK = "callback";
    private static final String EXTRA_DELEGATE = "delegate";

    private CmDataInputActivityCallback mCallback;
    private CmDataInputActivityDelegate mDelegate;

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

        String callbackKey = getIntent().getExtras().getString(EXTRA_CALLBACK);
        mCallback = (CmDataInputActivityCallback) MblUtils.removeFromCommonBundle(callbackKey);

        String delegateKey = getIntent().getExtras().getString(EXTRA_DELEGATE);
        mDelegate = (CmDataInputActivityDelegate) MblUtils.removeFromCommonBundle(delegateKey);
    }

    protected void cancelInput() {
        if (mCallback != null) {
            MblUtils.executeOnMainThread(new Runnable() {
                @Override
                public void run() {
                    mCallback.onCancel();
                }
            });
        }
        finish();
    }

    protected void finishInput(final Object... outputData) {
        if (mDelegate != null && !mDelegate.checkBeforeFinish(this, outputData)) {
            return;
        }
        if (mCallback != null) {
            MblUtils.executeOnMainThread(new Runnable() {
                @Override
                public void run() {
                    mCallback.onFinish(outputData);
                }
            });
        }
        finish();
    }

    public static interface CmDataInputActivityCallback {
        public void onFinish(Object... outputData);
        public void onCancel();
    }

    public static interface CmDataInputActivityDelegate {
        public boolean checkBeforeFinish(MblDataInputActivity me, Object...outputData);
    }

    @SuppressWarnings("rawtypes")
    protected static Intent createIntent(Class clazz, CmDataInputActivityCallback callback, CmDataInputActivityDelegate delegate) {
        Context context = MblUtils.getCurrentContext();
        Intent intent = new Intent(context, clazz);

        if (callback != null) {
            intent.putExtra(EXTRA_CALLBACK, MblUtils.putToCommonBundle(callback));
        }

        if (delegate != null) {
            intent.putExtra(EXTRA_DELEGATE, MblUtils.putToCommonBundle(delegate));
        }

        return intent;
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        cancelInput();
    }
}




Java Source Code List

com.datdo.mobilib.api.DBBase.java
com.datdo.mobilib.api.DBHelper.java
com.datdo.mobilib.api.MblApi.java
com.datdo.mobilib.api.MblCache.java
com.datdo.mobilib.api.MblException.java
com.datdo.mobilib.api.MblSSLCertificateUtils.java
com.datdo.mobilib.base.MblActivityPlugin.java
com.datdo.mobilib.base.MblBaseActionBarActivity.java
com.datdo.mobilib.base.MblBaseActivity.java
com.datdo.mobilib.base.MblBaseAdapter.java
com.datdo.mobilib.base.MblBaseApplication.java
com.datdo.mobilib.base.MblBaseFragmentActivity.java
com.datdo.mobilib.base.MblDecorView.java
com.datdo.mobilib.base.MblNetworkStatusChangedReceiver.java
com.datdo.mobilib.event.MblCommonEvents.java
com.datdo.mobilib.event.MblEventCenter.java
com.datdo.mobilib.event.MblEventListener.java
com.datdo.mobilib.event.MblStrongEventListener.java
com.datdo.mobilib.event.MblWeakArrayList.java
com.datdo.mobilib.imageinput.MblAutoResizeSquareImageView.java
com.datdo.mobilib.imageinput.MblDataInputActivity.java
com.datdo.mobilib.imageinput.MblImageFolderScanner.java
com.datdo.mobilib.imageinput.MblImageInput.java
com.datdo.mobilib.imageinput.MblImagePickingScanEngine.java
com.datdo.mobilib.imageinput.MblPickImageActivity.java
com.datdo.mobilib.imageinput.MblPickImageGridViewAdapter.java
com.datdo.mobilib.imageinput.MblTakeImageActivity.java
com.datdo.mobilib.util.MblAsyncTask.java
com.datdo.mobilib.util.MblImageLoader.java
com.datdo.mobilib.util.MblLinkMovementMethod.java
com.datdo.mobilib.util.MblUrlRecognizer.java
com.datdo.mobilib.util.MblUtils.java
com.datdo.mobilib.widget.MblHorizontalViewPager.java
com.datdo.mobilib.widget.MblListViewWithScrollableItems.java
com.datdo.mobilib.widget.MblSequenceImage.java
com.datdo.mobilib.widget.MblSideMenuEnabledLayout.java
com.datdo.mobilib.widget.MblTouchImageView.java