android.widget.BaseAdapter Java Examples

The following examples show how to use android.widget.BaseAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: T9SearchFragment.java    From PinyinSearchLibrary with Apache License 2.0 6 votes vote down vote up
private void refreshT9SearchGv() {
	if (null == mT9SearchGv) {
		return;
	}

	BaseAdapter baseAdapter = (BaseAdapter) mT9SearchGv.getAdapter();
	Log.i(TAG, "getCount"+baseAdapter.getCount()+"");
	if (null != baseAdapter) {
		baseAdapter.notifyDataSetChanged();
		if (baseAdapter.getCount() > 0) {
			ViewUtil.showView(mT9SearchGv);
			ViewUtil.hideView(mSearchResultPromptTv);
		} else {
			ViewUtil.hideView(mT9SearchGv);
			ViewUtil.showView(mSearchResultPromptTv);
		}
	}
}
 
Example #2
Source File: ZSwipeItem.java    From AutoLoadListView with Apache License 2.0 6 votes vote down vote up
/**
 * if working in {@link android.widget.AdapterView}, we should response
 * {@link android.widget.Adapter} isEnable(int position).
 *
 * @return true when item is enabled, else disabled.
 */
private boolean isEnabledInAdapterView() {
	@SuppressWarnings("rawtypes")
	AdapterView adapterView = getAdapterView();
	boolean enable = true;
	if (adapterView != null) {
		Adapter adapter = adapterView.getAdapter();
		if (adapter != null) {
			int p = adapterView.getPositionForView(ZSwipeItem.this);
			if (adapter instanceof BaseAdapter) {
				enable = ((BaseAdapter) adapter).isEnabled(p);
			} else if (adapter instanceof ListAdapter) {
				enable = ((ListAdapter) adapter).isEnabled(p);
			}
		}
	}
	return enable;
}
 
Example #3
Source File: ScrollingPauseLoadManager.java    From sketch with Apache License 2.0 6 votes vote down vote up
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (AppConfig.INSTANCE.getBoolean(view.getContext(), AppConfig.Key.SCROLLING_PAUSE_LOAD) && view.getAdapter() != null) {
        ListAdapter listAdapter = view.getAdapter();
        if (listAdapter instanceof WrapperListAdapter) {
            listAdapter = ((WrapperListAdapter) listAdapter).getWrappedAdapter();
        }
        if (listAdapter instanceof BaseAdapter) {
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
                if (!sketch.getConfiguration().isPauseLoadEnabled()) {
                    sketch.getConfiguration().setPauseLoadEnabled(true);
                }
            } else if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
                if (sketch.getConfiguration().isPauseLoadEnabled()) {
                    sketch.getConfiguration().setPauseLoadEnabled(false);
                    ((BaseAdapter) listAdapter).notifyDataSetChanged();
                }
            }
        }
    }

    if (absListScrollListener != null) {
        absListScrollListener.onScrollStateChanged(view, scrollState);
    }
}
 
Example #4
Source File: BaseAdapterConverter.java    From UniversalAdapter with Apache License 2.0 6 votes vote down vote up
/**
 * Binds this adapter to the given {@link AdapterView}, setting it as its adapter. This should be done by
 * construction or immediately after, before this adapter is used. This mechanism sets this class as the view's
 * adapter and permits certain functionality such as click events. Without it, this class will still function as
 * a normal {@link BaseAdapter}, but additional functionality may not work. Ignore this step at your own risk.
 *
 * @param adapterView The {@link AdapterView} to bind to.
 */
public void bindToAdapterView(AdapterView<? super BaseAdapter> adapterView) {
    if (adapterView != null) {
        adapterView.setAdapter(this);

        // Spinners don't like on item click listeners.
        // We will still delegate calls to it since you're clicking on an item to select it...
        if (!(adapterView instanceof Spinner)) {
            adapterView.setOnItemClickListener(internalItemClickListener);
        } else {
            adapterView.setOnItemSelectedListener(internalItemSelectedListener);
        }

        adapterView.setOnItemLongClickListener(internalLongClickListener);
    }
}
 
Example #5
Source File: EditMicroBlogEmotionItemClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	BaseAdapter adapter = (BaseAdapter)parent.getAdapter();
	String emotion = (String)adapter.getItem(position);
       if (StringUtil.isEmpty(emotion)) {
       	return;
       }
       
	EditText etText = (EditText)((Activity)context).findViewById(R.id.etText);
	int currentPos = 0;
	if (etText != null) {
		currentPos = etText.getSelectionStart();
		etText.getText().insert(currentPos, emotion);
	}

}
 
Example #6
Source File: AdmobBannerAdapterWrapper.java    From admobadapter with Apache License 2.0 6 votes vote down vote up
/**
 * Sets underlying adapter with your data collection.
 * If you want to inject your implementation of {@link AdmobAdapterCalculator} please set it before this call
 */
public Builder setAdapter(BaseAdapter adapter) {
    mAdapter = adapter;
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            notifyDataSetChanged();
        }

        @Override
        public void onInvalidated() {
            notifyDataSetInvalidated();
        }
    });
    return this;
}
 
Example #7
Source File: AdmobExpressAdapterWrapper.java    From admobadapter with Apache License 2.0 6 votes vote down vote up
/**
 * Sets underlying adapter with your data collection.
 * If you want to inject your implementation of {@link AdmobAdapterCalculator} please set it before this call
 */
public Builder setAdapter(BaseAdapter adapter) {
    mAdapter = adapter;
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            notifyDataSetChanged();
        }

        @Override
        public void onInvalidated() {
            notifyDataSetInvalidated();
        }
    });
    return this;
}
 
Example #8
Source File: CustomListView.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 主要更新一下刷新时间啦!
 * @param adapter
 * @date 2013-11-20 下午5:35:51
 * @change JohnWatson
 * @version 1.0
 */
public void setAdapter(BaseAdapter adapter) {
	// 最近更新: Time
	mLastUpdatedTextView.setText(
			getResources().getString(R.string.p2refresh_refresh_lasttime) + 
			new SimpleDateFormat(DATE_FORMAT_STR, Locale.CHINA).format(new Date()));
	super.setAdapter(adapter);
}
 
Example #9
Source File: VoicePlayClickListener.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 * @param message
 * @param v
 * @param iv_read_status
 * @param context
 * @param activity
 * @param user
 * @param chatType
 */
public VoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity activity,
		String username) {
	this.message = message;
	voiceBody = (VoiceMessageBody) message.getBody();
	this.iv_read_status = iv_read_status;
	this.adapter = adapter;
	voiceIconView = v;
	this.activity = activity;
	this.chatType = message.getChatType();
}
 
Example #10
Source File: XiHaHouFragment.java    From Android-EmotionInputDetector with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.emotion_gird, container, false);
    BaseAdapter adapter = new XiHaHouEmojiAdapter(mContext);
    GridView grid = (GridView) view.findViewById(R.id.grid);
    grid.setAdapter(adapter);
    grid.setOnItemClickListener(GlobalOnItemClickManager.getInstance().getOnItemClickListener(1));
    return view;
}
 
Example #11
Source File: FanfouServiceManager.java    From fanfouapp-opensource with Apache License 2.0 5 votes vote down vote up
public static void doFavorite(final Activity activity, final Status s,
        final BaseAdapter adapter) {
    final ActionResultHandler li = new ActionResultHandler() {
        @Override
        public void onActionSuccess(final int type, final String message) {
            if (type == Constants.TYPE_FAVORITES_CREATE) {
                s.favorited = true;
            } else {
                s.favorited = false;
            }
            adapter.notifyDataSetChanged();
        }
    };
    FanfouServiceManager.doFavorite(activity, s, li);
}
 
Example #12
Source File: NavBean.java    From StickyNavigationBar with GNU General Public License v3.0 5 votes vote down vote up
public NavBean(@TYPE int type, BaseAdapter adapter) {
    this.type = type;
    this.adapter = adapter;
    switch (type) {
        case TYPE_REPOST:
            title = "转发";
            break;
        case TYPE_COMMENT:
            title = "评论";
            break;
        case TYPE_LIKE:
            title = "赞";
            break;
    }
}
 
Example #13
Source File: AnimateAdditionAdapter.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new {@link com.marshalchen.common.uimodule.listviewanimations.itemmanipulation.AnimateAdditionAdapter} with given {@link android.widget.BaseAdapter}.
 *
 * @param baseAdapter should implement {@link com.marshalchen.common.uimodule.listviewanimations.itemmanipulation.AnimateAdditionAdapter.Insertable},
 *                    or be a {@link com.marshalchen.common.uimodule.listviewanimations.BaseAdapterDecorator} whose BaseAdapter implements the interface.
 */
public AnimateAdditionAdapter(final BaseAdapter baseAdapter) {
    super(baseAdapter);

    BaseAdapter rootAdapter = getRootAdapter();
    if (!(rootAdapter instanceof Insertable)) {
        throw new IllegalArgumentException("BaseAdapter should implement Insertable!");
    }

    mInsertable = (Insertable<T>) rootAdapter;
    mInsertQueue = new InsertQueue<T>(mInsertable);
}
 
Example #14
Source File: ComprehensionTemplate.java    From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public BaseAdapter loadProjectMetaEditor(Context context, Document doc) {

        String title = doc.getElementsByTagName(ComprehensionMetaModel.TITLE_TAG).item(0).getTextContent();
        String passage = doc.getElementsByTagName(ComprehensionMetaModel.PASSAGE_TAG).item(0).getTextContent();
        long timer = Long.parseLong(doc.getElementsByTagName(ComprehensionMetaModel.TIMER_TAG).item(0).getTextContent());
        metaData.add(new ComprehensionMetaModel(title, passage, timer));
        metaAdapter = new ComprehensionMetaAdapter(context, metaData);
        setEmptyView((Activity) context);

        return metaAdapter;

    }
 
Example #15
Source File: PanelListAdapter.java    From SmartChart with Apache License 2.0 5 votes vote down vote up
/**
 * 返回纵向表头的适配器
 *
 * @return adapter of column ListView
 */
private BaseAdapter getColumnAdapter() {
    if (columnAdapter == null) {
        columnAdapter = new ColumnAdapter(context, android.R.layout.simple_list_item_1, getColumnDataList());
    }
    return columnAdapter;
}
 
Example #16
Source File: WriteilySingleton.java    From writeily-pro with MIT License 5 votes vote down vote up
public void copySelectedNotes(SparseBooleanArray checkedIndices, BaseAdapter notesAdapter, String destination) {
    for (int i = 0; i < checkedIndices.size(); i++) {
        if (checkedIndices.valueAt(i)) {
            File file = (File) notesAdapter.getItem(checkedIndices.keyAt(i));
            copyFile(file, destination);
        }
    }
}
 
Example #17
Source File: EaseChatRow.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
public EaseChatRow(Context context, EMMessage message, int position, BaseAdapter adapter) {
    super(context);
    this.context = context;
    this.activity = (Activity) context;
    this.message = message;
    this.position = position;
    this.adapter = adapter;
    inflater = LayoutInflater.from(context);

    initView();
}
 
Example #18
Source File: VoicePlayClickListener.java    From school_shop with MIT License 5 votes vote down vote up
/**
 * 
 * @param message
 * @param v
 * @param iv_read_status
 * @param context
 * @param activity
 * @param user
 * @param chatType
 */
public VoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity activity,
		String username) {
	this.message = message;
	voiceBody = (VoiceMessageBody) message.getBody();
	this.iv_read_status = iv_read_status;
	this.adapter = adapter;
	voiceIconView = v;
	this.activity = activity;
	this.chatType = message.getChatType();
}
 
Example #19
Source File: TagCloudLayout.java    From tagcloud with Apache License 2.0 5 votes vote down vote up
public void setAdapter(BaseAdapter adapter){
    if (mAdapter == null){
        mAdapter = adapter;
        if (mObserver == null){
            mObserver = new DataChangeObserver();
            mAdapter.registerDataSetObserver(mObserver);
        }
        drawLayout();
    }
}
 
Example #20
Source File: SwitchAccessPreferenceActivity.java    From talkback with Apache License 2.0 5 votes vote down vote up
private void adjustAutoscanPrefs() {
  PreferenceScreen autoScanScreen =
      (PreferenceScreen) findPreference(R.string.pref_category_auto_scan_key);
  PreferenceCategory movementAndSelectionCategory = getMovementAndSelectionCategory();
  Preference autoScanKeyPreference =
      movementAndSelectionCategory.findPreference(
          getString(R.string.pref_key_mapped_to_auto_scan_key));
  Preference reverseAutoScanKeyPreference =
      movementAndSelectionCategory.findPreference(
          getString(R.string.pref_key_mapped_to_reverse_auto_scan_key));

  boolean isAutoScanEnabled = SwitchAccessPreferenceUtils.isAutoScanEnabled(getActivity());
  if (isAutoScanEnabled) {
    autoScanScreen.setSummary(R.string.preference_on);
    autoScanKeyPreference.setTitle(R.string.title_pref_category_auto_scan);
    reverseAutoScanKeyPreference.setTitle(R.string.action_name_reverse_auto_scan);

    if (FeatureFlags.groupSelectionWithAutoScan()) {
      return;
    }

    if (SwitchAccessPreferenceUtils.isGroupSelectionEnabled(getActivity())) {
      /* If somehow both autoscan and group selection are enabled, turn off group selection. */
      SwitchAccessPreferenceUtils.setScanningMethod(
          getActivity(), R.string.row_col_scanning_key);
    }
  } else {
    autoScanScreen.setSummary(R.string.preference_off);
    autoScanKeyPreference.setTitle(R.string.title_pref_auto_scan_disabled);
    reverseAutoScanKeyPreference.setTitle(R.string.title_pref_reverse_auto_scan_disabled);
    if (SwitchAccessPreferenceUtils.isGroupSelectionEnabled(getActivity())
        && !FeatureFlags.groupSelectionWithAutoScan()) {
      findPreference(R.string.pref_category_auto_scan_key).setEnabled(false);
    }
  }
  ((BaseAdapter) autoScanScreen.getRootAdapter()).notifyDataSetChanged();
  ScanningMethodPreference scanMethodsPref = getScanningMethodPreference();
  scanMethodsPref.enableScanningMethod(R.string.group_selection_key, !isAutoScanEnabled);
}
 
Example #21
Source File: ColorChooserDialog.java    From APlayer with GNU General Public License v3.0 5 votes vote down vote up
private void invalidate() {
  if (mGrid.getAdapter() == null) {
    mGrid.setAdapter(new ColorGridAdapter());
    mGrid.setSelector(
        ResourcesCompat.getDrawable(getResources(), R.drawable.md_transparent, null));
  } else {
    ((BaseAdapter) mGrid.getAdapter()).notifyDataSetChanged();
  }
  if (getDialog() != null) {
    getDialog().setTitle(getTitle());
  }
}
 
Example #22
Source File: MainApp.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoadAppInfoList(BaseAdapter adapter) {
    Log.d("MainApp", "加载数据咯");
    app_listView.setAdapter(adapter);

    adapter.notifyDataSetChanged();
}
 
Example #23
Source File: ListContextMenuListener.java    From GifAssistant with Apache License 2.0 5 votes vote down vote up
public ListContextMenuListener(Context context, BaseAdapter adapter, int fileType) {
	mContext = context;
	mAdapter = adapter;
	mFileType = fileType;
	mCallBack = null;
	mResideMenu = null;
}
 
Example #24
Source File: EaseChatRow.java    From monolog-android with MIT License 5 votes vote down vote up
public EaseChatRow(Context context, EMMessage message, int position, BaseAdapter adapter) {
    super(context);
    this.context = context;
    this.activity = (Activity) context;
    this.message = message;
    this.position = position;
    this.adapter = adapter;
    inflater = LayoutInflater.from(context);

    initView();
}
 
Example #25
Source File: RefreshListView.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public void setAdapter(BaseAdapter adapter) {
    super.setAdapter(adapter);
    mAdapter = (IRefreshAndEditableAdapter) adapter;
    setEditable(isEditable);
    if (autoRefresh) {
        refresh();
    }
}
 
Example #26
Source File: MultiChoiceAdapterHelperBase.java    From example with Apache License 2.0 4 votes vote down vote up
public MultiChoiceAdapterHelperBase(BaseAdapter owner) {
    this.owner = owner;
}
 
Example #27
Source File: MatchTemplate.java    From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public BaseAdapter currentTemplateEditorAdapter() {
    return adapter;
}
 
Example #28
Source File: InnerListView.java    From MagicHeaderViewPager with Apache License 2.0 4 votes vote down vote up
@Override
public void notifyDataSetChanged() {
    if (mAdapter instanceof BaseAdapter) {
        ((BaseAdapter) mAdapter).notifyDataSetChanged();
    }
}
 
Example #29
Source File: SwingLeftInAnimationAdapter.java    From ALLGO with Apache License 2.0 4 votes vote down vote up
public SwingLeftInAnimationAdapter(BaseAdapter baseAdapter, long animationDelayMillis, long animationDurationMillis) {
	super(baseAdapter);
	mAnimationDelayMillis = animationDelayMillis;
	mAnimationDurationMillis = animationDurationMillis;
}
 
Example #30
Source File: SwingRightInAnimationAdapter.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public SwingRightInAnimationAdapter(final BaseAdapter baseAdapter, final long animationDelayMillis, final long animationDurationMillis) {
    super(baseAdapter);
    mAnimationDelayMillis = animationDelayMillis;
    mAnimationDurationMillis = animationDurationMillis;
}