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.alfresco.mobile.android.application.activity.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    super.onCreate(savedInstanceState);

    // Loading progress
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.app_main);/*ww  w . j  av a  2s  .c  o m*/
    mdmManager = MDMManager.getInstance(this);

    if (capture != null)
        capture.setActivity(this);

    if (savedInstanceState != null) {
        MainActivityHelper helper = new MainActivityHelper(
                savedInstanceState.getBundle(MainActivityHelper.TAG));
        currentAccount = helper.getCurrentAccount();
        importParent = helper.getFolder();
        fragmentQueue = helper.getFragmentQueue();

        if (helper.getDeviceCapture() != null) {
            capture = helper.getDeviceCapture();
            capture.setActivity(this);
        }
    } else {
        MainMenuFragment.with(this).display();
    }

    // After account creation via welcome screen
    if (currentAccount != null) {
        requestSwapAccount = true;
        if (currentAccount.getIsPaidAccount()
                && !prefs.getBoolean(GeneralPreferences.HAS_ACCESSED_PAID_SERVICES, false)) {

            if (!mdmManager.hasConfig()) {
                // Check if we've prompted the user for Data Protection yet.
                // This is needed on new AlfrescoAccount creation, as the
                // Activity gets
                // re-created after the AlfrescoAccount is created.
                DataProtectionUserDialogFragment.newInstance(true).show(getFragmentManager(),
                        DataProtectionUserDialogFragment.TAG);
                prefs.edit().putBoolean(GeneralPreferences.HAS_ACCESSED_PAID_SERVICES, true).commit();
            }
        }
    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawer = (ViewGroup) findViewById(R.id.left_drawer);
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.open_in, R.string.cancel) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            invalidateOptionsMenu();
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            MainMenuFragment slidefragment = (MainMenuFragment) getFragment(MainMenuFragment.SLIDING_TAG);
            if (slidefragment != null) {
                slidefragment.refreshData();
            }
            super.onDrawerOpened(drawerView);
            invalidateOptionsMenu();
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    getActionBar().setDisplayHomeAsUpEnabled(true);
    if (AndroidVersion.isICSOrAbove()) {
        getActionBar().setHomeButtonEnabled(true);
    }
}

From source file:org.mariotaku.twidere.activity.TwitterLoginActivity.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();/*from  ww w  . j a va  2s.  c  o  m*/
    mApplication = TwidereApplication.getInstance(this);
    setContentView(R.layout.twitter_login);
    mEditUsername = (EditText) findViewById(R.id.username);
    mEditPassword = (EditText) findViewById(R.id.password);
    mSignInButton = (Button) findViewById(R.id.sign_in);
    mSignUpButton = (Button) findViewById(R.id.sign_up);
    mSigninSignup = (LinearLayout) findViewById(R.id.sign_in_sign_up);
    mUsernamePassword = (LinearLayout) findViewById(R.id.username_password);
    mSetColorButton = (ImageButton) findViewById(R.id.set_color);
    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 (isNullOrEmpty(mRESTBaseURL)) {
        mRESTBaseURL = DEFAULT_REST_BASE_URL;
    }
    if (isNullOrEmpty(mOAuthBaseURL)) {
        mOAuthBaseURL = DEFAULT_OAUTH_BASE_URL;
    }
    if (isNullOrEmpty(mSigningRESTBaseURL)) {
        mSigningRESTBaseURL = DEFAULT_SIGNING_REST_BASE_URL;
    }
    if (isNullOrEmpty(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);
    }
    mUsernamePassword.setVisibility(mAuthType == Accounts.AUTH_TYPE_TWIP_O_MODE ? View.GONE : View.VISIBLE);
    mSigninSignup.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:net.reichholf.dreamdroid.abstivities.AbstractHttpListActivity.java

@SuppressWarnings("unchecked")
@Override//from   ww  w .  j av a2 s .  c  o m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.list_or_empty);
    mEmpty = (TextView) findViewById(android.R.id.empty);
    mEmpty.setText(R.string.loading);

    mExtras = getIntent().getExtras();
    mMapList = new ArrayList<ExtendedHashMap>();

    if (mExtras != null) {
        HashMap<String, Object> map = (HashMap<String, Object>) mExtras.getSerializable("data");
        if (map != null) {
            mData = new ExtendedHashMap();
            mData.putAll(map);
        }
    } else {
        mExtras = new Bundle();
        getIntent().putExtras(mExtras);
    }

    mShc = null;

    if (savedInstanceState != null) {
        Object retained = getLastNonConfigurationInstance();
        if (retained instanceof HashMap) {
            mShc = (SimpleHttpClient) ((HashMap<String, Object>) retained).get("shc");
        }
    }

    if (mShc == null) {
        setClient();
    }
}

From source file:in.shick.diode.threads.ThreadsListActivity.java

/**
 * Called when the activity starts up. Do activity initialization
 * here, not in a constructor./*  w  ww . j av a2  s . c  om*/
 *
 * @see Activity#onCreate
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    CookieSyncManager.createInstance(getApplicationContext());

    mSettings.loadRedditPreferences(getApplicationContext());
    setRequestedOrientation(mSettings.getRotation());
    setTheme(mSettings.getTheme());
    requestWindowFeature(Window.FEATURE_PROGRESS);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.threads_list_content);
    swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
    swipeLayout.setOnRefreshListener(this);
    swipeLayout.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
            android.R.color.holo_orange_light, android.R.color.holo_red_light);

    registerForContextMenu(getListView());

    if (savedInstanceState != null) {
        if (Constants.LOGGING)
            Log.d(TAG, "using savedInstanceState");
        mSubreddit = savedInstanceState.getString(Constants.SUBREDDIT_KEY);
        if (mSubreddit == null)
            mSubreddit = mSettings.getHomepage();
        mAfter = savedInstanceState.getString(Constants.AFTER_KEY);
        mBefore = savedInstanceState.getString(Constants.BEFORE_KEY);
        mCount = savedInstanceState.getInt(Constants.THREAD_COUNT_KEY);
        mLastAfter = savedInstanceState.getString(Constants.LAST_AFTER_KEY);
        mLastBefore = savedInstanceState.getString(Constants.LAST_BEFORE_KEY);
        mLastCount = savedInstanceState.getInt(Constants.THREAD_LAST_COUNT_KEY);
        mSortByUrl = savedInstanceState.getString(Constants.ThreadsSort.SORT_BY_KEY);
        mJumpToThreadId = savedInstanceState.getString(Constants.JUMP_TO_THREAD_ID_KEY);
        mSearchQuery = savedInstanceState.getString(Constants.QUERY_KEY);
        mVoteTargetThing = savedInstanceState.getParcelable(Constants.VOTE_TARGET_THING_INFO_KEY);

        // try to restore mThreadsList using getLastNonConfigurationInstance()
        // (separate function to avoid a compiler warning casting ArrayList<ThingInfo>
        restoreLastNonConfigurationInstance();

        if (mObjectStates == null) {
            mObjectStates = new ObjectStates();
            if (mObjectStates.mThreadsList == null) {
                // Load previous view of threads
                if (mLastAfter != null) {
                    mObjectStates.mCurrentDownloadThreadsTask = new MyDownloadThreadsTask(mSubreddit,
                            mLastAfter, null, mLastCount);
                } else if (mLastBefore != null) {
                    mObjectStates.mCurrentDownloadThreadsTask = new MyDownloadThreadsTask(mSubreddit, null,
                            mLastBefore, mLastCount);
                } else {
                    mObjectStates.mCurrentDownloadThreadsTask = new MyDownloadThreadsTask(mSubreddit);
                }
                mObjectStates.mCurrentDownloadThreadsTask.execute();
            }
        } else {
            if (mObjectStates.mCurrentDownloadThreadsTask.getStatus() != Status.FINISHED) {
                mObjectStates.mCurrentDownloadThreadsTask.attach(this);
            } else {
                // Orientation change. Use prior instance.
                resetUI(new ThreadsListAdapter(this, mObjectStates.mThreadsList));
                setWindowTitle();
            }
        }
    }
    // Handle subreddit Uri passed via Intent
    else if (getIntent().getData() != null) {
        mObjectStates = new ObjectStates();
        Matcher redditContextMatcher = REDDIT_PATH_PATTERN.matcher(getIntent().getData().getPath());
        if (redditContextMatcher.matches()) {
            mObjectStates.mCurrentDownloadThreadsTask = new MyDownloadThreadsTask(
                    redditContextMatcher.group(1));
        } else if (getIntent().getData().toString().toLowerCase().endsWith("/saved.json")) {
            mSavedUri = getIntent().getData();
            mObjectStates.mCurrentDownloadThreadsTask = new MyDownloadThreadsTask(getIntent().getData());
        } else {
            mObjectStates.mCurrentDownloadThreadsTask = new MyDownloadThreadsTask(mSettings.getHomepage());
        }
        mObjectStates.mCurrentDownloadThreadsTask.execute();
    }
    // No subreddit specified by Intent, so load the user's home reddit
    else {
        mObjectStates = new ObjectStates();
        mObjectStates.mCurrentDownloadThreadsTask = new MyDownloadThreadsTask(mSettings.getHomepage());
        mObjectStates.mCurrentDownloadThreadsTask.execute();
    }
}

From source file:org.videolan.vlc.gui.VLCMainActivity.java

@SuppressLint("NewApi")
@Override//from   ww  w .  j  a  v  a  2  s . c o  m
protected void onCreate(Bundle savedInstanceState) {

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    if (!LibVlcUtil.hasCompatibleCPU(this)) {
        Log.e(TAG, LibVlcUtil.getErrorMsg());
        Intent i = new Intent(this, CompatErrorActivity.class);
        startActivity(i);
        finish();
        super.onCreate(savedInstanceState);
        return;
    }

    /* Get the current version from package */
    PackageInfo pinfo = null;
    try {
        pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    } catch (NameNotFoundException e) {
        Log.e(TAG, "package info not found.");
    }
    if (pinfo != null)
        mVersionNumber = pinfo.versionCode;

    /* Get settings */
    mSettings = PreferenceManager.getDefaultSharedPreferences(this);

    /* Check if it's the first run */
    mFirstRun = mSettings.getInt(PREF_FIRST_RUN, -1) != mVersionNumber;
    if (mFirstRun) {
        Editor editor = mSettings.edit();
        editor.putInt(PREF_FIRST_RUN, mVersionNumber);
        editor.commit();
    }

    try {
        // Start LibVLC
        VLCInstance.getLibVlcInstance();
    } catch (LibVlcException e) {
        //e.printStackTrace();
        Intent i = new Intent(this, CompatErrorActivity.class);
        i.putExtra("runtimeError", true);
        i.putExtra("message", "LibVLC failed to initialize (LibVlcException)");
        startActivity(i);
        finish();
        super.onCreate(savedInstanceState);
        return;
    }

    super.onCreate(savedInstanceState);

    /*** Start initializing the UI ***/

    /* Enable the indeterminate progress feature */
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    boolean enableBlackTheme = pref.getBoolean("enable_black_theme", false);
    if (enableBlackTheme)
        setTheme(R.style.Theme_VLC_Black);

    View v_main = LayoutInflater.from(this).inflate(R.layout.main, null);
    setContentView(v_main);

    mSlidingPane = (SlidingPaneLayout) v_main.findViewById(R.id.pane);
    mSlidingPane.setPanelSlideListener(mPanelSlideListener);

    mListView = (ListView) v_main.findViewById(R.id.sidelist);
    mListView.setFooterDividersEnabled(true);
    mSidebarAdapter = new SidebarAdapter(this);
    mListView.setAdapter(mSidebarAdapter);

    /* Initialize UI variables */
    mInfoLayout = v_main.findViewById(R.id.info_layout);
    mInfoProgress = (ProgressBar) v_main.findViewById(R.id.info_progress);
    mInfoText = (TextView) v_main.findViewById(R.id.info_text);
    mAudioPlayerFilling = v_main.findViewById(R.id.audio_player_filling);
    mRootContainer = (DrawerLayout) v_main.findViewById(R.id.root_container);

    /* Set up the action bar */
    // commit for android 4.1...tempory
    //        prepareActionBar(); 

    /* Set up the sidebar click listener
     * no need to invalidate menu for now */
    mDrawerToggle = new ActionBarDrawerToggle(this, mRootContainer, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {
    };

    // Set the drawer toggle as the DrawerListener
    mRootContainer.setDrawerListener(mDrawerToggle);
    // set a custom shadow that overlays the main content when the drawer opens
    mRootContainer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    //        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    //        getSupportActionBar().setHomeButtonEnabled(true);

    mListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SidebarAdapter.SidebarEntry entry = (SidebarEntry) mListView.getItemAtPosition(position);
            Fragment current = getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder);

            if (current == null || (entry != null && current.getTag().equals(entry.id))) {
                /* Already selected */
                mRootContainer.closeDrawer(mListView);
                return;
            }

            // This should not happen
            if (entry == null || entry.id == null)
                return;

            /*
             * Clear any backstack before switching tabs. This avoids
             * activating an old backstack, when a user hits the back button
             * to quit
             */
            getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);

            /* Slide down the audio player */
            slideDownAudioPlayer();

            /* Switch the fragment */
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.replace(R.id.fragment_placeholder, getFragment(entry.id), entry.id);
            ft.commit();
            mCurrentFragment = entry.id;

            /*
             * Set user visibility hints to work around weird Android
             * behaviour of duplicate context menu events.
             */
            current.setUserVisibleHint(false);
            getFragment(mCurrentFragment).setUserVisibleHint(true);
            // HACK ALERT: Set underlying audio browser to be invisible too.
            if (current.getTag().equals("tracks"))
                getFragment("audio").setUserVisibleHint(false);

            mRootContainer.closeDrawer(mListView);
        }
    });

    /* Set up the audio player */
    mAudioPlayer = new AudioPlayer();
    mAudioController = AudioServiceController.getInstance();

    getSupportFragmentManager().beginTransaction().replace(R.id.audio_player, mAudioPlayer).commit();

    if (mFirstRun) {
        /*
         * The sliding menu is automatically opened when the user closes
         * the info dialog. If (for any reason) the dialog is not shown,
         * open the menu after a short delay.
         */
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                mRootContainer.openDrawer(mListView);
            }
        }, 500);
    }

    /* Prepare the progressBar */
    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_SHOW_PROGRESSBAR);
    filter.addAction(ACTION_HIDE_PROGRESSBAR);
    //        filter.addAction(ACTION_SHOW_TEXTINFO);
    filter.addAction(ACTION_SHOW_PLAYER);
    registerReceiver(messageReceiver, filter);

    /* Reload the latest preferences */
    reloadPreferences();
}

From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java

/**
 * Called when the activity starts up. Do activity initialization
 * here, not in a constructor./* w w  w  .j av a2s  .com*/
 * 
 * @see Activity#onCreate
 */
@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    CookieSyncManager.createInstance(getApplicationContext());

    mSettings.loadRedditPreferences(this, mClient);

    setRequestedOrientation(mSettings.getRotation());
    setTheme(mSettings.getTheme());
    requestWindowFeature(Window.FEATURE_PROGRESS);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.comments_list_content);
    registerForContextMenu(getListView());

    if (savedInstanceState != null) {
        mReplyTargetName = savedInstanceState.getString(Constants.REPLY_TARGET_NAME_KEY);
        mReportTargetName = savedInstanceState.getString(Constants.REPORT_TARGET_NAME_KEY);
        mEditTargetBody = savedInstanceState.getString(Constants.EDIT_TARGET_BODY_KEY);
        mDeleteTargetKind = savedInstanceState.getString(Constants.DELETE_TARGET_KIND_KEY);
        mThreadTitle = savedInstanceState.getString(Constants.THREAD_TITLE_KEY);
        mSubreddit = savedInstanceState.getString(Constants.SUBREDDIT_KEY);
        mThreadId = savedInstanceState.getString(Constants.THREAD_ID_KEY);
        mVoteTargetThing = savedInstanceState.getParcelable(Constants.VOTE_TARGET_THING_INFO_KEY);

        if (mThreadTitle != null) {
            setTitle(mThreadTitle + " : " + mSubreddit);
        }

        mCommentsList = (ArrayList<ThingInfo>) getLastNonConfigurationInstance();
        if (mCommentsList == null) {
            getNewDownloadCommentsTask().execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT);
        } else {
            // Orientation change. Use prior instance.
            resetUI(new CommentsListAdapter(this, mCommentsList));
        }
    }

    // No saved state; use info from Intent.getData()
    else {
        String commentPath;
        String commentQuery;
        String jumpToCommentId = null;
        int jumpToCommentContext = 0;
        // We get the URL through getIntent().getData()
        Uri data = getIntent().getData();
        if (data != null) {
            // Comment path: a URL pointing to a thread or a comment in a thread.
            commentPath = data.getPath();
            commentQuery = data.getQuery();
        } else {
            if (Constants.LOGGING)
                Log.e(TAG, "Quitting because no subreddit and thread id data was passed into the Intent.");
            finish();
            return;
        }

        if (commentPath != null) {
            if (Constants.LOGGING)
                Log.d(TAG, "comment path: " + commentPath);

            if (Util.isRedditShortenedUri(data)) {
                // http://redd.it/abc12
                mThreadId = commentPath.substring(1);
            } else {
                // http://www.reddit.com/...
                Matcher m = COMMENT_PATH_PATTERN.matcher(commentPath);
                if (m.matches()) {
                    mSubreddit = m.group(1);
                    mThreadId = m.group(2);
                    jumpToCommentId = m.group(3);
                }
            }
        } else {
            if (Constants.LOGGING)
                Log.e(TAG, "Quitting because of bad comment path.");
            finish();
            return;
        }

        if (commentQuery != null) {
            Matcher m = COMMENT_CONTEXT_PATTERN.matcher(commentQuery);
            if (m.find()) {
                jumpToCommentContext = m.group(1) != null ? Integer.valueOf(m.group(1)) : 0;
            }
        }

        // Extras: subreddit, threadTitle, numComments
        // subreddit is not always redundant to Intent.getData(),
        // since URL does not always contain the subreddit. (e.g., self posts)
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            // subreddit could have already been set from the Intent.getData. don't overwrite with null here!
            String subreddit = extras.getString(Constants.EXTRA_SUBREDDIT);
            if (subreddit != null)
                mSubreddit = subreddit;
            // mThreadTitle has not been set yet, so no need for null check before setting it
            mThreadTitle = extras.getString(Constants.EXTRA_TITLE);
            if (mThreadTitle != null) {
                setTitle(mThreadTitle + " : " + mSubreddit);
            }
            // TODO: use extras.getInt(Constants.EXTRA_NUM_COMMENTS) somehow
        }

        if (!StringUtils.isEmpty(jumpToCommentId)) {
            getNewDownloadCommentsTask().prepareLoadAndJumpToComment(jumpToCommentId, jumpToCommentContext)
                    .execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT);
        } else {
            getNewDownloadCommentsTask().execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT);
        }
    }
}

From source file:nl.mpcjanssen.simpletask.AddTask.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "onCreate()");

    m_app = (TodoApplication) getApplication();
    m_app.setActionBarStyle(getWindow());
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Constants.BROADCAST_UPDATE_UI);
    intentFilter.addAction(Constants.BROADCAST_SYNC_START);
    intentFilter.addAction(Constants.BROADCAST_SYNC_DONE);

    localBroadcastManager = m_app.getLocalBroadCastManager();

    m_broadcastReceiver = new BroadcastReceiver() {
        @Override//from   w ww .  j a  va  2 s. c  o m
        public void onReceive(Context context, @NotNull Intent intent) {
            if (intent.getAction().equals(Constants.BROADCAST_SYNC_START)) {
                setProgressBarIndeterminateVisibility(true);
            } else if (intent.getAction().equals(Constants.BROADCAST_SYNC_DONE)) {
                setProgressBarIndeterminateVisibility(false);
            }
        }
    };
    localBroadcastManager.registerReceiver(m_broadcastReceiver, intentFilter);

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    final Intent intent = getIntent();
    ActiveFilter mFilter = new ActiveFilter();
    mFilter.initFromIntent(intent);
    final String action = intent.getAction();
    // create shortcut and exit
    if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
        Log.d(TAG, "Setting up shortcut icon");
        setupShortcut();
        finish();
        return;
    } else if (Intent.ACTION_SEND.equals(action)) {
        Log.d(TAG, "Share");
        if (intent.hasExtra(Intent.EXTRA_TEXT)) {
            share_text = intent.getCharSequenceExtra(Intent.EXTRA_TEXT).toString();
        } else {
            share_text = "";
        }
        if (!m_app.hasShareTaskShowsEdit()) {
            if (!share_text.equals("")) {
                addBackgroundTask(share_text);
            }
            finish();
            return;
        }
    } else if ("com.google.android.gm.action.AUTO_SEND".equals(action)) {
        // Called as note to self from google search/now
        noteToSelf(intent);
        finish();
        return;
    } else if (Constants.INTENT_BACKGROUND_TASK.equals(action)) {
        Log.v(TAG, "Adding background task");
        if (intent.hasExtra(Constants.EXTRA_BACKGROUND_TASK)) {
            addBackgroundTask(intent.getStringExtra(Constants.EXTRA_BACKGROUND_TASK));
        } else {
            Log.w(TAG, "Task was not in extras");
        }
        finish();
        return;
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

    setContentView(R.layout.add_task);

    // text
    textInputField = (EditText) findViewById(R.id.taskText);
    m_app.setEditTextHint(textInputField, R.string.tasktexthint);

    if (share_text != null) {
        textInputField.setText(share_text);
    }

    Task iniTask = null;
    setTitle(R.string.addtask);

    m_backup = m_app.getTaskCache(this).getTasksToUpdate();
    if (m_backup != null && m_backup.size() > 0) {
        ArrayList<String> prefill = new ArrayList<String>();
        for (Task t : m_backup) {
            prefill.add(t.inFileFormat());
        }
        String sPrefill = Util.join(prefill, "\n");
        textInputField.setText(sPrefill);
        setTitle(R.string.updatetask);
    } else {
        if (textInputField.getText().length() == 0) {
            iniTask = new Task(1, "");
            iniTask.initWithFilter(mFilter);
        }

        if (iniTask != null && iniTask.getTags().size() == 1) {
            List<String> ps = iniTask.getTags();
            String project = ps.get(0);
            if (!project.equals("-")) {
                textInputField.append(" +" + project);
            }
        }

        if (iniTask != null && iniTask.getLists().size() == 1) {
            List<String> cs = iniTask.getLists();
            String context = cs.get(0);
            if (!context.equals("-")) {
                textInputField.append(" @" + context);
            }
        }
    }
    // Listen to enter events, use IME_ACTION_NEXT for soft keyboards
    // like Swype where ENTER keyCode is not generated.

    int inputFlags = InputType.TYPE_CLASS_TEXT;

    if (m_app.hasCapitalizeTasks()) {
        inputFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
    }
    textInputField.setRawInputType(inputFlags);
    textInputField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    textInputField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionId, @Nullable KeyEvent keyEvent) {

            boolean hardwareEnterUp = keyEvent != null && keyEvent.getAction() == KeyEvent.ACTION_UP
                    && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER;
            boolean hardwareEnterDown = keyEvent != null && keyEvent.getAction() == KeyEvent.ACTION_DOWN
                    && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER;
            boolean imeActionNext = (actionId == EditorInfo.IME_ACTION_NEXT);

            if (imeActionNext || hardwareEnterUp) {
                // Move cursor to end of line
                int position = textInputField.getSelectionStart();
                String remainingText = textInputField.getText().toString().substring(position);
                int endOfLineDistance = remainingText.indexOf('\n');
                int endOfLine;
                if (endOfLineDistance == -1) {
                    endOfLine = textInputField.length();
                } else {
                    endOfLine = position + endOfLineDistance;
                }
                textInputField.setSelection(endOfLine);
                replaceTextAtSelection("\n", false);

                if (hasCloneTags()) {
                    String precedingText = textInputField.getText().toString().substring(0, endOfLine);
                    int lineStart = precedingText.lastIndexOf('\n');
                    String line;
                    if (lineStart != -1) {
                        line = precedingText.substring(lineStart, endOfLine);
                    } else {
                        line = precedingText;
                    }
                    Task t = new Task(0, line);
                    LinkedHashSet<String> tags = new LinkedHashSet<String>();
                    for (String ctx : t.getLists()) {
                        tags.add("@" + ctx);
                    }
                    for (String prj : t.getTags()) {
                        tags.add("+" + prj);
                    }
                    replaceTextAtSelection(Util.join(tags, " "), true);
                }
                endOfLine++;
                textInputField.setSelection(endOfLine);
            }
            return (imeActionNext || hardwareEnterDown || hardwareEnterUp);
        }
    });

    setCloneTags(m_app.isAddTagsCloneTags());
    setWordWrap(m_app.isWordWrap());

    findViewById(R.id.cb_wrap).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setWordWrap(hasWordWrap());
        }
    });

    int textIndex = 0;
    textInputField.setSelection(textIndex);

    // Set button callbacks
    findViewById(R.id.btnContext).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showContextMenu();
        }
    });
    findViewById(R.id.btnProject).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showTagMenu();
        }
    });
    findViewById(R.id.btnPrio).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showPrioMenu();
        }
    });

    findViewById(R.id.btnDue).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            insertDate(Task.DUE_DATE);
        }
    });
    findViewById(R.id.btnThreshold).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            insertDate(Task.THRESHOLD_DATE);
        }
    });

    if (m_backup != null && m_backup.size() > 0) {
        textInputField.setSelection(textInputField.getText().length());
    }
}

From source file:android.support.v7.app.ActionBarActivityDelegateBase.java

@Override
public boolean supportRequestWindowFeature(int featureId) {
    switch (featureId) {
    case WindowCompat.FEATURE_ACTION_BAR:
        mHasActionBar = true;//from   w  w  w .jav  a 2 s . c om
        return true;
    case WindowCompat.FEATURE_ACTION_BAR_OVERLAY:
        mOverlayActionBar = true;
        return true;
    case Window.FEATURE_PROGRESS:
        mFeatureProgress = true;
        return true;
    case Window.FEATURE_INDETERMINATE_PROGRESS:
        mFeatureIndeterminateProgress = true;
        return true;
    default:
        return mActivity.requestWindowFeature(featureId);
    }
}

From source file:com.google.adsensequickstart.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_main);

    apiController = ApiController.getApiController(this);

    // Set up the action bar to show a dropdown list.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // Set up the dropdown list navigation in the action bar.
    actionBar.setListNavigationCallbacks(
            // Specify a SpinnerAdapter to populate the dropdown list.
            new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_list_item_1,
                    android.R.id.text1, new String[] { getString(R.string.title_section1),
                            getString(R.string.title_section2), getString(R.string.title_section3) }),
            this);
}