List of usage examples for android.view Window FEATURE_PROGRESS
int FEATURE_PROGRESS
To view the source code for android.view Window FEATURE_PROGRESS.
Click Source Link
From source file:org.peterbaldwin.vlcremote.app.PlaybackActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.main);//ww w . ja v a 2 s. c o m // Set the control stream to STREAM_MUSIC to suppress system beeps // that sound even when the activity handles volume key events. setVolumeControlStream(AudioManager.STREAM_MUSIC); Preferences pref = Preferences.get(this); isHideDVDTab = pref.isHideDVDTabSet(); String authority = pref.getAuthority(); if (authority != null) { mMediaServer = new MediaServer(this, authority); setServerSubtitle(pref.isServerSubtitleSet()); } mFlipper = (ViewFlipper) findViewById(R.id.flipper); mPager = (LockableViewPager) findViewById(R.id.pager); mTabHost = (TabHost) findViewById(android.R.id.tabhost); mVolumePanel = new VolumePanel(this); BrowseFragment browse = null; FragmentUtil fu = new FragmentUtil(getSupportFragmentManager()); fu.findOrAddFragment(Tags.FRAGMENT_STATUS, StatusFragment.class); if (mTabHost == null) { fu.findOrReplaceOptionalFragment(this, R.id.fragment_navigation, Tags.FRAGMENT_NAVIGATION, NavigationFragment.class); fu.findOrReplaceFragment(R.id.fragment_playlist, Tags.FRAGMENT_PLAYLIST, PlaylistFragment.class); browse = fu.findOrReplaceFragment(R.id.fragment_browse, Tags.FRAGMENT_BROWSE, BrowseFragment.class); fu.findOrReplaceFragment(R.id.fragment_tvshows, Tags.FRAGMENT_TV_SHOWS, TvShowsFragment.class); fu.findOrReplaceFragment(R.id.fragment_playback, Tags.FRAGMENT_PLAYBACK, PlaybackFragment.class); fu.findOrReplaceFragment(R.id.fragment_info, Tags.FRAGMENT_INFO, InfoFragment.class); fu.findOrReplaceOptionalFragment(this, R.id.fragment_art, Tags.FRAGMENT_ART, ArtFragment.class); fu.findOrReplaceFragment(R.id.fragment_buttons, Tags.FRAGMENT_BUTTONS, ButtonsFragment.class); VolumeFragment mVolume = fu.findOrReplaceFragment(R.id.fragment_volume, Tags.FRAGMENT_VOLUME, VolumeFragment.class); setVolumeFragmentVisible(mVolume != null); } else { setupTabHost(); mPager.setOffscreenPageLimit(4); mPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(), pref.isHideDVDTabSet())); mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { mTabHost.setCurrentTab(position); } }); if (savedInstanceState != null) { fu.removeFragmentsByTag(Tags.FRAGMENT_PLAYBACK, Tags.FRAGMENT_INFO, Tags.FRAGMENT_BUTTONS, Tags.FRAGMENT_VOLUME, Tags.FRAGMENT_BOTTOMBAR, Tags.FRAGMENT_BROWSE, Tags.FRAGMENT_TV_SHOWS, Tags.FRAGMENT_NAVIGATION, Tags.FRAGMENT_PLAYLIST); } } mDrawer = (SlidingDrawer) findViewById(R.id.drawer); if (mDrawer != null) { BrowseDrawerListener listener = new BrowseDrawerListener(this, mDrawer, browse); mDrawer.setOnDrawerOpenListener(listener); mDrawer.setOnDrawerCloseListener(listener); } if (savedInstanceState == null) { onNewIntent(getIntent()); } else { notifyMediaServerListeners(); } }
From source file:com.andrewshu.android.reddit.mail.InboxListActivity.java
/** * Called when the activity starts up. Do activity initialization * here, not in a constructor.//from w ww.ja v a 2 s .c om * * @see Activity#onCreate */ @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.inbox_list_content); registerForContextMenu(getListView()); if (mSettings.isLoggedIn()) { if (savedInstanceState != null) { mReplyTargetName = savedInstanceState.getString(Constants.REPLY_TARGET_NAME_KEY); 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); mVoteTargetThingInfo = savedInstanceState.getParcelable(Constants.VOTE_TARGET_THING_INFO_KEY); mWhichInbox = savedInstanceState.getString(Constants.WHICH_INBOX_KEY); restoreLastNonConfigurationInstance(); if (mMessagesList == null) { // Load previous view of threads if (mLastAfter != null) { new DownloadMessagesTask(mWhichInbox, mLastAfter, null, mLastCount) .execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT); } else if (mLastBefore != null) { new DownloadMessagesTask(mWhichInbox, null, mLastBefore, mLastCount) .execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT); } else { new DownloadMessagesTask(mWhichInbox).execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT); } } else { // Orientation change. Use prior instance. resetUI(new MessagesListAdapter(this, mMessagesList)); } } else { Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(Constants.WHICH_INBOX_KEY)) mWhichInbox = extras.getString(Constants.WHICH_INBOX_KEY); } new DownloadMessagesTask(mWhichInbox).execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT); } } else { showDialog(Constants.DIALOG_LOGIN); } setTitle(String.format(getResources().getString(R.string.inbox_title), mSettings.getUsername())); }
From source file:org.melato.bus.android.activity.PlanTabsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.plantabs);/* w ww. j av a 2 s . c o m*/ tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); tabHost.setOnTabChangedListener(this); tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); tabHost.addTab(tabHost.newTabSpec(TAB_SEARCH).setIndicator(getString(R.string.search)), PlanFragment.class, null); tabHost.addTab(tabHost.newTabSpec(TAB_RESULTS).setIndicator(getString(R.string.itineraries)), OTPItinerariesFragment.class, null); String tab = getIntent().getStringExtra(KEY_TAB); if (TAB_RESULTS.equals(tab)) { tabHost.setCurrentTabByTag(TAB_RESULTS); } else if (TAB_SEARCH.equals(tab)) { tabHost.setCurrentTabByTag(TAB_SEARCH); } else if (PlanFragment.plan != null) { tabHost.setCurrentTabByTag(TAB_RESULTS); } else { tabHost.setCurrentTabByTag(TAB_SEARCH); } }
From source file:org.openhab.habdroid.ui.OpenHABWidgetListActivity.java
/** * This is called when activity is created. Initializes the state, performs network * state based selection for app initialization and starts the widget list */// w w w . j a va 2s. co m @Override public void onCreate(Bundle savedInstanceState) { Log.d("OpenHABWidgetListActivity", "onCreate"); // Set default values, false means do it one time during the very first launch PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // Set non-persistant HABDroid version preference to current version from application package try { PreferenceManager.getDefaultSharedPreferences(this).edit().putString("default_openhab_appversion", getPackageManager().getPackageInfo(getPackageName(), 0).versionName).commit(); } catch (NameNotFoundException e1) { if (e1 != null) Log.d(TAG, e1.getMessage()); } // Set the theme to one from preferences Util.setActivityTheme(this); // Fetch openHAB service type name from strings.xml openHABServiceType = getString(R.string.openhab_service_type); // Enable progress ring bar requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_PROGRESS); setProgressBarIndeterminateVisibility(true); // Initialize crittercism reporting JSONObject crittercismConfig = new JSONObject(); try { crittercismConfig.put("shouldCollectLogcat", true); } catch (JSONException e) { if (e.getMessage() != null) Log.e(TAG, e.getMessage()); else Log.e(TAG, "Crittercism JSON exception"); } Crittercism.init(getApplicationContext(), "5117659f59e1bd4ba9000004", crittercismConfig); // Initialize activity view super.onCreate(savedInstanceState); setContentView(R.layout.openhabwidgetlist); // Disable screen timeout if set in preferences SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); if (settings.getBoolean("default_openhab_screentimeroff", false)) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } // Check if we got all needed permissions PackageManager pm = getPackageManager(); if (!(pm.checkPermission(permission.CHANGE_WIFI_MULTICAST_STATE, getPackageName()) == PackageManager.PERMISSION_GRANTED)) { showAlertDialog(getString(R.string.erorr_no_wifi_mcast_permission)); serviceDiscoveryEnabled = false; } if (!(pm.checkPermission(permission.ACCESS_WIFI_STATE, getPackageName()) == PackageManager.PERMISSION_GRANTED)) { showAlertDialog(getString(R.string.erorr_no_wifi_state_permission)); serviceDiscoveryEnabled = false; } // Get username/password from preferences openHABUsername = settings.getString("default_openhab_username", null); openHABPassword = settings.getString("default_openhab_password", null); // Create new data source and adapter and set it to list view openHABWidgetDataSource = new OpenHABWidgetDataSource(); openHABWidgetAdapter = new OpenHABWidgetAdapter(OpenHABWidgetListActivity.this, R.layout.openhabwidgetlist_genericitem, widgetList); getListView().setAdapter(openHABWidgetAdapter); // Set adapter parameters openHABWidgetAdapter.setOpenHABUsername(openHABUsername); openHABWidgetAdapter.setOpenHABPassword(openHABPassword); // Enable app logo as home button this.getActionBar().setHomeButtonEnabled(true); // Check if we have openHAB page url in saved instance state? if (savedInstanceState != null) { displayPageUrl = savedInstanceState.getString("displayPageUrl"); openHABBaseUrl = savedInstanceState.getString("openHABBaseUrl"); sitemapRootUrl = savedInstanceState.getString("sitemapRootUrl"); openHABWidgetAdapter.setOpenHABBaseUrl(openHABBaseUrl); } // Check if this is a launch from myself (drill down navigation) if (getIntent() != null) { if (getIntent().getAction() != null) { if (getIntent().getAction().equals("org.openhab.habdroid.ui.OpwnHABWidgetListActivity")) { displayPageUrl = getIntent().getExtras().getString("displayPageUrl"); openHABBaseUrl = getIntent().getExtras().getString("openHABBaseUrl"); sitemapRootUrl = getIntent().getExtras().getString("sitemapRootUrl"); this.setTitle(getIntent().getExtras().getString("pageTitle")); openHABWidgetAdapter.setOpenHABBaseUrl(openHABBaseUrl); } } } // If yes, then just go to it (means restore activity from it's saved state) if (displayPageUrl.length() > 0) { Log.d(TAG, "displayPageUrl = " + displayPageUrl); showPage(displayPageUrl, false); // If not means it is a clean start } else { if (getIntent() != null) { Log.i(TAG, "Launch intent = " + getIntent().getAction()); // If this is a launch through NFC tag reading if (getIntent().getAction() != null) { if (getIntent().getAction().equals("android.nfc.action.NDEF_DISCOVERED")) { // Save url which we got from NFC tag nfcTagData = getIntent().getDataString(); } } } // If we are in demo mode, ignore all settings and use demo url from strings if (settings.getBoolean("default_openhab_demomode", false)) { openHABBaseUrl = getString(R.string.openhab_demo_url); Log.i(TAG, "Demo mode, connecting to " + openHABBaseUrl); Toast.makeText(getApplicationContext(), getString(R.string.info_demo_mode), Toast.LENGTH_LONG) .show(); showTime(); } else { openHABBaseUrl = normalizeUrl(settings.getString("default_openhab_url", "")); // Check if we have a direct URL in preferences, if yes - use it if (openHABBaseUrl.length() > 0) { Log.i(TAG, "Connecting to configured URL = " + openHABBaseUrl); Toast.makeText(getApplicationContext(), getString(R.string.info_conn_url), Toast.LENGTH_SHORT) .show(); showTime(); } else { // Get current network information ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetworkInfo != null) { Log.i(TAG, "Network is connected"); // If network is mobile, try to use remote URL if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_MOBILE || serviceDiscoveryEnabled == false) { if (!serviceDiscoveryEnabled) { Log.i(TAG, "openHAB discovery is disabled"); } else { Log.i(TAG, "Network is Mobile (" + activeNetworkInfo.getSubtypeName() + ")"); } openHABBaseUrl = normalizeUrl(settings.getString("default_openhab_alturl", "")); // If remote URL is configured if (openHABBaseUrl.length() > 0) { Toast.makeText(getApplicationContext(), getString(R.string.info_conn_rem_url), Toast.LENGTH_SHORT).show(); Log.i(TAG, "Connecting to remote URL " + openHABBaseUrl); showTime(); } else { Toast.makeText(getApplicationContext(), getString(R.string.error_no_url), Toast.LENGTH_LONG).show(); } // If network is WiFi or Ethernet } if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI || activeNetworkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) { Log.i(TAG, "Network is WiFi or Ethernet"); // Start service discovery this.serviceResolver = new AsyncServiceResolver(this, openHABServiceType); progressDialog = ProgressDialog.show(this, "", "Discovering openHAB. Please wait...", true); this.serviceResolver.start(); // We don't know how to handle this network type } else { Log.i(TAG, "Network type (" + activeNetworkInfo.getTypeName() + ") is unsupported"); } // Network is not available } else { Log.i(TAG, "Network is not available"); Toast.makeText(getApplicationContext(), getString(R.string.error_network_not_available), Toast.LENGTH_LONG).show(); } } } } }
From source file:in.shick.diode.user.ProfileActivity.java
/** * Called when the activity starts up. Do activity initialization * here, not in a constructor.//from w w w.j ava2 s . c o m * * @see Activity#onCreate */ @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.profile_list_content); registerForContextMenu(getListView()); if (savedInstanceState != null) { if (Constants.LOGGING) Log.d(TAG, "using savedInstanceState"); mUsername = savedInstanceState.getString(Constants.USERNAME_KEY); 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); mKarma = savedInstanceState.getIntArray(Constants.KARMA_KEY); mSortByUrl = savedInstanceState.getString(Constants.CommentsSort.SORT_BY_KEY); mJumpToThreadId = savedInstanceState.getString(Constants.JUMP_TO_THREAD_ID_KEY); mVoteTargetThingInfo = savedInstanceState.getParcelable(Constants.VOTE_TARGET_THING_INFO_KEY); // try to restore mThingsList using getLastNonConfigurationInstance() // (separate function to avoid a compiler warning casting ArrayList<ThingInfo> restoreLastNonConfigurationInstance(); if (mThingsList == null) { // Load previous page of profile items if (mLastAfter != null) { new DownloadProfileTask(mUsername, mLastAfter, null, mLastCount).execute(); } else if (mLastBefore != null) { new DownloadProfileTask(mUsername, null, mLastBefore, mLastCount).execute(); } else { new DownloadProfileTask(mUsername).execute(); } } else { // Orientation change. Use prior instance. resetUI(new ThingsListAdapter(this, mThingsList)); setTitle(String.format(getResources().getString(R.string.user_profile), mUsername)); } return; } // Handle subreddit Uri passed via Intent else if (getIntent().getData() != null) { Matcher userPathMatcher = USER_PATH_PATTERN.matcher(getIntent().getData().getPath()); if (userPathMatcher.matches()) { mUsername = userPathMatcher.group(1); new DownloadProfileTask(mUsername).execute(); return; } } // No username specified by Intent, so load the logged in user's profile if (mSettings.isLoggedIn()) { mUsername = mSettings.getUsername(); new DownloadProfileTask(mUsername).execute(); return; } // Can't find a username to use. Quit. if (Constants.LOGGING) Log.e(TAG, "Could not find a username to use for ProfileActivity"); finish(); }
From source file:com.andrewshu.android.reddit.threads.ThreadsListActivity.java
/** * Called when the activity starts up. Do activity initialization * here, not in a constructor./*from ww w .j ava2 s. c o m*/ * * @see Activity#onCreate */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); CookieSyncManager.createInstance(getApplicationContext()); mSettings.loadRedditPreferences(getApplicationContext(), mClient); setRequestedOrientation(mSettings.getRotation()); setTheme(mSettings.getTheme()); requestWindowFeature(Window.FEATURE_PROGRESS); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.threads_list_content); 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); 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 (mThreadsList == null) { // Load previous view of threads if (mLastAfter != null) { new MyDownloadThreadsTask(mSubreddit, mLastAfter, null, mLastCount).execute(); } else if (mLastBefore != null) { new MyDownloadThreadsTask(mSubreddit, null, mLastBefore, mLastCount).execute(); } else { new MyDownloadThreadsTask(mSubreddit).execute(); } } else { // Orientation change. Use prior instance. resetUI(new ThreadsListAdapter(this, mThreadsList)); if (Constants.FRONTPAGE_STRING.equals(mSubreddit)) setTitle("reddit.com: what's new online!"); else setTitle("/r/" + mSubreddit.trim()); } } // Handle subreddit Uri passed via Intent else if (getIntent().getData() != null) { Matcher redditContextMatcher = REDDIT_PATH_PATTERN.matcher(getIntent().getData().getPath()); if (redditContextMatcher.matches()) { new MyDownloadThreadsTask(redditContextMatcher.group(1)).execute(); } else { new MyDownloadThreadsTask(mSettings.getHomepage()).execute(); } } // No subreddit specified by Intent, so load the user's home reddit else { new MyDownloadThreadsTask(mSettings.getHomepage()).execute(); } }
From source file:com.andrewshu.android.reddit.user.ProfileActivity.java
/** * Called when the activity starts up. Do activity initialization * here, not in a constructor.//from www . ja va 2 s.c o m * * @see Activity#onCreate */ @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.profile_list_content); registerForContextMenu(getListView()); if (savedInstanceState != null) { if (Constants.LOGGING) Log.d(TAG, "using savedInstanceState"); mUsername = savedInstanceState.getString(Constants.USERNAME_KEY); 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); mKarma = savedInstanceState.getIntArray(Constants.KARMA_KEY); mSortByUrl = savedInstanceState.getString(Constants.CommentsSort.SORT_BY_KEY); mJumpToThreadId = savedInstanceState.getString(Constants.JUMP_TO_THREAD_ID_KEY); mVoteTargetThingInfo = savedInstanceState.getParcelable(Constants.VOTE_TARGET_THING_INFO_KEY); // try to restore mThingsList using getLastNonConfigurationInstance() // (separate function to avoid a compiler warning casting ArrayList<ThingInfo> restoreLastNonConfigurationInstance(); if (mThingsList == null) { // Load previous page of profile items if (mLastAfter != null) { new DownloadProfileTask(mUsername, mLastAfter, null, mLastCount).execute(); } else if (mLastBefore != null) { new DownloadProfileTask(mUsername, null, mLastBefore, mLastCount).execute(); } else { new DownloadProfileTask(mUsername).execute(); } } else { // Orientation change. Use prior instance. resetUI(new ThingsListAdapter(this, mThingsList)); setTitle(mUsername + "'s profile"); } return; } // Handle subreddit Uri passed via Intent else if (getIntent().getData() != null) { Matcher userPathMatcher = USER_PATH_PATTERN.matcher(getIntent().getData().getPath()); if (userPathMatcher.matches()) { mUsername = userPathMatcher.group(1); new DownloadProfileTask(mUsername).execute(); return; } } // No username specified by Intent, so load the logged in user's profile if (mSettings.isLoggedIn()) { mUsername = mSettings.getUsername(); new DownloadProfileTask(mUsername).execute(); return; } // Can't find a username to use. Quit. if (Constants.LOGGING) Log.e(TAG, "Could not find a username to use for ProfileActivity"); finish(); }
From source file:com.andrewshu.android.reddit.profile.ProfileActivity.java
/** * Called when the activity starts up. Do activity initialization * here, not in a constructor./*w w w . ja va 2s . com*/ * * @see Activity#onCreate */ @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.profile_list_content); if (savedInstanceState != null) { if (Constants.LOGGING) Log.d(TAG, "using savedInstanceState"); mUsername = savedInstanceState.getString(Constants.USERNAME_KEY); 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); mKarma = savedInstanceState.getStringArray(Constants.KARMA_KEY); mSortByUrl = savedInstanceState.getString(Constants.CommentsSort.SORT_BY_KEY); mJumpToThreadId = savedInstanceState.getString(Constants.JUMP_TO_THREAD_ID_KEY); mVoteTargetThingInfo = savedInstanceState.getParcelable(Constants.VOTE_TARGET_THING_INFO_KEY); // try to restore mThingsList using getLastNonConfigurationInstance() // (separate function to avoid a compiler warning casting ArrayList<ThingInfo> restoreLastNonConfigurationInstance(); if (mThingsList == null) { // Load previous page of profile items if (mLastAfter != null) { new DownloadProfileTask(mUsername, mLastAfter, null, mLastCount).execute(); } else if (mLastBefore != null) { new DownloadProfileTask(mUsername, null, mLastBefore, mLastCount).execute(); } else { new DownloadProfileTask(mUsername).execute(); } } else { // Orientation change. Use prior instance. resetUI(new ThingsListAdapter(this, mThingsList)); setTitle(mUsername + "'s profile"); } return; } // Handle subreddit Uri passed via Intent else if (getIntent().getData() != null) { Matcher userPathMatcher = USER_PATH_PATTERN.matcher(getIntent().getData().getPath()); if (userPathMatcher.matches()) { mUsername = userPathMatcher.group(1); new DownloadProfileTask(mUsername).execute(); return; } } // No username specified by Intent, so load the logged in user's profile if (mSettings.isLoggedIn()) { mUsername = mSettings.getUsername(); new DownloadProfileTask(mUsername).execute(); return; } // Can't find a username to use. Quit. if (Constants.LOGGING) Log.e(TAG, "Could not find a username to use for ProfileActivity"); finish(); }
From source file:in.shick.diode.threads.ThreadsListActivity.java
/** * Called when the activity starts up. Do activity initialization * here, not in a constructor.//from w ww . j a v a 2s . com * * @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:com.andrewshu.android.reddit.comments.CommentsListActivity.java
/** * Called when the activity starts up. Do activity initialization * here, not in a constructor./*from ww w . j ava2 s . c o m*/ * * @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); } } }