Skip to content

Commit

Permalink
朋友圈样式
Browse files Browse the repository at this point in the history
  • Loading branch information
LwkCoder committed Apr 26, 2020
1 parent 1d0757f commit 1d585ef
Show file tree
Hide file tree
Showing 8 changed files with 7,787 additions and 4,430 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "com.github.bumptech.glide:glide:${LIB_GLIDE_VERSION}"
implementation "com.lwkandroid:ImagePicker:${LIB_IMAGEPICKER_VERSION}"
implementation "com.lwkandroid:recyclerviewadapter:1.4.3"
implementation project(':NineGridView')
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
12,014 changes: 7,596 additions & 4,418 deletions app/proguardMapping.txt

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.lwk.libsample"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lwk.libsample">

<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".WechatActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/lwk/libsample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Toast;
Expand Down Expand Up @@ -55,6 +56,15 @@ protected void onCreate(Bundle savedInstanceState)
mNineGridView.setIcAddMoreResId(R.drawable.ic_plus);
//设置各类点击监听
mNineGridView.setOnItemClickListener(this);

findViewById(R.id.btn_wechat).setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
startActivity(new Intent(MainActivity.this, WechatActivity.class));
}
});
}

@Override
Expand Down
107 changes: 107 additions & 0 deletions app/src/main/java/com/lwk/libsample/WechatActivity.java
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;
}
}

}
22 changes: 14 additions & 8 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/activity_main"
xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.lwk.libsample.MainActivity"
xmlns:app="http://schemas.android.com/apk/res-auto">
tools:context="com.lwk.libsample.MainActivity">

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -18,16 +17,23 @@
android:id="@+id/ck_main_is_edit_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:checked="true"
android:text="打开编辑模式"/>
android:text="打开编辑模式" />

<com.lwkandroid.widget.ninegridview.NineGridView
android:id="@+id/ninegridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content" />


<Button
android:id="@+id/btn_wechat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="朋友圈样式" />
</LinearLayout>

</ScrollView>
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_wechat.xml
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>
42 changes: 42 additions & 0 deletions app/src/main/res/layout/adapter_wechat.xml
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>

0 comments on commit 1d585ef

Please sign in to comment.