예제 #1
0
  private List<Submission> clearSeenPosts(boolean forever) {
    if (adapter.dataSet.posts != null) {

      List<Submission> originalDataSetPosts = adapter.dataSet.posts;

      OfflineSubreddit o = OfflineSubreddit.getSubreddit(id.toLowerCase());
      for (int i = adapter.dataSet.posts.size(); i > -1; i--) {
        try {
          if (HasSeen.getSeen(adapter.dataSet.posts.get(i))) {
            if (forever) {
              Hidden.setHidden(adapter.dataSet.posts.get(i));
            }
            o.clearPost(adapter.dataSet.posts.get(i));

            adapter.dataSet.posts.remove(i);
            if (adapter.dataSet.posts.size() == 0) {
              adapter.notifyDataSetChanged();
            } else {
              rv.setItemAnimator(new FadeInAnimator());
              adapter.notifyItemRemoved(i + 1);
            }
          }
        } catch (IndexOutOfBoundsException e) {
          // Let the loop reset itself
        }
      }
      o.writeToMemory();
      rv.setItemAnimator(new SlideInUpAnimator(new AccelerateDecelerateInterpolator()));
      return originalDataSetPosts;
    }

    return null;
  }
예제 #2
0
  private void setupVideoList() {
    adapter = new VideoListAdapter();
    videoList.setLayoutManager(new LinearLayoutManager(this));
    videoList.setAdapter(adapter);
    videoList.setItemAnimator(new VideoItemAnimator());
    videoList.addItemDecoration(new ItemDecoration(VIDEO_LIST_SPACING));
    videoList.addOnScrollListener(
        new RecyclerView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
              int positionView = findPartlyVisiblePosition();
              if (positionView >= 0) {
                if (positionView == currentVideoPos) {
                  return;
                }
                videoList
                    .getLayoutManager()
                    .findViewByPosition(positionView)
                    .findViewById(R.id.video_progress_view)
                    .setVisibility(View.VISIBLE);
                handler.postDelayed(new PlayerUpdater(positionView), UPDATE_PLAYER_DELAY);
              }
            }
          }

          @Override
          public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            isScrolledUp = (dy < 0);
          }
        });
  }
예제 #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    List<String> list = new ArrayList<>(5);
    list.add(
        "在很多时候xml里面的布局并不能满足我们的需求。这时候就需要用代码进行动态布局,前些天在对RelativeLayout 进行动态布局时遇到了些问题,现在解决了,分享下。");
    list.add("人生自古谁无死,留取丹心照汗青");
    list.add("我们经常会遇到让控件或是view实现叠加的效果,一般...不如RelativeLayout。");
    list.add(
        "private RecyclerView recyclerView;在很多时候xml里面的布局并不能满足我们的需求。这时候就需要用代码进行动态布局,前些天在对RelativeLayout 进行动态布局时遇到了些问题,现在解决了,分享下。");

    recyclerView = (RecyclerView) findViewById(R.id.v_recyclerView);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    adapter =
        new TVListAdapter(
            list,
            new OnItemClickForRecycler() {
              @Override
              public void onItemClick(View v, int position) {
                //                L.i(list.get(position));
              }
            });
    recyclerView.setAdapter(adapter);
    adapter.notifyDataSetChanged();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbarLayout);
    backdrop = (ImageView) findViewById(R.id.backdrop);
    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(
        new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    recyclerView.setItemAnimator(new DefaultItemAnimator());

    int id = getIntent().getIntExtra("ID", 0);

    TheMovieDBDetailsApi.getInstance()
        .getMovieDetails(
            id,
            new TheMovieDBDetailsApi.NetworkResponseListener() {
              @Override
              public void onSuccess(final MovieDetails details) {
                runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        setData(details);
                      }
                    });
              }

              @Override
              public void onFailure(Request request, IOException e) {}
            });
  }
  private void initialize() {
    rvOffers = (RecyclerView) fragView.findViewById(R.id.rv_offers_list);
    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    rvOffers.setLayoutManager(llm);
    rvOffers.setItemAnimator(new DefaultItemAnimator());

    Bundle bundle = getArguments();
    offersList = Parcels.unwrap(bundle.getParcelable("offers"));
    if (offersList != null && offersList.size() > 0) {
      adapter = new RVOffersAdapter(offersList, getActivity());
      rvOffers.setAdapter(adapter);
    }

    rvOffers.addOnItemTouchListener(
        new RecyclerItemClickListener(
            getActivity(),
            new RecyclerItemClickListener.OnItemClickListener() {
              @Override
              public void onItemClick(View view, int position) {
                Intent browserIntent =
                    new Intent(
                        Intent.ACTION_VIEW, Uri.parse(offersList.get(position).getOfferLink()));
                startActivity(browserIntent);
              }
            }));
  }
예제 #6
0
  private void initGridLayout() {
    mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);

    try {
      int screenOrientation = getResources().getConfiguration().orientation;

      if (!TextUtils.isEmpty(BrewSharedPrefs.getUserToken())) {
        userToken = BrewSharedPrefs.getUserToken();
      }

      grid = (RecyclerView) findViewById(R.id.grid);
      grid.setItemAnimator(new DefaultItemAnimator());
      grid.setHasFixedSize(false);

      int gridColumns = 3;
      if (screenOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        gridColumns = 4;
      }

      final StaggeredGridLayoutManager layoutManager =
          new StaggeredGridLayoutManager(gridColumns, LinearLayoutManager.VERTICAL);
      layoutManager.scrollToPosition(0);
      grid.setLayoutManager(layoutManager);

      List<Image> placeHolder = new Vector<>();
      adapter = new GridImagesRecycler(placeHolder, this);
      grid.setAdapter(adapter);

      load();
    } catch (Exception e) {
      if (BuildConfig.DEBUG) {
        Log.e(Constants.LOG, e.getMessage());
      }
    }
  }
예제 #7
0
  private void initiateView() {
    LayoutInflater.from(mContext).inflate((R.layout.search_view), this, true);

    mSearchLayout = findViewById(R.id.search_layout);
    mCardView = (CardView) mSearchLayout.findViewById(R.id.cardView);

    LinearLayoutManager layoutManager =
        new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
    mSuggestionsRecyclerView = (RecyclerView) mSearchLayout.findViewById(R.id.recyclerView);
    mSuggestionsRecyclerView.setLayoutManager(layoutManager);
    mSuggestionsRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mSuggestionsRecyclerView.setVisibility(GONE);

    mSearchEditText = (EditText) mSearchLayout.findViewById(R.id.editText_input);
    mBackImageView = (ImageView) mSearchLayout.findViewById(R.id.imageView_arrow_back);
    mVoiceImageView = (ImageView) mSearchLayout.findViewById(R.id.imageView_mic);
    mEmptyImageView = (ImageView) mSearchLayout.findViewById(R.id.imageView_clear); // CLEAR
    mTintView = mSearchLayout.findViewById(R.id.view_transparent);
    mSeparatorView = mSearchLayout.findViewById(R.id.view_separator);

    mSearchEditText.setOnClickListener(mOnClickListener);
    mBackImageView.setOnClickListener(mOnClickListener);
    mVoiceImageView.setOnClickListener(mOnClickListener);
    mEmptyImageView.setOnClickListener(mOnClickListener);
    mTintView.setOnClickListener(mOnClickListener);
    mSeparatorView.setVisibility(GONE);

    showVoice(true);
    initSearchView();
  }
 private void initView() {
   view = LayoutInflater.from(context).inflate(R.layout.floating_layout_list, null);
   RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler);
   recyclerView.setLayoutManager(
       new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
   recyclerView.setItemAnimator(new DefaultItemAnimator());
   setupBackground();
   hideRecycler();
   recyclerView.setAdapter(adapter);
   windowManager.addView(view, rParams);
   if (floatingImage == null) floatingImage = new ImageView(context);
   setupFloatingImage(false);
   floatingImage.setOnTouchListener(
       new View.OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           gestureDetector.onTouchEvent(event);
           return FloatingHorizontalLayout.this.onTouch(v, event);
         }
       });
   windowManager.addView(floatingImage, mParams);
   onMyAppsLoader = new MyPopupAppsLoader(context, this);
   onMyAppsLoader.registerListener(3, onLoadCompleteListener);
   onMyAppsLoader.startLoading();
   animateHidden();
 }
예제 #9
0
  private void setRecyclerView() {
    Database = new LibraryDatabaseAdapter(getActivity());
    adapter =
        new LibraryRecyclerViewAdapter(
            getActivity(), Database.advanced_key_search(MainActivity.SearchQuery, Library.type));

    mRecyclerView.addItemDecoration(
        new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setAdapter(adapter);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    // on recycler touch item event see FragmentDrawer line 87 for more info
    mRecyclerView.addOnItemTouchListener(
        new RecyclerView.OnItemTouchListener() {
          @Override
          public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
            return false;
          }

          @Override
          public void onTouchEvent(RecyclerView rv, MotionEvent e) {}

          @Override
          public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {}
        });
  }
예제 #10
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // get list state from saved instance
    if (savedInstanceState != null) {
      mListState = savedInstanceState.getParcelable(TransistorKeys.INSTANCE_LIST_STATE);
    }

    // inflate root view from xml
    mRootView = inflater.inflate(R.layout.fragment_main, container, false);

    // get reference to action call view from inflated root view
    mActionCallView = mRootView.findViewById(R.id.main_actioncall_layout);

    // get reference to recycler list view from inflated root view
    mRecyclerView = (RecyclerView) mRootView.findViewById(R.id.main_recyclerview_collection);

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

    // set animator
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());

    // use a linear layout manager
    mLayoutManager = new LinearLayoutManager(mActivity);
    mRecyclerView.setLayoutManager(mLayoutManager);

    // attach adapter to list view
    mRecyclerView.setAdapter(mCollectionAdapter);

    return mRootView;
  }
예제 #11
0
파일: Home.java 프로젝트: HKMOpen/KAM
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   AppController.getController().getBus().register(this);
   manager = new GridLayoutManager(this, getResources().getInteger(R.integer.num_row));
   recycler.setItemAnimator(new DefaultItemAnimator());
   recycler.setHasFixedSize(true);
   recycler.setLayoutManager(manager);
   mDrawerLayout.setStatusBarBackgroundColor(
       AppHelper.getPrimaryDarkColor(AppHelper.getPrimaryColor(this)));
   navigationView.setItemIconTintList(ColorStateList.valueOf(AppHelper.getAccentColor(this)));
   if (AppHelper.isDarkTheme(this)) {
     navigationView.setItemTextColor(ColorStateList.valueOf(AppHelper.getAccentColor(this)));
   }
   adapter = new AppsAdapter(this, new ArrayList<AppsModel>());
   recycler.setAdapter(adapter);
   mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
   if (navigationView != null) {
     setupDrawerContent(navigationView);
   }
   getLoaderManager().restartLoader(0, null, this);
   productsList.addAll(Arrays.asList(getResources().getStringArray(R.array.in_app_billing)));
   mHelper = new IabHelper(this, getString(R.string.base64));
   mHelper.startSetup(mPurchaseFinishedListener);
   showWhatsNew();
   countBackup();
 }
  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recycle_swipetolayout);

    swipeToLoadLayout = ((SwipeToLoadLayout) findViewById(R.id.swipeToLoadLayout));

    mRecycleView = ((RecyclerView) findViewById(R.id.swipe_target));

    adapter = new HomeAdapter();

    // 设置垂直的线性布局管理器,Orientation -->   VERTICAL:垂直   HORIZONTAL:水平
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);

    //        StaggeredGridLayoutManager layoutManager = new
    // StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);

    // 添加分割线
    mRecycleView.addItemDecoration(
        new DividerItemDecoration(getApplicationContext(), DividerItemDecoration.VERTICAL_LIST));

    mRecycleView.setLayoutManager(layoutManager);

    mRecycleView.setItemAnimator(new DefaultItemAnimator());

    mRecycleView.setAdapter(adapter);

    adapter.refresh();

    /** 设置下拉刷新和上拉加载监听 */
    swipeToLoadLayout.setOnRefreshListener(this);
    swipeToLoadLayout.setOnLoadMoreListener(this);
  }
예제 #13
0
  @Override
  protected void init(Bundle savedInstanceState) {
    ButterKnife.bind(this);
    setHeadMiddleUpText("着色器Tint");
    for (int i = 0; i < 40; i++) {
      StringBuilder builder = new StringBuilder();
      builder.append("#");
      for (int j = 0; j < 6; j++) {
        builder.append(Integer.toHexString((int) (15 * (1 - Math.random()))));
      }
      mData.add(builder.toString());
    }
    mAdapterTint = new TintAdapter(mData);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 5));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addItemDecoration(new DividerGridItemDecoration(this));

    mRecyclerView.setAdapter(mAdapterTint);
    mAdapterTint.setOnRecyclerViewItemClickListener(
        new BaseQuickAdapter.OnRecyclerViewItemClickListener() {
          @Override
          public void onItemClick(View view, int position) {
            ToastUtil.showToast("Click" + position);
          }
        });
    OverScrollDecoratorHelper.setUpOverScroll(
        mRecyclerView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL);
  }
예제 #14
0
  @Override
  public void onPostExecute() {

    list.clear();

    try {
      JSONObject jsonObject = new JSONObject(sb);
      JSONArray jsonArray = jsonObject.getJSONArray("list");

      for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject c = jsonArray.getJSONObject(i);
        String title = c.getString("title");
        String nicname = c.getString("nicname");
        String content = c.getString("content");
        int count = c.getInt("count");
        int number = c.getInt("number");
        int reply_count = c.getInt("reply_count");
        String day = c.getString("day");

        list.add(
            new Item(
                number, count, title, content, nicname, Date.valueOf(day), View.GONE, reply_count));
      }

    } catch (Exception e) {
    }
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setOrientation(linearLayoutManager.VERTICAL);
    adapter = new NoticeBoardAdapter(getActivity(), list);
    recyclerView.setAdapter(adapter);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    refreshLayout.setRefreshing(false);
  }
예제 #15
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // get the recyclerview from her layout
    final RecyclerView list =
        (RecyclerView) inflater.inflate(R.layout.f_recyclerview, container, false);

    // CREATE ADAPTER, SETS ONCLICK AND SETS TO LIST
    MainListAdapter adapter = new MainListAdapter();
    adapter.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Snackbar.make(
                    v,
                    "Pulsado el item: " + (1 + list.getChildAdapterPosition(v)),
                    Snackbar.LENGTH_SHORT)
                .show();
          }
        });
    list.setAdapter(adapter);

    // sets the layout manager, decoration and animation for correcty implementation of recyclerview
    // ( recycler require that)
    list.setLayoutManager(
        new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    list.setItemAnimator(new DefaultItemAnimator());
    list.addItemDecoration(
        new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));

    return list;
  }
  private void initializeUserRecyclerView() {
    mUserResourceAdapter = new SelectableResourceListAdapter(mResourceList);

    mUserListContainer.setVisibility(View.VISIBLE);
    mExpandCollapseUsers.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mUsersRecyclerView.getVisibility() == View.VISIBLE) {
              mUsersRecyclerView.setVisibility(View.GONE);
              mExpandCollapseUsers.setImageResource(R.drawable.nav_next);
            } else {
              mUsersRecyclerView.setVisibility(View.VISIBLE);
              mExpandCollapseUsers.setImageResource(R.drawable.arrow_down);
            }
          }
        });

    mUsersRecyclerView.setVisibility(View.VISIBLE);
    mUsersRecyclerView.setHasFixedSize(true);
    mUsersRecyclerView.addItemDecoration(
        new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
    mUsersRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mUsersRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mUsersRecyclerView.setAdapter(mUserResourceAdapter);
  }
예제 #17
0
 // Obtiene e inicializa las vistas.
 private void initVistas() {
   configToolbar();
   swlPanel = (SwipeRefreshLayout) findViewById(R.id.swlPanel);
   swlPanel.setColorSchemeResources(
       android.R.color.holo_blue_bright,
       android.R.color.holo_green_light,
       android.R.color.holo_orange_light,
       android.R.color.holo_red_light);
   swlPanel.setOnRefreshListener(this);
   RecyclerView lstFotos = (RecyclerView) this.findViewById(R.id.lstFotos);
   mAdaptador = new FotosAdapter(mDatos);
   lstFotos.setHasFixedSize(true);
   lstFotos.setAdapter(mAdaptador);
   mGridLayoutManager =
       new GridLayoutManager(
           this,
           getResources().getInteger(R.integer.grid_columns),
           LinearLayoutManager.VERTICAL,
           false);
   lstFotos.setLayoutManager(mGridLayoutManager);
   lstFotos.setItemAnimator(new DefaultItemAnimator());
   mEndlessScrollListener =
       new EndlessRecyclerOnScrollListener(mGridLayoutManager) {
         @Override
         public void onLoadMore(int current_page) {
           obtenerDatos();
         }
       };
   lstFotos.addOnScrollListener(mEndlessScrollListener);
 }
  @Override
  public void onLoadFinished(Loader loader, Object data) {
    recyclerView = (RecyclerView) findViewById(R.id.store_list);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setItemAnimator(new DefaultItemAnimator());

    mStoreList = (ArrayList<Store>) data;
    mStoreAdaptor = new StoreAdapter(this, R.layout.store_layout, mStoreList);
    recyclerView.setAdapter(mStoreAdaptor);

    // Create an instance of the dialog fragment and show it
    mStoreAdaptor.SetOnItemClickListener(this);

    ItemTouchHelper.Callback callback = new ListItemTouchHelper();
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
    ((ListItemTouchHelper) callback)
        .SetOnItemClickListener(
            new ListItemTouchHelper.OnItemSwipeListener() {
              @Override
              public void onItemSwipe(int position) {
                mStoreDbAdapter.deleteStore(mStoreList.get(position));
                mStoreList.remove(position);
                mStoreAdaptor.notifyDataSetChanged();
                Toast.makeText(StoreListActivity.this, "position: " + position, Toast.LENGTH_SHORT)
                    .show();
              }
            });
  }
예제 #19
0
 /**
  * *********************************************************************************************
  */
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
   swipeRefreshLayout.setColorSchemeColors(Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW);
   swipeRefreshLayout.setOnRefreshListener(
       new SwipeRefreshLayout.OnRefreshListener() {
         @Override
         public void onRefresh() {
           swipeRefreshLayout.setRefreshing(true);
           layoutManager.scrollToPosition(0);
           imageItemList.clear();
           currentPage = 1;
           refreshItems(currentPage);
         }
       });
   layoutManager = new GridLayoutManager(this, 3);
   layoutManager.setOrientation(GridLayoutManager.VERTICAL);
   sharkRecyclerView = (RecyclerView) findViewById(R.id.sharkRecyclerView);
   sharkRecyclerView.setLayoutManager(layoutManager);
   imageItemAdapter = new ImageItemAdapter(imageItemList, this);
   sharkRecyclerView.setAdapter(imageItemAdapter);
   sharkRecyclerView.setItemAnimator(new DefaultItemAnimator());
   addScrollListener();
 }
  @Override
  public void onDestroyView() {
    if (mRecyclerViewDragDropManager != null) {
      mRecyclerViewDragDropManager.release();
      mRecyclerViewDragDropManager = null;
    }

    if (mRecyclerViewSwipeManager != null) {
      mRecyclerViewSwipeManager.release();
      mRecyclerViewSwipeManager = null;
    }

    if (mRecyclerViewTouchActionGuardManager != null) {
      mRecyclerViewTouchActionGuardManager.release();
      mRecyclerViewTouchActionGuardManager = null;
    }

    if (mRecyclerView != null) {
      mRecyclerView.setItemAnimator(null);
      mRecyclerView.setAdapter(null);
      mRecyclerView = null;
    }

    if (mWrappedAdapter != null) {
      WrapperAdapterUtils.releaseAll(mWrappedAdapter);
      mWrappedAdapter = null;
    }
    //        mSetlistAdapter = null;
    mLayoutManager = null;

    super.onDestroyView();
  }
예제 #21
0
  /** 初始化根布局 */
  private void initView() {
    srlComment = (SwipeRefreshLayout) rootView.findViewById(R.id.comment_srl_comment);
    rvComment = (RecyclerView) rootView.findViewById(R.id.comment_rv_comment);

    commentAdapter = new CommentAdapter(getActivity(), commentList);
    rvComment.setAdapter(commentAdapter);
    rvComment.setLayoutManager(new LinearLayoutManager(getActivity()));
    rvComment.setItemAnimator(new DefaultItemAnimator());

    commentAutoTvComment =
        (AutoCompleteTextView) rootView.findViewById(R.id.comment_autotv_comment);
    commentBtrCommiteComment =
        (ButtonRectangle) rootView.findViewById(R.id.comment_btr_commitecomment);

    srlComment.setOnRefreshListener(this);
    srlComment.setRefreshing(true);
    isRefreshing = true;
    BillCommentUtils.clearList(StringUtils.FRAGMENT_BILL_COMMENT);
    BillCommentUtils.startGetBillCommentTransaction(
        StringUtils.FRAGMENT_BILL_COMMENT, handler, bill.getObjectId());

    rvComment.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (isRefreshing) {
              return true;
            } else {
              return false;
            }
          }
        });
  }
예제 #22
0
  @Override
  public void initUI() {

    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    mAdapter = new JobAdapter(new ArrayList(JobStore.getInstance().getJobSets()), getActivity());
    recyclerView.setAdapter(mAdapter);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
  }
예제 #23
0
 /** 设置RecyclerView */
 private void setupRecyclerView() {
   adapter = new SampleAdapter(SampleUtils.generateSampleListData(getResources()));
   recyclerView.setAdapter(adapter);
   recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
   recyclerView.setItemAnimator(new DefaultItemAnimator());
   recyclerView.setHasFixedSize(true);
   recyclerView.addItemDecoration(new ItemDivider(getResources(), 1));
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content)
        .setSystemUiVisibility(
            findViewById(android.R.id.content).getSystemUiVisibility()
                | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    // as we use an icon from Android-Iconics via xml we add the IconicsLayoutInflater
    // https://github.com/mikepenz/Android-Iconics
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_collapsible);

    // style our ui
    new MaterializeBuilder().withActivity(this).build();

    // create our FastAdapter
    fastItemAdapter = new FastItemAdapter<>();
    fastItemAdapter.withSelectable(true);

    // get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
    rv.setLayoutManager(new LinearLayoutManager(this));
    rv.setItemAnimator(new SlideDownAlphaAnimator());
    rv.setAdapter(fastItemAdapter);

    // fill with some sample data
    List<IItem> items = new ArrayList<>();
    for (int i = 1; i <= 100; i++) {
      if (i % 10 == 0) {
        ExpandableItem expandableItem =
            new ExpandableItem().withName("Test " + i).withIdentifier(100 + 1);

        // add subitems so we can showcase the collapsible functionality
        List<IItem> subItems = new LinkedList<>();
        for (int ii = 1; ii <= 5; ii++) {
          subItems.add(new SampleItem().withName("-- Test " + ii).withIdentifier(1000 + ii));
        }
        expandableItem.withSubItems(subItems);

        items.add(expandableItem);
      } else {
        items.add(new SampleItem().withName("Test " + i).withIdentifier(100 + i));
      }
    }
    fastItemAdapter.add(items);

    // restore selections (this has to be done after the items were added
    fastItemAdapter.withSavedInstanceState(savedInstanceState);

    // set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
  }
예제 #25
0
  /**
   * build the MiniDrawer
   *
   * @param ctx
   * @return
   */
  public View build(Context ctx) {
    mContainer = new LinearLayout(ctx);
    if (mInnerShadow) {
      if (!mInRTL) {
        mContainer.setBackgroundResource(R.drawable.material_drawer_shadow_left);
      } else {
        mContainer.setBackgroundResource(R.drawable.material_drawer_shadow_right);
      }
    }

    // create and append recyclerView
    mRecyclerView = new RecyclerView(ctx);
    mContainer.addView(
        mRecyclerView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    // set the itemAnimator
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    // some style improvements on older devices
    mRecyclerView.setFadingEdgeLength(0);
    // set the drawing cache background to the same color as the slider to improve performance
    // mRecyclerView.setDrawingCacheBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(mActivity,
    // R.attr.material_drawer_background, R.color.material_drawer_background));
    mRecyclerView.setClipToPadding(false);
    // additional stuff
    mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
    // adapter
    mDrawerAdapter = new DrawerAdapter();
    mRecyclerView.setAdapter(mDrawerAdapter);

    // if the activity with the drawer should be fullscreen add the padding for the statusbar
    if (mDrawer != null
        && mDrawer.mDrawerBuilder != null
        && (mDrawer.mDrawerBuilder.mFullscreen || mDrawer.mDrawerBuilder.mTranslucentStatusBar)) {
      mRecyclerView.setPadding(
          mRecyclerView.getPaddingLeft(),
          UIUtils.getStatusBarHeight(ctx),
          mRecyclerView.getPaddingRight(),
          mRecyclerView.getPaddingBottom());
    }

    // if the activity with the drawer should be fullscreen add the padding for the navigationBar
    if (mDrawer != null
        && mDrawer.mDrawerBuilder != null
        && (mDrawer.mDrawerBuilder.mFullscreen
            || mDrawer.mDrawerBuilder.mTranslucentNavigationBar)) {
      mRecyclerView.setPadding(
          mRecyclerView.getPaddingLeft(),
          mRecyclerView.getPaddingTop(),
          mRecyclerView.getPaddingRight(),
          UIUtils.getNavigationBarHeight(ctx));
    }

    // set the adapter with the items
    createItems();

    return mContainer;
  }
예제 #26
0
 /** 配置RecyclerView */
 public void configRecycerView() {
   adapter = new RecycleAdapterEx(getActivity().getApplicationContext(), datas);
   LinearLayoutManager linearLayoutManager =
       new LinearLayoutManager(
           getActivity().getApplicationContext(), LinearLayoutManager.VERTICAL, false);
   mRecyclerView.setLayoutManager(linearLayoutManager);
   mRecyclerView.setItemAnimator(new DefaultItemAnimator());
   mRecyclerView.setAdapter(adapter);
 }
  @Override
  public void initializeComponents() {
    timesheetEntryRecyclerView.setAdapter(
        new TimesheetReportAdapter(presenter.getDefaultDiaryEntryList()));
    timesheetEntryRecyclerView.setItemAnimator(new DefaultItemAnimator());
    timesheetEntryRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    setNoMatchingTimesheetEntriesPromptVisible(presenter.getDefaultDiaryEntryList().isEmpty());
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.create_key_email_fragment, container, false);

    mEmailEdit = (EmailEditText) view.findViewById(R.id.create_key_email);
    View backButton = view.findViewById(R.id.create_key_back_button);
    View nextButton = view.findViewById(R.id.create_key_next_button);
    CheatSheet.setup(backButton, getContentDescription(backButton));
    CheatSheet.setup(nextButton, getContentDescription(nextButton));
    RecyclerView emailsRecyclerView = (RecyclerView) view.findViewById(R.id.create_key_emails);

    // initial values
    mEmailEdit.setText(mCreateKeyActivity.mEmail);

    // focus empty edit fields
    if (mCreateKeyActivity.mEmail == null) {
      mEmailEdit.requestFocus();
    }
    backButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mCreateKeyActivity.loadFragment(null, FragAction.TO_LEFT);
          }
        });
    nextButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            nextClicked();
          }
        });
    emailsRecyclerView.setHasFixedSize(true);
    emailsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    emailsRecyclerView.setItemAnimator(new DefaultItemAnimator());

    if (mEmailAdapter == null) {
      mEmailAdapter =
          new EmailAdapter(
              mAdditionalEmailModels,
              new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  addEmail();
                }
              });

      if (mCreateKeyActivity.mAdditionalEmails != null) {
        mEmailAdapter.addAll(mCreateKeyActivity.mAdditionalEmails);
      }
    }

    emailsRecyclerView.setAdapter(mEmailAdapter);

    return view;
  }
예제 #29
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout view =
        (RelativeLayout) inflater.inflate(R.layout.fragment_list, container, false);
    tvListEmptyNotifier = (TextView) view.findViewById(R.id.emptyLayout);

    RecyclerView rvContent = (RecyclerView) view.findViewById(R.id.rvContent);
    rvContent.setLayoutManager(new LinearLayoutManager(view.getContext()));
    mAdapter = new RemindAdapter(getActivity(), new ArrayList<Remind>());
    mAdapter.setOnListChangesListener(
        new RemindAdapter.ListChangesListener() {
          @Override
          public void onListSizeChanged() {
            if (mAdapter.getItemCount() == 0) {
              tvListEmptyNotifier.setVisibility(View.VISIBLE);
            } else {
              tvListEmptyNotifier.setVisibility(View.INVISIBLE);
            }
          }
        });
    switch (mFragmentType) {
      case FRAGMENT_TYPE_CURRENT:
        mAdapter.updateData(
            RemindDatabase.getInstance().getStoredData(DatabaseHelper.FILTER_WAITING_REMINDS));
        mAdapter.setItemEditable(true);
        rvContent.setItemAnimator(new FadeInRightAnimator());
        break;

      case FRAGMENT_TYPE_DONE:
        mAdapter.updateData(
            RemindDatabase.getInstance().getStoredData(DatabaseHelper.FILTER_DONE_REMINDS));
        mAdapter.setItemEditable(false);
        rvContent.setItemAnimator(new FadeInLeftAnimator());

        rvContent.setAlpha((float) FRAGMENT_DONE_ITEM_ALPHA);
        ((TextView) view.findViewById(R.id.emptyLayout))
            .setText(R.string.empty_layout_no_done_reminds);
        break;
    }
    rvContent.setAdapter(mAdapter);

    return view;
  }
예제 #30
0
  private void initList() {

    mAdapter = new DeviceListAdapter(mContext, mDataList);
    mAdapter.setOnItemListener(
        new OnItemListener() {
          @Override
          public void onClick(int pos) {
            Intent i = new Intent(mContext, IOListActivity.class);

            i.putExtra(Constant.KEY_ENTITY, mDataList.get(pos));

            i.putExtra(Constant.KEY_APPTYPE_ENTITY, mAppTypeEnt);
            startActivity(i);
          }

          @Override
          public boolean onLongClick(int pos) {
            showLongDialog(pos);
            return false;
          }

          @Override
          public void onCheckedChanged(int pos, boolean b) {}

          @Override
          public boolean onCheckedTouch(int pos, MotionEvent motionEvent) {
            return false;
          }
        });

    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mRecyclerView.setAdapter(mAdapter);

    mLayoutManager = new LinearLayoutManager(mRecyclerView.getContext());
    mRecyclerView.setLayoutManager(mLayoutManager);

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());

    refresh_layout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
    refresh_layout.setColorSchemeResources(
        android.R.color.holo_red_light,
        android.R.color.holo_green_light,
        android.R.color.holo_blue_light,
        android.R.color.holo_orange_light);
    refresh_layout.setEnabled(false);
    //        refresh_layout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    //            @Override
    //            public void onRefresh() {
    //
    //                mMode = MODE_HAND_REFRESH;
    //                loadFirstPage();
    //            }
    //        });
  }