@Override protected void onResume() { super.onResume(); photosGridViewContents = this.filesAtPath(getFilesDir().getAbsolutePath() + "/images"); // new String[]{}; photosGridViewAdapter = new PhotoGridAdapter(this, R.layout.item_imagesgrid, photosGridViewContents); photosGridView = (GridView) findViewById(R.id.photosGridView); photosGridView.setAdapter(photosGridViewAdapter); photosGridView.setOnItemClickListener(this); }
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Thread.setDefaultUncaughtExceptionHandler(new MyExceptionHandler(this)); Colors.updateColors(this); startService(new Intent(this, JTalkService.class)); service = JTalkService.getInstance(); prefs = PreferenceManager.getDefaultSharedPreferences(this); setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark); setContentView(R.layout.roster); LinearLayout roster = (LinearLayout) findViewById(R.id.roster_linear); roster.setBackgroundColor(Colors.BACKGROUND); getActionBar().setHomeButtonEnabled(true); statusArray = getResources().getStringArray(R.array.statusArray); rosterAdapter = new RosterAdapter(this); simpleAdapter = new NoGroupsAdapter(this); searchAdapter = new SearchAdapter(this); int cols = 1; if (!prefs.getBoolean("ShowGroups", true) && !prefs.getBoolean("ShowMucGroup", false)) { try { cols = Integer.parseInt(prefs.getString("RosterColumns", "1")); } catch (Exception e) { cols = 1; } } gridView = (GridView) findViewById(R.id.users); gridView.setNumColumns(cols); gridView.setCacheColorHint(0x00000000); gridView.setOnItemClickListener(this); gridView.setOnItemLongClickListener(this); gridView.setAdapter(rosterAdapter); if (getIntent().getBooleanExtra("status", false)) { RosterDialogs.changeStatusDialog(this, null, null); } if (getIntent().getBooleanExtra("password", false)) { String account = getIntent().getStringExtra("account"); RosterDialogs.passwordDialog(this, account); } if (getIntent().getBooleanExtra("subscribtion", false)) { String account = getIntent().getStringExtra("account"); String jid = getIntent().getStringExtra("jid"); RosterDialogs.subscribtionRequestDialog(this, account, jid); } File table = new File(Constants.PATH_SMILES + "/default/table.xml"); if (!table.exists()) { new CreateDefaultSmiles().execute(); } else { Cursor cursor = getContentResolver() .query( JTalkProvider.ACCOUNT_URI, null, AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null); if (cursor == null || cursor.getCount() < 1) startActivity(new Intent(this, Accounts.class)); } if (prefs.getBoolean("BUG", false)) { new ErrorDialog(this).show(); } String action = getIntent().getAction(); if (action != null && action.equals(Intent.ACTION_VIEW)) { Uri data = getIntent().getData(); if (data != null && data.getScheme().equals("xmpp")) { XMPPUri xmppUri; try { xmppUri = new XMPPUri(data); } catch (IllegalArgumentException e) { xmppUri = null; } List<String> accounts = new ArrayList<String>(); for (XMPPConnection connection : service.getAllConnections()) { accounts.add(StringUtils.parseBareAddress(connection.getUser())); } if (xmppUri != null && !accounts.isEmpty()) { final String xmppJid = xmppUri.getJid(); final String body = xmppUri.getBody(); String queryType = xmppUri.getQueryType(); final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, accounts); if (queryType.equals("roster")) { RosterDialogs.addDialog(this, xmppUri.getJid()); } else if (queryType.equals("join")) { if (accounts.size() > 1) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.Accounts); builder.setAdapter( adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String account = adapter.getItem(which); MucDialogs.joinDialog(RosterActivity.this, account, xmppJid, null); } }); builder.create().show(); } else MucDialogs.joinDialog(RosterActivity.this, accounts.get(0), xmppJid, null); } else { service.setText(xmppJid, body); if (accounts.size() > 1) { service.setText(xmppJid, body); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.Accounts); builder.setAdapter( adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String account = adapter.getItem(which); Intent intent = new Intent(RosterActivity.this, Chat.class); intent.putExtra("account", account); intent.putExtra("jid", xmppJid); startActivity(intent); } }); builder.create().show(); } else { Intent intent = new Intent(RosterActivity.this, Chat.class); intent.putExtra("account", accounts.get(0)); intent.putExtra("jid", xmppJid); startActivity(intent); } } } } } }