use of ml.docilealligator.infinityforreddit.activities.BaseActivity in project Infinity-For-Reddit by Docile-Alligator.
the class FABMoreOptionsBottomSheetFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_fab_more_options_bottom_sheet, container, false);
ButterKnife.bind(this, rootView);
if (getArguments() != null && getArguments().getBoolean(EXTRA_ANONYMOUS_MODE, false)) {
submitPostTextView.setVisibility(View.GONE);
hideReadPostsTextView.setVisibility(View.GONE);
} else {
submitPostTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_SUBMIT_POST);
dismiss();
});
hideReadPostsTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_HIDE_READ_POSTS);
dismiss();
});
}
refreshTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_REFRESH);
dismiss();
});
changeSortTypeTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_CHANGE_SORT_TYPE);
dismiss();
});
changePostLayoutTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_CHANGE_POST_LAYOUT);
dismiss();
});
searchTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_SEARCH);
dismiss();
});
goToSubredditTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_GO_TO_SUBREDDIT);
dismiss();
});
goToUserTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_GO_TO_USER);
dismiss();
});
randomTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_RANDOM);
dismiss();
});
filterPostsTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_FILTER_POSTS);
dismiss();
});
Activity baseActivity = getActivity();
if (baseActivity instanceof BaseActivity) {
if (((BaseActivity) baseActivity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((BaseActivity) baseActivity).typeface);
}
}
return rootView;
}
use of ml.docilealligator.infinityforreddit.activities.BaseActivity in project Infinity-For-Reddit by Docile-Alligator.
the class FilteredThingFABMoreOptionsBottomSheetFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_filtered_thing_fab_more_options_bottom_sheet, container, false);
ButterKnife.bind(this, rootView);
filterTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_FILTER);
dismiss();
});
hideReadPostsTextView.setOnClickListener(view -> {
activity.fabOptionSelected(FAB_OPTION_HIDE_READ_POSTS);
dismiss();
});
Activity baseActivity = getActivity();
if (baseActivity instanceof BaseActivity) {
if (((BaseActivity) baseActivity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((BaseActivity) baseActivity).typeface);
}
}
return rootView;
}
use of ml.docilealligator.infinityforreddit.activities.BaseActivity in project Infinity-For-Reddit by Docile-Alligator.
the class UploadedImagesBottomSheetFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_uploaded_images_bottom_sheet, container, false);
uploadButton = rootView.findViewById(R.id.upload_button_uploaded_images_bottom_sheet_fragment);
captureButton = rootView.findViewById(R.id.capture_button_uploaded_images_bottom_sheet_fragment);
uploadButton.setOnClickListener(view -> {
activity.uploadImage();
dismiss();
});
captureButton.setOnClickListener(view -> {
activity.captureImage();
dismiss();
});
uploadedImagesRecyclerView = rootView.findViewById(R.id.recycler_view_uploaded_images_bottom_sheet);
adapter = new UploadedImagesRecyclerViewAdapter(getActivity(), getArguments().getParcelableArrayList(EXTRA_UPLOADED_IMAGES), uploadedImage -> {
activity.insertImageUrl(uploadedImage);
dismiss();
});
uploadedImagesRecyclerView.setAdapter(adapter);
Activity baseActivity = getActivity();
if (baseActivity instanceof BaseActivity) {
if (((BaseActivity) activity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((BaseActivity) activity).typeface);
}
}
return rootView;
}
use of ml.docilealligator.infinityforreddit.activities.BaseActivity in project Infinity-For-Reddit by Docile-Alligator.
the class UrlMenuBottomSheetFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_url_menu_bottom_sheet, container, false);
ButterKnife.bind(this, rootView);
url = getArguments().getString(EXTRA_URL);
Uri uri = Uri.parse(url);
if (uri.getScheme() == null && uri.getHost() == null) {
url = "https://www.reddit.com" + url;
}
linkTextView.setText(url);
openLinkTextView.setOnClickListener(view -> {
Intent intent = new Intent(activity, LinkResolverActivity.class);
intent.setData(Uri.parse(url));
activity.startActivity(intent);
dismiss();
});
copyLinkTextView.setOnClickListener(view -> {
ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null) {
ClipData clip = ClipData.newPlainText("simple text", url);
clipboard.setPrimaryClip(clip);
Toast.makeText(activity, R.string.copy_success, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(activity, R.string.copy_link_failed, Toast.LENGTH_SHORT).show();
}
dismiss();
});
shareLinkTextView.setOnClickListener(view -> {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, url);
try {
Intent shareIntent = Intent.createChooser(intent, null);
startActivity(shareIntent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
Toast.makeText(activity, R.string.no_app, Toast.LENGTH_SHORT).show();
}
dismiss();
});
if (activity instanceof BaseActivity) {
if (((BaseActivity) activity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((BaseActivity) activity).typeface);
}
} else if (activity instanceof ViewRedditGalleryActivity) {
if (((ViewRedditGalleryActivity) activity).typeface != null) {
Utils.setFontToAllTextViews(rootView, ((ViewRedditGalleryActivity) activity).typeface);
}
}
return rootView;
}
use of ml.docilealligator.infinityforreddit.activities.BaseActivity in project Infinity-For-Reddit by Docile-Alligator.
the class AccountManagementSectionRecyclerViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof AccountViewHolder) {
glide.load(accounts.get(position).getProfileImageUrl()).error(glide.load(R.drawable.subreddit_default_icon)).apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0))).into(((AccountViewHolder) holder).profileImageGifImageView);
((AccountViewHolder) holder).usernameTextView.setText(accounts.get(position).getAccountName());
holder.itemView.setOnClickListener(view -> itemClickListener.onAccountClick(accounts.get(position).getAccountName()));
} else if (holder instanceof MenuItemViewHolder) {
int stringId = 0;
int drawableId = 0;
if (isLoggedIn) {
int offset = accounts == null ? 0 : accounts.size();
if (position == offset) {
stringId = R.string.add_account;
drawableId = R.drawable.ic_outline_add_circle_outline_24dp;
} else if (position == offset + 1) {
stringId = R.string.anonymous_account;
drawableId = R.drawable.ic_anonymous_24dp;
} else if (position == offset + 2) {
stringId = R.string.log_out;
drawableId = R.drawable.ic_log_out_24dp;
}
} else {
stringId = R.string.add_account;
drawableId = R.drawable.ic_outline_add_circle_outline_24dp;
}
if (stringId != 0) {
((MenuItemViewHolder) holder).menuTextView.setText(stringId);
((MenuItemViewHolder) holder).imageView.setImageDrawable(ContextCompat.getDrawable(baseActivity, drawableId));
}
int finalStringId = stringId;
holder.itemView.setOnClickListener(view -> itemClickListener.onMenuClick(finalStringId));
}
}
Aggregations