-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
7,787 additions
and
4,430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
app/src/main/java/com/lwk/libsample/WechatActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package com.lwk.libsample; | ||
|
||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.widget.Toast; | ||
|
||
import com.lwkandroid.rcvadapter.RcvSingleAdapter; | ||
import com.lwkandroid.rcvadapter.holder.RcvHolder; | ||
import com.lwkandroid.rcvadapter.utils.RcvLinearDecoration; | ||
import com.lwkandroid.widget.ninegridview.NineGirdImageContainer; | ||
import com.lwkandroid.widget.ninegridview.NineGridBean; | ||
import com.lwkandroid.widget.ninegridview.NineGridView; | ||
|
||
import java.util.ArrayList; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.recyclerview.widget.LinearLayoutManager; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
public class WechatActivity extends AppCompatActivity | ||
{ | ||
private RecyclerView mRecyclerView; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) | ||
{ | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_wechat); | ||
|
||
mRecyclerView = findViewById(R.id.rcv_wechat); | ||
mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); | ||
mRecyclerView.addItemDecoration(RcvLinearDecoration.createDefaultVertical(this)); | ||
|
||
List<String> dataList = new LinkedList<>(); | ||
for (int i = 0; i < 20; i++) | ||
{ | ||
dataList.add("i=" + i); | ||
} | ||
|
||
mRecyclerView.setAdapter(new MyAdapter(this, dataList)); | ||
} | ||
|
||
public static class MyAdapter extends RcvSingleAdapter<String> | ||
{ | ||
|
||
public MyAdapter(Context context, List<String> datas) | ||
{ | ||
super(context, R.layout.adapter_wechat, datas); | ||
} | ||
|
||
@Override | ||
public void onBindView(RcvHolder holder, String itemData, int position) | ||
{ | ||
NineGridView nine_grid_view = holder.findView(R.id.ngv_images); | ||
nine_grid_view.setImageLoader(new GlideImageLoader()); | ||
//设置显示列数,默认3列 | ||
nine_grid_view.setColumnCount(3); | ||
//设置是否为编辑模式,默认为false | ||
nine_grid_view.setIsEditMode(false); | ||
//设置单张图片显示时的尺寸,默认100dp | ||
nine_grid_view.setSingleImageWidth(120); | ||
//设置单张图片显示时的宽高比,默认1.0f | ||
nine_grid_view.setSingleImageRatio(0.8f); | ||
//设置最大显示数量,默认9张 | ||
nine_grid_view.setMaxNum(9); | ||
//设置图片显示间隔大小,默认3dp | ||
nine_grid_view.setSpcaeSize(5); | ||
nine_grid_view.setDataList(createData()); | ||
nine_grid_view.setOnItemClickListener(new NineGridView.onItemClickListener() | ||
{ | ||
@Override | ||
public void onNineGirdAddMoreClick(int dValue) | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public void onNineGirdItemClick(int position, NineGridBean gridBean, NineGirdImageContainer imageContainer) | ||
{ | ||
Toast.makeText(getContext(), gridBean.getOriginUrl(), Toast.LENGTH_LONG).show(); | ||
} | ||
|
||
@Override | ||
public void onNineGirdItemDeleted(int position, NineGridBean gridBean, NineGirdImageContainer imageContainer) | ||
{ | ||
|
||
} | ||
}); | ||
} | ||
|
||
private List<NineGridBean> createData() | ||
{ | ||
// String url = "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=173843264,1010023015&fm=26&gp=0.jpg"; | ||
String url = "https://c-ssl.duitang.com/uploads/item/201503/21/20150321160159_vVxSC.jpeg"; | ||
List<NineGridBean> imageInfos = new ArrayList<>(); | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
NineGridBean imageInfo = new NineGridBean(url, url); | ||
imageInfos.add(imageInfo); | ||
} | ||
return imageInfos; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:id="@+id/rcv_wechat" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".WechatActivity"> | ||
|
||
</androidx.recyclerview.widget.RecyclerView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp"> | ||
|
||
<ImageView | ||
android:id="@+id/img_profile" | ||
android:layout_width="40dp" | ||
android:layout_height="40dp" | ||
android:src="@mipmap/ic_launcher" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="8dp" | ||
android:text="NAME" | ||
android:textSize="16sp" | ||
app:layout_constraintLeft_toRightOf="@+id/img_profile" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="2020-01-01 00:00:00" | ||
android:textSize="16sp" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<com.lwkandroid.widget.ninegridview.NineGridView | ||
android:id="@+id/ngv_images" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/img_profile" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |