List of usage examples for java.lang Thread setDefaultUncaughtExceptionHandler
public static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh)
From source file:com.vinexs.eeb.BaseActivity.java
@Override public void onStart() { super.onStart(); BackStackSyncStatus();//from w w w . jav a 2s . co m if (!BuildConfig.DEBUG && exceptionHandler != null) { Thread.setDefaultUncaughtExceptionHandler(exceptionHandler); } }
From source file:org.apache.hadoop.corona.Utilities.java
/** * Sets an uncaught exception handler. This will make the process exit with * exit code 1 if a thread exits due to an uncaught exception. *//*from w ww .j av a2s . c o m*/ public static void makeProcessExitOnUncaughtException(final Log log) { Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { log.error("UNCAUGHT: Thread " + t.getName() + " got an uncaught exception", e); System.exit(1); } }); }
From source file:com.wbtech.ums.UmsAgent.java
/** * @param context/*from w ww. ja v a 2 s. c o m*/ */ public static void onError(final Context context) { Thread thread = new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub MyCrashHandler handler = MyCrashHandler.getInstance(); handler.init(context.getApplicationContext()); Thread.setDefaultUncaughtExceptionHandler(handler); } }); handler.post(thread); }
From source file:op.OPDE.java
/** * Hier ist die main Methode von OPDE. In dieser Methode wird auch festgestellt, wie OPDE gestartet wurde. * <ul>/*from w ww.j ava 2 s .c o m*/ * <li>Im Standard Modus, das heisst mit graphischer Oberflche. Das drfte der hufigste Fall sein.</li> * <li>Im DFNImport Modus. Der wird meist auf dem Datenbankserver gebraucht um Nachts die Durchfhrungsnachweise anhand der * DFNImport Tabelle zu generieren. Das alles gehrt zu der Pflegeplanung.</li> * <li>Im BHPImport Modus. Auch dieser Modus wird auf dem DB-Server gebraucht um die Behandlungspflege Massnahmen * anhand der rztlichen Verordnungen zu generieren.</li> * </ul> * * @param args Hier stehen die Kommandozeilen Parameter. Diese werden mit */ public static void main(String[] args) throws Exception { /*** * * ____ * ,' , `. * ,-+-,.' _ | ,--, * ,-+-. ; , || ,--.'| ,---, * ,--.'|' | ;| | |, ,-+-. / | * | | ,', | ': ,--.--. `--'_ ,--.'|' | * | | / | | || / \ ,' ,'| | | ,"' | * ' | : | : |,.--. .-. | ' | | | | / | | * ; . | ; |--' \__\/: . . | | : | | | | | * | : | | , ," .--.; | ' : |__ | | | |/ * | : ' |/ / / ,. | | | '.'|| | |--' * ; | |`-' ; : .' \; : ;| |/ * | ;/ | , .-./| , / '---' * '---' `--`---' ---`-' * */ uptime = SYSCalendar.now(); // arial14 = new Font("Arial", Font.PLAIN, 14); // arial28 = new Font("Arial", Font.PLAIN, 28); /*** * _ ____ _ _ * | | __ _ _ __ __ _ _ _ __ _ __ _ ___ | __ ) _ _ _ __ __| | | ___ * | | / _` | '_ \ / _` | | | |/ _` |/ _` |/ _ \ | _ \| | | | '_ \ / _` | |/ _ \ * | |__| (_| | | | | (_| | |_| | (_| | (_| | __/ | |_) | |_| | | | | (_| | | __/ * |_____\__,_|_| |_|\__, |\__,_|\__,_|\__, |\___| |____/ \__,_|_| |_|\__,_|_|\___| * |___/ |___/ */ lang = ResourceBundle.getBundle("languageBundle", Locale.getDefault()); validatorFactory = Validation.buildDefaultValidatorFactory(); /*** * ____ _ _ _ _ _ _ * / ___|__ _| |_ ___| |__ __ _| | | _ __ ___ __ _ _ _ ___ _____ _____ ___ _ __ | |_(_) ___ _ __ ___ * | | / _` | __/ __| '_ \ / _` | | | | '__/ _ \ / _` | | | |/ _ \ / _ \ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \/ __| * | |__| (_| | || (__| | | | | (_| | | | | | | (_) | (_| | |_| | __/ | __/> < (_| __/ |_) | |_| | (_) | | | \__ \ * \____\__,_|\__\___|_| |_| \__,_|_|_| |_| \___/ \__, |\__,_|\___| \___/_/\_\___\___| .__/ \__|_|\___/|_| |_|___/ * |___/ |_| */ Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { OPDE.fatal(e); } }); localProps = new SortedProperties(); props = new Properties(); /*** * _ _ ___ __ * _ __ ___ __ _ __| | / \ _ __ _ __|_ _|_ __ / _| ___ * | '__/ _ \/ _` |/ _` | / _ \ | '_ \| '_ \| || '_ \| |_ / _ \ * | | | __/ (_| | (_| | / ___ \| |_) | |_) | || | | | _| (_) | * |_| \___|\__,_|\__,_| /_/ \_\ .__/| .__/___|_| |_|_| \___/ * |_| |_| */ appInfo = new AppInfo(); /*** * ____ _ _ _ ___ _ _ * / ___|___ _ __ ___ _ __ ___ __ _ _ __ __| | | | (_)_ __ ___ / _ \ _ __ | |_(_) ___ _ __ ___ * | | / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` | | | | | '_ \ / _ \ | | | | '_ \| __| |/ _ \| '_ \/ __| * | |__| (_) | | | | | | | | | | | (_| | | | | (_| | | |___| | | | | __/ | |_| | |_) | |_| | (_) | | | \__ \ * \____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_| |_____|_|_| |_|\___| \___/| .__/ \__|_|\___/|_| |_|___/ * |_| */ Options opts = new Options(); opts.addOption("h", "hilfe", false, "Gibt die Hilfeseite fr OPDE aus."); opts.addOption("v", "version", false, "Zeigt die Versionsinformationen an."); opts.addOption("x", "experimental", false, "Schaltet experimentelle Programm-Module fr User frei, die Admin Rechte haben. VORSICHT !!!!"); opts.addOption("a", "anonym", false, "Blendet die Bewohnernamen in allen Ansichten aus. Spezieller Modus fr Schulungsmaterial zu erstellen."); opts.addOption("w", "workingdir", true, "Damit kannst Du ein anderes Arbeitsverzeichnis setzen. Wenn Du diese Option weglsst, dann ist das Dein Benutzerverzeichnis: " + System.getProperty("user.home")); opts.addOption("l", "debug", false, "Schaltet alle Ausgaben ein auf der Konsole ein, auch die, die eigentlich nur whrend der Softwareentwicklung angezeigt werden."); opts.addOption("t", "training", false, "Wird fr Einarbeitungsversionen bentigt. Frbt die Oberflche anders ein und zeigt eine Warnmeldung nach jeder Anmeldung."); Option optFTPserver = OptionBuilder.withLongOpt("ftpserver").withArgName("ip or hostname").hasArgs(1) .withDescription(lang.getString("cmdline.ftpserver")).create("f"); opts.addOption(optFTPserver); // opts.addOption("p", "pidfile", false, "Path to the pidfile which needs to be deleted when this application ends properly."); Option notification = OptionBuilder.withLongOpt("notification").hasOptionalArg() .withDescription("Schickt allen festgelegten Empfngern die jeweilige Benachrichtungs-Mail.") .create("n"); notification.setArgName( "Liste der Empfnger (durch Komma getrennt, ohne Leerzeichen. UID verwenden). Damit kannst Du die Benachrichtigungen einschrnken. Fehlt diese Liste, erhalten ALLE Empfnger eine Mail."); opts.addOption(notification); opts.addOption(OptionBuilder.withLongOpt("jdbc").hasArg().withDescription(lang.getString("cmdline.jdbc")) .create("j")); Option dfnimport = OptionBuilder //.withArgName("datum") .withLongOpt("dfnimport").hasOptionalArg() .withDescription("Startet OPDE im DFNImport Modus fr den aktuellen Tag.").create("d"); dfnimport.setArgName( "Anzahl der Tage (+ oder -) abweichend vom aktuellen Tag fr den der Import durchgefhrt werden soll. Nur in Ausnahmefllen anzuwenden."); opts.addOption(dfnimport); Option bhpimport = OptionBuilder.withLongOpt("bhpimport").hasOptionalArg() .withDescription("Startet OPDE im BHPImport Modus fr den aktuellen Tag.").create("b"); // bhpimport.setOptionalArg(true); bhpimport.setArgName( "Anzahl der Tage (+ oder -) abweichend vom aktuellen Tag fr den der Import durchgefhrt werden soll. Nur in Ausnahmefllen anzuwenden."); opts.addOption(bhpimport); BasicParser parser = new BasicParser(); CommandLine cl = null; String footer = "http://www.Offene-Pflege.de"; /*** * _ _ * | |__ ___| |_ __ ___ ___ _ __ ___ ___ _ __ * | '_ \ / _ \ | '_ \ / __|/ __| '__/ _ \/ _ \ '_ \ * | | | | __/ | |_) | \__ \ (__| | | __/ __/ | | | * |_| |_|\___|_| .__/ |___/\___|_| \___|\___|_| |_| * |_| */ try { cl = parser.parse(opts, args); } catch (ParseException ex) { HelpFormatter f = new HelpFormatter(); f.printHelp("OffenePflege.jar [OPTION]", "Offene-Pflege.de, Version " + appInfo.getVersion() + " Build:" + appInfo.getBuildnum(), opts, footer); System.exit(0); } // Alternative FTP-Server if (cl.hasOption("f")) { UPDATE_FTPSERVER = cl.getOptionValue("f"); } if (cl.hasOption("h")) { HelpFormatter f = new HelpFormatter(); f.printHelp("OffenePflege.jar [OPTION]", "Offene-Pflege.de, Version " + appInfo.getVersion() + " Build:" + appInfo.getBuildnum(), opts, footer); System.exit(0); } String homedir = System.getProperty("user.home"); // alternatice working dir if (cl.hasOption("w")) { File dir = new File(cl.getOptionValue("w")); if (dir.exists() && dir.isDirectory()) { homedir = dir.getAbsolutePath(); } } opwd = homedir + sep + AppInfo.dirBase; /*** * ___ * __ _ _ __ ___ _ __ _ _ _ __ ___ ___ _ _ ___ |__ \ * / _` | '_ \ / _ \| '_ \| | | | '_ ` _ \ / _ \| | | / __| / / * | (_| | | | | (_) | | | | |_| | | | | | | (_) | |_| \__ \ |_| * \__,_|_| |_|\___/|_| |_|\__, |_| |_| |_|\___/ \__,_|___/ (_) * |___/ */ if (cl.hasOption("a")) { // anonym Modus //localProps.put("anonym", "true"); anonym = true; anonymize = new HashMap[] { SYSConst.getNachnamenAnonym(), SYSConst.getVornamenFrauAnonym(), SYSConst.getVornamenMannAnonym() }; } else { anonym = false; } /*** * _ _ _ _ _ * (_)_ __ (_) |_ _ __ _ __(_)_ __ | |_ ___ _ __ ___ * | | '_ \| | __| | '_ \| '__| | '_ \| __/ _ \ '__/ __| * | | | | | | |_ | |_) | | | | | | | || __/ | \__ \ * |_|_| |_|_|\__| | .__/|_| |_|_| |_|\__\___|_| |___/ * |_| */ printers = new LogicalPrinters(); /*** * _ _ _ _ _ _ * | | ___ __ _ __| | | | ___ ___ __ _| | _ __ _ __ ___ _ __ ___ _ __| |_(_) ___ ___ * | |/ _ \ / _` |/ _` | | |/ _ \ / __/ _` | | | '_ \| '__/ _ \| '_ \ / _ \ '__| __| |/ _ \/ __| * | | (_) | (_| | (_| | | | (_) | (_| (_| | | | |_) | | | (_) | |_) | __/ | | |_| | __/\__ \ * |_|\___/ \__,_|\__,_| |_|\___/ \___\__,_|_| | .__/|_| \___/| .__/ \___|_| \__|_|\___||___/ * |_| |_| */ if (loadLocalProperties()) { // try { // FileAppender fileAppender = new FileAppender(layout, , true); // logger.addAppender(fileAppender); // } catch (IOException ex) { // fatal(ex); // } animation = localProps.containsKey("animation") && localProps.getProperty("animation").equals("true"); logger.info("######### START ########### " + OPDE.getAppInfo().getProgname() + ", v" + OPDE.getAppInfo().getVersion() + "/" + OPDE.getAppInfo().getBuildnum()); logger.info(System.getProperty("os.name").toLowerCase()); /*** * _ ____ _ ___ ___ * (_)___| _ \ ___| |__ _ _ __ _ |__ \__ \ * | / __| | | |/ _ \ '_ \| | | |/ _` | / / / / * | \__ \ |_| | __/ |_) | |_| | (_| | |_| |_| * |_|___/____/ \___|_.__/ \__,_|\__, | (_) (_) * |___/ */ if (cl.hasOption("l") || SYSTools.catchNull(localProps.getProperty("debug")).equalsIgnoreCase("true")) { debug = true; logger.setLevel(Level.DEBUG); } else { debug = false; logger.setLevel(Level.INFO); } Logger.getLogger("org.hibernate").setLevel(Level.OFF); if (cl.hasOption("x") || SYSTools.catchNull(localProps.getProperty("experimental")).equalsIgnoreCase("true")) { experimental = true; } else { experimental = false; } if (cl.hasOption("t") || SYSTools.catchNull(localProps.getProperty("training")).equalsIgnoreCase("true")) { training = true; } else { training = false; } /*** * _ _ _ _ _ _ _ ___ * __| | |____ _____ _ __ ___(_) ___ _ __ ___ ___ _ __ ___ _ __ __ _| |_(_) |__ | | ___ |__ \ * / _` | '_ \ \ / / _ \ '__/ __| |/ _ \| '_ \ / __/ _ \| '_ ` _ \| '_ \ / _` | __| | '_ \| |/ _ \ / / * | (_| | |_) \ V / __/ | \__ \ | (_) | | | | | (_| (_) | | | | | | |_) | (_| | |_| | |_) | | __/ |_| * \__,_|_.__/ \_/ \___|_| |___/_|\___/|_| |_| \___\___/|_| |_| |_| .__/ \__,_|\__|_|_.__/|_|\___| (_) * |_| */ url = cl.hasOption("j") ? cl.getOptionValue("j") : localProps.getProperty("javax.persistence.jdbc.url"); String hostkey = OPDE.getLocalProps().getProperty("hostkey"); String cryptpassword = localProps.getProperty("javax.persistence.jdbc.password"); DesEncrypter desEncrypter = new DesEncrypter(hostkey); Connection jdbcConnection = DriverManager.getConnection(url, localProps.getProperty("javax.persistence.jdbc.user"), desEncrypter.decrypt(cryptpassword)); if (appInfo.getDbversion() != getDBVersion(jdbcConnection)) { SYSFilesTools.print(lang.getString("cant.start.with.version.mismatch"), false); System.exit(1); } jdbcConnection.close(); /*** * _ ____ _ ____ _ _ * | | _ \ / \ | _ \ __ _| |_ __ _| |__ __ _ ___ ___ * _ | | |_) / _ \ | | | |/ _` | __/ _` | '_ \ / _` / __|/ _ \ * | |_| | __/ ___ \ | |_| | (_| | || (_| | |_) | (_| \__ \ __/ * \___/|_| /_/ \_\ |____/ \__,_|\__\__,_|_.__/ \__,_|___/\___| * */ Properties jpaProps = new Properties(); jpaProps.put("javax.persistence.jdbc.user", localProps.getProperty("javax.persistence.jdbc.user")); try { jpaProps.put("javax.persistence.jdbc.password", desEncrypter.decrypt(cryptpassword)); } catch (Exception e) { if (Desktop.isDesktopSupported()) { JOptionPane.showMessageDialog(null, SYSTools.xx("misc.msg.decryption.failure"), appInfo.getProgname(), JOptionPane.ERROR_MESSAGE); } else { OPDE.fatal(e); } System.exit(1); } jpaProps.put("javax.persistence.jdbc.driver", localProps.getProperty("javax.persistence.jdbc.driver")); jpaProps.put("javax.persistence.jdbc.url", url); // if (cl.hasOption("d") || cl.hasOption("d")) { // not for BHP or DFN // jpaProps.put("eclipselink.cache.shared.default", "false"); // } else { // jpaProps.put("eclipselink.cache.shared.default", "true"); // } jpaProps.put("eclipselink.cache.shared.default", "false"); jpaProps.put("eclipselink.session.customizer", "entity.JPAEclipseLinkSessionCustomizer"); emf = Persistence.createEntityManagerFactory("OPDEPU", jpaProps); /*** * __ __ _ * \ \ / /__ _ __ ___(_) ___ _ __ * \ \ / / _ \ '__/ __| |/ _ \| '_ \ * \ V / __/ | \__ \ | (_) | | | | * \_/ \___|_| |___/_|\___/|_| |_| * */ String header = SYSTools.getWindowTitle(""); if (cl.hasOption("v")) { System.out.println(header); System.out.println(footer); System.exit(0); } /*** * ____ _ ____ _____ _ _ * / ___| ___ _ __ ___ _ __ __ _| |_ ___ | _ \| ___| \ | |___ * | | _ / _ \ '_ \ / _ \ '__/ _` | __/ _ \ | | | | |_ | \| / __| * | |_| | __/ | | | __/ | | (_| | || __/ | |_| | _| | |\ \__ \ * \____|\___|_| |_|\___|_| \__,_|\__\___| |____/|_| |_| \_|___/ * */ if (cl.hasOption("d")) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Users rootUser = em.find(Users.class, "admin"); SYSLogin rootLogin = em.merge(new SYSLogin(rootUser)); OPDE.setLogin(rootLogin); initProps(); // create the new DFNs DFNTools.generate(em); // move over the floating ones that have not yet been clicked to the current day DFNTools.moveFloating(em); em.getTransaction().commit(); } catch (Exception ex) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } fatal(ex); } finally { em.close(); } System.exit(0); } /*** * ____ _ ____ _ _ ____ * / ___| ___ _ __ ___ _ __ __ _| |_ ___ | __ )| | | | _ \ ___ * | | _ / _ \ '_ \ / _ \ '__/ _` | __/ _ \ | _ \| |_| | |_) / __| * | |_| | __/ | | | __/ | | (_| | || __/ | |_) | _ | __/\__ \ * \____|\___|_| |_|\___|_| \__,_|\__\___| |____/|_| |_|_| |___/ * */ if (cl.hasOption("b")) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Users rootUser = em.find(Users.class, "admin"); SYSLogin rootLogin = em.merge(new SYSLogin(rootUser)); OPDE.setLogin(rootLogin); initProps(); BHPTools.generate(em); em.getTransaction().commit(); } catch (Exception ex) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } fatal(ex); } finally { em.close(); } System.exit(0); } /*** * _ _ _ _ __ _ _ _ * | \ | | ___ | |_(_)/ _(_) ___ __ _| |_(_) ___ _ __ * | \| |/ _ \| __| | |_| |/ __/ _` | __| |/ _ \| '_ \ * | |\ | (_) | |_| | _| | (_| (_| | |_| | (_) | | | | * |_| \_|\___/ \__|_|_| |_|\___\__,_|\__|_|\___/|_| |_| * */ if (cl.hasOption("n")) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Users rootUser = em.find(Users.class, "admin"); SYSLogin rootLogin = em.merge(new SYSLogin(rootUser)); OPDE.setLogin(rootLogin); initProps(); EMailSystem.notify(cl.getOptionValue("n")); em.getTransaction().commit(); } catch (Exception ex) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } fatal(ex); } finally { em.close(); } System.exit(0); } // to speed things later. The first connection loads the while JPA system. EntityManager em1 = createEM(); em1.close(); UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); setStandardFont(); try { css = SYSTools.readFileAsString(opwd + sep + AppInfo.dirTemplates + sep + AppInfo.fileStandardCSS); } catch (IOException ie) { css = ""; } // JideSoft Lm.verifyLicense("Torsten Loehr", "Open-Pflege.de", "G9F4JW:Bm44t62pqLzp5woAD4OCSUAr2"); WizardStyle.setStyle(WizardStyle.JAVA_STYLE); // JideSoft /*** * _____ __ __ _ ____ * | ___| __ _ __ ___ | \/ | __ _(_)_ __ / /\ \ * | |_ | '__| '_ ` _ \| |\/| |/ _` | | '_ \| | | | * | _|| | | | | | | | | | | (_| | | | | | | | | * |_| |_| |_| |_| |_|_| |_|\__,_|_|_| |_| | | | * \_\/_/ */ // JFrame frm = new JFrame(); // frm.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // frm.setLayout(new FlowLayout()); // // frm.getContentPane().add(new PnlBodyScheme(new Properties())); // // frm.setVisible(true); SYSTools.checkForSoftwareupdates(); mainframe = new FrmMain(); mainframe.setVisible(true); } }
From source file:com.moto.miletus.application.tabs.CommandsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View commandsLayout = inflater.inflate(R.layout.fragment_commands, container, false); if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) { Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this.getContext())); }/*from w w w. j a va 2 s . c o m*/ RecyclerView recyclerViewCommands = (RecyclerView) commandsLayout.findViewById(R.id.commandsList); // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView recyclerViewCommands.setHasFixedSize(true); // use a linear layout manager recyclerViewCommands.setLayoutManager(new LinearLayoutManager(getActivity())); // specify an adapter (see also next example) commandsAdapter = new CommandsAdapter(this); recyclerViewCommands.setAdapter(commandsAdapter); recyclerViewCommands.setHasFixedSize(true); return commandsLayout; }
From source file:com.kayzook.bracediary.BaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!BuildConfig.DEBUG) { Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); }// w ww. j a va 2 s .c o m setContentView(R.layout.activity_base); mTitle = mDrawerTitle = getTitle(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer_list); mDrawer = (LinearLayout) findViewById(R.id.left_drawer); ArrayList<CustomDrawerListData> objects = new ArrayList<CustomDrawerListData>(); for (int i = 0; i < 5; i++) { CustomDrawerListData item = new CustomDrawerListData(); HashMap<String, Object> map = getHashMapForNaviMenu(i); Log.d(TAG, String.valueOf(map.get(KEY_NAV_ACTION))); item.setActionName(String.valueOf(map.get(KEY_NAV_ACTION))); item.setActionDetail(String.valueOf(map.get(KEY_NAV_ACTION_DETAIL))); item.setImageId((Integer) map.get(KEY_NAV_IMAGE)); objects.add(item); } CustomDrawerListAdapter customAdapater = new CustomDrawerListAdapter(this, R.id.drawer_layout, objects); mDrawerList.setAdapter(customAdapater); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ 0, /* "open drawer" description for accessibility */ 0 /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } //set up usernames TextView currentPoint = (TextView) findViewById(R.id.current_point); if (UserProfile.getUserProfile() != null) { UserProfile profile = UserProfile.getUserProfile(); currentPoint.setText(profile.getPoints() + " pts"); TextView username = (TextView) findViewById(R.id.drawer_username); username.setText(profile.getFullName()); mProfilePicture = (RoundedImageView) findViewById(R.id.drawer_profile_pic); Picasso.with(this).load(profile.getPhotoUrl()).placeholder(R.drawable.icon_user).into(mProfilePicture); } }
From source file:eu.alefzero.owncloud.ui.activity.FileDisplayActivity.java
@Override public void onCreate(Bundle savedInstanceState) { Log.i(getClass().toString(), "onCreate() start"); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(getApplicationContext())); if (savedInstanceState != null) { mDirs = savedInstanceState.getStringArray(KEY_DIR_ARRAY); mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item); mDirectories.add(OCFile.PATH_SEPARATOR); if (mDirs != null) for (String s : mDirs) mDirectories.insert(s, 0); mCurrentDir = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_FILE); }/* w w w. ja v a 2 s .c o m*/ mLayoutView = getLayoutInflater().inflate(R.layout.files, null); // always inflate this at onCreate() ; just once! if (AccountUtils.accountsAreSetup(this)) { initDelayedTilAccountAvailabe(); // PIN CODE request ; best location is to decide, let's try this first //if (savedInstanceState == null) { if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) { requestPinCode(); } } else { setContentView(R.layout.no_account_available); getSupportActionBar().setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE); findViewById(R.id.setup_account).setOnClickListener(this); setSupportProgressBarIndeterminateVisibility(false); Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT); intent.putExtra(android.provider.Settings.EXTRA_AUTHORITIES, new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE }); startActivity(intent); // although the code is here, the activity won't be created until this.onStart() and this.onResume() are finished; mForcedLoginToCreateFirstAccount = true; } Log.i(getClass().toString(), "onCreate() end"); }
From source file:org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ContainerLocalizer.java
public static void main(String[] argv) throws Throwable { Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler()); // usage: $0 user userFolder appId locId host port app_log_dir user_dir [user_dir]* // let $x = $x/usercache for $local.dir // MKDIR $x/$user/appcache/$appid // MKDIR $x/$user/appcache/$appid/output // MKDIR $x/$user/appcache/$appid/filecache // LOAD $x/$user/appcache/$appid/appTokens try {//from www . j a va2 s .c o m String user = argv[0]; String userFolder = argv[1]; String appId = argv[2]; String locId = argv[3]; InetSocketAddress nmAddr = new InetSocketAddress(argv[4], Integer.parseInt(argv[5])); String[] sLocaldirs = Arrays.copyOfRange(argv, 6, argv.length); ArrayList<Path> localDirs = new ArrayList<Path>(sLocaldirs.length); for (String sLocaldir : sLocaldirs) { localDirs.add(new Path(sLocaldir)); } final String uid = UserGroupInformation.getCurrentUser().getShortUserName(); if (!user.equals(uid)) { // TODO: fail localization LOG.warn("Localization running as " + uid + " not " + user); } ContainerLocalizer localizer = new ContainerLocalizer(FileContext.getLocalFSFileContext(), user, appId, locId, localDirs, RecordFactoryProvider.getRecordFactory(null), userFolder); localizer.runLocalization(nmAddr); return; } catch (Throwable e) { // Print traces to stdout so that they can be logged by the NM address // space in both DefaultCE and LCE cases e.printStackTrace(System.out); LOG.error("Exception in main:", e); System.exit(-1); } }
From source file:org.geometerplus.android.fbreader.QuotesFragmentActivity.java
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); Thread.setDefaultUncaughtExceptionHandler( new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this)); PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); int theme = PreferenceManager.getDefaultSharedPreferences(this).getInt(IConstants.THEME_PREF, IConstants.THEME_REDTREE);/* w ww. ja v a2 s . c o m*/ switch (theme) { case IConstants.THEME_MYBLACK: setTheme(R.style.Theme_myBlack); break; case IConstants.THEME_LAMINAT: setTheme(R.style.Theme_Laminat); break; case IConstants.THEME_REDTREE: setTheme(R.style.Theme_Redtree); break; } // requestWindowFeature(Window.FEATURE_NO_TITLE); setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); // final SearchManager manager = (SearchManager) getSystemService(SEARCH_SERVICE); manager.setOnCancelListener(null); // // final TabHost host = getTabHost(); // LayoutInflater.from(this).inflate(R.layout.quotes, host.getTabContentView(), true); myBook = SerializerUtil.deserializeBook(getIntent().getStringExtra(FullReaderActivity.BOOK_KEY)); myTabListener = new MyTabListener(); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (loadCurrentLanguage().equals("en")) { getSupportActionBar().setSubtitle("Quotes"); } else if (loadCurrentLanguage().equals("ru")) { getSupportActionBar().setSubtitle(""); } else if (loadCurrentLanguage().equals("fr")) { getSupportActionBar().setSubtitle("Citations"); } else if (loadCurrentLanguage().equals("de")) { getSupportActionBar().setSubtitle("Zitate"); } else if (loadCurrentLanguage().equals("uk")) { getSupportActionBar().setSubtitle(""); } else { if (Locale.getDefault().getDisplayLanguage().equals("??")) { getSupportActionBar().setSubtitle(""); } else if (Locale.getDefault().getDisplayLanguage().equals("?")) { getSupportActionBar().setSubtitle(""); } else { getSupportActionBar().setSubtitle("Quotes"); } } }
From source file:org.pdfsam.PdfsamApp.java
@Override public void start(Stage primaryStage) { primaryStage.setScene(mainScene);/*from w w w . jav a 2 s. com*/ primaryStage.getIcons().addAll(ApplicationContextHolder.getContext().getBeansOfType(Image.class).values()); primaryStage.setTitle(ApplicationContextHolder.getContext().getBean(Pdfsam.class).name()); initWindowsStatusController(primaryStage); initOverwriteDialogController(primaryStage); initActiveModule(); primaryStage.show(); Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionLogger()); requestCheckForUpdateIfNecessary(); requestLatestNewsPanelDisplay(); eventStudio().addAnnotatedListeners(this); STOPWATCH.stop(); LOG.info(DefaultI18nContext.getInstance().i18n("Started in {0}", DurationFormatUtils.formatDurationWords(STOPWATCH.getTime(), true, true))); }