Example usage for android.view Window FEATURE_PROGRESS

List of usage examples for android.view Window FEATURE_PROGRESS

Introduction

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

Prototype

int FEATURE_PROGRESS

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

Click Source Link

Document

Flag for the progress indicator feature.

Usage

From source file:org.anhonesteffort.flock.EditAutoRenewActivity.java

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

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    requestWindowFeature(Window.FEATURE_PROGRESS);

    setContentView(R.layout.activity_edit_auto_renew);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setTitle(R.string.button_edit_payment_details);

    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        if (!DavAccount.build(savedInstanceState.getBundle(KEY_DAV_ACCOUNT_BUNDLE)).isPresent()) {
            finish();//  ww  w .  j  a  va2s.com
            return;
        }

        davAccount = DavAccount.build(savedInstanceState.getBundle(KEY_DAV_ACCOUNT_BUNDLE)).get();
        flockAccount = FlockAccount.build(savedInstanceState.getBundle(KEY_FLOCK_ACCOUNT_BUNDLE));
        cardInformation = FlockCardInformation.build(savedInstanceState.getBundle(KEY_CARD_INFORMATION_BUNDLE));
    } else if (getIntent().getExtras() != null) {
        if (!DavAccount.build(getIntent().getExtras().getBundle(KEY_DAV_ACCOUNT_BUNDLE)).isPresent()) {
            finish();
            return;
        }

        davAccount = DavAccount.build(getIntent().getExtras().getBundle(KEY_DAV_ACCOUNT_BUNDLE)).get();
        flockAccount = FlockAccount.build(getIntent().getExtras().getBundle(KEY_FLOCK_ACCOUNT_BUNDLE));
        cardInformation = FlockCardInformation
                .build(getIntent().getExtras().getBundle(KEY_CARD_INFORMATION_BUNDLE));
    }

    initCostPerYear();
}

From source file:com.github.naofum.epubconverter.Convert.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_PROGRESS);
    setProgressBarVisibility(true);/*ww w.  j  a va2  s  .co m*/
    setContentView(R.layout.progressview);
    setProgress(0);

    // Set variables
    progressSv = (ScrollView) findViewById(R.id.scroll);
    progressTv = (TextView) findViewById(R.id.progress);
    okBt = (Button) findViewById(R.id.ok);
    okBt.setOnClickListener(mOkListener);
    stopBt = (Button) findViewById(R.id.stop);
    stopBt.setOnClickListener(mStopListener);

    if (conversionStarted) {
        // Update screen
        progressTv.setText(progressSb);
        setButtons(okBtEnabled);
    } else if (!notificationSent) {
        // Get filename
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            if (extras.containsKey("filename")) {
                String pdfFilename = extras.getString("filename");
                filename = pdfFilename.substring(0, pdfFilename.lastIndexOf(PDF_EXT));
                new convertTask().execute();
            }
        }
    }

    // Remove notification
    ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).cancel(R.string.app_name);
    notificationSent = false;
}

From source file:au.com.wallaceit.reddinator.TabWebFragment.java

@SuppressLint("SetJavaScriptEnabled")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mContext = this.getActivity();
    if (container == null) {
        return null;
    }//from  ww  w . ja va 2 s . c  o m
    if (mFirstTime) {
        // get shared preferences
        SharedPreferences prefs = PreferenceManager
                .getDefaultSharedPreferences(this.getActivity().getApplicationContext());
        // work out the url this instance should load
        boolean commentswv = false;
        if (this.getArguments() != null) {
            commentswv = this.getArguments().getBoolean("loadcom", false);
        }

        int fontsize;
        String url;
        if (commentswv) {
            url = "http://reddit.com" + getActivity().getIntent().getStringExtra(WidgetProvider.ITEM_PERMALINK)
                    + ".compact";
            fontsize = Integer.parseInt(prefs.getString("commentfontpref", "22"));
        } else {
            url = getActivity().getIntent().getStringExtra(WidgetProvider.ITEM_URL);
            fontsize = Integer.parseInt(prefs.getString("contentfontpref", "18"));
        }
        // setup progressbar
        mActivity = this.getActivity();
        mActivity.getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
        ll = (LinearLayout) inflater.inflate(R.layout.tab1, container, false);
        mWebView = (WebView) ll.findViewById(R.id.webView1);
        // fixes for webview not taking keyboard input on some devices
        mWebView.requestFocus(View.FOCUS_DOWN);
        mWebView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                case MotionEvent.ACTION_UP:
                    if (!v.hasFocus()) {
                        v.requestFocus();
                    }
                    break;
                }
                return false;
            }
        });
        mWebView.getSettings().setJavaScriptEnabled(true); // enable ecmascript
        mWebView.getSettings().setSupportZoom(true);
        mWebView.getSettings().setUseWideViewPort(true);
        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setDisplayZoomControls(true);
        mWebView.getSettings().setDefaultFontSize(fontsize);
        mChromeClient = newchromeclient;
        mWebView.setWebChromeClient(mChromeClient);
        mWebView.setWebViewClient(new WebViewClient());
        mWebView.loadUrl(url);
        mFirstTime = false;
        //System.out.println("Created fragment");
    } else {
        ((ViewGroup) ll.getParent()).removeView(ll);
    }

    return ll;
}

From source file:de.trier.infsec.koch.droidsheep.activities.HijackActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_PROGRESS);
    setContentView(R.layout.webview);//from w ww  . ja v  a 2s  .  c  o m
    CookieSyncManager.createInstance(this);
}

From source file:com.klinker.android.twitter.activities.tweet_viewer.TweetPager.java

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

    overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down);

    try {// www  .  j av  a 2s .com
        getWindow().requestFeature(Window.FEATURE_PROGRESS);
    } catch (Exception e) {

    }

    context = this;
    settings = AppSettings.getInstance(this);

    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }

    getFromIntent();

    mSectionsPagerAdapter = new TweetPagerAdapter(getFragmentManager(), context, name, screenName, tweet, time,
            retweeter, webpage, proPic, tweetId, picture, users, hashtags, otherLinks, isMyTweet, isMyRetweet,
            secondAcc, animatedGif);

    // methods for advancing windowed
    boolean settingsVal = settings.advanceWindowed;
    boolean fromWidget = getIntent().getBooleanExtra("from_widget", false);
    final boolean youtube;

    youtube = mSectionsPagerAdapter.getHasYoutube() || mSectionsPagerAdapter.getHasGif()
            || mSectionsPagerAdapter.hasVine();

    if (fromWidget || settingsVal) {
        setUpWindow(youtube);
    }

    setUpTheme();

    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }

    if (getIntent().getBooleanExtra("clicked_youtube", false)) {
        IntentFilter i = new IntentFilter("com.klinker.android.twitter.YOUTUBE_READY");
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                TweetYouTubeFragment.resume();

                context.unregisterReceiver(this);
            }
        }, i);
    }

    setContentView(R.layout.tweet_pager);
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(mSectionsPagerAdapter);
    pager.setOffscreenPageLimit(5);

    final int numberOfPages = mSectionsPagerAdapter.getCount();

    pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int i, float v, int i2) {

        }

        @Override
        public void onPageSelected(int i) {
            if (youtube) {
                try {
                    switch (numberOfPages) {
                    case 3:
                    case 4:
                        if (i != 0) {
                            TweetYouTubeFragment.pause();
                        } else {
                            TweetYouTubeFragment.resume();
                        }
                        break;
                    case 5:
                        if (i != 1) {
                            TweetYouTubeFragment.pause();
                        } else {
                            TweetYouTubeFragment.resume();
                        }
                        break;
                    }
                } catch (Exception e) {

                }
            }
        }

        @Override
        public void onPageScrollStateChanged(int i) {

        }
    });

    switch (numberOfPages) {
    case 2:
        if (settings.pageToOpen == AppSettings.PAGE_CONVO) {
            pager.setCurrentItem(1);
        } else {
            pager.setCurrentItem(0);
        }
        break;
    case 3:
        if (mSectionsPagerAdapter.getHasWebpage()) {
            switch (settings.pageToOpen) {
            case AppSettings.PAGE_CONVO:
                pager.setCurrentItem(2);
                break;
            case AppSettings.PAGE_WEB:
                pager.setCurrentItem(0);
                break;
            default:
                pager.setCurrentItem(1);
                break;
            }
        } else { // no web page
            switch (settings.pageToOpen) {
            case AppSettings.PAGE_CONVO:
                pager.setCurrentItem(2);
                break;
            default:
                pager.setCurrentItem(1);
                break;
            }
        }
        break;
    case 4: // webpage and youtube
        switch (settings.pageToOpen) {
        case AppSettings.PAGE_CONVO:
            pager.setCurrentItem(3);
            break;
        case AppSettings.PAGE_WEB:
            pager.setCurrentItem(1);
            break;
        default:
            pager.setCurrentItem(0);
            break;
        }
        break;
    }

    if (getIntent().getBooleanExtra("clicked_youtube", false)) {
        pager.setCurrentItem(0);
    }

    if (settings.addonTheme) {
        PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
        strip.setBackgroundColor(settings.pagerTitleInt);

        if (!settings.showTitleStrip) {
            strip.setVisibility(View.GONE);
        }
    }

}

From source file:cn.devit.app.ip_messenger.MainActivity.java

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

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    // ?// w w  w.ja va2  s .  co  m
    supportRequestWindowFeature(Window.FEATURE_PROGRESS);
    setContentView(R.layout.activity_main);

    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // TODO ????

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    setupListener();

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

    network = new NetworkMonitor();
    network.setPacketListener(this.pl);
    network.param = new SocketParam();
    network.param.charset = Charset.forName(preferences.getString(CHARSET, "UTF-8"));
    network.param.port = 2425;
    network.listener = listener;
    UserData me = new UserData(preferences.getString(DISPLAY_NAME, "robot"),
            preferences.getString(HOST_NAME, "localhost"), preferences.getString(WORKGROUP_NAME, "IT"));
    // me.setAddress(new InetSocketAddress(InetAddress.getByName(""),
    // 2425));
    network.param.user = me;
    network.param.broadcastAddresses = new ArrayList<InetAddress>(1);
    try {
        network.param.broadcastAddresses.add(InetAddress.getByName("255.255.255.255"));
    } catch (UnknownHostException e) {
        Log.e("main", "Address lookup(255.255.255.255) failure.", e);
    }

    new Thread(network, "udp socket " + network.param.port).start();
    ;
}

From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java

/**
 * (non-Javadoc)//from   ww w  . j a  v  a  2  s.  c o m
 *
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    global = ((GlobalObjects) ViewRedditActivity.this.getApplicationContext());
    prefs = PreferenceManager.getDefaultSharedPreferences(ViewRedditActivity.this);
    // set window flags
    getWindow().requestFeature(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    getWindow().requestFeature(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    // request loading bar first
    getWindow().requestFeature(Window.FEATURE_PROGRESS);
    // get actionbar and set home button, pad the icon
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    ImageView view = (ImageView) findViewById(android.R.id.home);
    if (view != null) {
        view.setPadding(5, 0, 5, 0);
    }
    // set content view
    setContentView(R.layout.viewreddit);
    // Setup TabHost
    initialiseTabHost(savedInstanceState);
    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); //set the tab as per the saved state
    }
    redditItemId = getIntent().getStringExtra(WidgetProvider.ITEM_ID);
    widgetId = getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 0);
    feedposition = getIntent().getIntExtra("itemposition", 0);
    // Get selected item from feed and user vote preference
    JSONObject currentFeedItem = global.getFeedObject(prefs, widgetId, feedposition, redditItemId);
    try {
        userLikes = currentFeedItem.getString("likes");
    } catch (JSONException e) {
        e.printStackTrace();
    }
    //System.out.println("User likes post: " + userLikes);
}

From source file:com.klinker.android.twitter.ui.tweet_viewer.TweetPager.java

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

    overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down);

    try {/*  w  w  w  .  ja  v  a2 s  . c o  m*/
        getWindow().requestFeature(Window.FEATURE_PROGRESS);
    } catch (Exception e) {

    }

    context = this;
    settings = AppSettings.getInstance(this);

    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }

    getFromIntent();

    // methods for advancing windowed
    boolean settingsVal = settings.advanceWindowed;
    boolean fromWidget = getIntent().getBooleanExtra("from_widget", false);
    final boolean youtube;
    if (webpage != null && linkString != null) {
        youtube = webpage.contains("youtu") || linkString.contains("youtu");
    } else {
        youtube = true;
    }

    // cases: (youtube will ALWAYS be full screen...)
    // from widget
    // the user set the preference to advance windowed
    // has a webview and want to advance windowed
    if (fromWidget || settingsVal) {
        setUpWindow(youtube);
    }

    setUpTheme();

    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }

    if (getIntent().getBooleanExtra("clicked_youtube", false)) {
        IntentFilter i = new IntentFilter("com.klinker.android.twitter.YOUTUBE_READY");
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                TweetYouTubeFragment.resume();

                context.unregisterReceiver(this);
            }
        }, i);
    }

    setContentView(R.layout.tweet_pager);
    pager = (ViewPager) findViewById(R.id.pager);
    mSectionsPagerAdapter = new TweetPagerAdapter(getFragmentManager(), context, name, screenName, tweet, time,
            retweeter, webpage, proPic, tweetId, picture, users, hashtags, otherLinks, isMyTweet, isMyRetweet);
    pager.setAdapter(mSectionsPagerAdapter);
    pager.setOffscreenPageLimit(5);

    final int numberOfPages = mSectionsPagerAdapter.getCount();

    pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int i, float v, int i2) {

        }

        @Override
        public void onPageSelected(int i) {
            if (youtube) {
                try {
                    switch (numberOfPages) {
                    case 3:
                    case 4:
                        if (i != 0) {
                            TweetYouTubeFragment.pause();
                        } else {
                            TweetYouTubeFragment.resume();
                        }
                        break;
                    case 5:
                        if (i != 1) {
                            TweetYouTubeFragment.pause();
                        } else {
                            TweetYouTubeFragment.resume();
                        }
                        break;
                    }
                } catch (Exception e) {

                }
            }
        }

        @Override
        public void onPageScrollStateChanged(int i) {

        }
    });

    switch (numberOfPages) {
    case 2:
        if (settings.pageToOpen == AppSettings.PAGE_CONVO) {
            pager.setCurrentItem(1);
        } else {
            pager.setCurrentItem(0);
        }
        break;
    case 3:
        if (mSectionsPagerAdapter.getHasWebpage()) {
            switch (settings.pageToOpen) {
            case AppSettings.PAGE_CONVO:
                pager.setCurrentItem(2);
                break;
            case AppSettings.PAGE_WEB:
                pager.setCurrentItem(0);
                break;
            default:
                pager.setCurrentItem(1);
                break;
            }
        } else { // no web page
            switch (settings.pageToOpen) {
            case AppSettings.PAGE_CONVO:
                pager.setCurrentItem(2);
                break;
            default:
                pager.setCurrentItem(1);
                break;
            }
        }
        break;
    case 4: // webpage and youtube
        switch (settings.pageToOpen) {
        case AppSettings.PAGE_CONVO:
            pager.setCurrentItem(3);
            break;
        case AppSettings.PAGE_WEB:
            pager.setCurrentItem(1);
            break;
        default:
            pager.setCurrentItem(0);
            break;
        }
        break;
    }

    if (getIntent().getBooleanExtra("clicked_youtube", false)) {
        pager.setCurrentItem(0);
    }

    if (settings.addonTheme) {
        PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
        strip.setBackgroundColor(settings.pagerTitleInt);

        if (!settings.showTitleStrip) {
            strip.setVisibility(View.GONE);
        }
    }

}

From source file:it.gulch.linuxday.android.activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_PROGRESS);
    setContentView(R.layout.main);// w w w  .j  a v  a2  s .c o  m

    refreshItem = null;

    setupServices();

    setupDrawer();

    restoreCurrentSection(savedInstanceState);
    setupMainMenu();
    updateActionBar();
}

From source file:au.com.wallaceit.reddinator.ViewRedditActivity.java

/**
 * (non-Javadoc)/*www .  j  av  a  2  s  .c  o m*/
 *
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    global = ((GlobalObjects) ViewRedditActivity.this.getApplicationContext());
    prefs = PreferenceManager.getDefaultSharedPreferences(ViewRedditActivity.this);
    global.loadSavedAccn(prefs);
    // set window flags
    getWindow().requestFeature(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    getWindow().requestFeature(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    // request loading bar first
    getWindow().requestFeature(Window.FEATURE_PROGRESS);
    // get actionbar and set home button, pad the icon
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    ImageView view = (ImageView) findViewById(android.R.id.home);
    if (view != null) {
        view.setPadding(5, 0, 5, 0);
    }
    // set content view
    setContentView(R.layout.viewreddit);
    // Setup TabHost
    initialiseTabHost(savedInstanceState);
    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); //set the tab as per the saved state
    }
    redditItemId = getIntent().getStringExtra(WidgetProvider.ITEM_ID);
    widgetId = getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 0);
    feedposition = getIntent().getIntExtra("itemposition", 0);
    // Get selected item from feed and user vote preference
    JSONObject currentFeedItem = global.getFeedObject(prefs, widgetId, feedposition, redditItemId);
    try {
        userLikes = currentFeedItem.getString("likes");
    } catch (JSONException e) {
        e.printStackTrace();
    }
    System.out.println("User likes post: " + userLikes);
}