Java Code Examples for androidx.recyclerview.widget.RecyclerView#setHasFixedSize()

The following examples show how to use androidx.recyclerview.widget.RecyclerView#setHasFixedSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilesFragment.java    From ArchPackages with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (fragmentFilesBinding != null) {
        fragmentFilesBinding.setFiles(files);
        fragmentFilesBinding.executePendingBindings();
        Context context = fragmentFilesBinding.getRoot().getContext();
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
        RecyclerView recyclerView = fragmentFilesBinding.fragmentFilesRecyclerView;
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setHasFixedSize(true);
        recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
        RoomFileAdapter roomFileAdapter = new RoomFileAdapter();
        RoomFileViewModel mViewModel = new ViewModelProvider(this).get(RoomFileViewModel.class);
        mViewModel.getPagedListLiveData().observe(getViewLifecycleOwner(), roomFiles -> {
            if (roomFiles != null) {
                roomFileAdapter.submitList(roomFiles);
            }
        });
        recyclerView.setAdapter(roomFileAdapter);
    }
}
 
Example 2
Source File: PropertiesBSFragment.java    From PhotoEditor with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    RecyclerView rvColor = view.findViewById(R.id.rvColors);
    SeekBar sbOpacity = view.findViewById(R.id.sbOpacity);
    SeekBar sbBrushSize = view.findViewById(R.id.sbSize);

    sbOpacity.setOnSeekBarChangeListener(this);
    sbBrushSize.setOnSeekBarChangeListener(this);

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
    rvColor.setLayoutManager(layoutManager);
    rvColor.setHasFixedSize(true);
    ColorPickerAdapter colorPickerAdapter = new ColorPickerAdapter(getActivity());
    colorPickerAdapter.setOnColorPickerClickListener(new ColorPickerAdapter.OnColorPickerClickListener() {
        @Override
        public void onColorPickerClickListener(int colorCode) {
            if (mProperties != null) {
                dismiss();
                mProperties.onColorChanged(colorCode);
            }
        }
    });
    rvColor.setAdapter(colorPickerAdapter);
}
 
Example 3
Source File: SessionListDialog.java    From RedReader with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
	super.onCreateDialog(savedInstanceState);

	if (alreadyCreated) return getDialog();
	alreadyCreated = true;

	final Context context = getContext();

	final AlertDialog.Builder builder = new AlertDialog.Builder(context);
	builder.setTitle(context.getString(R.string.options_past));

	rv = new RecyclerView(context);
	builder.setView(rv);

	rv.setLayoutManager(new LinearLayoutManager(context));
	rv.setAdapter(new SessionListAdapter(context, url, current, type, this));
	rv.setHasFixedSize(true);

	RedditAccountManager.getInstance(context).addUpdateListener(this);

	builder.setNeutralButton(context.getString(R.string.dialog_close), null);

	return builder.create();
}
 
Example 4
Source File: RecyclerViewFragment.java    From android-test with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
  final LayoutManagerType layoutManagerType = (LayoutManagerType) getArguments()
      .getSerializable(KEY_EXTRA_LAYOUT_MANAGER_TYPE);

  final View view = inflater
      .inflate(layoutManagerType.getLayoutId(), container, false);

  selectedItemView = (TextView) view.findViewById(layoutManagerType.getSelectedItemId());
  recyclerView = (RecyclerView) view.findViewById(layoutManagerType.getRVId());
  recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),
      DividerItemDecoration.VERTICAL_LIST));
  recyclerView.setHasFixedSize(true);
  recyclerView.addOnItemTouchListener(this);
  gestureDetector = new GestureDetectorCompat(getActivity(), new ItemTouchGestureDetector());
  layoutManager = getLayoutManager(layoutManagerType);
  recyclerView.setLayoutManager(layoutManager);

  // Specify an adapter which displays items
  List<String> items = makeItems();
  adapter = ItemListAdapter.newItemListAdapter(items, inflater);
  recyclerView.setAdapter(adapter);
  return view;
}
 
Example 5
Source File: DailyReportFragment.java    From privacy-friendly-interval-timer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_daily_report, container, false);

    mRecyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);

    // Generate the reports
    generateReports(false);

    mAdapter = new ReportAdapter(reports);
    mAdapter.setOnItemClickListener(this);
    mRecyclerView.setAdapter(mAdapter);

    // use a linear layout manager
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
    mRecyclerView.setLayoutManager(layoutManager);

    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    mRecyclerView.setHasFixedSize(true);

    return view;
}
 
Example 6
Source File: SecurityActivity.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_onboarding_security);
    setTitle("");
    getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(android.R.color.transparent));

    final String[] choices = getResources().getStringArray(R.array.twoFactorChoices);
    final String[] methods = getResources().getStringArray(R.array.twoFactorMethods);
    final Integer[] images = {
        R.drawable.ic_2fa_email,
        R.drawable.ic_2fa_sms,
        R.drawable.ic_2fa_call,
        R.drawable.ic_2fa_google
    };

    if (!isFromOnboarding()) {
        UI.hide(UI.find(this, R.id.nextButton));
        setTitleBack();
    }

    mMethodsAdapter = new ViewAdapter(this,
                                      Arrays.asList(methods),
                                      Arrays.asList(choices),
                                      Arrays.asList(images));
    final RecyclerView wordsRecyclerView = UI.find(this, R.id.twoFactorsRecyclerView);
    wordsRecyclerView.setHasFixedSize(true);
    wordsRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    wordsRecyclerView.setAdapter(mMethodsAdapter);
}
 
Example 7
Source File: EmojiFragment.java    From react-native-photo-editor with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main_photo_edit_emoji, container, false);

    emojiRecyclerView = (RecyclerView) rootView.findViewById(R.id.fragment_main_photo_edit_emoji_rv);
    emojiRecyclerView.setHasFixedSize(true);
    emojiRecyclerView.setLayoutManager(new GridLayoutManager(photoEditorActivity, 4));
    EmojiAdapter adapter = new EmojiAdapter(photoEditorActivity, emojiIds);
    adapter.setOnEmojiClickListener(this);
    emojiRecyclerView.setAdapter(adapter);

    return rootView;
}
 
Example 8
Source File: RackMonthPicker.java    From RackMonthPicker with Apache License 2.0 5 votes vote down vote up
private Builder() {
    alertBuilder = new AlertDialog.Builder(context);

    contentView = LayoutInflater.from(context).inflate(R.layout.dialog_month_picker, null);
    contentView.setFocusable(true);
    contentView.setFocusableInTouchMode(true);

    mTitleView = (TextView) contentView.findViewById(R.id.title);
    mYear = (TextView) contentView.findViewById(R.id.text_year);

    ImageView next = (ImageView) contentView.findViewById(R.id.btn_next);
    next.setOnClickListener(nextButtonClick());

    ImageView previous = (ImageView) contentView.findViewById(R.id.btn_previous);
    previous.setOnClickListener(previousButtonClick());

    mPositiveButton = (Button) contentView.findViewById(R.id.btn_p);
    mNegativeButton = (Button) contentView.findViewById(R.id.btn_n);

    monthAdapter = new MonthAdapter(context, this);

    RecyclerView recyclerView = (RecyclerView) contentView.findViewById(R.id.recycler_view);
    recyclerView.setLayoutManager(new GridLayoutManager(context, 4));
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(monthAdapter);

    Date date = new Date();
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    year = cal.get(Calendar.YEAR);
    month = cal.get(Calendar.MONTH);

    setColorTheme(getColorByThemeAttr(context, android.R.attr.colorPrimary, R.color.color_primary));
}
 
Example 9
Source File: AbstractPagerFragment.java    From cloudinary_android with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_pager_page, container, false);

    recyclerView = (RecyclerView) rootView.findViewById(R.id.mainGallery);
    recyclerView.setHasFixedSize(true);
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    RecyclerView.LayoutManager layoutManager = getLayoutManager(getContext());
    recyclerView.setLayoutManager(layoutManager);
    emptyView = rootView.findViewById(R.id.emptyListView);
    dividerSize = getResources().getDimensionPixelSize(R.dimen.grid_divider_width);
    addItemDecoration(recyclerView);
    observer = new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            emptyView.setVisibility(recyclerView.getAdapter().getItemCount() == 0 ? View.VISIBLE : View.INVISIBLE);
        }

        @Override
        public void onItemRangeInserted(int positionStart, int itemCount) {
            super.onItemRangeInserted(positionStart, itemCount);
            emptyView.setVisibility(recyclerView.getAdapter().getItemCount() == 0 ? View.VISIBLE : View.INVISIBLE);

        }

        @Override
        public void onItemRangeRemoved(int positionStart, int itemCount) {
            super.onItemRangeRemoved(positionStart, itemCount);
            emptyView.setVisibility(recyclerView.getAdapter().getItemCount() == 0 ? View.VISIBLE : View.INVISIBLE);

        }
    };

    return rootView;
}
 
Example 10
Source File: PerfActivity.java    From ticker with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_perf);

    final RecyclerView recyclerView = findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(new TestAdapter());
}
 
Example 11
Source File: SelectFriendActivity.java    From FChat with MIT License 5 votes vote down vote up
private void initComponent() {
    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);

    // use a linear layout manager
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setHasFixedSize(true);
    recyclerView.addItemDecoration(
        new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
}
 
Example 12
Source File: CustomNotificationSettingsActivity.java    From an2linuxclient with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom_notification_settings);

    final CustomProgressDialog progressDialog = new CustomProgressDialog();
    progressDialog.setCancelable(false);
    progressDialog.show(getSupportFragmentManager(), "progressDialog");

    final RecyclerView recyclerView = findViewById(R.id.recyclerView);
    final ConstraintLayout emptyView = findViewById(R.id.emptyView);
    emptyView.setOnClickListener(view -> {
        Intent intent = new Intent(CustomNotificationSettingsActivity.this, EnabledApplicationsActivity.class);
        startActivityForResult(intent, RETURNED_FROM_ENABLED_APPS_SETTINGS_REQUEST);
    });

    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    final CustomNotificationSettingsAdapter adapter = new CustomNotificationSettingsAdapter(this);
    recyclerView.setAdapter(adapter);

    recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL));

    viewModel = ViewModelProviders.of(this).get(CustomNotificationSettingsViewModel.class);
    viewModel.getAppsDataList().observe(this, customSettingsAppData -> {
        adapter.setAppDataList(customSettingsAppData);
        progressDialog.dismiss();
        if (customSettingsAppData.size() == 0) {
            emptyView.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        } else {
            emptyView.setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);
        }
    });
}
 
Example 13
Source File: BlacklistFragment.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_blacklist, container, false);
    mInflater = inflater;

    mDrawable = new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_close)
            .color(Color.GRAY)
            .sizeDp(12);

    mOnClickListener = new OnSingleClickListener() {
        @Override
        public void onSingleClick(View v) {
            removeFromBlacklist((String) v.getTag());
            v.setVisibility(View.INVISIBLE);
        }
    };

    mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
    mSwipeLayout.setOnRefreshListener(this);
    mSwipeLayout.setColorSchemeColors(ColorHelper.getSwipeColor(getActivity()));
    mSwipeLayout.setProgressBackgroundColorSchemeColor(ColorHelper.getSwipeBackgroundColor(getActivity()));

    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.addItemDecoration(new SimpleDivider(getActivity()));

    mLoadingView = (ContentLoadingView) view.findViewById(R.id.content_loading);

    recyclerView.setAdapter(mAdapter);

    refresh();

    setActionBarTitle("黑名单");
    return view;
}
 
Example 14
Source File: ModifyAndDeleteActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
private void updateDeviceList() {
    mListAdapter = new ListAdapter<>(
            mSwitchBotMessageService.getDeviceList(),
            R.layout.list_modify_and_delete_row,
            this);
    RecyclerView deviceList = findViewById(R.id.list_device);
    deviceList.setHasFixedSize(true);
    deviceList.setLayoutManager(new LinearLayoutManager(this));
    deviceList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    deviceList.setAdapter(mListAdapter);
}
 
Example 15
Source File: EditObservationFragment.java    From ground-android with Apache License 2.0 5 votes vote down vote up
private void onShowPhotoSelectorDialog(Field field) {
  EditObservationBottomSheetBinding addPhotoBottomSheetBinding =
      EditObservationBottomSheetBinding.inflate(getLayoutInflater());
  addPhotoBottomSheetBinding.setViewModel(viewModel);
  addPhotoBottomSheetBinding.setField(field);

  BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getContext());
  bottomSheetDialog.setContentView(addPhotoBottomSheetBinding.getRoot());
  bottomSheetDialog.setCancelable(true);
  bottomSheetDialog.show();

  AddPhotoDialogAdapter.ItemClickListener listener =
      type -> {
        bottomSheetDialog.dismiss();
        switch (type) {
          case PHOTO_SOURCE_CAMERA:
            viewModel.showPhotoCapture(field);
            break;
          case PHOTO_SOURCE_STORAGE:
            viewModel.showPhotoSelector(field);
            break;
          default:
            throw new IllegalArgumentException("Unknown type: " + type);
        }
      };

  RecyclerView recyclerView = addPhotoBottomSheetBinding.recyclerView;
  recyclerView.setHasFixedSize(true);
  recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
  recyclerView.setAdapter(new AddPhotoDialogAdapter(listener));
}
 
Example 16
Source File: ReactWithAnyEmojiAdapter.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
  recyclerView.setNestedScrollingEnabled(false);
  ViewGroup.LayoutParams params = recyclerView.getLayoutParams();
  params.height = (int) (recyclerView.getResources().getDisplayMetrics().heightPixels * 0.80);
  recyclerView.setLayoutParams(params);
  recyclerView.setHasFixedSize(true);
}
 
Example 17
Source File: BottomSheetAdapterBuilder.java    From SimplicityBrowser with MIT License 4 votes vote down vote up
@SuppressLint("InflateParams")
public View createView(int titleTextColor, int backgroundDrawable, int backgroundColor,
                       int dividerBackground, int itemTextColor, int itemBackground,
                       int tintColor, BottomSheetItemClickListener itemClickListener) {

    if (mFromMenu) {
        mItems = createAdapterItems(dividerBackground, titleTextColor,
                itemTextColor, itemBackground, tintColor);
    }

    LayoutInflater layoutInflater = LayoutInflater.from(mContext);

    View sheet = mMode == BottomSheetBuilder.MODE_GRID ?
            layoutInflater.inflate(R.layout.bottomsheetbuilder_sheet_grid, null)
            : layoutInflater.inflate(R.layout.bottomsheetbuilder_sheet_list, null);

    final RecyclerView recyclerView = (RecyclerView) sheet.findViewById(R.id.recyclerView);
    recyclerView.setHasFixedSize(true);

    if (backgroundDrawable != 0) {
        sheet.setBackgroundResource(backgroundDrawable);
    } else {
        if (backgroundColor != 0) {
            sheet.setBackgroundColor(backgroundColor);
        }
    }

    // If we only have one title and it's the first item, set it as fixed
    if (mTitles == 1 && mMode == BottomSheetBuilder.MODE_LIST) {
        BottomSheetItem header = mItems.get(0);
        TextView headerTextView = (TextView) sheet.findViewById(R.id.textView);
        if (header instanceof BottomSheetHeader) {
            headerTextView.setVisibility(View.VISIBLE);
            headerTextView.setText(header.getTitle());
            if (titleTextColor != 0) {
                headerTextView.setTextColor(titleTextColor);
            }
            mItems.remove(0);
        }
    }

    final BottomSheetItemAdapter adapter = new BottomSheetItemAdapter(mItems, mMode,
            itemClickListener);

    if (mMode == BottomSheetBuilder.MODE_LIST) {
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerView.setAdapter(adapter);
    } else {
        final int columns = mContext.getResources().getInteger(R.integer.bottomsheet_grid_columns);
        GridLayoutManager layoutManager = new GridLayoutManager(mContext, columns);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.post(new Runnable() {
            @Override
            public void run() {
                float margin = mContext.getResources()
                        .getDimensionPixelSize(R.dimen.bottomsheet_grid_horizontal_margin);
                adapter.setItemWidth((int) ((recyclerView.getWidth() - 2 * margin) / columns));
                recyclerView.setAdapter(adapter);
            }
        });
    }

    return sheet;
}
 
Example 18
Source File: SearchActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_search);

    // bind views
    toolbarSearchView = findViewById(R.id.search_view);
    View searchClearButton = findViewById(R.id.search_clear);

    // Clear search text when clear button is tapped
    searchClearButton.setOnClickListener(v -> toolbarSearchView.setText(""));

    // set indicator enable
    Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    if(getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }

    // change status bar color tint, and this require SDK16
    if (Build.VERSION.SDK_INT >= 16 ) { //&& Build.VERSION.SDK_INT <= 21) {
        // Android API 22 has more effects on status bar, so ignore

        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable all tint
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintAlpha(0.15f);
        tintManager.setNavigationBarAlpha(0.0f);
        // set all color
        tintManager.setTintColor(getResources().getColor(android.R.color.black));
        // set Navigation bar color
        if(Build.VERSION.SDK_INT >= 21)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColorWhite));
    }

    // set search clear icon color
    ImageView searchClearIcon = findViewById(R.id.search_clear_icon);
    searchClearIcon.setColorFilter(getResources().getColor(R.color.mySearchToggleColor), PorterDuff.Mode.SRC_ATOP);

    // set history list
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);

    RecyclerView mRecyclerView = this.findViewById(R.id.search_history_list);
    mRecyclerView.setHasFixedSize(true); // set variable size
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(mLayoutManager);

    historyList = GlobalConfig.getSearchHistory();
    adapter = new SearchHistoryAdapter(historyList);
    adapter.setOnItemClickListener(this); // add item click listener
    adapter.setOnItemLongClickListener(this); // add item click listener
    mRecyclerView.setAdapter(adapter);

    // set search action
    toolbarSearchView.setOnEditorActionListener((v, actionId, event) -> {
        // purify
        String temp = toolbarSearchView.getText().toString().trim();
        if(temp.length()==0) return false;

        // real action
        //Toast.makeText(MyApp.getContext(), temp, Toast.LENGTH_SHORT).show();
        GlobalConfig.addSearchHistory(temp);
        refreshHistoryList();

        // jump to search
        Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
        intent.putExtra("key", temp);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); // long-press will cause repetitions
        startActivity(intent);
        overridePendingTransition( R.anim.fade_in, R.anim.hold);

        return false;
    });
}
 
Example 19
Source File: SinglePostView.java    From Hify with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    ViewPump.init(ViewPump.builder()
            .addInterceptor(new CalligraphyInterceptor(
                    new CalligraphyConfig.Builder()
                            .setDefaultFontPath("fonts/bold.ttf")
                            .setFontAttrId(R.attr.fontPath)
                            .build()))
            .build());

    setContentView(R.layout.activity_single_post_view);

    String post_id=getIntent().getStringExtra("post_id");

    Toolbar toolbar=findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("Post");

    getSupportActionBar().setTitle("Post");
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if(!TextUtils.isEmpty(post_id)){

        boolean forComment=getIntent().getBooleanExtra("forComment",false);

        pbar=findViewById(R.id.pbar);
        mFirestore=FirebaseFirestore.getInstance();

        statsheetView = getLayoutInflater().inflate(R.layout.stat_bottom_sheet_dialog, null);
        mmBottomSheetDialog = new BottomSheetDialog(this);
        mmBottomSheetDialog.setContentView(statsheetView);
        mmBottomSheetDialog.setCanceledOnTouchOutside(true);

        mPostsList = new ArrayList<>();

        if(forComment)
            mAdapter = new PostsAdapter(mPostsList, this,this,mmBottomSheetDialog,statsheetView,true);
        else
            mAdapter = new PostsAdapter(mPostsList, this,this,mmBottomSheetDialog,statsheetView,false);


        RecyclerView mRecyclerView=findViewById(R.id.recyclerView);
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setAdapter(mAdapter);

        pbar.setVisibility(View.VISIBLE);
        getPosts(post_id);



    }else{
        finish();
    }

}
 
Example 20
Source File: MainActivity.java    From LicenseAdapter with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  List<Library> licenses = new ArrayList<>();

  // These libraries aren't hosted on GitHub (and you chose not to show the license text)
  licenses.add(Licenses.noContent("Android SDK", "Google Inc.",
      "https://developer.android.com/sdk/terms.html"));
  licenses.add(Licenses.noContent("Fabric", "Google Inc.", "https://fabric.io/terms"));

  licenses.add(Licenses.fromGitHubApacheV2("JakeWharton/ButterKnife"));
  licenses.add(Licenses.fromGitHubApacheV2("Hdodenhof/CircleImageView"));
  licenses.add(Licenses.fromGitHubApacheV2("Google/Dagger"));
  licenses.add(Licenses.fromGitHubApacheV2("Google/Gson"));
  licenses.add(Licenses.fromGitHubApacheV2("Immutables/Immutables"));
  licenses.add(Licenses.fromGitHubApacheV2("Square/LeakCanary"));
  licenses.add(Licenses.fromGitHubApacheV2("Square/OkHttp"));
  licenses.add(Licenses.fromGitHubApacheV2("Realm/Realm-Java"));
  licenses.add(Licenses.fromGitHubApacheV2("yqritc/RecyclerView-MultipleViewTypesAdapter"));
  licenses.add(Licenses.fromGitHubApacheV2("yshrsmz/LicenseAdapter"));
  licenses.add(Licenses.fromGitHubApacheV2("JakeWharton/ThreeTenABP"));
  licenses.add(Licenses.fromGitHubApacheV2("JakeWharton/Timber"));
  licenses.add(Licenses.fromGitHubApacheV2("GrandCentrix/Tray"));
  licenses.add(Licenses.fromGitHubApacheV2("Twitter/Twitter-Text"));
  licenses.add(Licenses.fromGitHubMIT("Jhy/Jsoup"));
  licenses.add(Licenses.fromGitHubBSD("Bumptech/Glide"));
  licenses.add(Licenses.fromGitHubBSD("Facebook/Stetho"));

  // This repository does not have license file
  licenses.add(Licenses.fromGitHub("GabrieleMariotti/ChangelogLib", Licenses.LICENSE_APACHE_V2));

  // These 2 licenses have a different branch name
  licenses.add(Licenses.fromGitHubApacheV2("ReactiveX/RxAndroid", "2.x/" + Licenses.FILE_AUTO));
  licenses.add(Licenses.fromGitHubApacheV2("ReactiveX/RxJava", "2.x/" + Licenses.FILE_AUTO));

  licenses.add(Licenses.noLink("Library without a link to the license, like Google Play Services",
      "Author", "License name", "License content"));

  RecyclerView list = findViewById(R.id.list);
  list.setLayoutManager(new LinearLayoutManager(this));
  list.setHasFixedSize(true);
  list.setAdapter(new LicenseAdapter(licenses));
}