@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.offline_media); setTitle(getString(R.string.offline)); mLoadingBar = findViewById(R.id.offline_loading_bar); mLoadingBar.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (mLoadingCount > 0) { Intent intent = new Intent(OfflineMediaActivity.this, OfflineActivity.class); startActivity(intent); } } }); mLoadingCountTextView = (TextView) mLoadingBar.findViewById(R.id.offline_media_bar_title); mLoadingProgressTextView = (TextView) mLoadingBar.findViewById(R.id.offline_media_bar_subtitle); setLoadingCount(0); setLoadingProgress(0, 0); adapter = new RelativeAdapter(getBaseContext(), null, true); mListView = (GridView) findViewById(R.id.offline_media_block_grids); // update UI mListView.setAdapter(adapter); mLoadingView = makeEmptyLoadingView(getBaseContext(), (RelativeLayout) findViewById(R.id.tabs_content)); findViewById(R.id.offline_media_block).setVisibility(View.GONE); // after check then load getSupportLoaderManager().initLoader(cursorFinishedLoaderID, null, this); }
@Override public View getView(final int position, View convertView, ViewGroup parent) { View v; if (convertView == null) { v = mInflater.inflate(R.layout.monitor, parent, false); } else { v = convertView; } Monitor monitor = getMonitorByPosition(position); TextView monitorName = (TextView) v.findViewById(R.id.monitorName); monitorName.setText(monitor.name()); TextView monitorDescription = (TextView) v.findViewById(R.id.monitorDescription); monitorDescription.setText(monitor.desc()); Button removeButton = (Button) v.findViewById(R.id.removeMonitorButton); removeButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { new DeleteMonitorDialogFragment( new Runnable() { @Override public void run() { monitoringService.removeMonitor(getMonitorIdByPosition(position)); onDataChange(); } }) .show(getFragmentManager(), "DeleteMonitor"); } }); Button editButton = (Button) v.findViewById(R.id.editMonitorButton); editButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, TickerMonitorEditActivity.class); intent.putExtra(MONITOR_ID, getMonitorIdByPosition(position)); startActivityForResult(intent, 1); // actual change the monitor is done on onActivityResult } }); GridView monitorResponses = (GridView) v.findViewById(R.id.monitorResponses); try { ResponseAdapter adapter = monitorResultsAdapters.get(monitor); monitorResponses.setAdapter(adapter); } catch (RuntimeException e) { Log.e(CoynesMonitoring.TAG, "caught exception", e); throw e; } return v; }
private void populateRhymes() { itemData.add(new BasicNameValuePair("K3YQsmznd4c", "A B C D E F G")); itemData.add(new BasicNameValuePair("gBEHFFnV3RY", "Baa Baa Black Sheep")); itemData.add(new BasicNameValuePair("Bhz2ycHGITw", "Diddle, Diddle, Dumpling, My Son John")); itemData.add(new BasicNameValuePair("iqn7Qm3h1u0", "Doctor Foster went to Gloucester")); itemData.add(new BasicNameValuePair("yyl8n-dzIk8", "Eeny, Meeny, Miny, Moe")); itemData.add(new BasicNameValuePair("SVPmtaHmL4g", "Five Little Speckeled Frog")); itemData.add(new BasicNameValuePair("_RQDTNrC6lQ", "Hey Diddle Diddle")); itemData.add(new BasicNameValuePair("UneYkq0FzKA", "Humpty Dumpty")); itemData.add(new BasicNameValuePair("oODul5hgIl4", "Hot Cross Buns")); itemData.add(new BasicNameValuePair("icUSwG83ES8", "It's Raining, It's Pouring")); itemData.add(new BasicNameValuePair("MBxeKG7_Hq4", "Incy Wincy Spider")); itemData.add(new BasicNameValuePair("lsbFIYSK26E", "Jack And Jill, Went Up The Hill")); itemData.add(new BasicNameValuePair("OHIbdUmeQwk", "Little Bo Peep")); itemData.add(new BasicNameValuePair("bneJKq-ksjM", "Little Miss Muffet")); itemData.add(new BasicNameValuePair("vTvNwAT29Lo", "London Bridge Is Falling Down")); itemData.add(new BasicNameValuePair("u_K9hFxSvDM", "Mary Had A Little Lamb")); itemData.add(new BasicNameValuePair("F3cedGb7lIo", "One, Two, Three, Four, Five")); itemData.add(new BasicNameValuePair("Wlc6Mho-PxE", "Pat-a-cake, Pat-a-cake")); itemData.add(new BasicNameValuePair("eh2Ud9KReWY", "Polly Put The Kettle On")); itemData.add(new BasicNameValuePair("fv4kp4ZnSuE", "Pop goes the Weasel")); itemData.add(new BasicNameValuePair("Izq1E6b4WlQ", "Rain Rain Go Away")); itemData.add(new BasicNameValuePair("Tbf0cDiqr-U", "Ring a RIng o' Roses")); itemData.add(new BasicNameValuePair("e66wIEbiMro", "Row, Row, Row Your Boat")); itemData.add(new BasicNameValuePair("-ORqKcPJYDg", "Solomon Grundy")); itemData.add(new BasicNameValuePair("tU85Kd-7bjM", "Star Light, Star Bright")); itemData.add(new BasicNameValuePair("yCjJyiqpAuU", "Twinkle Twinkle Little Star")); itemData.add(new BasicNameValuePair("-Xui9N1xjUM", "The Muffin Man")); // list = (ListView)findViewById(R.id.listRhymes); list = (GridView) findViewById(R.id.listRhymes); adapter = new LazyAdapter(this, itemData); // adapter = new LazyAdapter(this, mStrings); list.setAdapter(adapter); list.setOnItemClickListener( new OnItemClickListener() { public void onItemClick( AdapterView<?> myAdapter, View myView, int myItemInt, long mylng) { // String videoName = ((TextView) // myView.findViewById(R.id.itemText)).getText().toString(); // Toast.makeText(getApplicationContext(), "item selected... : "+ videoId, // Toast.LENGTH_SHORT).show(); String videoId = ((ImageView) myView.findViewById(R.id.itemImage)).getTag().toString(); // Toast.makeText(getApplicationContext(), "item selected... : "+ videoId, // Toast.LENGTH_SHORT).show(); Intent lVideoIntent = new Intent( null, Uri.parse("ytv://" + videoId), MainActivity.this, OpenYouTubePlayerActivity.class); startActivity(lVideoIntent); } }); }
/** @Method: openPopupwin @Description: popupwindow�����ü���Ӧ */ private void openPopupwin() { LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); ViewGroup menuView = (ViewGroup) mLayoutInflater.inflate(R.layout.gridview_popx, null, true); menuGrid = (GridView) menuView.findViewById(R.id.popgridview); menuGrid.setAdapter(getMenuAdapter(menu_name_array, menu_image_array)); // menuGrid�����ò��� menuGrid.requestFocus(); // ����popupwindow���������Ϣ menuGrid.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { menuPopupWindow.dismiss(); if (arg2 == 0) { // �ϴ� albumPopupwin(); } else if (arg2 == 1) // �༭ { Intent intent = new Intent(LocalImageView.this, PictureEditActivity.class); intent.putExtra("photopath", photoPath); startActivity(intent); } else if (arg2 == 2) // ɾ�� { sureToDelete(); } } }); // ���㵽��gridview�ϣ�������Ҫ����˴��ļ����¼����������ֲ���Ӧ�����¼������ menuGrid.setOnKeyListener( new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_MENU: if (menuPopupWindow != null && menuPopupWindow.isShowing()) { menuPopupWindow.dismiss(); } break; } System.out.println("menuGridfdsfdsfdfd"); return true; } }); // ��ʾpopupwindow menuPopupWindow = new PopupWindow(menuView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true); menuPopupWindow.setBackgroundDrawable(new BitmapDrawable()); menuPopupWindow.setAnimationStyle(R.style.PopupAnimation); menuPopupWindow.showAtLocation( findViewById(R.id.filpperparent), Gravity.BOTTOM | Gravity.BOTTOM, 0, 0); menuPopupWindow.update(); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_club); height = getWindowManager().getDefaultDisplay().getHeight(); getActionBar().setDisplayHomeAsUpEnabled(true); // 实例化GridView mGridView = (GridView) findViewById(R.id.gridview); adapter = new MyAdapter(this); mGridView.setAdapter(adapter); mGridView.setOnItemClickListener(onItemClickListener); }
@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); }
@Inject public FileDetailsCtrl(FileNavigationState navState) { this.navState = navState; this.navState.selectedFileProperty().addListener(new SelectedFileListener()); listFiles = FXCollections.observableList(new ArrayList<>()); fileDetails = FXCollections.observableList(new ArrayList<>()); fileGrid.setCellHeight(80); fileGrid.setCellWidth(100); fileGrid.getItems().addAll(listFiles); fileDetailsList.getItems().addAll(fileDetails); }
public DropdownContainer( Context context, int layout_id, Drawable background, DropdownAdapter adapter, OnItemClickListener listener) { super(context); int m = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); AbsListView content = (AbsListView) LayoutInflater.from(context).inflate(layout_id, null); if (content instanceof ListView) { ((ListView) content).setAdapter((BaseAdapter) adapter); } else if (content instanceof GridView) { ((GridView) content).setAdapter((BaseAdapter) adapter); } content.setOnItemClickListener(listener); content.measure(m, m); if (adapter.getRows() > adapter.getWrapRow()) { init( content, LayoutParams.WRAP_CONTENT, content.getMeasuredHeight() * adapter.getWrapRow(), R.style.drop_down_anim, background); } else { init( content, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, R.style.drop_down_anim, background); } }
@Override protected void onRemove(ListStore<ModelData> ds, ModelData m, int index, boolean isUpdate) { super.onRemove(ds, m, index, isUpdate); if (!isUpdate && liveStore.hasRecord(m)) { liveStore.getRecord(m).reject(false); } }
@Override protected void onMouseDown(GridEvent<ModelData> ge) { super.onMouseDown(ge); El hd = ge.getTarget(".x-grid-group-hd", 10); if (hd != null) { ge.stopEvent(); toggleGroup(hd.dom.getParentElement(), isGroupExpanded(hd.dom.getParentElement())); } }
@Override protected void onAdd(ListStore<ModelData> store, List<ModelData> models, int index) { if (enableGrouping) { Point ss = getScrollState(); refresh(false); restoreScroll(ss); } else { super.onAdd(store, models, index); } }
public void getScreenShot() { // if (!kenKenGrid.mActive) // return; File path = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/Calcudoku/"); if (!path.exists()) path.mkdir(); GridView grid = (GridView) findViewById(R.id.gridview); if (grid.mCells == null) { return; } for (GridCell cell : grid.mCells) cell.mSelected = false; grid.setDrawingCacheEnabled(true); String filename = "/calcudoku_" + grid.mGridSize + "_" + new SimpleDateFormat("yyyyMMdd_HHmm").format(new Date()) + ".png"; // Bitmap bitmap = loadBitmapFromView(grid); Bitmap bitmap = grid.getDrawingCache(); File file = new File(path, filename); try { file.createNewFile(); FileOutputStream ostream = new FileOutputStream(file); bitmap.compress(CompressFormat.PNG, 90, ostream); ostream.flush(); ostream.close(); } catch (Exception e) { e.printStackTrace(); } grid.destroyDrawingCache(); makeToast(getString(R.string.puzzle_screenshot) + path); // Initiate sharing dialog Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/png"); share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); startActivity(Intent.createChooser(share, getString(R.string.menu_share))); }
/** @Method: init @Description: ��ʼ������ */ private void initComponents() { titleReturnButton = (ImageButton) findViewById(R.id.upgridbutton1); titleReturnButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { finish(); } }); titleTextView = (TextView) findViewById(R.id.upgridtextview); titleTextView.setText( "����/" + AlbumName + "(" + PhotoAlbumActivity.AlbumsFloderName.get(AlbumName).size() + ")"); localGridAdapter = new ImageAdapter(this); localGridAdapter.mImageList = new ArrayList<Bitmap>(); gv = (GridView) findViewById(R.id.gridview); // GridView gv.setAdapter(localGridAdapter); // ���ͼ���еĵ����Ӧ����ת��������Ƭ�Ĵ�ͼ���Activity gv.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { try { Intent i = new Intent(InLocalSmallPhotoActivity.this, LocalImageView.class); i.putExtra("currentpic", arg2); i.putExtra("albumArray", albumArray); i.putExtra("photopath", PhotoAlbumActivity.AlbumsFloderPath.get(AlbumName).get(arg2)); i.putExtra("AlbumName", AlbumName); startActivity(i); } catch (Exception e) { Toast.makeText(InLocalSmallPhotoActivity.this, "ͼ�����������~~~~", 0).show(); } } }); // ClickListener }
// OnCreate running public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { MainActivity act = (MainActivity) this.getActivity(); // toDo = act.getTasks(); nThumbsIds = act.getTaskList(); chosen = act.getToAdd(); View rootView = inflater.inflate(R.layout.start_grid, container, false); super.onCreate(savedInstanceState); int iconSize = getResources().getDimensionPixelSize(android.R.dimen.app_icon_size); GridView gridview = (GridView) rootView.findViewById(R.id.taskgrid); gridview.setAdapter(new TaskAdapter(getActivity())); gridview.setOnItemClickListener(this); return rootView; }
@Override public void refresh(boolean headerToo) { super.refresh(headerToo); if (headerToo) { positionLiveScroller(); } if (!preventScrollToTopOnRefresh) { // we scrolled to the top updateRows(0, false); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Intent serviceIntent = new Intent(this, NotifyService.class); this.startService(serviceIntent); orders = (GridView) findViewById(R.id.ordersList); orders.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Order order = (Order) parent.getAdapter().getItem(position); Intent intent = new Intent(ShopActivity.this, OrderDetailActivity.class); intent.putExtra(ORDER_EXTRA, order); startActivity(intent); } }); ordersAdapter = new OrdersAdapter(this, ordersList); orders.setAdapter(ordersAdapter); getOrdersButton = (Button) findViewById(R.id.new_orders_button); getOrdersButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { v.setEnabled(false); loadOrders(true); } }); loadOrders(false); }
public void postNewGame(final int gridSize) { if (kenKenGrid.mActive) storeStreak(false); kenKenGrid.mGridSize = gridSize; showDialog(0); Thread t = new Thread() { public void run() { MainActivity.this.kenKenGrid.reCreate(); MainActivity.this.mHandler.post(newGameReady); } }; t.start(); }
@Override protected void initTemplates() { super.initTemplates(); GridSelectionModel<ModelData> sm = grid.getSelectionModel(); sm.addListener( Events.BeforeSelect, new Listener<SelectionEvent<ModelData>>() { @Override public void handleEvent(SelectionEvent<ModelData> be) { onBeforeRowSelect(be); } }); }
public void storeStats(boolean newGame) { if (newGame) { int gamestat = stats.getInt("playedgames" + kenKenGrid.mGridSize, 0); SharedPreferences.Editor editor = stats.edit(); editor.putInt("playedgames" + kenKenGrid.mGridSize, gamestat + 1); editor.commit(); } else { int gridsize = this.kenKenGrid.mGridSize; // assess hint penalty - gridsize^2/2 seconds for each cell long penalty = kenKenGrid.countCheated() * 500 * gridsize * gridsize; kenKenGrid.mPlayTime += penalty; long solvetime = kenKenGrid.mPlayTime; String solveStr = Utils.convertTimetoStr(solvetime); timeView.setText(solveStr); int hintedstat = stats.getInt("hintedgames" + gridsize, 0); int solvedstat = stats.getInt("solvedgames" + gridsize, 0); long timestat = stats.getLong("solvedtime" + gridsize, 0); long totaltimestat = stats.getLong("totaltime" + gridsize, 0); SharedPreferences.Editor editor = stats.edit(); if (penalty != 0) { editor.putInt("hintedgames" + gridsize, hintedstat + 1); solveStr += "^"; } else editor.putInt("solvedgames" + gridsize, solvedstat + 1); editor.putLong("totaltime" + gridsize, totaltimestat + solvetime); if (timestat == 0 || timestat > solvetime) { editor.putLong("solvedtime" + gridsize, solvetime); makeToast(getString(R.string.puzzle_record_time) + " " + solveStr); } editor.commit(); } }
@Override protected void renderUI() { super.renderUI(); scroller.setStyleAttribute("overflowY", "hidden"); liveScroller = grid.el() .insertFirst( "<div class=\"x-livegrid-scroller\"><div style=\"width: " + XDOM.getScrollBarWidth() + "px;\"> </div></div>"); positionLiveScroller(); liveScroller.addEventsSunk(Event.ONSCROLL); mainBody.addEventsSunk(Event.ONMOUSEWHEEL); }
@Override protected void resize() { final int oldCount = getVisibleRowCount(); super.resize(); if (mainBody != null) { resizeLiveScroller(); scroller.setWidth(grid.getWidth() - getScrollAdjust(), true); DeferredCommand.addCommand( new Command() { public void execute() { if (oldCount != getVisibleRowCount()) { updateRows(LiveGridView.this.viewIndex, true); } } }); } }
@Override protected void onRemove(ListStore<ModelData> ds, ModelData m, int index, boolean isUpdate) { super.onRemove(ds, m, index, isUpdate); String groupField = getGroupField(); if (enableGrouping) { String id = getGroupId( grid.getId(), groupField, getGroup(m.get(groupField), m, index, cm.findColumnIndex(groupField), ds)); Element g = XDOM.getElementById(id); if (g != null && !g.getChildNodes().getItem(1).hasChildNodes()) { fly(g).removeFromParent(); removeGroupId(id); } } // apply empty text }
@SuppressWarnings("rawtypes") @Override public void handleComponentEvent(GridEvent ge) { super.handleComponentEvent(ge); int type = ge.getEventTypeInt(); Element target = ge.getTarget(); if (!ignoreScroll && (type == Event.ONSCROLL && liveScroller.dom.isOrHasChild(target)) || (type == Event.ONMOUSEWHEEL && mainBody.dom.isOrHasChild(target))) { ge.stopEvent(); if (type == Event.ONMOUSEWHEEL) { int v = ge.getEvent().getMouseWheelVelocityY() * getCalculatedRowHeight(); liveScroller.setScrollTop(liveScroller.getScrollTop() + v); } else { updateRows( (int) Math.ceil((double) liveScroller.getScrollTop() / getCalculatedRowHeight()), false); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); /* First Tab Content */ Bundle bundle = getIntent().getExtras(); date1 = bundle.getString("date"); /*String[]s=date1.split("-"); day1=s[0]; mnth=s[1]; yr=s[2];*/ System.out.println("date bun" + date1); final Calendar c = Calendar.getInstance(); /*mYear =Integer.parseInt(yr); mMonth = getMonthAsNO(mnth); mDay = Integer.parseInt(day1); date=(+ (mDay) + "-" +(mMonth+1)+ "-" +mYear);*/ data = new DataBaseHelper(this); data.open(); setContentView(R.layout.gridtask); tv = (TextView) findViewById(R.id.txt); tv.setVisibility(View.GONE); showtask(); if (results.size() == 0) { tv.setVisibility(View.VISIBLE); tv.setText("No Tasks!!"); } grid_main = (GridView) findViewById(R.id.GridView01); grid_main.setAdapter(new ImageAdapter(this)); es = (EditText) findViewById(R.id.esearch); Window window = getWindow(); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); data.close(); }
@Override protected void updateColumnHidden(int index, boolean hidden) { super.updateColumnHidden(index, hidden); resizeLiveScroller(); updateRows(viewIndex, true); }
@Override protected void updateColumnWidth(int col, int width) { super.updateColumnWidth(col, width); resizeLiveScroller(); updateRows(viewIndex, true); }
@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); } } } } } }
private void updateMenu() { if (menu != null) { if (gridView.getAdapter() instanceof SearchAdapter) return; menu.clear(); getMenuInflater().inflate(R.menu.roster, menu); menu.findItem(R.id.add).setEnabled(service.isAuthenticated()); menu.findItem(R.id.notes).setEnabled(service.isAuthenticated()); menu.findItem(R.id.disco).setEnabled(service.isAuthenticated()); menu.findItem(R.id.offline) .setTitle( prefs.getBoolean("hideOffline", false) ? R.string.ShowOfflineContacts : R.string.HideOfflineContacts); MenuItem sound = menu.findItem(R.id.notify); sound.setShowAsActionFlags( prefs.getBoolean("showSound", false) ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER); if (prefs.getBoolean("soundDisabled", false)) { sound.setTitle(R.string.EnableSound); sound.setIcon(R.drawable.ic_menu_sound_off); } else { sound.setTitle(R.string.DisableSound); sound.setIcon(R.drawable.ic_menu_sound_on); } MenuItem.OnActionExpandListener listener = new MenuItem.OnActionExpandListener() { @Override public boolean onMenuItemActionCollapse(MenuItem item) { gridView.setAdapter(null); searchString = null; updateList(); updateMenu(); return true; } @Override public boolean onMenuItemActionExpand(MenuItem item) { gridView.setAdapter(searchAdapter); searchString = ""; updateList(); return true; } }; SearchView searchView = new SearchView(this); searchView.setQueryHint(getString(android.R.string.search_go)); searchView.setSubmitButtonEnabled(false); searchView.setOnQueryTextListener( new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { searchString = newText; updateList(); return true; } @Override public boolean onQueryTextSubmit(String query) { return true; } }); MenuItem item = menu.findItem(R.id.search); item.setActionView(searchView); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); item.setOnActionExpandListener(listener); super.onCreateOptionsMenu(menu); } }
/** Functionality of chapter dialog box to show the list of chapters for the selected book. */ void chapterDialogDisplayedFunc(final Dialog dialog) { // initialize the widgets of this view final AutoCompleteTextView searchBoxChapters = (AutoCompleteTextView) dialog.findViewById(R.id.chapter_list_search_box); final GridView chapterList = (GridView) dialog.findViewById(R.id.chapter_list); TextView bookName = (TextView) dialog.findViewById(R.id.chapter_list_bookname_txt); int numberOfChapters; // find the selected book if (selectedBookNameForHeading.equalsIgnoreCase("Genesis")) { numberOfChapters = 50; bookName.setText("Genesis"); selectedBookName = "genesis"; } else if (selectedBookNameForHeading.equalsIgnoreCase("John")) { numberOfChapters = 21; bookName.setText("John"); selectedBookName = "john"; } else if (selectedBookNameForHeading.equalsIgnoreCase("John1")) { numberOfChapters = 5; bookName.setText("John1"); selectedBookName = "1john"; } else if (selectedBookNameForHeading.equalsIgnoreCase("John2")) { numberOfChapters = 1; bookName.setText("John2"); selectedBookName = "2john"; } else { numberOfChapters = 1; bookName.setText("John3"); selectedBookName = "3john"; } // store the chapters counting into the array final String[] numberOfChaptersList = new String[numberOfChapters]; for (int count = 0; count < numberOfChapters; count++) { int chapterNumber = count + 1; numberOfChaptersList[count] = "" + chapterNumber; Log.i("", "chapter list = " + numberOfChaptersList[count]); } // set the adapter class to show the list of Books chapterList.setAdapter(new ChapterListAdapter(numberOfChaptersList, dialog)); // set the text that enters to search searchBoxChapters.setThreshold(1); // set the list of the books to show by search ArrayAdapter<String> adapter = new ArrayAdapter<String>( this, android.R.layout.simple_dropdown_item_1line, numberOfChaptersList); // search functionality to get book name of the list // that will works with dynamically text entered by user searchBoxChapters.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub searchChapterNameArr.clear(); int searchTextlength = searchBoxChapters.getText().length(); Log.i("", "chapter list size = " + numberOfChaptersList.length); if (searchTextlength > 0) { for (int j = 0; j < numberOfChaptersList.length; j++) { Log.i("", "i = " + j); if (searchTextlength <= numberOfChaptersList[j].length()) { if (searchBoxChapters .getText() .toString() .equalsIgnoreCase( (String) numberOfChaptersList[j].subSequence(0, searchTextlength))) { searchChapterNameArr.add(numberOfChaptersList[j]); Log.e("", " searched chapter= " + searchChapterNameArr); } } } } // if search text is entered then // show the search items list if (searchChapterNameArr.size() > 0) { String[] searchBookNameStringArr = searchChapterNameArr.toArray(new String[0]); Log.i("", "searched chapter string array" + searchBookNameStringArr.length); chapterList.setAdapter(new ChapterListAdapter(searchBookNameStringArr, dialog)); } else // show the whole list of books { chapterList.setAdapter(new ChapterListAdapter(numberOfChaptersList, dialog)); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); }
/** Functionality of verses dialog box to show the list of verses for the selected chapter. */ void verseDialogDisplayedFunc(final Dialog dialog) { // initialize the widgets of this view final AutoCompleteTextView searchBox = (AutoCompleteTextView) dialog.findViewById(R.id.verse_list_search_box); final GridView verseList = (GridView) dialog.findViewById(R.id.verse_list); TextView bookNameText = (TextView) dialog.findViewById(R.id.verse_list_bookname_txt); TextView chapterNameText = (TextView) dialog.findViewById(R.id.verse_list_chaptername_heading_txt); // set the heading text with chapter name and book name bookNameText.setText(selectedBookNameForHeading); chapterNameText.setText(selectedChapterName); // convert array list into string array of the verse list final String[] verseListArr = EBibleConstants.verseList.toArray(new String[0]); // set the adapter class to show the list of verses verseList.setAdapter(new ChapterListAdapter(verseListArr, dialog)); // set the text that enters to search searchBox.setThreshold(1); // set the list of the verse to show by search ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, verseListArr); // search functionality to get verse name of the list // that will works with dynamically text entered by user searchBox.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub searchVerseNameArr.clear(); int searchTextlength = searchBox.getText().length(); if (searchTextlength > 0) { for (int i = 0; i < verseListArr.length; i++) { if (searchTextlength <= verseListArr[i].length()) { if (searchBox .getText() .toString() .equalsIgnoreCase( (String) verseListArr[i].subSequence(0, searchTextlength))) { searchVerseNameArr.add(verseListArr[i]); Log.e("", " searched friend data " + searchVerseNameArr); } } } } // if search text is entered then // show the search items list if (searchVerseNameArr.size() > 0) { String[] searchVerseNameStringArr = searchVerseNameArr.toArray(new String[0]); Log.i("", "searched verse string array" + searchVerseNameStringArr.length); verseList.setAdapter(new ChapterListAdapter(searchVerseNameStringArr, dialog)); } else // show the whole list of verse { verseList.setAdapter(new ChapterListAdapter(verseListArr, dialog)); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); }