Example usage for android.view Window FEATURE_INDETERMINATE_PROGRESS

List of usage examples for android.view Window FEATURE_INDETERMINATE_PROGRESS

Introduction

In this page you can find the example usage for android.view Window FEATURE_INDETERMINATE_PROGRESS.

Prototype

int FEATURE_INDETERMINATE_PROGRESS

To view the source code for android.view Window FEATURE_INDETERMINATE_PROGRESS.

Click Source Link

Document

Flag for indeterminate progress.

Usage

From source file:org.getlantern.firetweet.activity.support.SignInActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
    mResolver = getContentResolver();// w ww  .  j  a  v a2  s.  com
    mApplication = FiretweetApplication.getInstance(this);
    setContentView(R.layout.activity_sign_in);
    setSupportProgressBarIndeterminateVisibility(false);
    final long[] account_ids = getActivatedAccountIds(this);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(account_ids.length > 0);
    }

    if (savedInstanceState != null) {
        mAPIUrlFormat = savedInstanceState.getString(Accounts.API_URL_FORMAT);
        mAuthType = savedInstanceState.getInt(Accounts.AUTH_TYPE);
        mSameOAuthSigningUrl = savedInstanceState.getBoolean(Accounts.SAME_OAUTH_SIGNING_URL);
        mConsumerKey = trim(savedInstanceState.getString(Accounts.CONSUMER_KEY));
        mConsumerSecret = trim(savedInstanceState.getString(Accounts.CONSUMER_SECRET));
        mUsername = savedInstanceState.getString(Accounts.SCREEN_NAME);
        mPassword = savedInstanceState.getString(Accounts.PASSWORD);
        mAPIChangeTimestamp = savedInstanceState.getLong(EXTRA_API_LAST_CHANGE);
    }

    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/ProximaNova-Semibold.ttf");

    mSigninSignupContainer.setOrientation(
            mAuthType == Accounts.AUTH_TYPE_TWIP_O_MODE ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);

    final Resources resources = getResources();
    final ColorStateList color = ColorStateList.valueOf(resources.getColor(R.color.material_light_blue));

    mSignInButton.setTextColor(Color.parseColor("#38c6f3"));
    mSignInButton.setBackgroundColor(Color.parseColor("#E7E7E7"));
    mSignInButton.setBackgroundResource(R.drawable.sign_in_btn);
    mSignInButton.setTypeface(font);
    mSignUpButton.setTypeface(font);
    poweredByButton.setTypeface(font);

    autoTweetCheckBox = (CheckBox) findViewById(R.id.autotweet_checkbox);
    autoTweetText = (TextView) findViewById(R.id.should_send_autotweet);

    // don't display the auto tweet text on subsequent runs
    if (mPreferences.contains(APP_RAN_BEFORE)) {
        autoTweetCheckBox.setVisibility(View.GONE);
        autoTweetText.setVisibility(View.GONE);
    } else {
        // the checkbox color attribute isn't a simple attribute
        // we have to grab the default checkbox and apply a color filter
        int id = Resources.getSystem().getIdentifier("btn_check_holo_light", "drawable", "android");
        Drawable drawable = ResourcesCompat.getDrawable(getResources(), id, null);
        if (drawable != null) {
            drawable.setColorFilter(Color.parseColor("white"), PorterDuff.Mode.SRC_ATOP);
            autoTweetCheckBox.setButtonDrawable(drawable);
        }

        autoTweetText.setTypeface(font);
        autoTweetText.setTextColor(Color.parseColor("white"));
    }

    setSignInButton();
}

From source file:org.mariotaku.twidere.activity.SignInActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    requestSupportWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
    mResolver = getContentResolver();/* w w  w  .  j  a  v  a 2 s.c om*/
    mApplication = TwidereApplication.getInstance(this);
    setContentView(R.layout.sign_in);
    setSupportProgressBarIndeterminateVisibility(false);
    final long[] account_ids = getActivatedAccountIds(this);
    getSupportActionBar().setDisplayHomeAsUpEnabled(account_ids.length > 0);

    Bundle bundle = savedInstanceState == null ? getIntent().getExtras() : savedInstanceState;
    if (bundle == null) {
        bundle = new Bundle();
    }
    mRESTBaseURL = bundle.getString(Accounts.REST_BASE_URL);
    mOAuthBaseURL = bundle.getString(Accounts.OAUTH_BASE_URL);
    mSigningRESTBaseURL = bundle.getString(Accounts.SIGNING_REST_BASE_URL);
    mSigningOAuthBaseURL = bundle.getString(Accounts.SIGNING_OAUTH_BASE_URL);

    if (isEmpty(mRESTBaseURL)) {
        mRESTBaseURL = DEFAULT_REST_BASE_URL;
    }
    if (isEmpty(mOAuthBaseURL)) {
        mOAuthBaseURL = DEFAULT_OAUTH_BASE_URL;
    }
    if (isEmpty(mSigningRESTBaseURL)) {
        mSigningRESTBaseURL = DEFAULT_SIGNING_REST_BASE_URL;
    }
    if (isEmpty(mSigningOAuthBaseURL)) {
        mSigningOAuthBaseURL = DEFAULT_SIGNING_OAUTH_BASE_URL;
    }

    mUsername = bundle.getString(Accounts.SCREEN_NAME);
    mPassword = bundle.getString(Accounts.PASSWORD);
    mAuthType = bundle.getInt(Accounts.AUTH_TYPE);
    if (bundle.containsKey(Accounts.USER_COLOR)) {
        mUserColor = bundle.getInt(Accounts.USER_COLOR, Color.TRANSPARENT);
    }
    mUsernamePasswordContainer
            .setVisibility(mAuthType == Accounts.AUTH_TYPE_TWIP_O_MODE ? View.GONE : View.VISIBLE);
    mSigninSignupContainer.setOrientation(
            mAuthType == Accounts.AUTH_TYPE_TWIP_O_MODE ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);

    mEditUsername.setText(mUsername);
    mEditUsername.addTextChangedListener(this);
    mEditPassword.setText(mPassword);
    mEditPassword.addTextChangedListener(this);
    setSignInButton();
    setUserColorButton();
    if (!mPreferences.getBoolean(PREFERENCE_KEY_API_UPGRADE_CONFIRMED, false)) {
        final FragmentManager fm = getSupportFragmentManager();
        if (fm.findFragmentByTag(FRAGMENT_TAG_API_UPGRADE_NOTICE) == null
                || !fm.findFragmentByTag(FRAGMENT_TAG_API_UPGRADE_NOTICE).isAdded()) {
            new APIUpgradeConfirmDialog().show(getSupportFragmentManager(), "api_upgrade_notice");
        }
    }
}

From source file:org.onebusaway.android.ui.HomeActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);/*w  ww.  j  a  v a  2  s .c o m*/
    mContext = this;

    setupNavigationDrawer();

    setupSlidingPanel();

    setupMapState(savedInstanceState);

    setupMyLocationButton();

    setupGooglePlayServices();

    UIUtils.setupActionBar(this);

    autoShowWhatsNew();

    checkRegionStatus();

    // Tutorials - only one will show at a time, so "Welcome" is shown before "Recents"
    ShowcaseViewUtils.showTutorial(ShowcaseViewUtils.TUTORIAL_WELCOME, this, null);
    ShowcaseViewUtils.showTutorial(ShowcaseViewUtils.TUTORIAL_RECENT_STOPS_ROUTES, this, null);
}

From source file:edu.sfsu.cs.orange.ocr.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    checkFirstLaunch();//from  w ww. j a v  a2 s  .  co  m

    if (isFirstLaunch) {
        setDefaultPreferences();
    }

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.capture);
    viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
    cameraButtonView = findViewById(R.id.camera_button_view);
    resultView = findViewById(R.id.result_view);

    statusViewBottom = (TextView) findViewById(R.id.status_view_bottom);
    registerForContextMenu(statusViewBottom);
    statusViewTop = (TextView) findViewById(R.id.status_view_top);
    registerForContextMenu(statusViewTop);

    handler = null;
    lastResult = null;
    hasSurface = false;
    beepManager = new BeepManager(this);

    // Camera shutter button
    if (DISPLAY_SHUTTER_BUTTON) {
        shutterButton = (ShutterButton) findViewById(R.id.shutter_button);
        shutterButton.setOnShutterButtonListener(this);
    }

    ocrResultView = (TextView) findViewById(R.id.ocr_result_text_view);
    registerForContextMenu(ocrResultView);
    translationView = (TextView) findViewById(R.id.translation_text_view);
    registerForContextMenu(translationView);

    progressView = (View) findViewById(R.id.indeterminate_progress_indicator_view);

    cameraManager = new CameraManager(getApplication());
    viewfinderView.setCameraManager(cameraManager);

    // Set listener to change the size of the viewfinder rectangle.
    viewfinderView.setOnTouchListener(new View.OnTouchListener() {
        int lastX = -1;
        int lastY = -1;

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                lastX = -1;
                lastY = -1;
                return true;
            case MotionEvent.ACTION_MOVE:
                int currentX = (int) event.getX();
                int currentY = (int) event.getY();

                try {
                    Rect rect = cameraManager.getFramingRect();

                    final int BUFFER = 50;
                    final int BIG_BUFFER = 60;
                    if (lastX >= 0) {
                        // Adjust the size of the viewfinder rectangle. Check if the touch event occurs in the corner areas first, because the regions overlap.
                        if (((currentX >= rect.left - BIG_BUFFER && currentX <= rect.left + BIG_BUFFER)
                                || (lastX >= rect.left - BIG_BUFFER && lastX <= rect.left + BIG_BUFFER))
                                && ((currentY <= rect.top + BIG_BUFFER && currentY >= rect.top - BIG_BUFFER)
                                        || (lastY <= rect.top + BIG_BUFFER
                                                && lastY >= rect.top - BIG_BUFFER))) {
                            // Top left corner: adjust both top and left sides
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BIG_BUFFER && currentX <= rect.right + BIG_BUFFER)
                                || (lastX >= rect.right - BIG_BUFFER && lastX <= rect.right + BIG_BUFFER))
                                && ((currentY <= rect.top + BIG_BUFFER && currentY >= rect.top - BIG_BUFFER)
                                        || (lastY <= rect.top + BIG_BUFFER
                                                && lastY >= rect.top - BIG_BUFFER))) {
                            // Top right corner: adjust both top and right sides
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.left - BIG_BUFFER && currentX <= rect.left + BIG_BUFFER)
                                || (lastX >= rect.left - BIG_BUFFER && lastX <= rect.left + BIG_BUFFER))
                                && ((currentY <= rect.bottom + BIG_BUFFER
                                        && currentY >= rect.bottom - BIG_BUFFER)
                                        || (lastY <= rect.bottom + BIG_BUFFER
                                                && lastY >= rect.bottom - BIG_BUFFER))) {
                            // Bottom left corner: adjust both bottom and left sides
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BIG_BUFFER && currentX <= rect.right + BIG_BUFFER)
                                || (lastX >= rect.right - BIG_BUFFER && lastX <= rect.right + BIG_BUFFER))
                                && ((currentY <= rect.bottom + BIG_BUFFER
                                        && currentY >= rect.bottom - BIG_BUFFER)
                                        || (lastY <= rect.bottom + BIG_BUFFER
                                                && lastY >= rect.bottom - BIG_BUFFER))) {
                            // Bottom right corner: adjust both bottom and right sides
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.left - BUFFER && currentX <= rect.left + BUFFER)
                                || (lastX >= rect.left - BUFFER && lastX <= rect.left + BUFFER))
                                && ((currentY <= rect.bottom && currentY >= rect.top)
                                        || (lastY <= rect.bottom && lastY >= rect.top))) {
                            // Adjusting left side: event falls within BUFFER pixels of left side, and between top and bottom side limits
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 0);
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BUFFER && currentX <= rect.right + BUFFER)
                                || (lastX >= rect.right - BUFFER && lastX <= rect.right + BUFFER))
                                && ((currentY <= rect.bottom && currentY >= rect.top)
                                        || (lastY <= rect.bottom && lastY >= rect.top))) {
                            // Adjusting right side: event falls within BUFFER pixels of right side, and between top and bottom side limits
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 0);
                            viewfinderView.removeResultText();
                        } else if (((currentY <= rect.top + BUFFER && currentY >= rect.top - BUFFER)
                                || (lastY <= rect.top + BUFFER && lastY >= rect.top - BUFFER))
                                && ((currentX <= rect.right && currentX >= rect.left)
                                        || (lastX <= rect.right && lastX >= rect.left))) {
                            // Adjusting top side: event falls within BUFFER pixels of top side, and between left and right side limits
                            cameraManager.adjustFramingRect(0, 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentY <= rect.bottom + BUFFER && currentY >= rect.bottom - BUFFER)
                                || (lastY <= rect.bottom + BUFFER && lastY >= rect.bottom - BUFFER))
                                && ((currentX <= rect.right && currentX >= rect.left)
                                        || (lastX <= rect.right && lastX >= rect.left))) {
                            // Adjusting bottom side: event falls within BUFFER pixels of bottom side, and between left and right side limits
                            cameraManager.adjustFramingRect(0, 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        }
                    }
                } catch (NullPointerException e) {
                    Log.e(TAG, "Framing rect not available", e);
                }
                v.invalidate();
                lastX = currentX;
                lastY = currentY;
                return true;
            case MotionEvent.ACTION_UP:
                lastX = -1;
                lastY = -1;
                return true;
            }
            return false;
        }
    });

    isEngineReady = false;
    aq = new AQuery(this);
    beerQuery = new BeerQuery();

}

From source file:org.onebusaway.android.report.ui.InfrastructureIssueActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.infrastructure_issue);

    setUpOpen311();/* w w w  .  j  av a2 s .  co  m*/

    setUpProgressBar();

    setupMapFragment(savedInstanceState);

    setupLocationHelper(savedInstanceState);

    setupViews();

    setupIntentData(savedInstanceState);

    setupIconColors();

    initLocation();

    setActionBarTitle(savedInstanceState);
}

From source file:com.arantius.tivocommander.MyShows.java

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

    Bundle bundle = getIntent().getExtras();
    if (MindRpc.init(this, bundle)) {
        return;/*w ww . j  a v  a2  s  . co m*/
    }

    if (bundle != null) {
        mFolderId = bundle.getString("folderId");
        setTitle(bundle.getString("folderName"));
    } else {
        mFolderId = null;
        setTitle("My Shows");
    }

    Utils.log(String.format("MyShows: folderId:%s", mFolderId));

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.list_my_shows);

    if (mFolderId != null) {
        findViewById(R.id.sort_button).setVisibility(View.GONE);
    }

    mListAdapter = new ShowsAdapter(this);
    final ListView lv = getListView();
    lv.setAdapter(mListAdapter);
    lv.setOnItemClickListener(mOnClickListener);
    lv.setLongClickable(true);
    lv.setOnItemLongClickListener(this);

    mDetailCallback = new MindRpcResponseListener() {
        public void onResponse(MindRpcResponse response) {
            setProgressIndicator(-1);

            String itemId = "recordingFolderItem";
            if ("deleted".equals(mFolderId)) {
                itemId = "recording";
            }
            final JsonNode items = response.getBody().path(itemId);

            ArrayList<Integer> slotMap = mRequestSlotMap.get(response.getRpcId());

            MindRpc.saveBodyId(items.path(0).path("bodyId").asText(), MyShows.this);

            for (int i = 0; i < items.size(); i++) {
                int pos = slotMap.get(i);
                JsonNode item = items.get(i);
                mShowData.set(pos, item);
                mShowStatus.set(pos, ShowStatus.LOADED);
            }

            mRequestSlotMap.remove(response.getRpcId());
            mListAdapter.notifyDataSetChanged();
        }
    };

    mIdSequenceCallback = new MindRpcResponseListener() {
        public void onResponse(MindRpcResponse response) {
            JsonNode body = response.getBody();
            if ("error".equals(body.path("status").asText())) {
                Utils.log("Handling mIdSequenceCallback error response by " + "finishWithRefresh()");
                finishWithRefresh();
                return;
            }
            if (!body.has("objectIdAndType")) {
                Utils.log("Handling mIdSequenceCallback empty response by " + "finishWithRefresh()");
                finishWithRefresh();
                return;
            }

            setProgressIndicator(-1);

            mShowIds = (ArrayNode) body.findValue("objectIdAndType");
            if (mFolderId == null) {
                mShowIds.add("deleted");
            }

            if (mShowIds != null) {
                // e.g. "Suggestions" can be present, but empty!
                for (int i = 0; i < mShowIds.size(); i++) {
                    mShowData.add(null);
                    mShowStatus.add(ShowStatus.MISSING);
                }
            }
            mListAdapter.notifyDataSetChanged();
        }
    };

    startRequest();
}

From source file:com.arantius.tivocommander.SeasonPass.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (MindRpc.init(this, null)) {
        return;/*from   w w w. ja v  a  2 s.  c om*/
    }

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    Utils.activateHomeButton(this);
    setTitle("Season Pass Manager");
    setContentView(R.layout.list_season_pass);

    mListAdapter = new SubscriptionAdapter();
    setListAdapter(mListAdapter);
    DragSortListView dslv = (DragSortListView) getListView();
    dslv.setOnItemClickListener(mOnClickListener);
    dslv.setDropListener(mOnDrop);
    dslv.setLongClickable(true);
    dslv.setOnItemLongClickListener(this);

    startRequest();
}

From source file:com.edible.ocr.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    checkFirstLaunch();//  w w w .  ja v a2 s . c o m

    if (isFirstLaunch) {
        setDefaultPreferences();
    }
    currentContext = this;
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.capture);
    viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
    cameraButtonView = findViewById(R.id.camera_button_view);
    resultView = findViewById(R.id.result_view);

    statusViewBottom = (TextView) findViewById(R.id.status_view_bottom);
    registerForContextMenu(statusViewBottom);
    statusViewTop = (TextView) findViewById(R.id.status_view_top);
    registerForContextMenu(statusViewTop);
    handler = null;
    lastResult = null;
    hasSurface = false;
    beepManager = new BeepManager(this);

    // Camera shutter button
    if (DISPLAY_SHUTTER_BUTTON) {
        shutterButton = (ShutterButton) findViewById(R.id.shutter_button);
        shutterButton.setOnShutterButtonListener(this);

    }
    settingButton = (Button) findViewById(R.id.setting_button);
    settingButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(currentContext, PreferencesActivity.class);
            startActivity(intent);
        }
    });

    aboutButton = (Button) findViewById(R.id.about_button);
    aboutButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(currentContext, HelpActivity.class);
            intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, HelpActivity.ABOUT_PAGE);
            startActivity(intent);
        }
    });
    final EditText editText = (EditText) findViewById(R.id.typed_result);
    editText.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                // add capture button function 
                Intent openDetail = new Intent(currentContext, DetailInfo.class);
                String req = editText.getText().toString();
                //             openDetail.putExtra("request", "Filet Steak");
                openDetail.putExtra("request", req);
                editText.setText("");
                startActivity(openDetail);
                handled = true;
            }
            return handled;
        }
    });
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    //DB_textview = (TextView)findViewById(R.id.DB_text_view);
    //new HttpAsyncTask().execute("https://www.googleapis.com/language/translate/v2?key=" + KEY + "&q=hello%20world&source=en&target=de");
    /* For Client Server Connection */
    getButton = (Button) findViewById(R.id.get_text_button);
    getButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent openDetail = new Intent(currentContext, DetailInfo.class);
            String req = (String) ocrResultView.getText();
            //         openDetail.putExtra("request", "Filet Steak");
            openDetail.putExtra("request", req);
            startActivity(openDetail);

        }

    });
    ocrResultView = (TextView) findViewById(R.id.ocr_result_text_view);
    registerForContextMenu(ocrResultView);
    translationView = (TextView) findViewById(R.id.translation_text_view);
    registerForContextMenu(translationView);

    progressView = (View) findViewById(R.id.indeterminate_progress_indicator_view);

    cameraManager = new CameraManager(getApplication());
    viewfinderView.setCameraManager(cameraManager);

    // Set listener to change the size of the viewfinder rectangle.
    viewfinderView.setOnTouchListener(new View.OnTouchListener() {
        int lastX = -1;
        int lastY = -1;

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                lastX = -1;
                lastY = -1;
                return true;
            case MotionEvent.ACTION_MOVE:
                int currentX = (int) event.getX();
                int currentY = (int) event.getY();

                try {
                    Rect rect = cameraManager.getFramingRect();

                    final int BUFFER = 50;
                    final int BIG_BUFFER = 60;
                    if (lastX >= 0) {
                        // Adjust the size of the viewfinder rectangle. Check if the touch event occurs in the corner areas first, because the regions overlap.
                        if (((currentX >= rect.left - BIG_BUFFER && currentX <= rect.left + BIG_BUFFER)
                                || (lastX >= rect.left - BIG_BUFFER && lastX <= rect.left + BIG_BUFFER))
                                && ((currentY <= rect.top + BIG_BUFFER && currentY >= rect.top - BIG_BUFFER)
                                        || (lastY <= rect.top + BIG_BUFFER
                                                && lastY >= rect.top - BIG_BUFFER))) {
                            // Top left corner: adjust both top and left sides
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BIG_BUFFER && currentX <= rect.right + BIG_BUFFER)
                                || (lastX >= rect.right - BIG_BUFFER && lastX <= rect.right + BIG_BUFFER))
                                && ((currentY <= rect.top + BIG_BUFFER && currentY >= rect.top - BIG_BUFFER)
                                        || (lastY <= rect.top + BIG_BUFFER
                                                && lastY >= rect.top - BIG_BUFFER))) {
                            // Top right corner: adjust both top and right sides
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.left - BIG_BUFFER && currentX <= rect.left + BIG_BUFFER)
                                || (lastX >= rect.left - BIG_BUFFER && lastX <= rect.left + BIG_BUFFER))
                                && ((currentY <= rect.bottom + BIG_BUFFER
                                        && currentY >= rect.bottom - BIG_BUFFER)
                                        || (lastY <= rect.bottom + BIG_BUFFER
                                                && lastY >= rect.bottom - BIG_BUFFER))) {
                            // Bottom left corner: adjust both bottom and left sides
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BIG_BUFFER && currentX <= rect.right + BIG_BUFFER)
                                || (lastX >= rect.right - BIG_BUFFER && lastX <= rect.right + BIG_BUFFER))
                                && ((currentY <= rect.bottom + BIG_BUFFER
                                        && currentY >= rect.bottom - BIG_BUFFER)
                                        || (lastY <= rect.bottom + BIG_BUFFER
                                                && lastY >= rect.bottom - BIG_BUFFER))) {
                            // Bottom right corner: adjust both bottom and right sides
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.left - BUFFER && currentX <= rect.left + BUFFER)
                                || (lastX >= rect.left - BUFFER && lastX <= rect.left + BUFFER))
                                && ((currentY <= rect.bottom && currentY >= rect.top)
                                        || (lastY <= rect.bottom && lastY >= rect.top))) {
                            // Adjusting left side: event falls within BUFFER pixels of left side, and between top and bottom side limits
                            cameraManager.adjustFramingRect(2 * (lastX - currentX), 0);
                            viewfinderView.removeResultText();
                        } else if (((currentX >= rect.right - BUFFER && currentX <= rect.right + BUFFER)
                                || (lastX >= rect.right - BUFFER && lastX <= rect.right + BUFFER))
                                && ((currentY <= rect.bottom && currentY >= rect.top)
                                        || (lastY <= rect.bottom && lastY >= rect.top))) {
                            // Adjusting right side: event falls within BUFFER pixels of right side, and between top and bottom side limits
                            cameraManager.adjustFramingRect(2 * (currentX - lastX), 0);
                            viewfinderView.removeResultText();
                        } else if (((currentY <= rect.top + BUFFER && currentY >= rect.top - BUFFER)
                                || (lastY <= rect.top + BUFFER && lastY >= rect.top - BUFFER))
                                && ((currentX <= rect.right && currentX >= rect.left)
                                        || (lastX <= rect.right && lastX >= rect.left))) {
                            // Adjusting top side: event falls within BUFFER pixels of top side, and between left and right side limits
                            cameraManager.adjustFramingRect(0, 2 * (lastY - currentY));
                            viewfinderView.removeResultText();
                        } else if (((currentY <= rect.bottom + BUFFER && currentY >= rect.bottom - BUFFER)
                                || (lastY <= rect.bottom + BUFFER && lastY >= rect.bottom - BUFFER))
                                && ((currentX <= rect.right && currentX >= rect.left)
                                        || (lastX <= rect.right && lastX >= rect.left))) {
                            // Adjusting bottom side: event falls within BUFFER pixels of bottom side, and between left and right side limits
                            cameraManager.adjustFramingRect(0, 2 * (currentY - lastY));
                            viewfinderView.removeResultText();
                        }
                    }
                } catch (NullPointerException e) {
                    Log.e(TAG, "Framing rect not available", e);
                }
                v.invalidate();
                lastX = currentX;
                lastY = currentY;
                return true;
            case MotionEvent.ACTION_UP:
                lastX = -1;
                lastY = -1;
                return true;
            }
            return false;
        }
    });

    isEngineReady = false;

}

From source file:com.android.email.activity.zx.MessageView.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.message_view);

    mSubjectView = (TextView) findViewById(R.id.subject);
    mFromView = (TextView) findViewById(R.id.from);
    mToView = (TextView) findViewById(R.id.to);
    mCcView = (TextView) findViewById(R.id.cc);
    mCcContainerView = findViewById(R.id.cc_container);
    mDateView = (TextView) findViewById(R.id.date);
    mTimeView = (TextView) findViewById(R.id.time);
    mMessageContentView = (WebView) findViewById(R.id.message_content);
    mAttachments = (LinearLayout) findViewById(R.id.attachments);
    mAttachmentIcon = (ImageView) findViewById(R.id.attachment);
    mShowPicturesSection = findViewById(R.id.show_pictures_section);
    mSenderPresenceView = (ImageView) findViewById(R.id.presence);

    mMessageContentView.setVerticalScrollBarEnabled(false);
    mAttachments.setVisibility(View.GONE);
    mAttachmentIcon.setVisibility(View.GONE);

    mFromView.setOnClickListener(this);
    mSenderPresenceView.setOnClickListener(this);
    findViewById(R.id.reply).setOnClickListener(this);
    findViewById(R.id.reply_all).setOnClickListener(this);
    findViewById(R.id.delete).setOnClickListener(this);
    findViewById(R.id.show_pictures).setOnClickListener(this);

    mMessageContentView.getSettings().setBlockNetworkImage(true);
    mMessageContentView.getSettings().setSupportZoom(false);

    setTitle("");

    mDateFormat = android.text.format.DateFormat.getDateFormat(this); // short format
    mTimeFormat = android.text.format.DateFormat.getTimeFormat(this); // 12/24 date format

    Intent intent = getIntent();/*from w  w  w.  j a v a 2 s  .c om*/
    mAccount = (Account) intent.getSerializableExtra(EXTRA_ACCOUNT);
    mFolder = intent.getStringExtra(EXTRA_FOLDER);
    mMessageUid = intent.getStringExtra(EXTRA_MESSAGE);
    mFolderUids = intent.getStringArrayListExtra(EXTRA_FOLDER_UIDS);

    View next = findViewById(R.id.next);
    View previous = findViewById(R.id.previous);
    /*
     * Next and Previous Message are not shown in landscape mode, so
     * we need to check before we use them.
     */
    if (next != null && previous != null) {
        next.setOnClickListener(this);
        previous.setOnClickListener(this);

        findSurroundingMessagesUid();

        previous.setVisibility(mPreviousMessageUid != null ? View.VISIBLE : View.GONE);
        next.setVisibility(mNextMessageUid != null ? View.VISIBLE : View.GONE);

        boolean goNext = intent.getBooleanExtra(EXTRA_NEXT, false);
        if (goNext) {
            next.requestFocus();
        }
    }

    MessagingController.getInstance(getApplication()).addListener(mListener);
    new Thread() {
        @Override
        public void run() {
            // TODO this is a spot that should be eventually handled by a MessagingController
            // thread pool. We want it in a thread but it can't be blocked by the normal
            // synchronization stuff in MC.
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
            MessagingController.getInstance(getApplication()).loadMessageForView(mAccount, mFolder, mMessageUid,
                    mListener);
        }
    }.start();
}

From source file:com.cuddlesoft.nori.SearchActivity.java

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

    // Request window manager features.
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    // Get shared preferences.
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    // Inflate views.
    setContentView(R.layout.activity_search);

    // Get search result grid fragment from fragment manager.
    searchResultGridFragment = (SearchResultGridFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragment_searchResultGrid);

    // If the activity was started from a Search intent, create the SearchClient object and submit search.
    Intent intent = getIntent();/*from  w  w w .j a  v a 2s .  c  om*/
    if (intent != null && intent.getAction().equals(Intent.ACTION_SEARCH)
            && searchResultGridFragment.getSearchResult() == null) {
        SearchClient.Settings searchClientSettings = intent
                .getParcelableExtra(BUNDLE_ID_SEARCH_CLIENT_SETTINGS);
        searchClient = searchClientSettings.createSearchClient();
        doSearch(intent.getStringExtra(BUNDLE_ID_SEARCH_QUERY));
    }

    // Set up the dropdown API server picker.
    setUpActionBar();
}