コード例 #1
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_layout_conversations, container, false);

    setTitle("Conversas");

    conversationsList = new ArrayList<>();
    conversationsList = generateConversationList();

    conversationsAdapter = new ConversationsAdapter(conversationsList);
    rvConversations = (RecyclerView) view.findViewById(R.id.recycler_conversations);

    final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    rvConversations.setLayoutManager(layoutManager);

    rvConversations.setAdapter(conversationsAdapter);

    rvConversations.addOnItemTouchListener(
        new RecyclerItemClickListener(
            getContext(),
            new RecyclerItemClickListener.OnItemClickListener() {
              @Override
              public void onItemClick(View view, int position) {
                openConversation(position);
              }
            }));

    return view;
  }
コード例 #2
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    EventManager eventManager = EventManager.getInstance();
    RecyclerView recList = (RecyclerView) rootView.findViewById(R.id.event_recycler_view);

    mType = getArguments().getInt(TYPE);
    recList.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(mContext);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    recList.setLayoutManager(llm);
    mAdapter = new EventRecyclerViewAdapter(mContext, eventManager);
    recList.setAdapter(mAdapter);

    switch (mType) {
      case ACCEPTED:
        mAdapter.updateEventList(eventManager.getAcceptedEvents());
        break;
      case DECLINED:
        mAdapter.updateEventList(eventManager.getDeclinedEvents());
        break;
    }

    return rootView;
  }
コード例 #3
0
  private void updateMicroThumbBackground(long newId) {
    for (int i = 1; i < mData.size(); i++) {
      StickerMicroThumb stickerMicroThumb = mData.get(i);
      stickerMicroThumb.isSelected = false;

      if (stickerMicroThumb.sticker != null) {
        if (stickerMicroThumb.sticker.setId == newId) {
          stickerMicroThumb.isSelected = true;
          mLinearLayoutManager.scrollToPosition(i);
        }
      }
    }

    if (newId == -1) {
      mData.get(1).isSelected = true;
      mLinearLayoutManager.scrollToPosition(0);
    }
    // без runInUI не работает на версии 4,1
    AndroidUtil.runInUI(
        new Runnable() {
          @Override
          public void run() {
            notifyDataSetChanged();
          }
        },
        1);
  }
コード例 #4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tarot_feedback);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final ActionBar ab = getSupportActionBar();
    ab.setDisplayHomeAsUpEnabled(false);

    FloatingActionButton fablogin = (FloatingActionButton) findViewById(R.id.fab_login);
    fablogin.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (TextUtils.isEmpty(getUsername())) {
              facebookLogin();
            } else {
              addFeedback(getUsername());
            }
          }
        });
    RecyclerView rv = (RecyclerView) findViewById(R.id.recyclerview);
    rv.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(this);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setLayoutManager(llm);
    updateList();
  }
コード例 #5
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_item_detail, container, false);

    // click on category in list
    OpenHoursManager lm = new OpenHoursManager(getActivity());
    String[] categories = {
      "library",
      "info",
      "cafeteria_gar",
      "cafeteria_grh",
      "cafeteria",
      "cafeteria_pas",
      "cafeteria_wst"
    };
    Cursor c = lm.getAllHoursFromDb(categories[mItemId]);

    RecyclerView recyclerView =
        (RecyclerView) rootView.findViewById(R.id.fragment_item_detail_recyclerview);
    recyclerView.setAdapter(new OpeningHoursDetailAdapter(c));
    final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);

    return rootView;
  }
コード例 #6
0
  private void initView() {
    title =
        new MyTitleBarHelper(this, getWindow().getDecorView().findViewById(android.R.id.content));
    title.setMiddleText("常用电话");
    title.setOnclickListener(this);

    keeperTitle = (TextView) findViewById(R.id.my_title_tel);
    wuyeKeeper = (TextView) findViewById(R.id.tv_wuye);
    keeperTel = (TextView) findViewById(R.id.tv_tel);
    cell = (RelativeLayout) findViewById(R.id.phone_line_one);
    cellTitle = (TextView) findViewById(R.id.my_title_tel);
    img_tel_one = (ImageView) findViewById(R.id.img_tel_one);
    ll_wuye_keeper = (LinearLayout) findViewById(R.id.ll_wuye_keeper);
    //        commTel = (TextView) findViewById(R.id.tel1);

    iv_title_bar_left = (ImageView) findViewById(R.id.iv_title_bar_left);
    tv_tel_pager = (TextView) findViewById(R.id.tv_tel_pager);
    //         创建布局管理器
    mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);
    adapter = new MyTelRecycleAdapter();
    adapter.setOnItemClickListener(this);
    mRecyclerView.setAdapter(adapter);
  }
コード例 #7
0
  private View findCenterView(LinearLayoutManager lm) {

    int minDistance = 0;
    View view = null;
    View returnView = null;
    boolean notFound = true;

    for (int i = lm.findFirstVisibleItemPosition();
        i <= lm.findLastVisibleItemPosition() && notFound;
        i++) {

      view = lm.findViewByPosition(i);

      int center =
          lm.getOrientation() == LinearLayoutManager.HORIZONTAL
              ? (view.getLeft() + view.getRight()) / 2
              : (view.getTop() + view.getBottom()) / 2;
      int leastDifference = Math.abs(mCenterPivot - center);

      if (leastDifference <= minDistance || i == lm.findFirstVisibleItemPosition()) {
        minDistance = leastDifference;
        returnView = view;
        setCenterView(returnView);
      } else {
        notFound = false;
      }
    }
    return returnView;
  }
コード例 #8
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);
  }
コード例 #9
0
  public boolean shouldHandleRecyclerViewLoadingMore(RecyclerView recyclerView) {
    if (mIsLoadingMore
        || mCurrentRefreshStatus == RefreshStatus.REFRESHING
        || mLoadMoreFooterView == null
        || mDelegate == null
        || recyclerView.getAdapter() == null
        || recyclerView.getAdapter().getItemCount() == 0) {
      return false;
    }

    RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
    if (manager == null || manager.getItemCount() == 0) {
      return false;
    }

    if (manager instanceof LinearLayoutManager) {
      LinearLayoutManager layoutManager = (LinearLayoutManager) manager;
      if (layoutManager.findLastCompletelyVisibleItemPosition()
          == recyclerView.getAdapter().getItemCount() - 1) {
        return true;
      }
    } else if (manager instanceof StaggeredGridLayoutManager) {
      StaggeredGridLayoutManager layoutManager = (StaggeredGridLayoutManager) manager;

      int[] out = layoutManager.findLastCompletelyVisibleItemPositions(null);
      int lastPosition = layoutManager.getItemCount() - 1;
      for (int position : out) {
        if (position == lastPosition) {
          return true;
        }
      }
    }
    return false;
  }
コード例 #10
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    Bus bus = ((ApplicationModified) getActivity().getApplication()).getBus();
    bus.register(this);

    View myFragment = inflater.inflate(R.layout.fragment_main, container, false);
    recList = (RecyclerView) myFragment.findViewById(R.id.card_list);
    recList.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(this.getActivity());
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    recList.setLayoutManager(llm);
    View.OnClickListener listener =
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String title = ((TextView) v.findViewById(R.id.title)).getText().toString();
            ((BaseActivity) getActivity()).openArticle(title);
          }
        };
    ArticlesAdapter articlesAdapter;
    if (articlesList == null) {
      articlesAdapter = new ArticlesAdapter(listener);
      new ServiceHelper().getSavedArticles(this.getActivity());
    } else {
      articlesAdapter = new ArticlesAdapter(listener, articlesList);
    }
    recList.setAdapter(articlesAdapter);
    if (noResults) {
      TextView no_Results = (TextView) myFragment.findViewById(R.id.NoResultMessage);
      no_Results.setVisibility(View.VISIBLE);
    }

    return myFragment;
  }
コード例 #11
0
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
          if (dy == 0 || recyclerView.getChildCount() <= 0) return;

          LinearLayoutManager linearLayoutManager =
              (LinearLayoutManager) recyclerView.getLayoutManager();
          int firstVisibleItem = linearLayoutManager.findFirstVisibleItemPosition();
          int lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();
          int visibleItemCount = lastVisibleItem - firstVisibleItem;
          int totalItemCount = recyclerView.getAdapter().getItemCount();

          NewsListRecyclerAdapter adapter = (NewsListRecyclerAdapter) recyclerView.getAdapter();

          // Set the item at top to read
          ViewHolder vh =
              (ViewHolder) recyclerView.findViewHolderForLayoutPosition(firstVisibleItem);
          if (vh != null && !vh.shouldStayUnread()) {
            adapter.ChangeReadStateOfItem(vh, true);
          }

          // Check if Listview is scrolled to bottom
          if (lastVisibleItem == (totalItemCount - 1)
              && recyclerView.getChildAt(visibleItemCount).getBottom()
                  <= recyclerView.getHeight()) {
            for (int i = firstVisibleItem + 1; i <= lastVisibleItem; i++) {
              vh = (ViewHolder) recyclerView.findViewHolderForLayoutPosition(i);
              if (vh != null && !vh.shouldStayUnread()) {
                adapter.ChangeReadStateOfItem(vh, true);
              }
            }
          }
        }
コード例 #12
0
ファイル: MainActivity.java プロジェクト: malsilico/midterm
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    listContact = new ArrayList<>();
    Contact john = new Contact("John", "Hudson", "555-5555", "*****@*****.**");
    Contact bill = new Contact("Bill", "Nye", "555-5554", "*****@*****.**");
    Contact neil = new Contact("Neil", "Tyson", "555-5553", "*****@*****.**");
    Contact phil = new Contact("Phil", "Plait", " 555-5552", "*****@*****.**");
    Contact nikola = new Contact("Nikola", "Tesla", "555-5551", "*****@*****.**");
    listContact.add(john);
    listContact.add(bill);
    listContact.add(neil);
    listContact.add(phil);
    listContact.add(nikola);

    RecyclerView recyclerView;
    recyclerView = (RecyclerView) findViewById(R.id.contact_list);
    ContactList contactList = new ContactList();
    recyclerView.setAdapter(contactList);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getBaseContext());
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(linearLayoutManager);
  }
コード例 #13
0
    /**
     * This method takes layout manager and finds the right center element of it
     *
     * @param layoutManager
     * @return View
     */
    private View findCenterView(LinearLayoutManager layoutManager) {

      int minDistance = 0;
      View view, returnView = null;
      boolean notFound = true;

      for (int i = layoutManager.findFirstVisibleItemPosition();
          i <= layoutManager.findLastVisibleItemPosition() && notFound;
          i++) {

        view = layoutManager.findViewByPosition(i);

        int center = (view.getLeft() + view.getRight()) / 2;

        int leastDifference = Math.abs(mCenterPivot - center);

        if (leastDifference <= minDistance || i == layoutManager.findFirstVisibleItemPosition()) {
          minDistance = leastDifference;
          returnView = view;
        } else {
          notFound = false;
        }
      }
      return returnView;
    }
コード例 #14
0
 @Override
 public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
   super.onScrolled(recyclerView, dx, dy);
   LinearLayoutManager mLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
   lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
   pulldown = (dy > 0);
 }
コード例 #15
0
  @Override
  public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final View view = getView();
    if (view == null) throw new AssertionError();
    final Context viewContext = view.getContext();
    mMultiSelectManager = getMultiSelectManager();
    final MessageEntriesAdapter adapter = getAdapter();
    final RecyclerView recyclerView = getRecyclerView();
    final LinearLayoutManager layoutManager = getLayoutManager();
    mNavigationHelper =
        new RecyclerViewNavigationHelper(recyclerView, layoutManager, adapter, this);

    adapter.setListener(this);

    final DividerItemDecoration itemDecoration =
        new DividerItemDecoration(viewContext, layoutManager.getOrientation());
    final Resources res = viewContext.getResources();
    final int decorPaddingLeft =
        res.getDimensionPixelSize(R.dimen.element_spacing_normal) * 3
            + res.getDimensionPixelSize(R.dimen.icon_size_status_profile_image);
    itemDecoration.setPadding(decorPaddingLeft, 0, 0, 0);
    itemDecoration.setDecorationEndOffset(1);
    recyclerView.addItemDecoration(itemDecoration);
    getLoaderManager().initLoader(0, null, this);
    showProgress();
  }
コード例 #16
0
  @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);
  }
コード例 #17
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View v = inflater.inflate(R.layout.fragment_history, container, false);
   swipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeRefesh);
   recyclerView = (RecyclerView) v.findViewById(R.id.historylist);
   swipeRefreshLayout.setColorSchemeColors(Color.RED, Color.GREEN, Color.BLUE);
   swipeRefreshLayout.setOnRefreshListener(
       new SwipeRefreshLayout.OnRefreshListener() {
         @Override
         public void onRefresh() {
           swipeRefreshLayout.postDelayed(
               new Runnable() {
                 @Override
                 public void run() {
                   getContext().startService(new Intent(getContext(), CloudSyncService.class));
                   recyclerView.setAdapter(new HistoryListAdapter(checkUpDAO.getAll()));
                   swipeRefreshLayout.setRefreshing(false);
                 }
               },
               300);
         }
       });
   LinearLayoutManager l = new LinearLayoutManager(getActivity());
   l.setOrientation(LinearLayoutManager.VERTICAL);
   recyclerView.setLayoutManager(l);
   recyclerView.setAdapter(new HistoryListAdapter(checkUpDAO.getAll()));
   return v;
 }
コード例 #18
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayShowHomeEnabled(true);
    View rootView = inflater.inflate(R.layout.fragment_weapon_list, container, false);
    RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.listview_landing_menu);
    recyclerView.setAdapter(new LandingMenuAdapter(getActivity()));
    recyclerView.setHasFixedSize(true);
    ItemClickSupport.addTo(recyclerView)
        .setOnItemClickListener(
            new ItemClickSupport.OnItemClickListener() {
              @Override
              public void onItemClicked(RecyclerView recyclerView, int position, View v) {
                Log.e("Listener", "anda");
              }
            });
    final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);

    recyclerView.setLayoutManager(layoutManager);

    return rootView;
  }
  @Override
  public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);

    visibleItemCount = recyclerView.getChildCount();
    totalItemCount = mLinearLayoutManager.getItemCount();
    firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition();

    if (loading) {
      if (totalItemCount > previousTotal) {
        loading = false;
        previousTotal = totalItemCount;
      }
    }
    if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
      // End has been reached

      // Do something
      current_page++;

      onLoadMore(current_page);

      loading = true;
    }
  }
コード例 #20
0
ファイル: Home.java プロジェクト: Tsiems/STRiNg
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    ButterKnife.bind(this);
    Log.d(TAG, "Cars in list: " + cars.size());
    // homeFab.attachToListView(carList);
    LinearLayoutManager llm = new LinearLayoutManager(this);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    carList.setLayoutManager(llm);
    carAdapter = new CarAdapter(cars, Home.this);
    carList.setAdapter(carAdapter);
    registerForContextMenu(carList);
    carAdapter.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(View view, int position) {
            Intent carPage = new Intent(getApplicationContext(), CarPage.class);
            Bundle b = new Bundle();
            b.putString("vin", cars.get(position).getVin());
            carPage.putExtras(b);
            startActivity(carPage);
          }

          @Override
          public void onItemLongClick(View view, int position) {
            Log.d(TAG, "ITEM WAS LONG PRESSED!");
            openContextMenu(view);
            selectedPosition = position;
          }
        });
  }
コード例 #21
0
  /** 初始化RecyclerView */
  public void initRecyclerView() {
    final LinearLayoutManager manager = new LinearLayoutManager(getActivity());
    manager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(manager);
    mRecyclerView.addOnScrollListener(
        new RecyclerView.OnScrollListener() {

          @Override
          public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            int num = manager.findLastVisibleItemPosition();
            // 只有滑动到了倒数第三个item,且没有数据在加载时,才去访问接口
            // cacheList.size()-1   是滑动到了底部 , dy>0表示在向下滑动
            if ((num == cacheList.size() - 3 || num == cacheList.size() - 1)
                && dy > 0
                && !isLoading
                && Application.connectedType == ConnectivityManager.TYPE_WIFI) {
              String url =
                  Interface.fuliImageUrl
                      + "&page="
                      + page
                      + "&page_size=15&max_timestamp="
                      + cacheList.get(cacheList.size() - 1).getUpdate_time()
                      + "&latest_viewed_ts="
                      + cacheList.get(0).getUpdate_time();
              adapter.addFooterView(getActivity(), R.layout.refresh_progress_bar, 0, 0, 0, 0);
              isLoading = true;
              HttpUtils.get(url, new GetData(true));
            }
          }
        });
  }
コード例 #22
0
  private void FadingOutOtherItems(PopupMenu popupMenu) {
    // Dim out all the other list items if they exist
    LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
    int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
    int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition();
    for (int i = firstVisibleItemPosition; i <= lastVisibleItemPosition; i++) {
      if (i == mHolder.getLayoutPosition()) continue;
      RecyclerViewHolder viewHolder =
          (RecyclerViewHolder) mRecyclerView.findViewHolderForLayoutPosition(i);
      View itemView = viewHolder.getItemView();
      itemView.clearAnimation();
      itemView.startAnimation(mFadeOut);
    }

    // Make sure to bring them back to normal after the menu is gone
    popupMenu.setOnDismissListener(
        new PopupMenu.OnDismissListener() {
          @Override
          public void onDismiss(PopupMenu popupMenu) {
            LinearLayoutManager layoutManager =
                (LinearLayoutManager) mRecyclerView.getLayoutManager();
            int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
            int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition();
            for (int i = firstVisibleItemPosition; i <= lastVisibleItemPosition; i++) {
              if (i == mHolder.getLayoutPosition()) continue;
              RecyclerViewHolder viewHolder =
                  (RecyclerViewHolder) mRecyclerView.findViewHolderForLayoutPosition(i);
              View itemView = viewHolder.getItemView();
              viewHolder.getLayoutPosition();
              itemView.clearAnimation();
              itemView.startAnimation(mFadeIn);
            }
          }
        });
  }
コード例 #23
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_visit, container, false);

    context = getActivity();

    visit_id = getArguments().getString("visit_id");
    pdv_id = getArguments().getString("pdv_id");
    pdv = getArguments().getString("pdv");
    credit = getArguments().getString("credit_line");
    pdv_rfc = getArguments().getString("pdv_rfc");

    GPSTracker tracker = new GPSTracker(getActivity());
    latitude = tracker.getLatitude();
    longitude = tracker.getLongitude();

    Log.d(LOG_VISIT_FRAGMENT, "PDV VISITADO: " + pdv_id);

    TrackerManager.sharedInstance().addInfoToCurrentUtils("id_pdv", pdv_id);

    TextView txt_header = (TextView) view.findViewById(R.id.txt_header);
    txt_header.setText(pdv);

    lst_step_visit = (RecyclerView) view.findViewById(R.id.lst_step_visit);
    lst_step_visit.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    lst_step_visit.setLayoutManager(llm);

    // checkin     = WorkPlan.getCheckInByVisitID(getActivity(),visit_id);

    currentCheckin = CheckIn.getActiveMap(getActivity(), visit_id);

    if (currentCheckin.size() > 0) checkin = "active";
    else checkin = "noactive";

    if (FormAnswers.getMapByVisitID(context, visit_id).size() > 0) form = "form";
    else form = "noform";

    adapter = new StepVisitsAdapter(createListData(), getActivity(), checkin, form);
    adapter.listener = this;

    lst_step_visit.setAdapter(adapter);

    bundle = new Bundle();

    bundle.putString("pdv_id", pdv_id);
    bundle.putString("pdv", pdv);
    bundle.putString("visit_id", visit_id);
    bundle.putString("latitude", String.valueOf(latitude));
    bundle.putString("longitude", String.valueOf(longitude));
    bundle.putString("pdv_rfc", pdv_rfc);
    bundle.putString("credit_line", credit);

    checkoutFlag = false;

    return view;
  }
コード例 #24
0
  @Override
  public void onBindViewHolder(final CashierAdapter.ViewHolder holder, final int position) {
    final KitchenOpen item = getItem(position);
    holder.vTextBillNo.setText(item.getOrderid());
    mOrderId = item.getOrderid();

    // float mServiceTax = item.getTotalamount() * 13 / 100;
    // mTotalAmount = item.getTotalamount() + mServiceTax;

    holder.vTextTotalAmount.setText("TOTAL AMOUNT : " + item.getTotalamount() + "");
    holder.vTextTableNo.setText("" + item.getTableid());

    // TODO FIX SOME LATE BUG HERE
    holder.vCashierCard.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (cashierClickListner != null) {
              mOrderId = item.getOrderid();
              cashierClickListner.itemClicked(
                  v, mOrderId, item.getSno(), item.getTableid(), item.getTotalamount());
              return true;
            } else {
              return false;
            }
          }
        });
    initFirebase(mOrderId);

    // RECYCLER VIEW
    mMyAdapter = new CashierItemAdapter(mQuery, Order.class, mAdapterItems, mAdapterKeys);
    LinearLayoutManager linearLayout = new LinearLayoutManager(context);
    linearLayout.setOrientation(LinearLayoutManager.VERTICAL);
    holder.recyclerView.setLayoutManager(linearLayout);
    holder.recyclerView.setLayoutManager(new LinearLayoutManager(context));
    holder.recyclerView.setAdapter(mMyAdapter);
    holder.recyclerView.setEnabled(false);

    String mActiveLink =
        context.getResources().getString(R.string.FireBase_Delivery_URL) + "/" + mOrderId;
    final Firebase mRef = new Firebase(mActiveLink);
    mRef.addValueEventListener(
        new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
            boolean vExist = dataSnapshot.exists();
            if (vExist) {
              Delivery post = dataSnapshot.getValue(Delivery.class);
              holder.vTextTableNo.setText(
                  "" + String.format("%1$.2f", post.getMobileno()).split("\\.")[0]);
            }
          }

          @Override
          public void onCancelled(FirebaseError firebaseError) {
            System.out.println("The read failed: " + firebaseError.getMessage());
          }
        });
  }
コード例 #25
0
 @Override
 public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
   if (dy > 0
       && viewListLayoutManager.findLastVisibleItemPosition()
           == viewListLayoutManager.getItemCount() - 1) {
     presenter.onScrolledToBottom();
   }
 }
コード例 #26
0
 private void initRecyclerView() {
   recyclerview = (RecyclerView) findViewById(R.id.recyclerview);
   final LinearLayoutManager linearLayoutManager =
       new LinearLayoutManager(getApplicationContext());
   linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
   recyclerview.setLayoutManager(linearLayoutManager);
   adapter = new RecyclerViewAdapter(MainActivity.this, dataSet, recyclerview);
   recyclerview.setAdapter(adapter);
 }
コード例 #27
0
 private void initImageList() {
   if (null == imageListAdapter) {
     imageListAdapter = new ReplyWidgetImageListAdapter(this);
     LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
     linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
     recyclerView.setLayoutManager(linearLayoutManager);
     recyclerView.setAdapter(imageListAdapter);
   }
 }
コード例 #28
0
 private int getOrientation(RecyclerView parent) {
   if (parent.getLayoutManager() instanceof LinearLayoutManager) {
     LinearLayoutManager layoutManager = (LinearLayoutManager) parent.getLayoutManager();
     return layoutManager.getOrientation();
   } else {
     throw new IllegalStateException(
         "ColorDividerItemDecoration can only be used with a LinearLayoutManager.");
   }
 }
コード例 #29
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_society_event_upload_requests, container, false);
    ButterKnife.bind(this, view);
    mLayoutNoRecord = (LinearLayout) view.findViewById(R.id.layout_no_record);
    mLayoutNoConnection = (LinearLayout) view.findViewById(R.id.layout_no_network);

    final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(layoutManager);

    mSwipeContainer.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            if (new BaseActivity().isNetworkAvailable(getActivity())) {
              refresh();
            } else {
              shortToast(getActivity(), "Network not available, failed to refresh");
              mSwipeContainer.setRefreshing(false);
            }
          }
        });
    mSwipeContainer.setColorSchemeResources(
        R.color.colorBlue, R.color.colorRed, R.color.colorGreen);

    mRecyclerView.addOnScrollListener(
        new RecyclerView.OnScrollListener() {
          @Override
          public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            int topRowVerticalPosition =
                (recyclerView == null || recyclerView.getChildCount() == 0)
                    ? 0
                    : recyclerView.getChildAt(0).getTop();
            mSwipeContainer.setEnabled(topRowVerticalPosition >= 0);
          }

          @Override
          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
          }
        });

    if (isNetworkAvailable(getContext()) == true) {
      new GetJson(GET_UPLOAD_REQUEST_URL).execute();
    } else {
      mRecyclerView.setVisibility(View.GONE);
      mLayoutNoConnection.setVisibility(View.VISIBLE);
      mSwipeContainer.setEnabled(false);
      mSwipeContainer.setRefreshing(false);
    }

    return view;
  }
コード例 #30
0
  private void initData() {
    LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(this);
    mLinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRvPhoneBooks.setLayoutManager(mLinearLayoutManager);
    mPhoneBookList = new ArrayList<PhoneBook>();
    getTelePhones();

    PhoneBookAdapter adapter = new PhoneBookAdapter(this, mPhoneBookList);
    mRvPhoneBooks.setAdapter(adapter);
  }