-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rel #67
- Loading branch information
Showing
13 changed files
with
461 additions
and
2 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
app/src/main/java/io/github/emanual/app/entity/InterviewInfoEntity.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,96 @@ | ||
package io.github.emanual.app.entity; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Author: jayin | ||
* Date: 2/25/16 | ||
*/ | ||
public class InterviewInfoEntity extends BaseEntity{ | ||
|
||
private String name; | ||
private String name_cn; | ||
private String md5; | ||
private String icon_url; | ||
private String url; | ||
private String author; | ||
private String homepage; | ||
private List<MaintainerEntity> maintainers; | ||
|
||
public String getAuthor() { | ||
return author; | ||
} | ||
|
||
public void setAuthor(String author) { | ||
this.author = author; | ||
} | ||
|
||
public String getHomepage() { | ||
return homepage; | ||
} | ||
|
||
public void setHomepage(String homepage) { | ||
this.homepage = homepage; | ||
} | ||
|
||
public String getIcon_url() { | ||
return icon_url; | ||
} | ||
|
||
public void setIcon_url(String icon_url) { | ||
this.icon_url = icon_url; | ||
} | ||
|
||
public List<MaintainerEntity> getMaintainers() { | ||
return maintainers; | ||
} | ||
|
||
public void setMaintainers(List<MaintainerEntity> maintainers) { | ||
this.maintainers = maintainers; | ||
} | ||
|
||
public String getMd5() { | ||
return md5; | ||
} | ||
|
||
public void setMd5(String md5) { | ||
this.md5 = md5; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName_cn() { | ||
return name_cn; | ||
} | ||
|
||
public void setName_cn(String name_cn) { | ||
this.name_cn = name_cn; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
@Override public String toString() { | ||
return "InterviewInfoEntity{" + | ||
"author='" + author + '\'' + | ||
", homepage='" + homepage + '\'' + | ||
", icon_url='" + icon_url + '\'' + | ||
", maintainers=" + maintainers + | ||
", md5='" + md5 + '\'' + | ||
", name='" + name + '\'' + | ||
", name_cn='" + name_cn + '\'' + | ||
", url='" + url + '\'' + | ||
'}'; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/io/github/emanual/app/entity/InterviewJSONEntity.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,27 @@ | ||
package io.github.emanual.app.entity; | ||
|
||
/** | ||
* Author: jayin | ||
* Date: 2/25/16 | ||
*/ | ||
public class InterviewJSONEntity extends BaseEntity { | ||
|
||
private String title; | ||
private InterviewInfoEntity info; | ||
|
||
public InterviewInfoEntity getInfo() { | ||
return info; | ||
} | ||
|
||
public void setInfo(InterviewInfoEntity info) { | ||
this.info = info; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
} |
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
75 changes: 75 additions & 0 deletions
75
app/src/main/java/io/github/emanual/app/ui/adapter/InterviewListAdapter.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,75 @@ | ||
package io.github.emanual.app.ui.adapter; | ||
|
||
import android.content.Context; | ||
import android.net.Uri; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import com.facebook.drawee.view.SimpleDraweeView; | ||
|
||
import java.util.List; | ||
|
||
import butterknife.Bind; | ||
import butterknife.ButterKnife; | ||
import io.github.emanual.app.R; | ||
import io.github.emanual.app.entity.InterviewJSONEntity; | ||
|
||
/** | ||
* Author: jayin | ||
* Date: 2/25/16 | ||
*/ | ||
public class InterviewListAdapter extends RecyclerView.Adapter<InterviewListAdapter.ViewHolder>{ | ||
Context context; | ||
List<InterviewJSONEntity> data; | ||
|
||
public InterviewListAdapter(Context context, List<InterviewJSONEntity> data){ | ||
this.context = context; | ||
this.data = data; | ||
} | ||
|
||
public Context getContext() { | ||
return context; | ||
} | ||
|
||
public List<InterviewJSONEntity> getData() { | ||
return data; | ||
} | ||
|
||
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.adapter_interviewlist, parent, false)); | ||
} | ||
|
||
@Override public void onBindViewHolder(ViewHolder holder, int position) { | ||
final InterviewJSONEntity item = data.get(position); | ||
holder.tv_name.setText(item.getInfo().getName_cn()); | ||
holder.iv_icon.setImageURI(Uri.parse(item.getInfo().getIcon_url())); | ||
holder.layout_container.setOnClickListener(new View.OnClickListener() { | ||
@Override public void onClick(View v) { | ||
Toast.makeText(getContext(), item.getInfo().getName_cn(), Toast.LENGTH_SHORT).show(); | ||
// Intent intent = new Intent(getContext(), BrowserActivity.class); | ||
// //can be custom the index.html | ||
// intent.putExtra(BrowserActivity.EXTRA_URL, AppPath.getBookIndexURL(getContext(), item.getInfo().getName())); | ||
// getContext().startActivity(intent); | ||
} | ||
}); | ||
} | ||
|
||
@Override public int getItemCount() { | ||
return data.size(); | ||
} | ||
|
||
public static class ViewHolder extends RecyclerView.ViewHolder { | ||
@Bind(R.id.layout_container) View layout_container; | ||
@Bind(R.id.tv_name) TextView tv_name; | ||
@Bind(R.id.iv_icon) SimpleDraweeView iv_icon; | ||
|
||
public ViewHolder(View itemView) { | ||
super(itemView); | ||
ButterKnife.bind(this, itemView); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
app/src/main/java/io/github/emanual/app/ui/event/FinishQueryInterviewListEvent.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,31 @@ | ||
package io.github.emanual.app.ui.event; | ||
|
||
import java.util.List; | ||
|
||
import io.github.emanual.app.entity.InterviewJSONEntity; | ||
|
||
/** | ||
* Author: jayin | ||
* Date: 2/25/16 | ||
*/ | ||
public class FinishQueryInterviewListEvent extends BaseEvent { | ||
List<InterviewJSONEntity> data; | ||
|
||
public FinishQueryInterviewListEvent(List<InterviewJSONEntity> data) { | ||
this.data = data; | ||
} | ||
|
||
public List<InterviewJSONEntity> getData() { | ||
return data; | ||
} | ||
|
||
public void setData(List<InterviewJSONEntity> data) { | ||
this.data = data; | ||
} | ||
|
||
@Override public String toString() { | ||
return "FinishQueryInterviewListEvent{" + | ||
"data=" + data + | ||
'}'; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/io/github/emanual/app/ui/event/QueryInterviewListEvent.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,8 @@ | ||
package io.github.emanual.app.ui.event; | ||
|
||
/** | ||
* Author: jayin | ||
* Date: 2/25/16 | ||
*/ | ||
public class QueryInterviewListEvent extends BaseEvent{ | ||
} |
66 changes: 66 additions & 0 deletions
66
app/src/main/java/io/github/emanual/app/ui/fragment/InterviewListFragment.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,66 @@ | ||
package io.github.emanual.app.ui.fragment; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
|
||
import java.util.List; | ||
|
||
import butterknife.Bind; | ||
import de.greenrobot.event.EventBus; | ||
import de.greenrobot.event.Subscribe; | ||
import de.greenrobot.event.ThreadMode; | ||
import io.github.emanual.app.R; | ||
import io.github.emanual.app.entity.InterviewJSONEntity; | ||
import io.github.emanual.app.ui.adapter.InterviewListAdapter; | ||
import io.github.emanual.app.ui.base.fragment.BaseFragment; | ||
import io.github.emanual.app.ui.event.FinishQueryInterviewListEvent; | ||
import io.github.emanual.app.ui.event.QueryInterviewListEvent; | ||
import io.github.emanual.app.ui.event.UnPackFinishEvent; | ||
import io.github.emanual.app.utils.InterviewResource; | ||
import timber.log.Timber; | ||
|
||
/** | ||
* 面试笔试列表 | ||
* Author: jayin | ||
* Date: 2/24/16 | ||
*/ | ||
public class InterviewListFragment extends BaseFragment{ | ||
|
||
@Bind(R.id.recyclerView) RecyclerView recyclerView; | ||
|
||
@Override protected void initData(Bundle savedInstanceState) { | ||
|
||
} | ||
|
||
@Override protected void initLayout(Bundle savedInstanceState) { | ||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); | ||
EventBus.getDefault().post(new QueryInterviewListEvent()); | ||
} | ||
|
||
@Override protected int getContentViewId() { | ||
return R.layout.fragment_interview_list; | ||
} | ||
|
||
/** | ||
* 新书下载解压完成后更新书本列表 | ||
* @param event | ||
*/ | ||
@Subscribe(threadMode = ThreadMode.MainThread) | ||
public void onUnPackFinish(UnPackFinishEvent event){ | ||
EventBus.getDefault().post(new QueryInterviewListEvent()); | ||
} | ||
|
||
@Subscribe(threadMode = ThreadMode.Async) | ||
public void onQueryInterviewList(QueryInterviewListEvent event) { | ||
List<InterviewJSONEntity> interviewJSONEntities = InterviewResource.getInterviewJSONList(getContext()); | ||
EventBus.getDefault().post(new FinishQueryInterviewListEvent(interviewJSONEntities)); | ||
} | ||
|
||
@Subscribe(threadMode = ThreadMode.MainThread) | ||
public void onFinishQueryInterviewList(FinishQueryInterviewListEvent event) { | ||
Timber.d(event.getData().toString()); | ||
recyclerView.setAdapter(new InterviewListAdapter(getContext(), event.getData())); | ||
} | ||
|
||
} |
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
Oops, something went wrong.