use of android.widget.AdapterView in project SimplifyReader by chentao0707.
the class HomeActivity method initializeViews.
@Override
public void initializeViews(List<BaseLazyFragment> fragments, List<NavigationEntity> navigationList) {
mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close) {
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
setTitle(getString(R.string.app_name));
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (null != mNavListAdapter) {
setTitle(mNavListAdapter.getItem(mCurrentMenuCheckedPos).getName());
}
}
};
mActionBarDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);
if (null != fragments && !fragments.isEmpty()) {
mViewPager.setEnableScroll(false);
mViewPager.setOffscreenPageLimit(fragments.size());
mViewPager.setAdapter(new VPFragmentAdapter(getSupportFragmentManager(), fragments));
}
mNavListAdapter = new ListViewDataAdapter<NavigationEntity>(new ViewHolderCreator<NavigationEntity>() {
@Override
public ViewHolderBase<NavigationEntity> createViewHolder(int position) {
return new ViewHolderBase<NavigationEntity>() {
ImageView itemIcon;
TextView itemName;
@Override
public View createView(LayoutInflater layoutInflater) {
View convertView = layoutInflater.inflate(R.layout.list_item_navigation, null);
itemIcon = ButterKnife.findById(convertView, R.id.list_item_navigation_icon);
itemName = ButterKnife.findById(convertView, R.id.list_item_navigation_name);
return convertView;
}
@Override
public void showData(int i, NavigationEntity navigationEntity) {
itemIcon.setImageResource(navigationEntity.getIconResId());
itemName.setText(navigationEntity.getName());
if (mCurrentMenuCheckedPos == i) {
// checked
itemName.setTextColor(getResources().getColor(mCheckedListItemColorResIds[i]));
} else {
// unchecked
itemName.setTextColor(getResources().getColor(android.R.color.black));
}
}
};
}
});
mNavListView.setAdapter(mNavListAdapter);
mNavListAdapter.getDataList().addAll(navigationList);
mNavListAdapter.notifyDataSetChanged();
setTitle(mNavListAdapter.getItem(mCurrentMenuCheckedPos).getName());
mNavListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mCurrentMenuCheckedPos = position;
mNavListAdapter.notifyDataSetChanged();
mDrawerLayout.closeDrawer(Gravity.LEFT);
mViewPager.setCurrentItem(mCurrentMenuCheckedPos, false);
}
});
}
use of android.widget.AdapterView in project cw-omnibus by commonsguy.
the class RowController method onTouch.
@Override
public boolean onTouch(View v, MotionEvent event) {
if ((event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0 && event.getAction() == MotionEvent.ACTION_DOWN) {
adapter.onChecked(position, true, true);
String[] items = itemView.getContext().getResources().getStringArray(R.array.popup);
ArrayAdapter<String> adapter = new ArrayAdapter<>(itemView.getContext(), android.R.layout.simple_list_item_1, items);
final ListPopupWindow popup = new ListPopupWindow(itemView.getContext());
popup.setAnchorView(itemView);
popup.setHorizontalOffset((int) event.getX());
popup.setVerticalOffset((int) event.getY() - itemView.getHeight());
popup.setAdapter(adapter);
popup.setWidth(measureContentWidth(itemView.getContext(), adapter));
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 0) {
((MainActivity) itemView.getContext()).playVideo(videoUri);
} else {
((MainActivity) itemView.getContext()).showLargeThumbnail(videoUri);
}
popup.dismiss();
}
});
popup.show();
return (true);
}
return (false);
}
use of android.widget.AdapterView in project android by cSploit.
the class PortScanner method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
Boolean isDark = themePrefs.getBoolean("isDark", false);
if (isDark)
setTheme(R.style.DarkTheme);
else
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
mPreferences = System.getSettings();
mTextDoc = (TextView) findViewById(R.id.scanDoc);
mTextParameters = (EditText) findViewById(R.id.scanParameters);
mScanFloatingActionButton = (FloatingActionButton) findViewById(R.id.scanToggleButton);
mScanProgress = (ProgressBar) findViewById(R.id.scanActivity);
mShowCustomParameters = mPreferences.getBoolean(CUSTOM_PARAMETERS, false);
if (mShowCustomParameters)
displayParametersField();
else
hideParametersField();
mScanFloatingActionButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mRunning) {
setStoppedState();
} else {
setStartedState();
}
}
});
ListView mScanList = (ListView) findViewById(R.id.scanListView);
createPortList();
final Target target = System.getCurrentTarget();
final String cmdlineRep = target.getCommandLineRepresentation();
mScanReceiver = new Receiver(target);
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mPortList);
mScanList.setAdapter(mListAdapter);
mScanList.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
int portNumber = target.getOpenPorts().get(position).getNumber();
if (!urlFormats.containsKey(portNumber)) {
portNumber = 0;
}
final String url = String.format(urlFormats.get(portNumber), cmdlineRep, portNumber);
new ConfirmDialog("Open", "Open " + url + " ?", PortScanner.this, new ConfirmDialogListener() {
@Override
public void onConfirm() {
try {
Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
PortScanner.this.startActivity(browser);
} catch (ActivityNotFoundException e) {
System.errorLogging(e);
new ErrorDialog(getString(R.string.error), getString(R.string.no_activities_for_url), PortScanner.this).show();
}
}
@Override
public void onCancel() {
}
}).show();
return false;
}
});
}
use of android.widget.AdapterView in project android by cSploit.
the class Hijacker method onCreate.
public void onCreate(Bundle savedInstanceState) {
SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
Boolean isDark = themePrefs.getBoolean("isDark", false);
if (isDark)
setTheme(R.style.DarkTheme);
else
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
setTitle(System.getCurrentTarget() + " > MITM > " + getString(R.string.session_sniffer));
setContentView(R.layout.plugin_mitm_hijacker);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mHijackToggleButton = (ToggleButton) findViewById(R.id.hijackToggleButton);
mHijackProgress = (ProgressBar) findViewById(R.id.hijackActivity);
ListView mListView = (ListView) findViewById(R.id.listView);
mAdapter = new SessionListAdapter(R.layout.plugin_mitm_hijacker_list_item);
mSpoof = new SpoofSession();
mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final Session session = mAdapter.getByPosition(position);
if (session != null) {
new ConfirmDialog(getString(R.string.hijack_session), mRunning ? getString(R.string.start_hijacking) : getString(R.string.start_hijacking2), Hijacker.this, new ConfirmDialogListener() {
@Override
public void onConfirm() {
if (mRunning)
setStoppedState();
System.setCustomData(session);
startActivity(new Intent(Hijacker.this, HijackerWebView.class));
}
@Override
public void onCancel() {
}
}).show();
}
}
});
mListView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
final Session session = mAdapter.getByPosition(position);
if (session != null) {
new InputDialog(getString(R.string.save_session), getString(R.string.set_session_filename), session.getFileName(), true, false, Hijacker.this, new InputDialogListener() {
@Override
public void onInputEntered(String name) {
if (!name.isEmpty()) {
try {
String filename = session.save(name);
Toast.makeText(Hijacker.this, getString(R.string.session_saved_to) + filename + " .", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
new ErrorDialog(getString(R.string.error), e.toString(), Hijacker.this).show();
}
} else
new ErrorDialog(getString(R.string.error), getString(R.string.invalid_session), Hijacker.this).show();
}
}).show();
}
return true;
}
});
mHijackToggleButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mRunning) {
setStoppedState();
} else {
setStartedState();
}
}
});
mRequestListener = new RequestListener();
}
use of android.widget.AdapterView in project UltimateAndroid by cymcsg.
the class UltimateRecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ultimate_recyclerview_activity);
toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
ultimateRecyclerView = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
ultimateRecyclerView.setHasFixedSize(false);
final List<String> stringList = new ArrayList<>();
stringList.add("111");
stringList.add("aaa");
stringList.add("222");
stringList.add("33");
stringList.add("44");
stringList.add("55");
stringList.add("66");
stringList.add("11771");
simpleRecyclerViewAdapter = new SimpleAdapter(stringList);
linearLayoutManager = new LinearLayoutManager(this);
ultimateRecyclerView.setLayoutManager(linearLayoutManager);
ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(simpleRecyclerViewAdapter);
ultimateRecyclerView.addItemDecoration(headersDecor);
ultimateRecyclerView.enableLoadmore();
simpleRecyclerViewAdapter.setCustomLoadMoreView(LayoutInflater.from(this).inflate(R.layout.custom_bottom_progressbar, null));
ultimateRecyclerView.setParallaxHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false));
ultimateRecyclerView.setOnParallaxScroll(new UltimateRecyclerView.OnParallaxScroll() {
@Override
public void onParallaxScroll(float percentage, float offset, View parallax) {
Drawable c = toolbar.getBackground();
c.setAlpha(Math.round(127 + percentage * 128));
toolbar.setBackgroundDrawable(c);
}
});
ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff"));
ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
simpleRecyclerViewAdapter.insert(moreNum++ + " Refresh things", 0);
ultimateRecyclerView.setRefreshing(false);
// ultimateRecyclerView.scrollBy(0, -50);
linearLayoutManager.scrollToPosition(0);
// ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
// simpleRecyclerViewAdapter.notifyDataSetChanged();
}
}, 1000);
}
});
ultimateRecyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {
@Override
public void loadMore(int itemsCount, final int maxLastVisiblePosition) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
// linearLayoutManager.scrollToPositionWithOffset(maxLastVisiblePosition,-1);
// linearLayoutManager.scrollToPosition(maxLastVisiblePosition);
}
}, 1000);
}
});
// ultimateRecyclerView.setDefaultSwipeToRefreshColorScheme(getResources().getColor(android.R.color.holo_blue_bright),
// getResources().getColor(android.R.color.holo_green_light),
// getResources().getColor(android.R.color.holo_orange_light),
// getResources().getColor(android.R.color.holo_red_light));
ultimateRecyclerView.setScrollViewCallbacks(new ObservableScrollViewCallbacks() {
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
}
@Override
public void onDownMotionEvent() {
}
@Override
public void onUpOrCancelMotionEvent(ObservableScrollState observableScrollState) {
if (observableScrollState == ObservableScrollState.DOWN) {
ultimateRecyclerView.showToolbar(toolbar, ultimateRecyclerView, getScreenHeight());
ultimateRecyclerView.showFloatingActionMenu();
} else if (observableScrollState == ObservableScrollState.UP) {
ultimateRecyclerView.hideToolbar(toolbar, ultimateRecyclerView, getScreenHeight());
ultimateRecyclerView.hideFloatingActionMenu();
} else if (observableScrollState == ObservableScrollState.STOP) {
}
}
});
ultimateRecyclerView.showFloatingButtonView();
ultimateRecyclerView.addOnItemTouchListener(new SwipeableRecyclerViewTouchListener(ultimateRecyclerView.mRecyclerView, new SwipeableRecyclerViewTouchListener.SwipeListener() {
@Override
public boolean canSwipe(int position) {
if (position > 0)
return true;
else
return false;
}
@Override
public void onDismissedBySwipeLeft(RecyclerView recyclerView, int[] reverseSortedPositions) {
for (int position : reverseSortedPositions) {
simpleRecyclerViewAdapter.remove(position);
}
simpleRecyclerViewAdapter.notifyDataSetChanged();
}
@Override
public void onDismissedBySwipeRight(RecyclerView recyclerView, int[] reverseSortedPositions) {
for (int position : reverseSortedPositions) {
simpleRecyclerViewAdapter.remove(position);
}
simpleRecyclerViewAdapter.notifyDataSetChanged();
}
}));
ItemTouchListenerAdapter itemTouchListenerAdapter = new ItemTouchListenerAdapter(ultimateRecyclerView.mRecyclerView, new ItemTouchListenerAdapter.RecyclerViewOnItemClickListener() {
@Override
public void onItemClick(RecyclerView parent, View clickedView, int position) {
}
@Override
public void onItemLongClick(RecyclerView parent, View clickedView, int position) {
URLogs.d("onItemLongClick()" + isDrag);
if (isDrag) {
URLogs.d("onItemLongClick()" + isDrag);
dragDropTouchListener.startDrag();
ultimateRecyclerView.enableDefaultSwipeRefresh(false);
}
}
});
ultimateRecyclerView.mRecyclerView.addOnItemTouchListener(itemTouchListenerAdapter);
dragDropTouchListener = new DragDropTouchListener(ultimateRecyclerView.mRecyclerView, this) {
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
@Override
protected void onItemSwitch(RecyclerView recyclerView, int from, int to) {
if (from > 0 && to > 0) {
simpleRecyclerViewAdapter.swapPositions(from, to);
// //simpleRecyclerViewAdapter.clearSelection(from);
// simpleRecyclerViewAdapter.notifyItemChanged(to);
//simpleRecyclerViewAdapter.remove(position);
// simpleRecyclerViewAdapter.notifyDataSetChanged();
URLogs.d("switch----");
// simpleRecyclerViewAdapter.insert(simpleRecyclerViewAdapter.remove(););
}
}
@Override
protected void onItemDrop(RecyclerView recyclerView, int position) {
URLogs.d("drop----");
ultimateRecyclerView.enableDefaultSwipeRefresh(true);
simpleRecyclerViewAdapter.notifyDataSetChanged();
}
};
dragDropTouchListener.setCustomDragHighlight(getResources().getDrawable(R.drawable.custom_drag_frame));
ultimateRecyclerView.mRecyclerView.addOnItemTouchListener(dragDropTouchListener);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
for (Type type : Type.values()) {
spinnerAdapter.add(type.name());
}
spinner.setAdapter(spinnerAdapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
ultimateRecyclerView.setItemAnimator(Type.values()[position].getAnimator());
ultimateRecyclerView.getItemAnimator().setAddDuration(300);
ultimateRecyclerView.getItemAnimator().setRemoveDuration(300);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
simpleRecyclerViewAdapter.insert("newly added item", 1);
}
});
findViewById(R.id.del).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
simpleRecyclerViewAdapter.remove(1);
}
});
// ultimateRecyclerView.addItemDecoration(
// new HorizontalDividerItemDecoration.Builder(this).build());
// ultimateRecyclerView.setCustomSwipeToRefresh();
// final StoreHouseHeader header = new StoreHouseHeader(this);
// // header.setPadding(0, 15, 0, 0);
//
// header.initWithString("Marshal Chen");
// // header.initWithStringArray(R.array.akta);
// ultimateRecyclerView.mPtrFrameLayout.setHeaderView(header);
// ultimateRecyclerView.mPtrFrameLayout.addPtrUIHandler(header);
//
// ultimateRecyclerView.mPtrFrameLayout.setPtrHandler(new PtrHandler() {
// @Override
// public boolean checkCanDoRefresh(PtrFrameLayout ptrFrameLayout, View view, View view2) {
// boolean canbePullDown = PtrDefaultHandler.checkContentCanBePulledDown(ptrFrameLayout, view, view2);
// return canbePullDown;
// }
//
// @Override
// public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) {
// ptrFrameLayout.postDelayed(new Runnable() {
// @Override
// public void run() {
// simpleRecyclerViewAdapter.insert("Refresh things", 0);
// // ultimateRecyclerView.scrollBy(0, -50);
// linearLayoutManager.scrollToPosition(0);
// ultimateRecyclerView.mPtrFrameLayout.refreshComplete();
// }
// }, 1800);
// }
// });
}
Aggregations