Skip to content

Commit

Permalink
update recyclerview adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
zjlong committed May 31, 2016
1 parent 2be4476 commit 99af799
Show file tree
Hide file tree
Showing 65 changed files with 1,346 additions and 370 deletions.
4 changes: 2 additions & 2 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/src/main/java/com/zhoujinlong/AndroidApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.android.core.MainApp;
import com.android.core.model.control.LogicProxy;
import com.zhoujinlong.presenter.CompeteLogic;
import com.zhoujinlong.presenter.LoginLogic;
import com.zhoujinlong.presenter.MainLogic;

/**
* author miekoz on 2016/3/17.
Expand All @@ -16,6 +16,6 @@ public void onCreate() {
super.onCreate();

LogicProxy.getInstance().init(
LoginLogic.class, CompeteLogic.class);
LoginLogic.class, MainLogic.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.zhoujinlong.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.zhoujinlong.R;

import java.util.List;

/**
* @author: 蜡笔小新
* @date: 2016-05-31 14:15
* @GitHub: https://github.com/meikoz
*/
public class CustomViewPageAdapter extends PagerAdapter {
public List<Integer> comm_data_ls;
private Context context;
private View itemView;

public CustomViewPageAdapter(Context context, List<Integer> comm_data_ls) {
this.context = context;
this.comm_data_ls = comm_data_ls;
}

@Override
public int getCount() {
return comm_data_ls.size() > 0 ? comm_data_ls.size() == 1 ? 1 : Integer.MAX_VALUE : 0;
}

public Object instantiateItem(ViewGroup container, final int position) {
itemView = View.inflate(context, R.layout.item_viewpage_content, null);
ImageView imageView = ((ImageView) itemView.findViewById(R.id.image));
imageView.setBackgroundResource(comm_data_ls.get(position % comm_data_ls.size()));
container.addView(itemView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
return itemView;
}

@Override
public void destroyItem(ViewGroup container, int position, Object obj) {
// container.removeView(itemView);
}

public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == (arg1);
}
}
44 changes: 44 additions & 0 deletions app/src/main/java/com/zhoujinlong/adapter/HomeRecyclerAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.zhoujinlong.adapter;

import android.content.Context;
import android.net.Uri;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.widget.ImageView;

import com.android.core.adapter.RecyclerAdapter;
import com.android.core.adapter.RecyclerViewHolder;
import com.bumptech.glide.Glide;
import com.zhoujinlong.R;
import com.zhoujinlong.model.bean.Classify;
import com.zhoujinlong.ui.activity.SwipBackActivity;

import java.util.List;

/**
* @author: 蜡笔小新
* @date: 2016-05-31 14:15
* @GitHub: https://github.com/meikoz
*/
public class HomeRecyclerAdapter extends RecyclerAdapter<Classify.TngouEntity> {

private String URL_Base = "http://tnfs.tngou.net/image";

public HomeRecyclerAdapter(Context context, int layoutId, List<Classify.TngouEntity> datas) {
super(context, layoutId, datas);
}

@Override
public void convert(final RecyclerViewHolder holder, final Classify.TngouEntity item) {
Uri uri = Uri.parse(URL_Base + item.getImg());
Glide.with(mContext).load(uri).into((ImageView) holder.getView(R.id.sv_classitfy_img));
holder.setText(R.id.sv_classitfy_des, item.getTitle());
holder.setOnClickListener(R.id.sv_classitfy_img, new View.OnClickListener() {
@Override
public void onClick(View v) {
Snackbar.make(holder.getView(R.id.sv_classitfy_img), item.getTitle(), Snackbar.LENGTH_LONG).show();
SwipBackActivity.start(mContext);
}
});
}
}
5 changes: 3 additions & 2 deletions app/src/main/java/com/zhoujinlong/model/bean/Classify.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import java.util.List;

/**
* author meikoz on 2016/4/27.
* email [email protected]
* @author: 蜡笔小新
* @date: 2016-05-31 14:15
* @GitHub: https://github.com/meikoz
*/
public class Classify {
private boolean status;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.zhoujinlong.model.config;

/**
* author meikoz on 2016/4/19.
* email [email protected]
* @author: 蜡笔小新
* @date: 2016-05-31 14:15
* @GitHub: https://github.com/meikoz
*/
public interface ApiConstant {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.zhoujinlong.model.config;

/**
* author meikoz on 2016/3/30.
* email [email protected]
* @author: 蜡笔小新
* @date: 2016-05-31 14:15
* @GitHub: https://github.com/meikoz
*/
public class LocalStorage {
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
import retrofit2.http.Query;

/**
* author miekoz on 2016/3/17.
* email [email protected]
* @author: 蜡笔小新
* @date: 2016-05-31 14:15
* @GitHub: https://github.com/meikoz
*/
public interface BaseHttpService {


@Headers("Cache-Control: public, max-age=3600")
@GET("tnfs/api/list")
Call<Classify> getImageClassify(@Query("id") int id);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.zhoujinlong.model.http;

/**
* author meikoz on 2016/4/26.
* email [email protected]
* @author: 蜡笔小新
* @date: 2016-05-31 14:15
* @GitHub: https://github.com/meikoz
*/
public interface BaseUserService {
}
5 changes: 3 additions & 2 deletions app/src/main/java/com/zhoujinlong/model/http/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@


/**
* author miekoz on 2016/3/21.
* email [email protected]
* @author: 蜡笔小新
* @date: 2016-05-31 14:15
* @GitHub: https://github.com/meikoz
*/
public class Factory {

Expand Down
19 changes: 0 additions & 19 deletions app/src/main/java/com/zhoujinlong/presenter/CompeteLogic.java

This file was deleted.

7 changes: 1 addition & 6 deletions app/src/main/java/com/zhoujinlong/presenter/LoginLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
import com.android.core.model.annotation.Implement;
import com.android.core.model.control.BaseLogic;
import com.zhoujinlong.presenter.impl.LoginLogicImpl;
import com.zhoujinlong.ui.view.LoginView;
import com.zhoujinlong.presenter.view.LoginView;


/**
* author meikoz on 2016/4/13.
* email [email protected]
*/

@Implement(LoginLogicImpl.class)
public interface LoginLogic extends BaseLogic<LoginView> {

Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/zhoujinlong/presenter/MainLogic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.zhoujinlong.presenter;

import com.android.core.model.annotation.Implement;
import com.zhoujinlong.presenter.impl.MainLogicImpl;

/**
* @author: 蜡笔小新
* @date: 2016-05-31 12:03
* @GitHub: https://github.com/meikoz
*/
@Implement(MainLogicImpl.class)
public interface MainLogic {
void onLoadRemoteData(boolean isMore, int page);
}
13 changes: 13 additions & 0 deletions app/src/main/java/com/zhoujinlong/presenter/base/CommonView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.zhoujinlong.presenter.base;

/**
* @author: 蜡笔小新
* @date: 2016-05-31 11:47
* @GitHub: https://github.com/meikoz
*/
public interface CommonView<T> {

void onLoadComplete();

void onShowListData(T response, boolean isMore);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.zhoujinlong.presenter.base;

import com.android.core.model.control.BaseLogic;

import retrofit2.Response;

/**
* @author: 蜡笔小新
* @date: 2016-05-31 14:39
* @GitHub: https://github.com/meikoz
*/
public interface LoadSuccessLogic<T> extends BaseLogic<CommonView<T>> {

void onLoadListSuccessHandle(Response<T> response, boolean isMore);

void onLoadFail(String msg);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.zhoujinlong.presenter.base;

import retrofit2.Response;

/**
* @author: 蜡笔小新
* @date: 2016-05-31 11:51
* @GitHub: https://github.com/meikoz
*/
public class LoadSuccessLogicImpl<T> implements LoadSuccessLogic<T> {

CommonView view;

/**
* 处理获取列表成功回调的公共函数
*
* @param response
* @param isMore
*/
public void onLoadListSuccessHandle(Response<T> response, boolean isMore) {
view.onLoadComplete();
T body = response.body();
if (body != null) {
view.onShowListData(body, isMore);
}
// else {
// if (isMore) {
// //加载更多 Toast "没有更多数据"
// } else {
//// Toast "没有更多数据"
// }
// }
}

@Override
public void onLoadFail(String msg) {
//提示请求失败
}

@Override
public void attachView(CommonView<T> v) {
view = v;
}
}

This file was deleted.

Loading

0 comments on commit 99af799

Please sign in to comment.