List of usage examples for android.widget AdapterView getAdapter
public abstract T getAdapter();
From source file:org.brandroid.openmanager.fragments.ContentFragment.java
public void onItemClick(AdapterView<?> list, View view, int pos, long id) { OpenPath file = (OpenPath) list.getItemAtPosition(pos); Logger.LogInfo("File clicked: " + file.getPath()); if (file.isArchive() && file instanceof OpenFile && Preferences.Pref_Zip_Internal) file = new OpenZip((OpenFile) file); if (getClipboard().isMultiselect()) { if (getClipboard().contains(file)) { getClipboard().remove(file); if (getClipboard().size() == 0) getClipboard().stopMultiselect(); ((BaseAdapter) list.getAdapter()).notifyDataSetChanged(); } else {/*from www .j a v a 2 s. co m*/ //Animation anim = Animation. /* Drawable dIcon = ((ImageView)view.findViewById(R.id.content_icon)).getDrawable(); if(dIcon instanceof BitmapDrawable) { IconAnimationPanel panel = new IconAnimationPanel(getExplorer()) .setIcon(((BitmapDrawable)dIcon).getBitmap()) .setStart(new Point(view.getLeft(), view.getRight())) .setEnd(new Point(getActivity().getWindow().getWindowManager().getDefaultDisplay().getWidth() / 2, getActivity().getWindowManager().getDefaultDisplay().getHeight())) .setDuration(500); ((ViewGroup)getView()).addView(panel); } */ addToMultiSelect(file); ((TextView) view.findViewById(R.id.content_text)).setTextAppearance(list.getContext(), R.style.Highlight); } return; } if (file.isDirectory() && !mActionModeSelected) { /* if (mThumbnail != null) { mThumbnail.setCancelThumbnails(true); mThumbnail = null; } */ //setContentPath(file, true); getExplorer().onChangeLocation(file); } else if (!file.isDirectory() && !mActionModeSelected) { if (file.requiresThread() && FileManager.hasOpenCache(file.getAbsolutePath())) { //getExplorer().showToast("Still need to handle this."); if (file.isTextFile()) getExplorer().editFile(file); else { showCopyFromNetworkDialog(file); //getEventHandler().copyFile(file, mPath, mContext); } return; } else if (file.isTextFile() && Preferences.Pref_Text_Internal) getExplorer().editFile(file); else if (!IntentManager.startIntent(file, getExplorer(), Preferences.Pref_Intents_Internal)) getExplorer().editFile(file); } }
From source file:com.ymt.demo1.plates.knowledge.KnowledgeItemListViewFragment.java
protected void initView(View view) { /*// ww w . ja v a2 s .co m *listView */ listView = (PullToRefreshListView) view.findViewById(R.id.pull_to_refresh_list_view); theListView = listView.getRefreshableView(); switch (mKnowledgeType) { case KNOWLEDGE_BZGF: case KNOWLEDGE_KYWX: case KNOWLEDGE_SJK: //?? adapter = new KnowledgeItemAdapter(getActivity()); listView.setAdapter(adapter); adapter.setKnowledgeItemList(knowledgeItemList); new AsyncTask<Void, Void, List<KnowledgeItem>>() { @Override protected List<KnowledgeItem> doInBackground(Void... params) { return DataSupport.where("type = ?", String.valueOf(mKnowledgeType)).find(KnowledgeItem.class); } @Override protected void onPostExecute(List<KnowledgeItem> itemList) { super.onPostExecute(itemList); knowledgeItemList.addAll(itemList); adapter.notifyDataSetChanged(); } }.execute(); break; default: break; } /* *?? */ theListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, final View view, final int position, long id) { /* *??? */ String[] actionList = new String[] { "", "?" }; PopActionUtil popActionUtil = PopActionUtil.getInstance(getActivity()); actionListener = new PopActionListener() { @Override public void onAction(String action) { switch (action) { case "": Toast.makeText(getActivity(), "", Toast.LENGTH_SHORT).show(); break; case "?": Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT).show(); break; default: break; } } @Override public void onDismiss() { } }; popActionUtil.setActionListener(actionListener); popActionUtil.setActions(actionList); final PopupWindow itemPopMenu = popActionUtil.getSimpleTxtPopActionMenu(); itemPopMenu.showAsDropDown(view, view.getWidth() - 20, -view.getHeight()); itemPopMenu.update(); return true; } }); /* listView ? */ theListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Intent intent = new Intent(getActivity(), KnowledgeItemDetailActivity.class); switch (mKnowledgeType) { case KNOWLEDGE_BZGF: case KNOWLEDGE_KYWX: case KNOWLEDGE_SJK: intent.putExtra("knowId", ((KnowledgeItem) parent.getAdapter().getItem(position)).getKnowId()); break; default: break; } startActivity(intent); } }); listView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() { @Override public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) { startIndex = 1; switch (mKnowledgeType) { case KNOWLEDGE_BZGF: case KNOWLEDGE_KYWX: case KNOWLEDGE_SJK: if (AppContext.internetAvialable()) { DataSupport.deleteAll(KnowledgeItem.class, "type = ?", String.valueOf(mKnowledgeType)); knowledgeItemList.clear(); adapter.setKnowledgeItemList(knowledgeItemList); mQueue.add(getListData(pageSize, startIndex, "")); } else { listView.onRefreshComplete(); } break; default: break; } } @Override public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) { startIndex++; switch (mKnowledgeType) { case KNOWLEDGE_BZGF: case KNOWLEDGE_KYWX: case KNOWLEDGE_SJK: if (AppContext.internetAvialable()) { mQueue.add(getListData(pageSize, startIndex, "")); } break; default: break; } } }); }
From source file:com.metaphyze.hackernewsfrontpage.HackerNewsFrontPageActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hacker_news_front_page); bookFileName = getFilesDir() + File.separator + "bookmarked_posts.js"; drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.drawer); location = (TextView) findViewById(R.id.location); webView = (WebView) findViewById(R.id.content_frame); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setAppCacheEnabled(true); loadingView = findViewById(R.id.loading); ProgressBar progressBar = ((ProgressBar) findViewById(R.id.progress_bar)); progressBar.setIndeterminate(true);// w w w . ja v a2s .com drawerList.setAdapter(new HackerNewsAdapter(HackerNewsFrontPageActivity.this, R.layout.post_item, new ArrayList<HackerNewsPost>(), true)); getActionBar().setTitle("Hacker News Front Page (Loading Live Stream...)"); drawerList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { HackerNewsPost post = (HackerNewsPost) parent.getItemAtPosition(position); webView.loadUrl(post.getUrl()); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); loadingView.setVisibility(View.VISIBLE); location.setText("LOADING......" + url); } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); loadingView.setVisibility(View.INVISIBLE); location.setText(url); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { loadingView.setVisibility(View.INVISIBLE); location.setText("ERROR LOADING PAGE"); view.loadUrl("file:///android_asset/failed_to_load_page.html"); } }); drawerLayout.closeDrawer(drawerList); } }); drawerList.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final HackerNewsPost clonedPost = ((HackerNewsPost) parent.getItemAtPosition(position)).clone(); clonedPost.setPostedAgo(new Date().toString()); AlertDialog.Builder builder = new AlertDialog.Builder(HackerNewsFrontPageActivity.this); if (((HackerNewsAdapter) parent.getAdapter()).isLive()) { builder.setTitle("Bookmark?"); builder.setMessage("Do you want to bookmark the post\n" + clonedPost.getTitle()); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { HackerNewsFrontPageContents contents = readContentsFromBookmarksFile(); if (contents == null) { showError("ERROR", "Failed to read bookmark file"); dialog.dismiss(); return; } if (!contents.addPost(clonedPost)) { showError("Already Exists", "Not added becasue bookmark already exists"); dialog.dismiss(); return; } if (!saveContentsToBookmarksFile(contents)) { showError("ERROR", "Failed to save bookmark"); dialog.dismiss(); } } catch (Exception ex) { ex.printStackTrace(); showError("ERROR", "Internal error: " + ex); } } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); } else { builder.setTitle("Delete?"); builder.setMessage("Do you want to delete the bookmarked post:\n" + clonedPost.getTitle()); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { HackerNewsFrontPageContents contents = readContentsFromBookmarksFile(); if (contents == null) { showError("ERROR", "Unable to find or generate bookmarks file"); dialog.dismiss(); return; } if (!contents.removePost(clonedPost)) { showError("Not Removed", "Does not exist? How's that possible?"); dialog.dismiss(); return; } if (saveContentsToBookmarksFile(contents)) { if (contents.getItems().size() > 0) { drawerList .setAdapter(new HackerNewsAdapter(HackerNewsFrontPageActivity.this, R.layout.post_item, contents.getItems(), false)); } else { showError("No more bookmarks", "Reverting to live stream"); loadLiveStream(); } } else { showError("ERROR", "Failed to save bookmark deletion"); } dialog.dismiss(); } catch (Exception ex) { ex.printStackTrace(); showError("ERROR", "Internal Error: " + ex); } } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); } builder.setCancelable(true); builder.create().show(); return false; } }); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.drawer_icon, 0, 0); drawerLayout.setDrawerListener(drawerToggle); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); // actionBar.setHomeButtonEnabled(true); requestQueue = Volley.newRequestQueue(this); loadLiveStream(); }
From source file:com.androidquery.AQuery.java
/** * Notify a ListView that the data of it's adapter is changed. * * @return self/*from w w w . j a va 2s . c om*/ */ public AQuery dataChanged() { if (view instanceof AdapterView) { AdapterView<?> av = (AdapterView<?>) view; Adapter a = av.getAdapter(); if (a instanceof BaseAdapter) { BaseAdapter ba = (BaseAdapter) a; ba.notifyDataSetChanged(); } } return self(); }
From source file:com.ifoer.expeditionphone.MainActivity.java
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { BaseDiagAdapter baseDiagAdapter = (BaseDiagAdapter) arg0.getAdapter(); baseDiagAdapter.setSelectItem(arg2); baseDiagAdapter.notifyDataSetChanged(); DataCleanManager.cleanLibs(contexts); this.cc = MySharedPreferences.getStringValue(contexts, MySharedPreferences.CCKey); if (this.cc != null) { if (!this.cc.equals(XmlPullParser.NO_NAMESPACE)) { String type = MySharedPreferences.getStringValue(this, "getSerialNo"); if (type == null || type.equals(Contact.RELATION_FRIEND)) { if (Common.isNetworkAvailable(this)) { new PortNumAsy(REQUEST_CONNECT_DEVICE).execute(new String[0]); } else { Toast.makeText(this, C0136R.string.network_exception, 0).show(); }/* w w w .java2 s . co m*/ } } } if (Environment.getExternalStorageState().equals("mounted")) { HashMap<String, Object> map = (HashMap) arg0.getItemAtPosition(arg2); String softPackageId = map.get("softPackageId").toString(); String softId = map.get("softId").toString(); String icon = map.get("icon").toString(); MySharedPreferences.setString(contexts, MySharedPreferences.savesoftPackageId, softPackageId); String serialNo1 = MySharedPreferences.getStringValue(contexts, MySharedPreferences.serialNoKey); MySharedPreferences.setString(contexts, MySharedPreferences.generateOperatingRecord, Contact.RELATION_ASK); if (serialNo1 != null) { if (!XmlPullParser.NO_NAMESPACE.equals(serialNo1)) { if (country == null || country.length() <= 0) { country = Locale.getDefault().getCountry(); } country = Locale.getDefault().getCountry(); if (!DBDao.getInstance(this).isDownload(softPackageId, serialNo1, AndroidToLan.toLan(country), database)) { this.cc = MySharedPreferences.getStringValue(contexts, MySharedPreferences.CCKey); if (this.cc != null) { if (!this.cc.equals(XmlPullParser.NO_NAMESPACE)) { String serialNo = MySharedPreferences.getStringValue(contexts, MySharedPreferences.serialNoKey); if (serialNo != null) { if (!XmlPullParser.NO_NAMESPACE.equals(serialNo)) { String softName = ((TextView) arg1.findViewById(C0136R.id.car_name)) .getText().toString(); if (Common.isNetworkAvailable(this)) { SoftIdListTask softListTask = new SoftIdListTask(); String[] strArr = new String[MESSAGE_DEVICE_NAME]; strArr[0] = softId; strArr[REQUEST_CONNECT_DEVICE] = softPackageId; strArr[REQUEST_ENABLE_BT] = softName; strArr[REQUEST_CIRCLE_ADD_IMAGE] = icon; softListTask.execute(strArr); return; } Toast.makeText(this, C0136R.string.network_exception, 0).show(); return; } } Toast.makeText(this, C0136R.string.port_input, 0).show(); return; } } SimpleDialog.ToastToLogin(this); return; } else if (serialPort != null) { openConnect(serialNo1, softPackageId); return; } else { return; } } } startActivity(new Intent(this, SerialNumberActivity.class)); overridePendingTransition(0, 0); return; } Toast.makeText(this, getResources().getString(C0136R.string.sdcard), 0).show(); }
From source file:com.androidquery.AbstractAQuery.java
/** * Notify a ListView that the data of it's adapter is changed. * * @return self//w w w . j a v a 2 s. c o m */ public T dataChanged() { if (view instanceof AdapterView) { AdapterView<?> av = (AdapterView<?>) view; Adapter a = av.getAdapter(); if (a instanceof BaseAdapter) { BaseAdapter ba = (BaseAdapter) a; ba.notifyDataSetChanged(); } } return self(); }
From source file:com.android.ex.chips.RecipientEditTextView.java
public RecipientEditTextView(final Context context, final AttributeSet attrs) { super(context, attrs); mAddTextWatcher = new Runnable() { @Override//w w w. j a va 2s . c o m public void run() { if (mTextWatcher == null) { mTextWatcher = new RecipientTextWatcher(); addTextChangedListener(mTextWatcher); } } }; mDelayedShrink = new Runnable() { @Override public void run() { shrink(); } }; mHandlePendingChips = new Runnable() { @Override public void run() { handlePendingChips(); } }; setChipDimensions(context, attrs); if (sSelectedTextColor == -1) sSelectedTextColor = ContextCompat.getColor(context, android.R.color.white); /*mAlternatesPopup=new ListPopupWindow(context); mAddressPopup=new ListPopupWindow(context);*/ mCopyDialog = new Dialog(context); mAlternatesListener = new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapterView, final View view, final int position, final long rowId) { //mAlternatesPopup.setOnItemClickListener(null); replaceChip(mSelectedChip, ((RecipientAlternatesAdapter) adapterView.getAdapter()).getRecipientEntry(position)); final Message delayed = Message.obtain(mHandler, DISMISS); //delayed.obj=mAlternatesPopup; mHandler.sendMessageDelayed(delayed, DISMISS_DELAY); clearComposingText(); } }; setInputType(getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); setOnItemClickListener(null); setCustomSelectionActionModeCallback(this); mHandler = new Handler() { @Override public void handleMessage(final Message msg) { if (msg.what == DISMISS) { //((ListPopupWindow)msg.obj).dismiss(); return; } super.handleMessage(msg); } }; mTextWatcher = new RecipientTextWatcher(); addTextChangedListener(mTextWatcher); mGestureDetector = new GestureDetector(context, this); setOnEditorActionListener(this); }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
@Override public boolean onPageTitleLongClick(int position, View titleView) { try {// www . j av a2 s .c om OpenFragment f = mViewPagerAdapter.getItem(position); if (f instanceof OnFragmentTitleLongClickListener) return ((OnFragmentTitleLongClickListener) f).onTitleLongClick(titleView); if (f instanceof TextEditorFragment) return false; if (!(f instanceof ContentFragment)) return false; OpenPath path = ((ContentFragment) mViewPagerAdapter.getItem(position)).getPath(); if (path.requiresThread()) return false; OpenPath parent = path.getParent(); if (path instanceof OpenCursor) parent = new OpenPathArray( new OpenPath[] { mVideoParent, mPhotoParent, mMusicParent, mDownloadParent }); if (parent == null) parent = new OpenPathArray(new OpenPath[] { path }); ArrayList<OpenPath> arr = new ArrayList<OpenPath>(); for (OpenPath kid : parent.list()) if ((path.equals(kid) || kid.isDirectory()) && !kid.isHidden()) arr.add(kid); Collections.sort(arr, new Comparator<OpenPath>() { public int compare(OpenPath a, OpenPath b) { return a.getName().compareTo(b.getName()); } }); OpenPath[] siblings = arr.toArray(new OpenPath[arr.size()]); ArrayList<OpenPath> siblingArray = new ArrayList<OpenPath>(); siblingArray.addAll(arr); OpenPath foster = new OpenPathArray(siblings); //Logger.LogVerbose("Siblings of " + path.getPath() + ": " + siblings.length); Context mContext = this; View anchor = titleView; //findViewById(R.id.title_bar); int[] offset = new int[2]; titleView.getLocationInWindow(offset); int offsetX = 0; int arrowLeft = 0; if (anchor == null && findViewById(R.id.content_pager_indicator) != null) { offsetX = titleView.getLeft(); arrowLeft += titleView.getWidth() / 2; Logger.LogDebug("Using Pager Indicator as Sibling anchor (" + offsetX + ")"); anchor = findViewById(R.id.content_pager_indicator); //if(anchor != null) // offsetX -= anchor.getLeft(); } final BetterPopupWindow mSiblingPopup = new BetterPopupWindow(mContext, anchor); //mSiblingPopup.USE_INDICATOR = false; OpenPathList mSiblingList = new OpenPathList(foster, mContext); mSiblingList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int pos, long id) { final OpenPath path = (OpenPath) ((BaseAdapter) arg0.getAdapter()).getItem(pos); mSiblingPopup.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss() { changePath(path, true); } }); mSiblingPopup.dismiss(); } }); mSiblingPopup.setContentView(mSiblingList); mSiblingPopup.setAnchorOffset(arrowLeft); mSiblingPopup.showLikePopDownMenu(offsetX, 0); return true; } catch (Exception e) { Logger.LogError("Couldn't show sibling dropdown", e); } return false; }