Beispiel #1
0
  private void initObjects(View root) {
    mDialog = new ProgressDialog(this);
    mDialog.setTitle(R.string.app_name);
    mDialog.setMessage("Fetching images...");

    mGridAdapter = new ImageGridAdapter();

    mSmallRecView = UiUtils.getView(root, R.id.MAIN_small_rec_view);
    mSmallRecView.setLayoutManager(new GridLayoutManager(this, 4));
    mSmallRecView.setAdapter(mGridAdapter);
    mSmallRecView.setAlpha(0f);
    mSmallRecView.setVisibility(View.VISIBLE);

    mBigRecView = UiUtils.getView(root, R.id.MAIN_big_rec_view);
    mBigRecView.setLayoutManager(new GridLayoutManager(this, 3));
    mBigRecView.setAdapter(mGridAdapter);
    mBigRecView.setVisibility(View.VISIBLE);
    mBigRecView.setAlpha(1f);

    UiUtils.getView(root, R.id.MAIN_root).setOnTouchListener(this);
    mSmallRecView.setOnTouchListener(this);
    mBigRecView.setOnTouchListener(this);

    mGestureDetector = new ScaleGestureDetector(this, this);
  }
  /** 初始化根布局 */
  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;
            }
          }
        });
  }
  private void initCaseView() {
    mCaseAdapter = new CaseAdapter(mContext, WorkingData.getInstance(mContext).getCases().get(0));
    mCaseOnTouchListener = new CaseOnTouchListener(mContext, mCaseView);
    mCaseLayoutManager = new LinearLayoutManager(mContext);

    mCaseView.setLayoutManager(mCaseLayoutManager);
    mCaseView.addItemDecoration(new CaseCardDecoration(mContext));
    mCaseView.setOnTouchListener(mCaseOnTouchListener);
    mCaseView.setAdapter(mCaseAdapter);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_kbp_resolved);

    assignViews();
    KeyboardUtil.attach(
        this,
        mPanelRoot,
        // Add keyboard showing state callback, do like this when you want to listen in the
        // keyboard's show/hide change.
        new KeyboardUtil.OnKeyboardShowingListener() {
          @Override
          public void onKeyboardShowing(boolean isShowing) {
            Log.d(TAG, String.format("Keyboard is %s", isShowing ? "showing" : "hiding"));
          }
        });

    KPSwitchConflictUtil.attach(mPanelRoot, mPlusIv, mSendEdt);

    mSendImgTv.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // mock start the translucent full screen activity.
            startActivity(new Intent(KBPresolvedActivity.this, TranslucentActivity.class));
          }
        });

    mContentRyv.setLayoutManager(new LinearLayoutManager(this));

    mContentRyv.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
              KPSwitchConflictUtil.hidePanelAndKeyboard(mPanelRoot);
            }

            return false;
          }
        });
  }
  private void setupViews(final View view) {

    recyclerView = (RecyclerView) view.findViewById(R.id.rv_select_airport_fragment);
    recyclerView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {

            hideKeyboard();
            return false;
          }
        });

    editText = (EditText) view.findViewById(R.id.etv_select_airport_fragment);
    FrameLayout findIconLayout =
        (FrameLayout) view.findViewById(R.id.fl_select_airport_fragment_find_icon_layout);
    FrameLayout cancelIconLayout =
        (FrameLayout) view.findViewById(R.id.fl_select_airport_fragment_cancel_icon_layout);
    findIconLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            showKeyboardAndFocusOnEditText();
          }
        });
    cancelIconLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (editText.getText().length() == 0) {
              popFragmentFromBackStack();
            } else {
              editText.setText("");
            }
          }
        });

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setHasFixedSize(false);
    recyclerView.setLayoutManager(layoutManager);

    editText.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View view, boolean focused) {
            if (focused) {
              ((EditText) view).setCursorVisible(true);
            } else {
              ((EditText) view).setCursorVisible(false);
            }
          }
        });

    editText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

          @Override
          public void afterTextChanged(Editable editable) {

            placesFromServer = new ArrayList<PlaceData>();

            if (editable.length() > 0) {
              infoAdapter.setInfoViewActive(true);
              infoAdapter.setInfoText(null);
              updateAdapter();
              SearchByNameParams params = setSearchByNameParams();

              AviasalesSDK.getInstance()
                  .startPlacesSearch(
                      params,
                      new OnSearchPlacesListener() {
                        @Override
                        public void onSuccess(List<PlaceData> placeDatas) {
                          placesFromServer = placeDatas;

                          if (placesFromServer.isEmpty()) {
                            infoAdapter.setInfoViewActive(true);
                            infoAdapter.setInfoText(R.string.destination_no_results);
                          } else {
                            infoAdapter.setInfoViewActive(false);
                            infoAdapter.setInfoText(null);
                          }
                          updateAdapter();
                        }

                        @Override
                        public void onCanceled() {}

                        @Override
                        public void onError(int errorCode, int responseCode, String searchId) {}
                      });
            } else {
              AviasalesSDK.getInstance().cancelPlacesSearch();
              infoAdapter.setInfoViewActive(false);
              infoAdapter.setInfoText(null);
              updateAdapter();
            }
          }
        });

    createRecyclerViewAdapter();
  }