-
Couldn't load subscription status.
- Fork 11
17023136+吴世冕 返工修改 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HeyBean-Xx
wants to merge
2
commits into
frtmobileapp:master
Choose a base branch
from
HeyBean-Xx:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
53 changes: 46 additions & 7 deletions
53
app/src/main/java/com/nd/frt/recentconversation/MainActivity.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,28 +1,67 @@ | ||
| package com.nd.frt.recentconversation; | ||
|
|
||
| import android.content.Intent; | ||
| import android.os.Bundle; | ||
| import android.support.annotation.Nullable; | ||
| import android.support.v7.app.AppCompatActivity; | ||
| import android.support.v7.widget.LinearLayoutManager; | ||
| import android.support.v7.widget.RecyclerView; | ||
|
|
||
| import com.nd.frt.recentconversation.adapter.UserAdapter; | ||
| import android.view.Menu; | ||
| import android.view.MenuItem; | ||
| import com.nd.frt.recentconversation.activity.DetailActivity; | ||
| import com.nd.frt.recentconversation.adapter.UsersAdapter; | ||
| import com.nd.frt.recentconversation.model.UserInfo; | ||
| import com.nd.frt.recentconversation.service.UserInfoService; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class MainActivity extends AppCompatActivity { | ||
|
|
||
| private RecyclerView.Adapter userAdapter; | ||
| private UsersAdapter mUserAdapter; | ||
|
|
||
| @Override | ||
| protected void onCreate(Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
| setContentView(R.layout.activity_main); | ||
| UserInfoService userInfoService = new UserInfoService(); | ||
| List<UserInfo> userInfos = userInfoService.getUserInfos(this); | ||
| UserAdapter userAdapter = new UserAdapter(userInfos); | ||
| RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rvRecyclerView); | ||
| recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); | ||
| recyclerView.setAdapter(userAdapter); | ||
| RecyclerView recyList = findViewById(R.id.recyList); | ||
| recyList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL,false)); | ||
| mUserAdapter = new UsersAdapter(userInfos); | ||
| recyList.setAdapter(mUserAdapter); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean onCreateOptionsMenu(Menu menu) { | ||
| getMenuInflater().inflate(R.menu.menu_main, menu); | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean onOptionsItemSelected(MenuItem item) { | ||
| if (item.getItemId()==R.id.menu_add){ | ||
| UserInfo userInfo = new UserInfo(); | ||
| userInfo.userName = "wushimian"; | ||
| userInfo.content = "767441080@qq.com"; | ||
| userInfo.avatarUrl = "https://randomuser.me/api/portraits/men/18.jpg"; | ||
| mUserAdapter.add(userInfo); | ||
| return true; | ||
| } | ||
| return super.onOptionsItemSelected(item); | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | ||
| super.onActivityResult(requestCode, resultCode, data); | ||
| if (resultCode == RESULT_OK){ | ||
| if (data != null) { | ||
| UserInfo userInfo = (UserInfo) data.getSerializableExtra(DetailActivity.PARAM_USER_INFO); | ||
| int index = data.getIntExtra(DetailActivity.PARAM_USER_INDEX,0); | ||
| mUserAdapter.edit(index,userInfo); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/nd/frt/recentconversation/activity/Actvity.java
This file contains hidden or 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,4 @@ | ||
| package com.nd.frt.recentconversation.activity; | ||
|
|
||
| class Actvity { | ||
| } |
70 changes: 70 additions & 0 deletions
70
app/src/main/java/com/nd/frt/recentconversation/activity/DetailActivity.java
This file contains hidden or 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,70 @@ | ||
| package com.nd.frt.recentconversation.activity; | ||
|
|
||
| import android.app.Activity; | ||
| import android.content.Intent; | ||
| import android.os.Bundle; | ||
| import android.support.v7.app.ActionBar; | ||
| import android.support.v7.app.AppCompatActivity; | ||
| import android.view.MenuItem; | ||
| import android.view.View; | ||
| import android.widget.EditText; | ||
| import android.widget.ImageView; | ||
|
|
||
| import com.bumptech.glide.Glide; | ||
| import com.nd.frt.recentconversation.R; | ||
| import com.nd.frt.recentconversation.model.UserInfo; | ||
|
|
||
| public class DetailActivity extends AppCompatActivity { | ||
| public static final String PARAM_USER_INFO = " user_info"; | ||
| public static final String PARAM_USER_INDEX = "user_index"; | ||
| public UserInfo mUserInfo; | ||
| private int mUserIndex; | ||
|
|
||
| public static void start(Activity context, int index, UserInfo userInfo,int requestCode) { | ||
| Intent starter = new Intent(context, DetailActivity.class); | ||
| starter.putExtra(PARAM_USER_INFO,userInfo); | ||
| starter.putExtra(PARAM_USER_INDEX,index); | ||
| context.startActivityForResult(starter,requestCode); | ||
| } | ||
|
|
||
| @Override | ||
| protected void onCreate(Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
| setContentView(R.layout.activity_detail); | ||
| ActionBar supportActionBar = getSupportActionBar(); | ||
| assert supportActionBar != null; | ||
| supportActionBar.setDisplayHomeAsUpEnabled(true); | ||
| final Intent intent = getIntent(); | ||
| mUserInfo = ((UserInfo) intent.getSerializableExtra(PARAM_USER_INFO)); | ||
| mUserIndex = intent.getIntExtra(PARAM_USER_INDEX,0); | ||
|
|
||
| supportActionBar.setTitle(mUserInfo.userName); | ||
| supportActionBar.setSubtitle(mUserInfo.content); | ||
| final EditText etUserName = findViewById(R.id.etUserName); | ||
| ImageView ivAvatar = findViewById(R.id.ivAvatar); | ||
| Glide.with(this) | ||
| .load(mUserInfo.avatarUrl) | ||
| .into(ivAvatar); | ||
| findViewById(R.id.btnOk).setOnClickListener(new View.OnClickListener() { | ||
| @Override | ||
| public void onClick(View v) { | ||
| mUserInfo.userName = etUserName.getText().toString(); | ||
| Intent intentResult = new Intent(); | ||
| intentResult.putExtra(PARAM_USER_INFO, mUserInfo); | ||
| intentResult.putExtra(PARAM_USER_INDEX, mUserIndex ); | ||
| setResult(RESULT_OK,intentResult); | ||
| finish(); | ||
| } | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public boolean onOptionsItemSelected(MenuItem item) { | ||
| if (item.getItemId()==android.R.id.home){ | ||
| finish(); | ||
| return true; | ||
| } | ||
| return super.onOptionsItemSelected(item); | ||
| } | ||
| } | ||
56 changes: 0 additions & 56 deletions
56
app/src/main/java/com/nd/frt/recentconversation/adapter/UserAdapter.java
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
app/src/main/java/com/nd/frt/recentconversation/adapter/UsersAdapter.java
This file contains hidden or 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,66 @@ | ||
| package com.nd.frt.recentconversation.adapter; | ||
|
|
||
| import android.app.Activity; | ||
| import android.support.annotation.NonNull; | ||
| import android.support.v7.widget.RecyclerView; | ||
| import android.view.LayoutInflater; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
|
|
||
| import com.bumptech.glide.Glide; | ||
| import com.nd.frt.recentconversation.R; | ||
| import com.nd.frt.recentconversation.activity.DetailActivity; | ||
| import com.nd.frt.recentconversation.model.UserInfo; | ||
| import com.nd.frt.recentconversation.viewholder.UserViewHolder; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class UsersAdapter extends RecyclerView.Adapter<UserViewHolder> { | ||
|
|
||
| private List<UserInfo> mUserInfos; | ||
| private int REQUEST_EDIT_USER_INFO = 0x1001; | ||
|
|
||
| public UsersAdapter(List<UserInfo>userInfos) { | ||
| mUserInfos = userInfos; | ||
| } | ||
|
|
||
| @NonNull | ||
| @Override | ||
| public UserViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { | ||
| LayoutInflater layoutInflater = LayoutInflater.from(viewGroup.getContext()); | ||
| View itemView = layoutInflater.inflate(R.layout.item_user, viewGroup, false); | ||
| return new UserViewHolder(itemView); | ||
| } | ||
|
|
||
| @Override | ||
| public void onBindViewHolder(@NonNull UserViewHolder userViewHolder, final int position) { | ||
| final UserInfo userInfo = mUserInfos.get(position); | ||
| Glide.with(userViewHolder.itemView.getContext()) | ||
| .load(userInfo.avatarUrl) | ||
| .into(userViewHolder.mIvatar); | ||
| userViewHolder.mtvUserName.setText(userInfo.userName); | ||
| userViewHolder.mtvEmail.setText(userInfo.content); | ||
| userViewHolder.itemView.setOnClickListener(new View.OnClickListener() { | ||
| @Override | ||
| public void onClick(View v) { | ||
| DetailActivity.start((Activity) v.getContext(),position,userInfo,REQUEST_EDIT_USER_INFO); | ||
| } | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public int getItemCount() { | ||
| return mUserInfos.size(); | ||
| } | ||
|
|
||
| public void add(UserInfo userInfo){ | ||
| mUserInfos.add(userInfo); | ||
| notifyDataSetChanged(); | ||
| } | ||
|
|
||
| public void edit(int index,UserInfo userInfo){ | ||
| mUserInfos.set(index,userInfo); | ||
| notifyDataSetChanged(); | ||
| } | ||
| } |
4 changes: 3 additions & 1 deletion
4
app/src/main/java/com/nd/frt/recentconversation/model/UserInfo.java
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="#FFFFFF"> | ||
| <path | ||
| android:fillColor="#FF000000" | ||
| android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/> | ||
| </vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,30 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:orientation="vertical" | ||
| android:gravity="center_horizontal" | ||
| tools:context=".activity.DetailActivity"> | ||
|
|
||
| <ImageView | ||
| android:contentDescription="@string/avatar" | ||
| android:id="@+id/ivAvatar" | ||
| android:layout_width="96dp" | ||
| android:layout_height="96dp" /> | ||
|
|
||
| <EditText | ||
| android:id="@+id/etUserName" | ||
| android:hint="@string/username" | ||
| android:layout_width="match_parent" | ||
| android:inputType="text" | ||
| android:layout_marginTop="10dp" | ||
| android:layout_height="wrap_content" | ||
| tools:ignore="Autofill" /> | ||
|
|
||
| <Button | ||
| android:id="@+id/btnOk" | ||
| android:text="@android:string/ok" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" /> | ||
| </LinearLayout> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
空行