use of android.support.v7.widget.AppCompatSpinner in project Carbon by ZieIony.
the class ToolbarWidgetWrapper method ensureSpinner.
private void ensureSpinner() {
if (mSpinner == null) {
mSpinner = new AppCompatSpinner(getContext(), null, R.attr.actionDropDownStyle);
Toolbar.LayoutParams lp = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL);
mSpinner.setLayoutParams(lp);
}
}
use of android.support.v7.widget.AppCompatSpinner in project Rashr by DsLNeXuS.
the class RecoverySystemFragment method onCreateView.
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
mActivity = (RashrActivity) getActivity();
final ScrollView root = (ScrollView) inflater.inflate(R.layout.fragment_recovery_system, container, false);
mContext = root.getContext();
final AppCompatTextView tvTitle = (AppCompatTextView) root.findViewById(R.id.tvSysName);
tvTitle.setText(mTitle.toUpperCase());
final AppCompatTextView tvDesc = (AppCompatTextView) root.findViewById(R.id.tvRecSysDesc);
tvDesc.setText(mDesc);
final AppCompatSpinner spVersions = (AppCompatSpinner) root.findViewById(R.id.spVersions);
ArrayList<String> formatedVersions = new ArrayList<>();
for (String versionLinks : mVersions) {
formatedVersions.add(formatName(versionLinks, mTitle));
}
final ArrayAdapter<String> adapter = new ArrayAdapter<>(root.getContext(), android.R.layout.simple_list_item_1, formatedVersions);
spVersions.setAdapter(adapter);
spVersions.setSelection(0);
final AppCompatTextView tvDev = (AppCompatTextView) root.findViewById(R.id.tvDevName);
tvDev.setText(mDev);
final AppCompatImageView imLogo = (AppCompatImageView) root.findViewById(R.id.ivRecLogo);
if (mLogo == 0) {
root.removeView(imLogo);
} else {
imLogo.setImageResource(mLogo);
}
final AppCompatButton bFlash = (AppCompatButton) root.findViewById(R.id.bFlashRecovery);
bFlash.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
flashSupportedRecovery(mTitle, mVersions.get(spVersions.getSelectedItemPosition()));
}
});
final LinearLayout ScreenshotLayout = (LinearLayout) root.findViewById(R.id.ScreenshotLayout);
if (mScreenshotURL == null) {
((ViewGroup) ScreenshotLayout.getParent()).removeView(ScreenshotLayout);
} else {
try {
Downloader jsonDownloader = new Downloader(new URL(mScreenshotURL + "/getScreenshots.php"), new File(mContext.getExternalCacheDir(), "screenhots.json"));
jsonDownloader.setOverrideFile(true);
jsonDownloader.setOnDownloadListener(new Downloader.OnDownloadListener() {
@Override
public void onSuccess(File file) {
try {
JSONArray arr = new JSONArray(Common.fileContent(file));
for (int i = 0; i < arr.length(); i++) {
final String name = arr.get(i).toString();
if (name.equals(".") || name.equals("..") || name.equals("getScreenshots.php"))
continue;
Downloader imageDownloader = new Downloader(new URL(mScreenshotURL + "/" + name), new File(file.getParentFile(), name));
//Do not redownload predownloaded images
imageDownloader.setOverrideFile(false);
imageDownloader.setOnDownloadListener(new Downloader.OnDownloadListener() {
@Override
public void onSuccess(File file) {
AppCompatImageView iv = (AppCompatImageView) inflater.inflate(R.layout.recovery_screenshot, null);
try {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;
Bitmap screenshot = BitmapFactory.decodeFile(file.toString());
iv.setImageBitmap(screenshot);
ScreenshotLayout.addView(iv);
} catch (OutOfMemoryError e) {
App.ERRORS.add("Screenshot " + file.toString() + " could not be decoded " + e.toString());
}
}
@Override
public void onFail(Exception e) {
}
});
imageDownloader.download();
}
} catch (JSONException e) {
e.printStackTrace();
} catch (IOException e) {
onFail(e);
}
}
@Override
public void onFail(Exception e) {
e.printStackTrace();
}
});
jsonDownloader.download();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
return root;
}
use of android.support.v7.widget.AppCompatSpinner in project Reader by TheKeeperOfPie.
the class FragmentProfile method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_profile, container, false);
layoutCoordinator = (CoordinatorLayout) view.findViewById(R.id.layout_coordinator);
layoutAppBar = (AppBarLayout) view.findViewById(R.id.layout_app_bar);
listener = new ControllerProfile.Listener() {
@Override
public void setSortAndTime(Sort sort, Time time) {
menu.findItem(sort.getMenuId()).setChecked(true);
menu.findItem(time.getMenuId()).setChecked(true);
itemSortTime.setTitle(getString(R.string.time_description, menu.findItem(controllerProfile.getTime().getMenuId()).toString()));
}
@Override
public void setPage(Page page) {
spinnerPage.setSelection(adapterProfilePage.getPages().indexOf(page));
if (page.getPage().equals(ControllerProfile.PAGE_HIDDEN)) {
callback.setDrawable(getResources().getDrawable(R.drawable.ic_visibility_white_24dp));
} else {
callback.setDrawable(getResources().getDrawable(R.drawable.ic_visibility_off_white_24dp));
}
}
@Override
public void setIsUser(boolean isUser) {
// TODO: Fix set page for Profile view
adapterProfilePage.setIsUser(isUser);
}
@Override
public void loadLink(Comment comment) {
Log.d(TAG, "Link ID: " + comment.getLinkId());
Intent intent = new Intent(activity, ActivityMain.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra(ActivityMain.REDDIT_PAGE, Reddit.BASE_URL + "/r/" + comment.getSubreddit() + "/comments/" + comment.getLinkId().replace("t3_", ""));
startActivity(intent);
}
@Override
public RecyclerView.Adapter getAdapter() {
return adapterProfile;
}
@Override
public void setToolbarTitle(CharSequence title) {
toolbar.setTitle(title);
}
@Override
public void setRefreshing(boolean refreshing) {
swipeRefreshProfile.setRefreshing(refreshing);
}
@Override
public void post(Runnable runnable) {
recyclerProfile.post(runnable);
}
};
int styleColorBackground = AppSettings.THEME_DARK.equals(mListener.getThemeBackground()) ? R.style.MenuDark : R.style.MenuLight;
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(new ThemeWrapper(activity, UtilsColor.getThemeForColor(getResources(), themer.getColorPrimary(), mListener)), styleColorBackground);
toolbar = (Toolbar) activity.getLayoutInflater().cloneInContext(contextThemeWrapper).inflate(R.layout.toolbar, layoutAppBar, false);
layoutAppBar.addView(toolbar);
((AppBarLayout.LayoutParams) toolbar.getLayoutParams()).setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
if (getFragmentManager().getBackStackEntryCount() <= 1) {
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.openDrawer();
}
});
} else {
toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.onNavigationBackClick();
}
});
}
toolbar.getNavigationIcon().mutate().setColorFilter(themer.getColorFilterPrimary());
toolbar.setTitleTextColor(themer.getColorFilterPrimary().getColor());
setUpOptionsMenu();
adapterProfilePage = new AdapterProfilePage(activity);
spinnerPage = new AppCompatSpinner(contextThemeWrapper);
toolbar.addView(spinnerPage);
((Toolbar.LayoutParams) spinnerPage.getLayoutParams()).setMarginEnd((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()));
spinnerPage.setAdapter(adapterProfilePage);
spinnerPage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
controllerProfile.setPage(adapterProfilePage.getItem(position)).subscribe(getReloadObserver());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
swipeRefreshProfile = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_profile);
swipeRefreshProfile.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
controllerProfile.reload().subscribe(getReloadObserver());
}
});
linearLayoutManager = new LinearLayoutManager(activity);
recyclerProfile = (RecyclerView) view.findViewById(R.id.recycler_profile);
recyclerProfile.setHasFixedSize(true);
recyclerProfile.setItemAnimator(null);
recyclerProfile.setLayoutManager(linearLayoutManager);
recyclerProfile.addItemDecoration(new ItemDecorationDivider(activity, ItemDecorationDivider.VERTICAL_LIST));
AdapterListener adapterListener = new AdapterListener() {
@Override
public void scrollAndCenter(int position, int height) {
UtilsAnimation.scrollToPositionWithCentering(position, recyclerProfile, false);
}
@Override
public void hideToolbar() {
AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
}
@Override
public void clearDecoration() {
AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
}
@Override
public void requestMore() {
controllerProfile.loadMoreLinks().observeOn(AndroidSchedulers.mainThread()).subscribe(new ObserverError<Listing>() {
@Override
public void onError(Throwable e) {
Toast.makeText(getContext(), getString(R.string.error_loading_links), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
recyclerProfile.requestDisallowInterceptTouchEvent(disallow);
swipeRefreshProfile.requestDisallowInterceptTouchEvent(disallow);
itemTouchHelper.select(null, CustomItemTouchHelper.ACTION_STATE_IDLE);
}
@Override
public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
itemTouchHelper.setDisallow(disallow);
}
};
AdapterLink.ViewHolderLink.Listener listenerLink = new AdapterLink.ViewHolderLink.Listener() {
@Override
public void onSubmitComment(Link link, String text) {
}
@Override
public void onDownloadImage(Link link) {
}
@Override
public void onDownloadImage(Link link, String title, String fileName, String url) {
}
@Override
public void onLoadUrl(Link link, boolean forceExternal) {
}
@Override
public void onShowFullEditor(Link link) {
}
@Override
public void onVote(Link link, AdapterLink.ViewHolderLink viewHolderLink, Likes vote) {
}
@Override
public void onCopyText(Link link) {
}
@Override
public void onEdit(Link link) {
}
@Override
public void onDelete(Link link) {
}
@Override
public void onReport(Link link) {
}
@Override
public void onSave(Link link) {
}
@Override
public void onShowComments(Link link, AdapterLink.ViewHolderLink viewHolderLink, Source source) {
}
@Override
public void onShowError(String error) {
}
@Override
public void onMarkNsfw(Link link) {
}
};
AdapterCommentList.ViewHolderComment.Listener listenerComments = new AdapterCommentList.ViewHolderComment.Listener() {
@Override
public void onToggleComment(Comment comment) {
}
@Override
public void onShowReplyEditor(Comment comment) {
}
@Override
public void onEditComment(Comment comment, String text) {
}
@Override
public void onSendComment(Comment comment, String text) {
}
@Override
public void onMarkRead(Comment comment) {
}
@Override
public void onLoadNestedComments(Comment comment) {
}
@Override
public void onJumpToParent(Comment comment) {
}
@Override
public void onViewProfile(Comment comment) {
}
@Override
public void onCopyText(Comment comment) {
}
@Override
public void onDeleteComment(Comment comment) {
}
@Override
public void onReport(Comment comment) {
}
@Override
public void onVoteComment(Comment comment, AdapterCommentList.ViewHolderComment viewHolderComment, Likes vote) {
}
@Override
public void onSave(Comment comment) {
}
};
if (adapterProfile == null) {
adapterProfile = new AdapterProfile(getActivity(), controllerProfile, adapterListener, listenerLink, listenerComments, listener);
}
recyclerProfile.setAdapter(adapterProfile);
callback = new CustomItemTouchHelper.SimpleCallback(activity, R.drawable.ic_delete_white_24dp, ItemTouchHelper.START | ItemTouchHelper.END, ItemTouchHelper.START | ItemTouchHelper.END) {
@Override
public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
int position = viewHolder.getAdapterPosition();
if (position == 2 || (position >= 6 && controllerProfile.getViewType(position - 6) == ControllerProfile.VIEW_TYPE_LINK)) {
return super.getSwipeDirs(recyclerView, viewHolder);
}
return 0;
}
@Override
public boolean isLongPressDragEnabled() {
return false;
}
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(final RecyclerView.ViewHolder viewHolder, int direction) {
Log.d(TAG, "onSwiped: " + viewHolder.getAdapterPosition());
final int adapterPosition = viewHolder.getAdapterPosition();
final int position = adapterPosition == 2 ? -1 : adapterPosition - 6;
final Link link = adapterPosition == 2 ? controllerProfile.remove(-1) : controllerProfile.remove(position);
mListener.getEventListenerBase().hide(link);
if (snackbar != null) {
snackbar.dismiss();
}
SpannableString text = new SpannableString(link.isHidden() ? getString(R.string.link_hidden) : getString(R.string.link_shown));
text.setSpan(new ForegroundColorSpan(themer.getColorFilterPrimary().getColor()), 0, text.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
// noinspection ResourceType
snackbar = Snackbar.make(recyclerProfile, text, UtilsAnimation.SNACKBAR_DURATION).setActionTextColor(themer.getColorFilterPrimary().getColor()).setAction(R.string.undo, new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.getEventListenerBase().hide(link);
if (adapterPosition == 2) {
controllerProfile.setTopLink(link);
adapterProfile.notifyItemChanged(2);
} else {
controllerProfile.add(position, link);
}
recyclerProfile.invalidate();
}
});
snackbar.getView().setBackgroundColor(themer.getColorPrimary());
snackbar.show();
}
};
itemTouchHelper = new CustomItemTouchHelper(callback);
itemTouchHelper.attachToRecyclerView(recyclerProfile);
return view;
}
use of android.support.v7.widget.AppCompatSpinner in project WordPress-Android by wordpress-mobile.
the class MediaGridFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
mFiltersText = new String[Filter.values().length];
View view = inflater.inflate(R.layout.media_grid_fragment, container);
mRecycler = (RecyclerView) view.findViewById(R.id.recycler);
mRecycler.setHasFixedSize(true);
int numColumns = MediaGridAdapter.getColumnCount(getActivity());
mGridManager = new GridLayoutManager(getActivity(), numColumns);
mRecycler.setLayoutManager(mGridManager);
mGridAdapter = new MediaGridAdapter(getActivity(), mSite, mImageLoader);
mGridAdapter.setCallback(this);
mGridAdapter.setAllowMultiselect(true);
mRecycler.setAdapter(mGridAdapter);
mEmptyView = (LinearLayout) view.findViewById(R.id.empty_view);
mEmptyViewTitle = (TextView) view.findViewById(R.id.empty_view_title);
mResultView = (TextView) view.findViewById(R.id.media_filter_result_text);
mSpinner = (AppCompatSpinner) view.findViewById(R.id.media_filter_spinner);
mSpinner.setOnItemSelectedListener(mFilterSelectedListener);
// swipe to refresh setup
mSwipeToRefreshHelper = new SwipeToRefreshHelper(getActivity(), (CustomSwipeRefreshLayout) view.findViewById(R.id.ptr_layout), new RefreshListener() {
@Override
public void onRefreshStarted() {
if (!isAdded()) {
return;
}
if (!NetworkUtils.checkConnection(getActivity())) {
updateEmptyView(EmptyViewMessageType.NETWORK_ERROR);
mSwipeToRefreshHelper.setRefreshing(false);
return;
}
fetchMediaList(false);
}
});
restoreState(savedInstanceState);
setupSpinnerAdapter();
return view;
}
use of android.support.v7.widget.AppCompatSpinner in project EssayJoke by qiyei2015.
the class SkinAppCompatViewInflater method createView.
public final View createView(View parent, final String name, @NonNull Context context, @NonNull AttributeSet attrs, boolean inheritContext, boolean readAndroidTheme, boolean readAppTheme) {
final Context originalContext = context;
// by using the parent's context
if (inheritContext && parent != null) {
context = parent.getContext();
}
if (readAndroidTheme || readAppTheme) {
// We then apply the theme on the context, if specified
context = themifyContext(context, attrs, readAndroidTheme, readAppTheme);
}
View view = null;
// We need to 'inject' our tint aware Views in place of the standard framework versions
switch(name) {
case "TextView":
view = new AppCompatTextView(context, attrs);
break;
case "ImageView":
view = new AppCompatImageView(context, attrs);
break;
case "Button":
view = new AppCompatButton(context, attrs);
break;
case "EditText":
view = new AppCompatEditText(context, attrs);
break;
case "Spinner":
view = new AppCompatSpinner(context, attrs);
break;
case "ImageButton":
view = new AppCompatImageButton(context, attrs);
break;
case "CheckBox":
view = new AppCompatCheckBox(context, attrs);
break;
case "RadioButton":
view = new AppCompatRadioButton(context, attrs);
break;
case "CheckedTextView":
view = new AppCompatCheckedTextView(context, attrs);
break;
case "AutoCompleteTextView":
view = new AppCompatAutoCompleteTextView(context, attrs);
break;
case "MultiAutoCompleteTextView":
view = new AppCompatMultiAutoCompleteTextView(context, attrs);
break;
case "RatingBar":
view = new AppCompatRatingBar(context, attrs);
break;
case "SeekBar":
view = new AppCompatSeekBar(context, attrs);
break;
}
if (view == null) {
// If the original context does not equal our themed context, then we need to manually
// inflate it using the name so that android:theme takes effect.
view = createViewFromTag(context, name, attrs);
}
if (view != null) {
// If we have created a view, check it's android:onClick
checkOnClickListener(view, attrs);
}
return view;
}
Aggregations