use of me.ccrama.redditslide.Activities.MainActivity in project Slide by ccrama.
the class SubmissionsView method updateOfflineError.
@Override
public void updateOfflineError() {
if (getActivity() instanceof MainActivity) {
if (((MainActivity) getActivity()).runAfterLoad != null) {
new Handler().post(((MainActivity) getActivity()).runAfterLoad);
}
}
mSwipeRefreshLayout.setRefreshing(false);
adapter.setError(true);
}
use of me.ccrama.redditslide.Activities.MainActivity in project Slide by ccrama.
the class SubmissionsView method updateError.
@Override
public void updateError() {
if (getActivity() instanceof MainActivity) {
if (((MainActivity) getActivity()).runAfterLoad != null) {
new Handler().post(((MainActivity) getActivity()).runAfterLoad);
}
}
mSwipeRefreshLayout.setRefreshing(false);
adapter.setError(true);
}
use of me.ccrama.redditslide.Activities.MainActivity in project Slide by ccrama.
the class PopulateNewsViewHolder method addClickFunctions.
private static void addClickFunctions(final View base, final ContentType.Type type, final Activity contextActivity, final Submission submission, final NewsViewHolder holder, final boolean full) {
base.setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
if (NetworkUtil.isConnected(contextActivity) || (!NetworkUtil.isConnected(contextActivity) && ContentType.fullImage(type))) {
if (SettingValues.storeHistory && !full) {
if (!submission.isNsfw() || SettingValues.storeNSFWHistory) {
HasSeen.addSeen(submission.getFullName());
if (contextActivity instanceof MainActivity || contextActivity instanceof MultiredditOverview || contextActivity instanceof SubredditView || contextActivity instanceof Search || contextActivity instanceof Profile) {
holder.title.setAlpha(0.54f);
}
}
}
if (!(contextActivity instanceof PeekViewActivity) || !((PeekViewActivity) contextActivity).isPeeking() || (base instanceof HeaderImageLinkView && ((HeaderImageLinkView) base).popped)) {
if (!PostMatch.openExternal(submission.getUrl()) || type == ContentType.Type.VIDEO) {
switch(type) {
case VID_ME:
case STREAMABLE:
if (SettingValues.video) {
Intent myIntent = new Intent(contextActivity, MediaView.class);
myIntent.putExtra(MediaView.SUBREDDIT, submission.getSubredditName());
myIntent.putExtra(MediaView.EXTRA_URL, submission.getUrl());
contextActivity.startActivity(myIntent);
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case IMGUR:
openImage(type, contextActivity, submission, holder.leadImage, holder.getAdapterPosition());
break;
case EMBEDDED:
if (SettingValues.video) {
String data = Html.fromHtml(submission.getDataNode().get("media_embed").get("content").asText()).toString();
{
Intent i = new Intent(contextActivity, FullscreenVideo.class);
i.putExtra(FullscreenVideo.EXTRA_HTML, data);
contextActivity.startActivity(i);
}
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case REDDIT:
openRedditContent(submission.getUrl(), contextActivity);
break;
case LINK:
LinkUtil.openUrl(submission.getUrl(), Palette.getColor(submission.getSubredditName()), contextActivity, holder.getAdapterPosition(), submission);
break;
case SELF:
if (holder != null) {
OnSingleClickListener.override = true;
holder.itemView.performClick();
}
break;
case ALBUM:
if (SettingValues.album) {
Intent i;
if (SettingValues.albumSwipe) {
i = new Intent(contextActivity, AlbumPager.class);
i.putExtra(AlbumPager.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
} else {
i = new Intent(contextActivity, Album.class);
i.putExtra(Album.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
}
addAdaptorPosition(i, submission, holder.getAdapterPosition());
contextActivity.startActivity(i);
contextActivity.overridePendingTransition(R.anim.slideright, R.anim.fade_out);
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case TUMBLR:
if (SettingValues.album) {
Intent i;
if (SettingValues.albumSwipe) {
i = new Intent(contextActivity, TumblrPager.class);
i.putExtra(TumblrPager.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
} else {
i = new Intent(contextActivity, Tumblr.class);
i.putExtra(Tumblr.SUBREDDIT, submission.getSubredditName());
i.putExtra(Album.EXTRA_URL, submission.getUrl());
}
addAdaptorPosition(i, submission, holder.getAdapterPosition());
contextActivity.startActivity(i);
contextActivity.overridePendingTransition(R.anim.slideright, R.anim.fade_out);
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
case DEVIANTART:
case XKCD:
case IMAGE:
openImage(type, contextActivity, submission, holder.leadImage, holder.getAdapterPosition());
break;
case GIF:
openGif(contextActivity, submission, holder.getAdapterPosition());
break;
case NONE:
if (holder != null) {
holder.itemView.performClick();
}
break;
case VIDEO:
if (Reddit.videoPlugin) {
try {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setClassName("ccrama.me.slideyoutubeplugin", "ccrama.me.slideyoutubeplugin.YouTubeView");
sharingIntent.putExtra("url", submission.getUrl());
contextActivity.startActivity(sharingIntent);
} catch (Exception e) {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
break;
}
} else {
LinkUtil.openExternally(submission.getUrl(), contextActivity);
}
}
} else {
if (!(contextActivity instanceof PeekViewActivity) || !((PeekViewActivity) contextActivity).isPeeking()) {
Snackbar s = Snackbar.make(holder.itemView, R.string.go_online_view_content, Snackbar.LENGTH_SHORT);
View view = s.getView();
TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
tv.setTextColor(Color.WHITE);
s.show();
}
}
}
});
}
use of me.ccrama.redditslide.Activities.MainActivity in project Slide by ccrama.
the class SettingsSubAdapter method showSubThemeEditor.
/**
* Displays the subreddit color chooser
* It is possible to color multiple subreddits at the same time
*
* @param subreddits Subreddits as an array
* @param context Context for getting colors
* @param dialoglayout The subchooser layout (R.layout.colorsub)
*/
public static void showSubThemeEditor(final ArrayList<String> subreddits, final Activity context, View dialoglayout) {
if (subreddits.isEmpty()) {
return;
}
final boolean multipleSubs = (subreddits.size() > 1);
boolean isAlternateLayout;
int currentColor;
int currentAccentColor;
final ColorPreferences colorPrefs = new ColorPreferences(context);
final String subreddit = multipleSubs ? null : subreddits.get(0);
final SwitchCompat bigPics = (SwitchCompat) dialoglayout.findViewById(R.id.bigpics);
final SwitchCompat selftext = (SwitchCompat) dialoglayout.findViewById(R.id.selftext);
// Selected multiple subreddits
if (multipleSubs) {
// Check if all selected subs have the same settings
int previousSubColor = 0;
int previousSubAccent = 0;
bigPics.setChecked(SettingValues.bigPicEnabled);
selftext.setChecked(SettingValues.cardText);
boolean sameMainColor = true;
boolean sameAccentColor = true;
for (String sub : subreddits) {
int currentSubColor = Palette.getColor(sub);
int currentSubAccent = colorPrefs.getColor("");
if (previousSubColor != 0 && previousSubAccent != 0) {
if (currentSubColor != previousSubColor) {
sameMainColor = false;
} else if (currentSubAccent != previousSubAccent) {
sameAccentColor = false;
}
}
if (!sameMainColor && !sameAccentColor) {
break;
}
previousSubAccent = currentSubAccent;
previousSubColor = currentSubColor;
}
currentColor = Palette.getDefaultColor();
currentAccentColor = colorPrefs.getColor("");
isAlternateLayout = false;
// If all selected subs have the same settings, display them
if (sameMainColor) {
currentColor = previousSubColor;
}
if (sameAccentColor) {
currentAccentColor = previousSubAccent;
}
} else {
// Is only one selected sub
currentColor = Palette.getColor(subreddit);
isAlternateLayout = SettingValues.prefs.contains(Reddit.PREF_LAYOUT + subreddit);
currentAccentColor = colorPrefs.getColor(subreddit);
bigPics.setChecked(SettingValues.isPicsEnabled(subreddit));
selftext.setChecked(SettingValues.isSelftextEnabled(subreddit));
}
AlertDialogWrapper.Builder builder = new AlertDialogWrapper.Builder(context);
final TextView title = (TextView) dialoglayout.findViewById(R.id.title);
title.setBackgroundColor(currentColor);
if (multipleSubs) {
String titleString = "";
for (String sub : subreddits) {
// if the subreddit is the frontpage, don't put "/r/" in front of it
if (sub.equals("frontpage")) {
titleString += sub + ", ";
} else {
if (sub.contains("/m/")) {
titleString += sub + ", ";
} else {
titleString += "/r/" + sub + ", ";
}
}
}
titleString = titleString.substring(0, titleString.length() - 2);
title.setMaxLines(3);
title.setText(titleString);
} else {
if (subreddit.contains("/m/")) {
title.setText(subreddit);
} else {
// if the subreddit is the frontpage, don't put "/r/" in front of it
title.setText(((subreddit.equals("frontpage")) ? "frontpage" : "/r/" + subreddit));
}
}
{
// Primary color pickers
final LineColorPicker colorPickerPrimary = (LineColorPicker) dialoglayout.findViewById(R.id.picker);
// shades of primary colors
final LineColorPicker colorPickerPrimaryShades = (LineColorPicker) dialoglayout.findViewById(R.id.picker2);
colorPickerPrimary.setColors(ColorPreferences.getBaseColors(context));
// Iterate through all colors and check if it matches the current color of the sub, then select it
for (int i : colorPickerPrimary.getColors()) {
for (int i2 : ColorPreferences.getColors(context, i)) {
if (i2 == currentColor) {
colorPickerPrimary.setSelectedColor(i);
colorPickerPrimaryShades.setColors(ColorPreferences.getColors(context, i));
colorPickerPrimaryShades.setSelectedColor(i2);
break;
}
}
}
// Base color changed
colorPickerPrimary.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int c) {
// Show variations of the base color
colorPickerPrimaryShades.setColors(ColorPreferences.getColors(context, c));
colorPickerPrimaryShades.setSelectedColor(c);
}
});
colorPickerPrimaryShades.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int i) {
if (context instanceof MainActivity) {
((MainActivity) context).updateColor(colorPickerPrimaryShades.getColor(), subreddit);
}
title.setBackgroundColor(colorPickerPrimaryShades.getColor());
}
});
{
/* TODO TextView dialogButton = (TextView) dialoglayout.findViewById(R.id.reset);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Palette.removeColor(subreddit);
hea.setBackgroundColor(Palette.getDefaultColor());
findViewById(R.id.header).setBackgroundColor(Palette.getDefaultColor());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.setStatusBarColor(Palette.getDarkerColor(Palette.getDefaultColor()));
context.setTaskDescription(new ActivityManager.TaskDescription(subreddit, ((BitmapDrawable) getResources().getDrawable(R.drawable.ic_launcher)).getBitmap(), colorPicker2.getColor()));
}
title.setBackgroundColor(Palette.getDefaultColor());
int cx = center.getWidth() / 2;
int cy = center.getHeight() / 2;
int initialRadius = body.getWidth();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Animator anim =
ViewAnimationUtils.createCircularReveal(body, cx, cy, initialRadius, 0);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
body.setVisibility(View.GONE);
}
});
anim.start();
} else {
body.setVisibility(View.GONE);
}
}
});*/
}
// Accent color picker
final LineColorPicker colorPickerAcc = (LineColorPicker) dialoglayout.findViewById(R.id.picker3);
{
// Get all possible accent colors (for day theme)
int[] arrs = new int[ColorPreferences.getNumColorsFromThemeType(0)];
int i = 0;
for (ColorPreferences.Theme type : ColorPreferences.Theme.values()) {
if (type.getThemeType() == 0) {
arrs[i] = ContextCompat.getColor(context, type.getColor());
i++;
}
colorPickerAcc.setColors(arrs);
colorPickerAcc.setSelectedColor(currentAccentColor);
}
}
builder.setView(dialoglayout);
builder.setCancelable(false);
builder.setNegativeButton(R.string.btn_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (context instanceof MainActivity) {
((MainActivity) context).updateColor(Palette.getColor(subreddit), subreddit);
}
}
}).setNeutralButton(R.string.btn_reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String subTitles = "";
if (multipleSubs) {
for (String sub : subreddits) {
// if the subreddit is the frontpage, don't put "/r/" in front of it
if (sub.equals("frontpage")) {
subTitles += sub + ", ";
} else {
subTitles += "/r/" + sub + ", ";
}
}
subTitles = subTitles.substring(0, subTitles.length() - 2);
} else {
// if the subreddit is the frontpage, don't put "/r/" in front of it
subTitles = (subreddit.equals("frontpage") ? "frontpage" : "/r/" + subreddit);
}
String titleStart = context.getString(R.string.settings_delete_sub_settings, subTitles);
titleStart = titleStart.replace("/r//r/", "/r/");
if (titleStart.contains("/r/frontpage")) {
titleStart = titleStart.replace("/r/frontpage", "frontpage");
}
new AlertDialogWrapper.Builder(context).setTitle(titleStart).setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
for (String sub : subreddits) {
Palette.removeColor(sub);
// Remove layout settings
SettingValues.prefs.edit().remove(Reddit.PREF_LAYOUT + sub).apply();
// Remove accent / font color settings
new ColorPreferences(context).removeFontStyle(sub);
SettingValues.resetPicsEnabled(sub);
SettingValues.resetSelftextEnabled(sub);
}
if (context instanceof MainActivity) {
((MainActivity) context).reloadSubs();
} else if (context instanceof SettingsSubreddit) {
((SettingsSubreddit) context).reloadSubList();
} else if (context instanceof SubredditView) {
((SubredditView) context).restartTheme();
}
}
}).setNegativeButton(R.string.btn_no, null).show();
}
}).setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final int newPrimaryColor = colorPickerPrimaryShades.getColor();
final int newAccentColor = colorPickerAcc.getColor();
for (String sub : subreddits) {
// Set main color
if (bigPics.isChecked() != SettingValues.isPicsEnabled(sub)) {
SettingValues.setPicsEnabled(sub, bigPics.isChecked());
}
if (selftext.isChecked() != SettingValues.isSelftextEnabled(sub)) {
SettingValues.setSelftextEnabled(sub, selftext.isChecked());
}
// Only do set colors if either subreddit theme color has changed
if (Palette.getColor(sub) != newPrimaryColor || Palette.getDarkerColor(sub) != newAccentColor) {
if (newPrimaryColor != Palette.getDefaultColor()) {
Palette.setColor(sub, newPrimaryColor);
} else {
Palette.removeColor(sub);
}
// Set accent color
ColorPreferences.Theme t = null;
// Do not save accent color if it matches the default accent color
if (newAccentColor != ContextCompat.getColor(context, colorPrefs.getFontStyle().getColor()) || newAccentColor != ContextCompat.getColor(context, colorPrefs.getFontStyleSubreddit(sub).getColor())) {
LogUtil.v("Accent colors not equal");
int back = new ColorPreferences(context).getFontStyle().getThemeType();
for (ColorPreferences.Theme type : ColorPreferences.Theme.values()) {
if (ContextCompat.getColor(context, type.getColor()) == newAccentColor && back == type.getThemeType()) {
t = type;
LogUtil.v("Setting accent color to " + t.getTitle());
break;
}
}
} else {
new ColorPreferences(context).removeFontStyle(sub);
}
if (t != null) {
colorPrefs.setFontStyle(t, sub);
}
}
// Set layout
SettingValues.prefs.edit().putBoolean(Reddit.PREF_LAYOUT + sub, true).apply();
}
// Only refresh stuff if the user changed something
if (Palette.getColor(subreddit) != newPrimaryColor || Palette.getDarkerColor(subreddit) != newAccentColor) {
if (context instanceof MainActivity) {
((MainActivity) context).reloadSubs();
} else if (context instanceof SettingsSubreddit) {
((SettingsSubreddit) context).reloadSubList();
} else if (context instanceof SubredditView) {
((SubredditView) context).restartTheme();
}
}
}
}).show();
}
}
use of me.ccrama.redditslide.Activities.MainActivity in project Slide by ccrama.
the class SideArrayAdapter method getView.
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (position < fitems.size()) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.subforsublist, parent, false);
final String sub;
final String base = fitems.get(position);
if (multiToMatch.containsKey(fitems.get(position)) && !fitems.get(position).contains("/m/")) {
sub = multiToMatch.get(fitems.get(position));
} else {
sub = fitems.get(position);
}
final TextView t = ((TextView) convertView.findViewById(R.id.name));
t.setText(sub);
if (height == 0) {
final View finalConvertView = convertView;
convertView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
height = finalConvertView.getHeight();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
finalConvertView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
finalConvertView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
});
}
final String subreddit = (sub.contains("+") || sub.contains("/m/")) ? sub : SantitizeField.sanitizeString(sub.replace(getContext().getString(R.string.search_goto) + " ", ""));
convertView.findViewById(R.id.color).setBackgroundResource(R.drawable.circle);
convertView.findViewById(R.id.color).getBackground().setColorFilter(Palette.getColor(subreddit), PorterDuff.Mode.MULTIPLY);
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (base.startsWith(getContext().getString(R.string.search_goto) + " ") || !((MainActivity) getContext()).usedArray.contains(base)) {
try {
// Hide the toolbar search UI without an animation because we're starting a new activity
if ((SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_TOOLBAR || SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) && ((MainActivity) getContext()).findViewById(R.id.toolbar_search).getVisibility() == View.VISIBLE) {
((MainActivity) getContext()).findViewById(R.id.toolbar_search_suggestions).setVisibility(View.GONE);
((MainActivity) getContext()).findViewById(R.id.toolbar_search).setVisibility(View.GONE);
((MainActivity) getContext()).findViewById(R.id.close_search_toolbar).setVisibility(View.GONE);
// Play the exit animations of the search toolbar UI to avoid the animations failing to animate upon the next time
// the search toolbar UI is called. Set animation to 0 because the UI is already hidden.
((MainActivity) getContext()).exitAnimationsForToolbarSearch(0, ((CardView) ((MainActivity) getContext()).findViewById(R.id.toolbar_search_suggestions)), ((AutoCompleteTextView) ((MainActivity) getContext()).findViewById(R.id.toolbar_search)), ((ImageView) ((MainActivity) getContext()).findViewById(R.id.close_search_toolbar)));
if (SettingValues.single) {
((MainActivity) getContext()).getSupportActionBar().setTitle(((MainActivity) getContext()).selectedSub);
} else {
((MainActivity) getContext()).getSupportActionBar().setTitle(((MainActivity) getContext()).tabViewModeTitle);
}
}
} catch (NullPointerException npe) {
Log.e(getClass().getName(), npe.getMessage());
}
Intent inte = new Intent(getContext(), SubredditView.class);
inte.putExtra(SubredditView.EXTRA_SUBREDDIT, subreddit);
((Activity) getContext()).startActivityForResult(inte, 2001);
} else {
if (((MainActivity) getContext()).commentPager && ((MainActivity) getContext()).adapter instanceof MainActivity.OverviewPagerAdapterComment) {
((MainActivity) getContext()).openingComments = null;
((MainActivity) getContext()).toOpenComments = -1;
((MainActivity.OverviewPagerAdapterComment) ((MainActivity) getContext()).adapter).size = (((MainActivity) getContext()).usedArray.size() + 1);
((MainActivity) getContext()).reloadItemNumber = ((MainActivity) getContext()).usedArray.indexOf(base);
((MainActivity) getContext()).adapter.notifyDataSetChanged();
((MainActivity) getContext()).doPageSelectedComments(((MainActivity) getContext()).usedArray.indexOf(base));
((MainActivity) getContext()).reloadItemNumber = -2;
}
try {
// Hide the toolbar search UI with an animation because we're just changing tabs
if ((SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_TOOLBAR || SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) && ((MainActivity) getContext()).findViewById(R.id.toolbar_search).getVisibility() == View.VISIBLE) {
((MainActivity) getContext()).findViewById(R.id.close_search_toolbar).performClick();
}
} catch (NullPointerException npe) {
Log.e(getClass().getName(), npe.getMessage());
}
((MainActivity) getContext()).pager.setCurrentItem(((MainActivity) getContext()).usedArray.indexOf(base));
((MainActivity) getContext()).drawerLayout.closeDrawers();
if (((MainActivity) getContext()).drawerSearch != null) {
((MainActivity) getContext()).drawerSearch.setText("");
}
}
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
});
convertView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
try {
// Hide the toolbar search UI without an animation because we're starting a new activity
if ((SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_TOOLBAR || SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) && ((MainActivity) getContext()).findViewById(R.id.toolbar_search).getVisibility() == View.VISIBLE) {
((MainActivity) getContext()).findViewById(R.id.toolbar_search_suggestions).setVisibility(View.GONE);
((MainActivity) getContext()).findViewById(R.id.toolbar_search).setVisibility(View.GONE);
((MainActivity) getContext()).findViewById(R.id.close_search_toolbar).setVisibility(View.GONE);
// Play the exit animations of the search toolbar UI to avoid the animations failing to animate upon the next time
// the search toolbar UI is called. Set animation to 0 because the UI is already hidden.
((MainActivity) getContext()).exitAnimationsForToolbarSearch(0, ((CardView) ((MainActivity) getContext()).findViewById(R.id.toolbar_search_suggestions)), ((AutoCompleteTextView) ((MainActivity) getContext()).findViewById(R.id.toolbar_search)), ((ImageView) ((MainActivity) getContext()).findViewById(R.id.close_search_toolbar)));
if (SettingValues.single) {
((MainActivity) getContext()).getSupportActionBar().setTitle(((MainActivity) getContext()).selectedSub);
} else {
((MainActivity) getContext()).getSupportActionBar().setTitle(((MainActivity) getContext()).tabViewModeTitle);
}
}
} catch (NullPointerException npe) {
Log.e(getClass().getName(), npe.getMessage());
}
Intent inte = new Intent(getContext(), SubredditView.class);
inte.putExtra(SubredditView.EXTRA_SUBREDDIT, subreddit);
((Activity) getContext()).startActivityForResult(inte, 2001);
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
return true;
}
});
} else {
if ((fitems.size() * height) < parentL.getHeight() && (SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_DRAWER || SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_BOTH)) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.spacer, parent, false);
ViewGroup.LayoutParams params = convertView.findViewById(R.id.height).getLayoutParams();
params.height = (parentL.getHeight() - (getCount() - 1) * height);
convertView.setLayoutParams(params);
} else {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.spacer, parent, false);
ViewGroup.LayoutParams params = convertView.findViewById(R.id.height).getLayoutParams();
params.height = 0;
convertView.setLayoutParams(params);
}
}
return convertView;
}
Aggregations