Search in sources :

Example 1 with SimpleListAdapter

use of me.yluo.ruisiapp.adapter.SimpleListAdapter 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 2 with SimpleListAdapter

use of me.yluo.ruisiapp.adapter.SimpleListAdapter in project Ruisi by freedom10086.

the class SearchActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    main_window = findViewById(R.id.main_window);
    findViewById(R.id.btn_back).setOnClickListener(this);
    RecyclerView listView = findViewById(R.id.recycler_view);
    searchInput = findViewById(R.id.search_input);
    searchCard = findViewById(R.id.search_card);
    findViewById(R.id.start_search).setOnClickListener(this);
    findViewById(R.id.nav_search).setOnClickListener(this);
    searchInput.setHint("请输入搜索内容!");
    adapter = new SimpleListAdapter(ListType.SERRCH, this, datas);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
    listView.setLayoutManager(layoutManager);
    listView.addItemDecoration(new MyListDivider(this, MyListDivider.VERTICAL));
    listView.addOnScrollListener(new LoadMoreListener((LinearLayoutManager) layoutManager, this, 20));
    listView.setAdapter(adapter);
    adapter.changeLoadMoreState(BaseAdapter.STATE_LOAD_NOTHING);
    navTitle = findViewById(R.id.nav_title);
    findViewById(R.id.nav_back).setOnClickListener(this);
    searchInput.setOnEditorActionListener(this);
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) LoadMoreListener(me.yluo.ruisiapp.listener.LoadMoreListener) SimpleListAdapter(me.yluo.ruisiapp.adapter.SimpleListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 3 with SimpleListAdapter

use of me.yluo.ruisiapp.adapter.SimpleListAdapter in project Ruisi by freedom10086.

the class FrageTopicStar method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    // 从activity传过来的Bundle
    Bundle bundle = getArguments();
    if (bundle != null) {
        int type = bundle.getInt("type", -1);
        switch(type) {
            case FrageType.TOPIC:
                currentIndex = 0;
                title = "我的帖子";
                break;
            case FrageType.START:
                currentIndex = 1;
                title = "我的收藏";
                break;
        }
    }
    initToolbar(true, title);
    RecyclerView recyclerView = mRootView.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    SwipeRefreshLayout refreshLayout = mRootView.findViewById(R.id.refresh_layout);
    refreshLayout.setEnabled(false);
    String uid = App.getUid(getActivity());
    switch(currentIndex) {
        case 0:
            // 主题
            url = "home.php?mod=space&uid=" + uid + "&do=thread&view=me&mobile=2";
            break;
        case 1:
            // 我的收藏
            url = "home.php?mod=space&uid=" + uid + "&do=favorite&view=me&type=thread&mobile=2";
            break;
    }
    datas = new ArrayList<>();
    adapter = new SimpleListAdapter(ListType.ARTICLE, getActivity(), datas);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.addItemDecoration(new MyListDivider(getActivity(), MyListDivider.VERTICAL));
    recyclerView.addOnScrollListener(new LoadMoreListener((LinearLayoutManager) layoutManager, this, 10));
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
    refresh();
    return mRootView;
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) LoadMoreListener(me.yluo.ruisiapp.listener.LoadMoreListener) Bundle(android.os.Bundle) SimpleListAdapter(me.yluo.ruisiapp.adapter.SimpleListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 RecyclerView (android.support.v7.widget.RecyclerView)3 SimpleListAdapter (me.yluo.ruisiapp.adapter.SimpleListAdapter)3 MyListDivider (me.yluo.ruisiapp.widget.MyListDivider)3 LoadMoreListener (me.yluo.ruisiapp.listener.LoadMoreListener)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 AlertDialog (android.support.v7.app.AlertDialog)1 Toolbar (android.support.v7.widget.Toolbar)1 CircleImageView (me.yluo.ruisiapp.widget.CircleImageView)1