Search in sources :

Example 1 with MyListDivider

use of me.yluo.ruisiapp.widget.MyListDivider in project Ruisi by freedom10086.

the class FrageMessage method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    messageList = mRootView.findViewById(R.id.recycler_view);
    tab1 = mRootView.findViewById(R.id.btn_1);
    tab2 = mRootView.findViewById(R.id.btn_2);
    tab3 = mRootView.findViewById(R.id.btn_3);
    // 设置可以滑出底栏
    messageList.setClipToPadding(false);
    messageList.setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.bottombarHeight));
    refreshLayout = mRootView.findViewById(R.id.refresh_layout);
    refreshLayout.setColorSchemeResources(R.color.red_light, R.color.green_light, R.color.blue_light, R.color.orange_light);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    messageList.setLayoutManager(layoutManager);
    messageList.addItemDecoration(new MyListDivider(getActivity(), MyListDivider.VERTICAL));
    messageList.addOnScrollListener(new LoadMoreListener(layoutManager, this, 8));
    adapter = new MessageAdapter(getActivity(), datas);
    if (!App.ISLOGIN(getActivity())) {
        adapter.changeLoadMoreState(BaseAdapter.STATE_NEED_LOGIN);
    }
    messageList.setAdapter(adapter);
    refreshLayout.setOnRefreshListener(() -> pullRefresh());
    RadioGroup swictchMes = mRootView.findViewById(R.id.btn_change);
    swictchMes.setOnCheckedChangeListener((radioGroup, id) -> {
        int pos = 2;
        if (id == R.id.btn_1) {
            pos = 0;
        } else if (id == R.id.btn_2) {
            pos = 1;
        }
        if (pos != index) {
            index = pos;
            getData(true);
        }
    });
    return mRootView;
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) MessageAdapter(me.yluo.ruisiapp.adapter.MessageAdapter) LoadMoreListener(me.yluo.ruisiapp.listener.LoadMoreListener) RadioGroup(android.widget.RadioGroup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 2 with MyListDivider

use of me.yluo.ruisiapp.widget.MyListDivider in project Ruisi by freedom10086.

the class PostsActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    datas = new ArrayList<>();
    setContentView(R.layout.activity_posts);
    if (getIntent().getExtras() != null) {
        FID = getIntent().getExtras().getInt("FID");
        TITLE = getIntent().getExtras().getString("TITLE");
    }
    initToolBar(true, TITLE);
    myToolbar = findViewById(R.id.myToolBar);
    btnRefresh = findViewById(R.id.btn);
    mRecyclerView = findViewById(R.id.recycler_view);
    tab = findViewById(R.id.tab);
    refreshLayout = findViewById(R.id.refresh_layout);
    refreshLayout.setColorSchemeResources(R.color.red_light, R.color.green_light, R.color.blue_light, R.color.orange_light);
    int top = DimmenUtils.dip2px(this, 60);
    refreshLayout.setProgressViewOffset(true, top, top + 60);
    isHideZhiding = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("setting_hide_zhidin", true);
    if (getType() == PostListAdapter.TYPE_IMAGE) {
        isEnableLoadMore = false;
        mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
        mRecyclerView.setHasFixedSize(false);
        addToolbarMenu(R.drawable.ic_column_change_24dp).setOnClickListener(this);
    } else {
        mLayoutManager = new LinearLayoutManager(this);
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.addItemDecoration(new MyListDivider(this, MyListDivider.VERTICAL));
        mRecyclerView.addOnScrollListener(new LoadMoreListener((LinearLayoutManager) mLayoutManager, this, 8));
        addToolbarMenu(R.drawable.ic_edit).setOnClickListener(this);
    }
    tab.addTab(tab.newTab().setText("最新"));
    tab.addTab(tab.newTab().setText("热门"));
    tab.addTab(tab.newTab().setText("热帖"));
    tab.addTab(tab.newTab().setText("精华"));
    adapter = new PostListAdapter(this, datas, getType());
    if (getType() == PostListAdapter.TYPE_IMAGE) {
        adapter.setEnablePlaceHolder(false);
    }
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(adapter);
    myDB = new MyDB(this);
    datas.clear();
    btnRefresh.setOnClickListener(v -> refresh());
    init();
    // 子类实现获取数据
    getData();
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) LoadMoreListener(me.yluo.ruisiapp.listener.LoadMoreListener) PostListAdapter(me.yluo.ruisiapp.adapter.PostListAdapter) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MyDB(me.yluo.ruisiapp.database.MyDB)

Example 3 with MyListDivider

use of me.yluo.ruisiapp.widget.MyListDivider in project Ruisi by freedom10086.

the class UserDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_detail);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.transparent));
    }
    toolbarLayout = findViewById(R.id.toolbar_layout);
    infoList = findViewById(R.id.recycler_view);
    CircleImageView imageView = findViewById(R.id.user_detail_img_avatar);
    layout = findViewById(R.id.main_window);
    progressView = findViewById(R.id.grade_progress);
    progresText = findViewById(R.id.progress_text);
    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(v -> fab_click());
    ViewCompat.setTransitionName(imageView, NAME_IMG_AVATAR);
    username = getIntent().getStringExtra("loginName");
    imageUrl = getIntent().getStringExtra("avatarUrl");
    Picasso.with(this).load(imageUrl).placeholder(R.drawable.image_placeholder).into(imageView);
    toolbarLayout.setTitle(username);
    Toolbar mToolbar = findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    adapter = new SimpleListAdapter(ListType.INFO, this, datas);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
    infoList.setLayoutManager(layoutManager);
    infoList.addItemDecoration(new MyListDivider(this, MyListDivider.VERTICAL));
    infoList.setAdapter(adapter);
    userUid = getIntent().getStringExtra("uid");
    if (TextUtils.isEmpty(userUid)) {
        userUid = GetId.getId("uid=", imageUrl);
    }
    // 如果是自己
    if (userUid.equals(App.getUid(this))) {
        fab.setImageResource(R.drawable.ic_close_24dp);
        imageView.setOnClickListener(view -> {
            final String[] items = { "修改密码" };
            AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
            alertBuilder.setTitle("操作");
            alertBuilder.setItems(items, (arg0, index) -> {
                if (index == 0) {
                    startActivity(new Intent(UserDetailActivity.this, ChangePasswordActivity.class));
                }
            });
            AlertDialog d = alertBuilder.create();
            d.show();
        });
    }
    loadData(UrlUtils.getUserHomeUrl(userUid, false));
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) AlertDialog(android.support.v7.app.AlertDialog) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CircleImageView(me.yluo.ruisiapp.widget.CircleImageView) SimpleListAdapter(me.yluo.ruisiapp.adapter.SimpleListAdapter) FloatingActionButton(android.support.design.widget.FloatingActionButton) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar)

Example 4 with MyListDivider

use of me.yluo.ruisiapp.widget.MyListDivider in project Ruisi by freedom10086.

the class FrageHotsNews method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    ((RadioButton) mRootView.findViewById(R.id.btn_1)).setText("新帖");
    mRootView.findViewById(R.id.btn_2).setVisibility(View.GONE);
    ((RadioButton) mRootView.findViewById(R.id.btn_3)).setText("热贴");
    postList = mRootView.findViewById(R.id.recycler_view);
    refreshLayout = mRootView.findViewById(R.id.refresh_layout);
    refreshLayout.setColorSchemeResources(R.color.red_light, R.color.green_light, R.color.blue_light, R.color.orange_light);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
    postList.setLayoutManager(mLayoutManager);
    postList.addItemDecoration(new MyListDivider(getActivity(), MyListDivider.VERTICAL));
    // 设置可以滑出底栏
    postList.setClipToPadding(false);
    postList.setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.bottombarHeight));
    adapter = new HotNewListAdapter(getActivity(), mydataset, galleryDatas);
    postList.setAdapter(adapter);
    postList.addOnScrollListener(new LoadMoreListener((LinearLayoutManager) mLayoutManager, this, 10));
    refreshLayout.setOnRefreshListener(this::refresh);
    RadioGroup swictchMes = mRootView.findViewById(R.id.btn_change);
    swictchMes.setOnCheckedChangeListener((radioGroup, id) -> {
        int pos = -1;
        if (id == R.id.btn_1) {
            pos = TYPE_NEW;
        } else {
            pos = TYPE_HOT;
        }
        if (pos != currentType) {
            currentType = pos;
            refreshLayout.setRefreshing(true);
            refresh();
        }
    });
    return mRootView;
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) LoadMoreListener(me.yluo.ruisiapp.listener.LoadMoreListener) HotNewListAdapter(me.yluo.ruisiapp.adapter.HotNewListAdapter) RadioGroup(android.widget.RadioGroup) RecyclerView(android.support.v7.widget.RecyclerView) RadioButton(android.widget.RadioButton) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 5 with MyListDivider

use of me.yluo.ruisiapp.widget.MyListDivider in project Ruisi by freedom10086.

the class FriendActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_friend);
    initToolBar(true, "我的好友");
    friends = findViewById(R.id.recycler_view);
    datas = new ArrayList<>();
    backUpdatas = new ArrayList<>();
    totalDatas = new ArrayList<>();
    adapter = new FriendAdapter(this, datas, this);
    friends.setHasFixedSize(true);
    LinearLayoutManager lm = new LinearLayoutManager(this);
    friends.addItemDecoration(new MyListDivider(this, MyListDivider.VERTICAL));
    friends.setLayoutManager(lm);
    friends.addOnScrollListener(new LoadMoreListener(lm, this, 12));
    friends.setAdapter(adapter);
    search_input = findViewById(R.id.search_input);
    search_input.setHint("查找好友");
    search_card = findViewById(R.id.search_card);
    final String url = "home.php?mod=space&do=friend&mobile=2";
    new GetDataTask().execute(url);
    search_input.setOnEditorActionListener(this);
    addToolbarMenu(R.drawable.ic_search_white_24dp).setOnClickListener(this);
    findViewById(R.id.btn_back).setOnClickListener(this);
    findViewById(R.id.start_search).setOnClickListener(this);
    search_card.setVisibility(View.INVISIBLE);
    search_input.addTextChangedListener(this);
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) LoadMoreListener(me.yluo.ruisiapp.listener.LoadMoreListener) FriendAdapter(me.yluo.ruisiapp.adapter.FriendAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 MyListDivider (me.yluo.ruisiapp.widget.MyListDivider)9 LoadMoreListener (me.yluo.ruisiapp.listener.LoadMoreListener)7 RecyclerView (android.support.v7.widget.RecyclerView)5 SimpleListAdapter (me.yluo.ruisiapp.adapter.SimpleListAdapter)3 Bundle (android.os.Bundle)2 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)2 AlertDialog (android.support.v7.app.AlertDialog)2 RadioGroup (android.widget.RadioGroup)2 MyDB (me.yluo.ruisiapp.database.MyDB)2 Dialog (android.app.Dialog)1 Intent (android.content.Intent)1 AsyncTask (android.os.AsyncTask)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 Toolbar (android.support.v7.widget.Toolbar)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 RadioButton (android.widget.RadioButton)1