This repository has been archived by the owner on May 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 200
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
lizhaotailang
committed
Mar 31, 2017
1 parent
630d5bf
commit 9f22b2a
Showing
18 changed files
with
511 additions
and
152 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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
86 changes: 86 additions & 0 deletions
86
wear/src/main/java/io/github/marktony/espresso/PackageRecyclerAdapter.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,86 @@ | ||
/* | ||
* Copyright(c) 2017 lizhaotailang | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.github.marktony.espresso; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.support.wearable.view.CircledImageView; | ||
import android.support.wearable.view.WearableRecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import java.util.List; | ||
|
||
import io.github.marktony.espresso.data.Package; | ||
|
||
/** | ||
* Created by lizhaotailang on 2017/3/31. | ||
*/ | ||
|
||
public class PackageRecyclerAdapter extends WearableRecyclerView.Adapter<RecyclerView.ViewHolder> { | ||
|
||
private final List<Package> mList; | ||
|
||
public PackageRecyclerAdapter(@NonNull List<Package> list) { | ||
mList = list; | ||
} | ||
|
||
@Override | ||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
return new ViewHolder(LayoutInflater.from(parent.getContext()) | ||
.inflate(R.layout.item_package, parent, false)); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | ||
Package p = mList.get(position); | ||
ViewHolder vh = (ViewHolder) holder; | ||
if (p != null) { | ||
vh.textViewAvatar.setText(p.getName().substring(0, 1)); | ||
vh.textViewName.setText(p.getName()); | ||
if (p.getData() != null && p.getData().size() > 0) { | ||
vh.textViewStatus.setText(p.getData().get(0).getContext()); | ||
} else { | ||
vh.textViewStatus.setText("Can not get the latest status."); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return mList.size(); | ||
} | ||
|
||
public class ViewHolder extends WearableRecyclerView.ViewHolder { | ||
|
||
private TextView textViewAvatar; | ||
private TextView textViewName; | ||
private TextView textViewStatus; | ||
private CircledImageView avatar; | ||
|
||
public ViewHolder(View itemView) { | ||
super(itemView); | ||
textViewAvatar = (TextView) itemView.findViewById(R.id.textViewAvatar); | ||
textViewName = (TextView) itemView.findViewById(R.id.textViewName); | ||
textViewStatus = (TextView) itemView.findViewById(R.id.textViewStatus); | ||
avatar = (CircledImageView) itemView.findViewById(R.id.avatar); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.