Search in sources :

Example 1 with BaseActivity

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;
}
Also used : BaseActivity(ml.docilealligator.infinityforreddit.activities.BaseActivity) BaseActivity(ml.docilealligator.infinityforreddit.activities.BaseActivity) Activity(android.app.Activity) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with BaseActivity

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;
}
Also used : BaseActivity(ml.docilealligator.infinityforreddit.activities.BaseActivity) BaseActivity(ml.docilealligator.infinityforreddit.activities.BaseActivity) Activity(android.app.Activity) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with BaseActivity

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;
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) R(ml.docilealligator.infinityforreddit.R) ViewGroup(android.view.ViewGroup) MaterialButton(com.google.android.material.button.MaterialButton) BaseActivity(ml.docilealligator.infinityforreddit.activities.BaseActivity) View(android.view.View) Utils(ml.docilealligator.infinityforreddit.utils.Utils) RecyclerView(androidx.recyclerview.widget.RecyclerView) UploadedImagesRecyclerViewAdapter(ml.docilealligator.infinityforreddit.adapters.UploadedImagesRecyclerViewAdapter) UploadImageEnabledActivity(ml.docilealligator.infinityforreddit.UploadImageEnabledActivity) Activity(android.app.Activity) LandscapeExpandedRoundedBottomSheetDialogFragment(ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment) UploadedImagesRecyclerViewAdapter(ml.docilealligator.infinityforreddit.adapters.UploadedImagesRecyclerViewAdapter) BaseActivity(ml.docilealligator.infinityforreddit.activities.BaseActivity) BaseActivity(ml.docilealligator.infinityforreddit.activities.BaseActivity) UploadImageEnabledActivity(ml.docilealligator.infinityforreddit.UploadImageEnabledActivity) Activity(android.app.Activity) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 4 with BaseActivity

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;
}
Also used : ClipboardManager(android.content.ClipboardManager) ViewRedditGalleryActivity(ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity) ActivityNotFoundException(android.content.ActivityNotFoundException) BaseActivity(ml.docilealligator.infinityforreddit.activities.BaseActivity) Intent(android.content.Intent) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) Uri(android.net.Uri) ClipData(android.content.ClipData)

Example 5 with BaseActivity

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));
    }
}
Also used : Account(ml.docilealligator.infinityforreddit.account.Account) RequestOptions(com.bumptech.glide.request.RequestOptions) ButterKnife(butterknife.ButterKnife) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) R(ml.docilealligator.infinityforreddit.R) ImageView(android.widget.ImageView) CustomThemeWrapper(ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) RoundedCornersTransformation(jp.wasabeef.glide.transformations.RoundedCornersTransformation) List(java.util.List) GifImageView(pl.droidsonroids.gif.GifImageView) TextView(android.widget.TextView) RequestManager(com.bumptech.glide.RequestManager) BaseActivity(ml.docilealligator.infinityforreddit.activities.BaseActivity) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ContextCompat(androidx.core.content.ContextCompat) RoundedCornersTransformation(jp.wasabeef.glide.transformations.RoundedCornersTransformation)

Aggregations

View (android.view.View)14 BaseActivity (ml.docilealligator.infinityforreddit.activities.BaseActivity)14 TextView (android.widget.TextView)13 BindView (butterknife.BindView)13 RecyclerView (androidx.recyclerview.widget.RecyclerView)10 ImageView (android.widget.ImageView)9 NonNull (androidx.annotation.NonNull)8 Resources (android.content.res.Resources)7 LayoutInflater (android.view.LayoutInflater)7 ViewGroup (android.view.ViewGroup)7 R (ml.docilealligator.infinityforreddit.R)7 Intent (android.content.Intent)6 ViewModelProvider (androidx.lifecycle.ViewModelProvider)6 ButterKnife (butterknife.ButterKnife)6 CustomThemeWrapper (ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper)6 LinearLayoutManagerBugFixed (ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed)6 Context (android.content.Context)5 SharedPreferences (android.content.SharedPreferences)5 Bundle (android.os.Bundle)5 Build (android.os.Build)4