20 | * @author zhou.wenkai ,Created on 2015-5-9 13:11:48 21 | * @Description Major Function:读取本地包内文件 22 | *
23 | * 注:如果您修改了本类请填写以下内容作为记录,如非本人操作劳烦通知,谢谢!!! 24 | * @author mender,Modified Date Modify Content: 25 | */ 26 | public class LocalFileUtils { 27 | 28 | /** 29 | * 获取Asset下文本内容 30 | * @param context 31 | * @param str 32 | * @return 33 | */ 34 | public final static String getStringFormAsset(Context context, String str) { 35 | BufferedReader in = null; 36 | try { 37 | in = new BufferedReader(new InputStreamReader(context.getAssets().open(str))); 38 | String line; 39 | StringBuilder buffer = new StringBuilder(); 40 | while ((line = in.readLine()) != null) { 41 | buffer.append(line).append('\n'); 42 | } 43 | return buffer.toString(); 44 | } catch (IOException e) { 45 | e.printStackTrace(); 46 | return ""; 47 | } finally { 48 | if (in != null) { 49 | try { 50 | in.close(); 51 | in = null; 52 | } catch (IOException e) { 53 | e.printStackTrace(); 54 | } 55 | } 56 | } 57 | } 58 | 59 | /** 60 | * @description 从Assets中读取图片 61 | * 62 | * @param context 63 | * @param fileName 64 | * @return 图片 65 | * @date 2015-6-11 15:00:55 66 | */ 67 | public static Bitmap getImageFromAssetsFile(Context context, String fileName) { 68 | Bitmap image = null; 69 | AssetManager am = context.getAssets(); 70 | InputStream is = null; 71 | try { 72 | is = am.open(fileName); 73 | image = BitmapFactory.decodeStream(is); 74 | return image; 75 | } catch (IOException e) { 76 | e.printStackTrace(); 77 | return image; 78 | } finally { 79 | if(is != null) { 80 | try { 81 | is.close(); 82 | is = null; 83 | } catch (IOException e) { 84 | e.printStackTrace(); 85 | } 86 | } 87 | } 88 | } 89 | 90 | /** 91 | * 获取Raw下文本内容 92 | * @param context 93 | * @param rawId 94 | * @return 95 | */ 96 | public final static String getStringFormRaw(Context context, int rawId) { 97 | ByteArrayOutputStream baos = null; 98 | InputStream in = context.getResources().openRawResource(rawId); 99 | try { 100 | baos = new ByteArrayOutputStream(); 101 | byte[] buffer = new byte[1024]; 102 | int len = 0; 103 | while ((len = in.read(buffer)) != -1) { 104 | baos.write(buffer, 0, len); 105 | } 106 | baos.close(); 107 | return baos.toString(); 108 | } catch (Exception e) { 109 | e.printStackTrace(); 110 | return ""; 111 | } finally { 112 | if (baos != null) { 113 | try { 114 | baos.close(); 115 | baos = null; 116 | } catch (IOException e) { 117 | e.printStackTrace(); 118 | } 119 | } 120 | } 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /AutoHome/src/main/java/com/kevin/pulltorefresh/autohome/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.autohome; 2 | 3 | import android.os.AsyncTask; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.FrameLayout; 12 | import android.widget.TextView; 13 | 14 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 15 | import com.handmark.pulltorefresh.library.extras.recyclerview.PullToRefreshRecyclerView; 16 | import com.kevin.loopview.AdLoopView; 17 | import com.kevin.pulltorefresh.autohome.loadinglayout.AutoHomeHeaderLayout; 18 | import com.kevin.wraprecyclerview.WrapAdapter; 19 | 20 | import java.util.Arrays; 21 | import java.util.LinkedList; 22 | 23 | /** 24 | * 版权所有:XXX有限公司 25 | * 26 | * MainActivity 27 | * 28 | * @author zhou.wenkai ,Created on 2015-12-22 9:04:49 29 | * @description Major Function:PullToRefresh框架之汽车之家刷新头部 30 | * 31 | * 注:如果您修改了本类请填写以下内容作为记录,如非本人操作劳烦通知,谢谢!!! 32 | * @author mender,Modified Date Modify Content: 33 | */ 34 | public class MainActivity extends AppCompatActivity { 35 | 36 | private String[] mStrings = { "Auto Home is a good website.", "There are a lot of friends who love cars."}; 37 | 38 | private PullToRefreshRecyclerView mPullToRefreshRecyclerView; 39 | private RecyclerView mRecyclerView; 40 | private LinkedList