├── .gitignore ├── README.md ├── blog ├── .gitignore ├── build.gradle ├── libs │ └── GDTUnionSDK.4.9.543.min.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── landptf │ │ └── blog │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── littlelucky.mp3 │ ├── java │ │ └── com │ │ │ └── landptf │ │ │ └── blog │ │ │ ├── BaseActivity.java │ │ │ ├── BlogApplication.java │ │ │ ├── Constants.java │ │ │ ├── MainActivity.java │ │ │ ├── MainFragment.java │ │ │ ├── activitylifecycle │ │ │ ├── ActivityA.java │ │ │ └── ActivityB.java │ │ │ ├── audiofocus │ │ │ └── MediaActivity.java │ │ │ ├── database │ │ │ ├── DataBaseManager.java │ │ │ ├── bean │ │ │ │ └── User.java │ │ │ └── gen │ │ │ │ ├── DaoMaster.java │ │ │ │ ├── DaoSession.java │ │ │ │ └── UserDao.java │ │ │ ├── picasso │ │ │ └── PicassoActivity.java │ │ │ └── splash │ │ │ └── SplashFragment.java │ └── res │ │ ├── drawable │ │ └── background_circle.xml │ │ ├── layout │ │ ├── activity_a.xml │ │ ├── activity_b.xml │ │ ├── activity_main.xml │ │ ├── activity_media.xml │ │ ├── activity_picasso.xml │ │ ├── fragment_main.xml │ │ └── fragment_splash.xml │ │ ├── mipmap-hdpi │ │ ├── default_image.png │ │ ├── ic_launcher.png │ │ └── splash_logo.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── splash_holder.jpg │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── landptf │ └── blog │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | **/build/* 8 | /captures 9 | /.idea/* 10 | /.gradle/* 11 | *.txt 12 | *.apk 13 | **/gradle/* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 博客专用演示代码 2 | *** 3 | [CSDN主页](http://blog.csdn.net/wangjihuanghun) 4 | 5 | [开源中国主页](https://my.oschina.net/landptf/blog) 6 | 7 | [简书主页](http://www.jianshu.com/u/aad15cb6f55c) 8 | 9 | -------------------------------------------------------------------------------- /blog/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /blog/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'org.greenrobot.greendao' 3 | apply plugin: 'me.tatarka.retrolambda' 4 | 5 | android { 6 | compileSdkVersion 23 7 | buildToolsVersion "23.0.3" 8 | 9 | defaultConfig { 10 | applicationId "com.landptf.blog" 11 | minSdkVersion 11 12 | targetSdkVersion 23 13 | versionCode 1 14 | versionName "1.0" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | 28 | greendao { 29 | schemaVersion 1 30 | daoPackage 'com.landptf.blog.database.gen' 31 | targetGenDir 'src/main/java' 32 | } 33 | } 34 | 35 | dependencies { 36 | compile fileTree(include: ['*.jar'], dir: 'libs') 37 | testCompile 'junit:junit:4.12' 38 | compile files('libs/GDTUnionSDK.4.9.543.min.jar') 39 | compile 'com.android.support:appcompat-v7:23.4.0' 40 | compile 'com.landptf:landptf:1.0.2' 41 | compile 'org.greenrobot:greendao:3.2.0' 42 | compile 'com.squareup.picasso:picasso:2.5.2' 43 | compile 'com.squareup.okhttp3:okhttp:3.6.0' 44 | compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.8.1' 45 | compile 'com.android.support:support-v4:23.4.0' 46 | compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.3@aar' 47 | compile 'io.reactivex.rxjava2:rxjava:2.0.3' 48 | } 49 | -------------------------------------------------------------------------------- /blog/libs/GDTUnionSDK.4.9.543.min.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landptf/BlogDemo/9ecc54d74e175b748a67aa169d4f41581ce660b4/blog/libs/GDTUnionSDK.4.9.543.min.jar -------------------------------------------------------------------------------- /blog/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/liyulong/Documents/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /blog/src/androidTest/java/com/landptf/blog/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /blog/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 20 | 21 | 24 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /blog/src/main/assets/littlelucky.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landptf/BlogDemo/9ecc54d74e175b748a67aa169d4f41581ce660b4/blog/src/main/assets/littlelucky.mp3 -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog; 2 | 3 | import android.content.Intent; 4 | import android.content.res.Configuration; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | import android.util.Log; 8 | 9 | public class BaseActivity extends AppCompatActivity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | Log.e(this.getClass().getSimpleName(), "onCreate()"); 15 | } 16 | 17 | @Override 18 | protected void onStart() { 19 | super.onStart(); 20 | Log.e(this.getClass().getSimpleName(), "onStart()"); 21 | } 22 | 23 | @Override 24 | protected void onNewIntent(Intent intent) { 25 | super.onNewIntent(intent); 26 | Log.e(this.getClass().getSimpleName(), "onNewIntent()"); 27 | } 28 | 29 | @Override 30 | protected void onRestoreInstanceState(Bundle savedInstanceState) { 31 | super.onRestoreInstanceState(savedInstanceState); 32 | Log.e(this.getClass().getSimpleName(), "onRestoreInstanceState()"); 33 | } 34 | 35 | @Override 36 | public void onConfigurationChanged(Configuration newConfig) { 37 | super.onConfigurationChanged(newConfig); 38 | Log.e(this.getClass().getSimpleName(), "onConfigurationChanged()"); 39 | } 40 | 41 | @Override 42 | protected void onRestart() { 43 | super.onRestart(); 44 | Log.e(this.getClass().getSimpleName(), "onRestart()"); 45 | } 46 | 47 | @Override 48 | protected void onResume() { 49 | super.onResume(); 50 | Log.e(this.getClass().getSimpleName(), "onResume()"); 51 | } 52 | 53 | @Override 54 | protected void onPause() { 55 | super.onPause(); 56 | Log.e(this.getClass().getSimpleName(), "onPause()"); 57 | } 58 | 59 | @Override 60 | protected void onSaveInstanceState(Bundle outState) { 61 | super.onSaveInstanceState(outState); 62 | Log.e(this.getClass().getSimpleName(), "onSaveInstanceState()"); 63 | } 64 | 65 | @Override 66 | protected void onStop() { 67 | super.onStop(); 68 | Log.e(this.getClass().getSimpleName(), "onStop()"); 69 | } 70 | 71 | @Override 72 | protected void onDestroy() { 73 | super.onDestroy(); 74 | Log.e(this.getClass().getSimpleName(), "onDestroy()"); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/BlogApplication.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | /** 7 | * Created by liyulong on 2017/3/11. 8 | */ 9 | public class BlogApplication extends Application { 10 | private static Context mContext; 11 | 12 | @Override 13 | public void onCreate() { 14 | super.onCreate(); 15 | mContext = getApplicationContext(); 16 | } 17 | 18 | public static Context getContext() { 19 | return mContext; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/Constants.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog; 2 | 3 | public class Constants { 4 | // public static final String APPID = "1105972269"; 5 | // public static final String SplashPosID = "1070620182465027"; 6 | public static final String APPID = "1101152570"; 7 | public static final String SplashPosID = "8863364436303842593"; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.app.FragmentActivity; 6 | import android.support.v4.app.FragmentManager; 7 | import android.support.v7.app.AppCompatActivity; 8 | 9 | import com.landptf.blog.splash.SplashFragment; 10 | 11 | /** 12 | * Created by landptf on 2017/03/18. 13 | * 主页面,包含了SplashFragment和MainFragment 14 | */ 15 | public class MainActivity extends AppCompatActivity { 16 | 17 | private FragmentManager frManager; 18 | private SplashFragment fmSplash; 19 | private MainFragment fmMain; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_main); 25 | initView(); 26 | } 27 | 28 | private void initView() { 29 | frManager = getSupportFragmentManager(); 30 | fmSplash = (SplashFragment) frManager.findFragmentById(R.id.fm_splash); 31 | fmMain = (MainFragment) frManager.findFragmentById(R.id.fm_main); 32 | showSplash(); 33 | } 34 | 35 | private void showSplash(){ 36 | frManager.beginTransaction().hide(fmMain).show(fmSplash).commit(); 37 | } 38 | 39 | public void dismissSplash(){ 40 | frManager.beginTransaction().hide(fmSplash).show(fmMain).commitAllowingStateLoss(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/MainFragment.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.support.v4.app.FragmentActivity; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.support.v7.widget.Toolbar; 10 | import android.util.Log; 11 | import android.view.LayoutInflater; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | 15 | import com.landptf.blog.activitylifecycle.ActivityA; 16 | import com.landptf.blog.audiofocus.MediaActivity; 17 | import com.landptf.blog.picasso.PicassoActivity; 18 | import com.landptf.view.ButtonM; 19 | 20 | public class MainFragment extends Fragment { 21 | private static final String TAG = MainFragment.class.getSimpleName(); 22 | 23 | @Override 24 | public void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | } 27 | 28 | @Override 29 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 30 | Bundle savedInstanceState) { 31 | return inflater.inflate(R.layout.fragment_main, container, false); 32 | } 33 | 34 | @Override 35 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 36 | super.onActivityCreated(savedInstanceState); 37 | initView(getActivity()); 38 | testThread(); 39 | } 40 | 41 | /** 42 | * 模拟后台耗时操作 43 | */ 44 | private void testThread(){ 45 | new Thread(() -> { 46 | int i = 0; 47 | while (i < 5) { 48 | try { 49 | Thread.sleep(1000); 50 | } catch (InterruptedException e) { 51 | e.printStackTrace(); 52 | } 53 | Log.e(TAG, "--- " + i + " ---"); 54 | i++; 55 | } 56 | }).start(); 57 | } 58 | 59 | private void initView(final FragmentActivity activity) { 60 | Toolbar tbMain = (Toolbar) activity.findViewById(R.id.tb_main); 61 | ((AppCompatActivity)activity).setSupportActionBar(tbMain); 62 | tbMain.setTitleTextColor(getResources().getColor(android.R.color.white)); 63 | 64 | ButtonM btmActivityLifeCycle = (ButtonM) activity.findViewById(R.id.btm_activity_life_cycle); 65 | if (btmActivityLifeCycle != null) { 66 | btmActivityLifeCycle.setOnClickListener(v -> startActivity(new Intent(activity, ActivityA.class))); 67 | } 68 | 69 | ButtonM btmAudioFocus = (ButtonM) activity.findViewById(R.id.btm_audio_focus); 70 | if(btmAudioFocus != null){ 71 | btmAudioFocus.setOnClickListener(v -> startActivity(new Intent(activity, MediaActivity.class))); 72 | } 73 | 74 | ButtonM btmPicasso = (ButtonM) activity.findViewById(R.id.btm_picasso); 75 | if(btmPicasso != null){ 76 | btmPicasso.setOnClickListener(v -> startActivity(new Intent(activity, PicassoActivity.class))); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/activitylifecycle/ActivityA.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog.activitylifecycle; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | import android.view.View; 7 | 8 | import com.landptf.blog.BaseActivity; 9 | import com.landptf.blog.R; 10 | import com.landptf.view.ButtonM; 11 | 12 | public class ActivityA extends BaseActivity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_a); 18 | initView(); 19 | } 20 | 21 | private void initView() { 22 | ButtonM btmStartActivity = (ButtonM) findViewById(R.id.btm_start_activity); 23 | if (btmStartActivity != null) { 24 | btmStartActivity.setOnClickListener(new View.OnClickListener() { 25 | @Override 26 | public void onClick(View v) { 27 | startActivity(new Intent(ActivityA.this, ActivityB.class)); 28 | } 29 | }); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/activitylifecycle/ActivityB.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog.activitylifecycle; 2 | 3 | import android.content.Intent; 4 | import android.graphics.Color; 5 | import android.graphics.drawable.ColorDrawable; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | 9 | import com.landptf.blog.BaseActivity; 10 | import com.landptf.blog.R; 11 | import com.landptf.view.ButtonM; 12 | 13 | public class ActivityB extends BaseActivity { 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_b); 19 | // getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 20 | initView(); 21 | } 22 | 23 | private void initView() { 24 | ButtonM btmStartActivity = (ButtonM) findViewById(R.id.btm_start_activity); 25 | if (btmStartActivity != null) { 26 | btmStartActivity.setOnClickListener(new View.OnClickListener() { 27 | @Override 28 | public void onClick(View v) { 29 | startActivity(new Intent(ActivityB.this, ActivityA.class)); 30 | } 31 | }); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/audiofocus/MediaActivity.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog.audiofocus; 2 | 3 | import android.content.Context; 4 | import android.content.res.AssetFileDescriptor; 5 | import android.media.AudioManager; 6 | import android.media.MediaPlayer; 7 | import android.provider.MediaStore; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.os.Bundle; 10 | import android.util.Log; 11 | import android.view.View; 12 | 13 | import com.landptf.blog.R; 14 | import com.landptf.view.ButtonM; 15 | 16 | import java.io.FileDescriptor; 17 | import java.io.IOException; 18 | 19 | /** 20 | * Created by landptf on 2017/01/08. 21 | * 本文旨在焦点管理的演示,涉及到的MediaPlayer播放音乐流程请自行查询相关文档,不在本文介绍范围 22 | * 通过MediaPlayer播放一首《小幸运》来作为测试实例 23 | */ 24 | public class MediaActivity extends AppCompatActivity { 25 | private final String TAG = MediaActivity.this.getClass().getSimpleName(); 26 | 27 | private AudioManager mAudioManager; 28 | private MediaPlayer mMediaPlayer; 29 | private ButtonM btmMusic; 30 | 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | setContentView(R.layout.activity_media); 35 | initData(); 36 | initView(); 37 | } 38 | 39 | private void initData() { 40 | //初始化AudioManager对象 41 | mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); 42 | //申请焦点 43 | mAudioManager.requestAudioFocus(mAudioFocusChange, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT); 44 | AssetFileDescriptor fileDescriptor; 45 | try { 46 | //获取音频文件 47 | fileDescriptor = this.getAssets().openFd("littlelucky.mp3"); 48 | //实例化MediaPlayer对象 49 | mMediaPlayer = new MediaPlayer(); 50 | //设置播放流类型 51 | mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 52 | //设置播放源,有多个参数可以选择,具体参考相关文档,本文旨在介绍音频焦点 53 | mMediaPlayer.setDataSource(fileDescriptor.getFileDescriptor(), 54 | fileDescriptor.getStartOffset(), 55 | fileDescriptor.getLength()); 56 | //设置循环播放 57 | mMediaPlayer.setLooping(true); 58 | //准备监听 59 | mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 60 | @Override 61 | public void onPrepared(MediaPlayer mp) { 62 | //准备完成后自动播放 63 | mMediaPlayer.start(); 64 | } 65 | }); 66 | //异步准备 67 | mMediaPlayer.prepareAsync(); 68 | } catch (IOException e) { 69 | e.printStackTrace(); 70 | } 71 | } 72 | 73 | private void initView() { 74 | btmMusic = (ButtonM) findViewById(R.id.btm_music); 75 | if (btmMusic != null){ 76 | btmMusic.setOnClickListener(new View.OnClickListener() { 77 | @Override 78 | public void onClick(View v) { 79 | if (mMediaPlayer != null){ 80 | if (mMediaPlayer.isPlaying()){ 81 | stop(); 82 | } else { 83 | start(); 84 | } 85 | } 86 | } 87 | }); 88 | } 89 | } 90 | 91 | private void start() { 92 | btmMusic.setText("Stop"); 93 | mAudioManager.requestAudioFocus(mAudioFocusChange, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); 94 | mMediaPlayer.start(); 95 | } 96 | 97 | private void stop() { 98 | btmMusic.setText("Start"); 99 | mMediaPlayer.pause(); 100 | 101 | } 102 | 103 | /** 104 | * 焦点变化监听器 105 | */ 106 | private AudioManager.OnAudioFocusChangeListener mAudioFocusChange = new AudioManager.OnAudioFocusChangeListener() { 107 | @Override 108 | public void onAudioFocusChange(int focusChange) { 109 | switch (focusChange){ 110 | case AudioManager.AUDIOFOCUS_LOSS: 111 | //长时间丢失焦点 112 | Log.d(TAG, "AUDIOFOCUS_LOSS"); 113 | stop(); 114 | //释放焦点 115 | mAudioManager.abandonAudioFocus(mAudioFocusChange); 116 | break; 117 | case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: 118 | //短暂性丢失焦点 119 | stop(); 120 | Log.d(TAG, "AUDIOFOCUS_LOSS_TRANSIENT"); 121 | break; 122 | case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: 123 | //短暂性丢失焦点并作降音处理 124 | Log.d(TAG, "AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK"); 125 | break; 126 | case AudioManager.AUDIOFOCUS_GAIN: 127 | //重新获得焦点 128 | Log.d(TAG, "AUDIOFOCUS_GAIN"); 129 | start(); 130 | break; 131 | } 132 | } 133 | }; 134 | 135 | @Override 136 | protected void onDestroy() { 137 | super.onDestroy(); 138 | mMediaPlayer.release(); 139 | mAudioManager.abandonAudioFocus(mAudioFocusChange); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/database/DataBaseManager.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog.database; 2 | 3 | import com.landptf.blog.BlogApplication; 4 | import com.landptf.blog.database.gen.DaoMaster; 5 | import com.landptf.blog.database.gen.DaoSession; 6 | 7 | /** 8 | * Created by landptf on 2017/3/11. 9 | * Data Manager 10 | */ 11 | public class DataBaseManager { 12 | 13 | private static DataBaseManager instance; 14 | 15 | private DaoMaster daoMaster; 16 | private DaoSession daoSession; 17 | private DaoMaster.DevOpenHelper devOpenHelper; 18 | 19 | private DataBaseManager(){ 20 | devOpenHelper = new DaoMaster.DevOpenHelper(BlogApplication.getContext(), "landptf", null); 21 | daoMaster = new DaoMaster(devOpenHelper.getWritableDatabase()); 22 | daoSession = daoMaster.newSession(); 23 | } 24 | 25 | public static DataBaseManager getInstance(){ 26 | if (instance == null) { 27 | synchronized (DataBaseManager.class) { 28 | if (instance == null) { 29 | instance = new DataBaseManager(); 30 | } 31 | } 32 | } 33 | return instance; 34 | } 35 | 36 | public DaoMaster getDaoMaster() { 37 | return daoMaster; 38 | } 39 | 40 | public DaoSession getDaoSession() { 41 | return daoSession; 42 | } 43 | 44 | /** 45 | * 关闭数据连接 46 | */ 47 | public void close() { 48 | if (devOpenHelper != null) { 49 | devOpenHelper.close(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/database/bean/User.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog.database.bean; 2 | 3 | import org.greenrobot.greendao.annotation.Entity; 4 | import org.greenrobot.greendao.annotation.Id; 5 | import org.greenrobot.greendao.annotation.NotNull; 6 | import org.greenrobot.greendao.annotation.Generated; 7 | 8 | /** 9 | * Created by liyulong on 2017/3/11. 10 | */ 11 | @Entity 12 | public class User { 13 | @Id 14 | private String uerId; 15 | @NotNull 16 | private String userName; 17 | private int password; 18 | @Generated(hash = 1346109477) 19 | public User(String uerId, @NotNull String userName, int password) { 20 | this.uerId = uerId; 21 | this.userName = userName; 22 | this.password = password; 23 | } 24 | @Generated(hash = 586692638) 25 | public User() { 26 | } 27 | public String getUerId() { 28 | return this.uerId; 29 | } 30 | public void setUerId(String uerId) { 31 | this.uerId = uerId; 32 | } 33 | public String getUserName() { 34 | return this.userName; 35 | } 36 | public void setUserName(String userName) { 37 | this.userName = userName; 38 | } 39 | public int getPassword() { 40 | return this.password; 41 | } 42 | public void setPassword(int password) { 43 | this.password = password; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/database/gen/DaoMaster.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog.database.gen; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteDatabase.CursorFactory; 6 | import android.util.Log; 7 | 8 | import org.greenrobot.greendao.AbstractDaoMaster; 9 | import org.greenrobot.greendao.database.StandardDatabase; 10 | import org.greenrobot.greendao.database.Database; 11 | import org.greenrobot.greendao.database.DatabaseOpenHelper; 12 | import org.greenrobot.greendao.identityscope.IdentityScopeType; 13 | 14 | 15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 16 | /** 17 | * Master of DAO (schema version 1): knows all DAOs. 18 | */ 19 | public class DaoMaster extends AbstractDaoMaster { 20 | public static final int SCHEMA_VERSION = 1; 21 | 22 | /** Creates underlying database table using DAOs. */ 23 | public static void createAllTables(Database db, boolean ifNotExists) { 24 | UserDao.createTable(db, ifNotExists); 25 | } 26 | 27 | /** Drops underlying database table using DAOs. */ 28 | public static void dropAllTables(Database db, boolean ifExists) { 29 | UserDao.dropTable(db, ifExists); 30 | } 31 | 32 | /** 33 | * WARNING: Drops all table on Upgrade! Use only during development. 34 | * Convenience method using a {@link DevOpenHelper}. 35 | */ 36 | public static DaoSession newDevSession(Context context, String name) { 37 | Database db = new DevOpenHelper(context, name).getWritableDb(); 38 | DaoMaster daoMaster = new DaoMaster(db); 39 | return daoMaster.newSession(); 40 | } 41 | 42 | public DaoMaster(SQLiteDatabase db) { 43 | this(new StandardDatabase(db)); 44 | } 45 | 46 | public DaoMaster(Database db) { 47 | super(db, SCHEMA_VERSION); 48 | registerDaoClass(UserDao.class); 49 | } 50 | 51 | public DaoSession newSession() { 52 | return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); 53 | } 54 | 55 | public DaoSession newSession(IdentityScopeType type) { 56 | return new DaoSession(db, type, daoConfigMap); 57 | } 58 | 59 | /** 60 | * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - 61 | */ 62 | public static abstract class OpenHelper extends DatabaseOpenHelper { 63 | public OpenHelper(Context context, String name) { 64 | super(context, name, SCHEMA_VERSION); 65 | } 66 | 67 | public OpenHelper(Context context, String name, CursorFactory factory) { 68 | super(context, name, factory, SCHEMA_VERSION); 69 | } 70 | 71 | @Override 72 | public void onCreate(Database db) { 73 | Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); 74 | createAllTables(db, false); 75 | } 76 | } 77 | 78 | /** WARNING: Drops all table on Upgrade! Use only during development. */ 79 | public static class DevOpenHelper extends OpenHelper { 80 | public DevOpenHelper(Context context, String name) { 81 | super(context, name); 82 | } 83 | 84 | public DevOpenHelper(Context context, String name, CursorFactory factory) { 85 | super(context, name, factory); 86 | } 87 | 88 | @Override 89 | public void onUpgrade(Database db, int oldVersion, int newVersion) { 90 | Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); 91 | dropAllTables(db, true); 92 | onCreate(db); 93 | } 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/database/gen/DaoSession.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog.database.gen; 2 | 3 | import java.util.Map; 4 | 5 | import org.greenrobot.greendao.AbstractDao; 6 | import org.greenrobot.greendao.AbstractDaoSession; 7 | import org.greenrobot.greendao.database.Database; 8 | import org.greenrobot.greendao.identityscope.IdentityScopeType; 9 | import org.greenrobot.greendao.internal.DaoConfig; 10 | 11 | import com.landptf.blog.database.bean.User; 12 | 13 | import com.landptf.blog.database.gen.UserDao; 14 | 15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 16 | 17 | /** 18 | * {@inheritDoc} 19 | * 20 | * @see org.greenrobot.greendao.AbstractDaoSession 21 | */ 22 | public class DaoSession extends AbstractDaoSession { 23 | 24 | private final DaoConfig userDaoConfig; 25 | 26 | private final UserDao userDao; 27 | 28 | public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> 29 | daoConfigMap) { 30 | super(db); 31 | 32 | userDaoConfig = daoConfigMap.get(UserDao.class).clone(); 33 | userDaoConfig.initIdentityScope(type); 34 | 35 | userDao = new UserDao(userDaoConfig, this); 36 | 37 | registerDao(User.class, userDao); 38 | } 39 | 40 | public void clear() { 41 | userDaoConfig.clearIdentityScope(); 42 | } 43 | 44 | public UserDao getUserDao() { 45 | return userDao; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/database/gen/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog.database.gen; 2 | 3 | import android.database.Cursor; 4 | import android.database.sqlite.SQLiteStatement; 5 | 6 | import org.greenrobot.greendao.AbstractDao; 7 | import org.greenrobot.greendao.Property; 8 | import org.greenrobot.greendao.internal.DaoConfig; 9 | import org.greenrobot.greendao.database.Database; 10 | import org.greenrobot.greendao.database.DatabaseStatement; 11 | 12 | import com.landptf.blog.database.bean.User; 13 | 14 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 15 | /** 16 | * DAO for table "USER". 17 | */ 18 | public class UserDao extends AbstractDao { 19 | 20 | public static final String TABLENAME = "USER"; 21 | 22 | /** 23 | * Properties of entity User.
24 | * Can be used for QueryBuilder and for referencing column names. 25 | */ 26 | public static class Properties { 27 | public final static Property UerId = new Property(0, String.class, "uerId", true, "UER_ID"); 28 | public final static Property UserName = new Property(1, String.class, "userName", false, "USER_NAME"); 29 | public final static Property Password = new Property(2, int.class, "password", false, "PASSWORD"); 30 | } 31 | 32 | 33 | public UserDao(DaoConfig config) { 34 | super(config); 35 | } 36 | 37 | public UserDao(DaoConfig config, DaoSession daoSession) { 38 | super(config, daoSession); 39 | } 40 | 41 | /** Creates the underlying database table. */ 42 | public static void createTable(Database db, boolean ifNotExists) { 43 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; 44 | db.execSQL("CREATE TABLE " + constraint + "\"USER\" (" + // 45 | "\"UER_ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: uerId 46 | "\"USER_NAME\" TEXT NOT NULL ," + // 1: userName 47 | "\"PASSWORD\" INTEGER NOT NULL );"); // 2: password 48 | } 49 | 50 | /** Drops the underlying database table. */ 51 | public static void dropTable(Database db, boolean ifExists) { 52 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"USER\""; 53 | db.execSQL(sql); 54 | } 55 | 56 | @Override 57 | protected final void bindValues(DatabaseStatement stmt, User entity) { 58 | stmt.clearBindings(); 59 | 60 | String uerId = entity.getUerId(); 61 | if (uerId != null) { 62 | stmt.bindString(1, uerId); 63 | } 64 | stmt.bindString(2, entity.getUserName()); 65 | stmt.bindLong(3, entity.getPassword()); 66 | } 67 | 68 | @Override 69 | protected final void bindValues(SQLiteStatement stmt, User entity) { 70 | stmt.clearBindings(); 71 | 72 | String uerId = entity.getUerId(); 73 | if (uerId != null) { 74 | stmt.bindString(1, uerId); 75 | } 76 | stmt.bindString(2, entity.getUserName()); 77 | stmt.bindLong(3, entity.getPassword()); 78 | } 79 | 80 | @Override 81 | public String readKey(Cursor cursor, int offset) { 82 | return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0); 83 | } 84 | 85 | @Override 86 | public User readEntity(Cursor cursor, int offset) { 87 | User entity = new User( // 88 | cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // uerId 89 | cursor.getString(offset + 1), // userName 90 | cursor.getInt(offset + 2) // password 91 | ); 92 | return entity; 93 | } 94 | 95 | @Override 96 | public void readEntity(Cursor cursor, User entity, int offset) { 97 | entity.setUerId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0)); 98 | entity.setUserName(cursor.getString(offset + 1)); 99 | entity.setPassword(cursor.getInt(offset + 2)); 100 | } 101 | 102 | @Override 103 | protected final String updateKeyAfterInsert(User entity, long rowId) { 104 | return entity.getUerId(); 105 | } 106 | 107 | @Override 108 | public String getKey(User entity) { 109 | if(entity != null) { 110 | return entity.getUerId(); 111 | } else { 112 | return null; 113 | } 114 | } 115 | 116 | @Override 117 | public boolean hasKey(User entity) { 118 | return entity.getUerId() != null; 119 | } 120 | 121 | @Override 122 | protected final boolean isEntityUpdateable() { 123 | return true; 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/picasso/PicassoActivity.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog.picasso; 2 | 3 | import android.graphics.Bitmap; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.os.Handler; 7 | import android.os.Message; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.widget.ImageView; 10 | 11 | import com.landptf.blog.R; 12 | import com.squareup.picasso.Callback; 13 | import com.squareup.picasso.Picasso; 14 | import com.squareup.picasso.Request; 15 | 16 | import java.io.IOException; 17 | 18 | public class PicassoActivity extends AppCompatActivity { 19 | private static final String imageUrl = "http://upload-images.jianshu.io/upload_images/589909-e339eb2763fa172c.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"; 20 | private ImageView imageView; 21 | 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_picasso); 27 | initView(); 28 | } 29 | 30 | private void initView() { 31 | imageView = (ImageView) findViewById(R.id.imageView); 32 | //设置图片来源指示图标 33 | Picasso.with(this).setIndicatorsEnabled(true); 34 | //从网络加载 35 | Picasso.with(this).load(imageUrl).into(imageView); 36 | 37 | //从res中加载 38 | //Picasso.with(this).load(R.mipmap.default_image).into(imageView); 39 | 40 | //加载过程中显示默认图片 41 | //Picasso.with(this).load(imageUrl).placeholder(R.mipmap.default_image).into(imageView); 42 | 43 | //加载失败后显示错误的图片 44 | //Picasso.with(this).load(imageUrl+"landptf").error(R.mipmap.default_image).into(imageView); 45 | 46 | //fit 47 | //Picasso.with(this).load(imageUrl).fit().into(imageView); 48 | //centerCrop 49 | //Picasso.with(this).load(imageUrl).resize(320, 640).centerCrop().into(imageView); 50 | //centerInside 51 | //Picasso.with(this).load(imageUrl).resize(320, 640).centerInside().into(imageView); 52 | //onlyScaleDown 53 | //Picasso.with(this).load(imageUrl).resize(3000, 1563).onlyScaleDown().into(imageView); 54 | 55 | //取消图片显示的过度效果 56 | //Picasso.with(this).load(imageUrl).noFade().into(imageView); 57 | 58 | //顺时针旋转 59 | //Picasso.with(this).load(imageUrl).rotate(45).into(imageView); 60 | 61 | //跳过从内存加载图片,并且图片下载之后也不在内存中进行缓存 62 | // Picasso.with(this) 63 | // .load(imageUrl) 64 | // .skipMemoryCache() 65 | // .into(imageView); 66 | // 67 | // Picasso.with(this) 68 | // .load(imageUrl) 69 | // .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) 70 | // .into(imageView); 71 | 72 | //跳过从磁盘加载图片,并且图片下载之后也不在磁盘中进行缓存 73 | // Picasso.with(this) 74 | // .load(imageUrl) 75 | // .networkPolicy(NetworkPolicy.OFFLINE) 76 | // .into(imageView); 77 | //优先级 78 | //Picasso.with(this).load(imageUrl).priority(Picasso.Priority.HIGH).into(imageView); 79 | 80 | //tag管理 81 | //Picasso.with(this).load(imageUrl).tag("landptf").into(imageView); 82 | //Picasso.with(this).pauseTag("landptf"); 83 | //Picasso.with(this).resumeTag("landptf"); 84 | //Picasso.with(this).cancelTag("landptf"); 85 | 86 | //手动指定key值 87 | //Picasso.with(this).load(imageUrl).stableKey("landptf").into(imageView); 88 | 89 | //同步加载图片 90 | // new Thread(new Runnable() { 91 | // @Override 92 | // public void run() { 93 | // try { 94 | // Bitmap bitmap = Picasso.with(PicassoActivity.this).load(imageUrl).get(); 95 | // handler.obtainMessage(0, bitmap).sendToTarget(); 96 | // } catch (IOException e) { 97 | // e.printStackTrace(); 98 | // } 99 | // } 100 | // }).start(); 101 | 102 | //异步加载图片 103 | //Picasso.with(PicassoActivity.this).load(imageUrl).fetch(); 104 | 105 | // Picasso.with(PicassoActivity.this).load(imageUrl).fetch(new Callback() { 106 | // @Override 107 | // public void onSuccess() { 108 | // 109 | // } 110 | // 111 | // @Override 112 | // public void onError() { 113 | // 114 | // } 115 | // }); 116 | } 117 | 118 | // private Handler handler = new Handler(){ 119 | // @Override 120 | // public void handleMessage(Message msg) { 121 | // super.handleMessage(msg); 122 | // switch (msg.what){ 123 | // case 0: 124 | // imageView.setImageBitmap((Bitmap) msg.obj); 125 | // break; 126 | // } 127 | // } 128 | // }; 129 | } 130 | -------------------------------------------------------------------------------- /blog/src/main/java/com/landptf/blog/splash/SplashFragment.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog.splash; 2 | 3 | import android.Manifest; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.util.Log; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.ImageView; 12 | import android.widget.TextView; 13 | 14 | import com.landptf.blog.Constants; 15 | import com.landptf.blog.MainActivity; 16 | import com.landptf.blog.R; 17 | import com.qq.e.ads.splash.SplashAD; 18 | import com.qq.e.ads.splash.SplashADListener; 19 | import com.tbruyelle.rxpermissions2.RxPermissions; 20 | 21 | /** 22 | * Created by landptf on 2017/03/18. 23 | * 启动页,集成了腾讯广告联盟的开屏广告 24 | */ 25 | public class SplashFragment extends Fragment { 26 | private static final String TAG = SplashFragment.class.getSimpleName(); 27 | 28 | private MainActivity activity; 29 | 30 | private ViewGroup container; 31 | private TextView tvSkip; 32 | private ImageView ivSplashHolder; 33 | private static final String SKIP_TEXT = "点击跳过 %d"; 34 | 35 | @Override 36 | public void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | } 39 | 40 | @Override 41 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 42 | Bundle savedInstanceState) { 43 | return inflater.inflate(R.layout.fragment_splash, container, false); 44 | } 45 | 46 | @Override 47 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 48 | super.onActivityCreated(savedInstanceState); 49 | activity = (MainActivity) getActivity(); 50 | initView(); 51 | } 52 | 53 | private void initView() { 54 | container = (ViewGroup) activity.findViewById(R.id.fl_splash_container); 55 | tvSkip = (TextView) activity.findViewById(R.id.tv_skip); 56 | ivSplashHolder = (ImageView) activity.findViewById(R.id.iv_splash_holder); 57 | //申请动态权限 58 | ApplyPermissions(); 59 | } 60 | 61 | /** 62 | * 动态申请集成腾讯广告联盟的开屏广告所需要的三个权限 63 | * 使用了RxPermissions开源框架 64 | */ 65 | private void ApplyPermissions() { 66 | RxPermissions rxPermissions = new RxPermissions(activity); 67 | rxPermissions 68 | .request(Manifest.permission.READ_PHONE_STATE, 69 | Manifest.permission.ACCESS_COARSE_LOCATION, 70 | Manifest.permission.WRITE_EXTERNAL_STORAGE) 71 | .subscribe(granted -> { 72 | if (granted) { 73 | //获取开屏广告 74 | new SplashAD(activity, container, tvSkip, Constants.APPID, Constants.SplashPosID, adListener, 5000); 75 | } else { 76 | //直接进入主页面 77 | activity.dismissSplash(); 78 | } 79 | }); 80 | 81 | } 82 | 83 | /** 84 | * 开屏广告状态的监听 85 | */ 86 | private SplashADListener adListener = new SplashADListener() { 87 | 88 | /** 89 | * 广告关闭时调用,可能是用户关闭或者展示时间到。此时一般需要跳过开屏的Activity,进入应用内容页面 90 | */ 91 | @Override 92 | public void onADDismissed() { 93 | activity.dismissSplash(); 94 | } 95 | 96 | /** 97 | * 广告加载失败,errCode用于描述失败原因。 98 | * @param i 99 | */ 100 | @Override 101 | public void onNoAD(int i) { 102 | Log.e(TAG, "error code = " + i); 103 | activity.dismissSplash(); 104 | } 105 | 106 | /** 107 | * 广告成功展示时调用 108 | */ 109 | @Override 110 | public void onADPresent() { 111 | ivSplashHolder.setVisibility(View.GONE); 112 | } 113 | 114 | /** 115 | * 广告被点击时调用 116 | */ 117 | @Override 118 | public void onADClicked() { 119 | Log.i(TAG, "SplashADClicked"); 120 | } 121 | 122 | /** 123 | * 倒计时回调,返回广告还将被展示的剩余时间,单位是ms 124 | * @param l 125 | */ 126 | @Override 127 | public void onADTick(long l) { 128 | tvSkip.setText(String.format(SKIP_TEXT, Math.round(l / 1000f))); 129 | } 130 | }; 131 | } 132 | -------------------------------------------------------------------------------- /blog/src/main/res/drawable/background_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 13 | 18 | 19 | -------------------------------------------------------------------------------- /blog/src/main/res/layout/activity_a.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /blog/src/main/res/layout/activity_b.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /blog/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /blog/src/main/res/layout/activity_media.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /blog/src/main/res/layout/activity_picasso.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /blog/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 22 | 23 | 35 | 36 | 49 | 50 | 51 | 52 | 57 | 58 | 70 | 71 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /blog/src/main/res/layout/fragment_splash.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 16 | 17 | 22 | 23 | 35 | 36 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /blog/src/main/res/mipmap-hdpi/default_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landptf/BlogDemo/9ecc54d74e175b748a67aa169d4f41581ce660b4/blog/src/main/res/mipmap-hdpi/default_image.png -------------------------------------------------------------------------------- /blog/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landptf/BlogDemo/9ecc54d74e175b748a67aa169d4f41581ce660b4/blog/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /blog/src/main/res/mipmap-hdpi/splash_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landptf/BlogDemo/9ecc54d74e175b748a67aa169d4f41581ce660b4/blog/src/main/res/mipmap-hdpi/splash_logo.png -------------------------------------------------------------------------------- /blog/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landptf/BlogDemo/9ecc54d74e175b748a67aa169d4f41581ce660b4/blog/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /blog/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landptf/BlogDemo/9ecc54d74e175b748a67aa169d4f41581ce660b4/blog/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /blog/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landptf/BlogDemo/9ecc54d74e175b748a67aa169d4f41581ce660b4/blog/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /blog/src/main/res/mipmap-xxhdpi/splash_holder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landptf/BlogDemo/9ecc54d74e175b748a67aa169d4f41581ce660b4/blog/src/main/res/mipmap-xxhdpi/splash_holder.jpg -------------------------------------------------------------------------------- /blog/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/landptf/BlogDemo/9ecc54d74e175b748a67aa169d4f41581ce660b4/blog/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /blog/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /blog/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /blog/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /blog/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Blog 3 | 4 | Landptf Blog 5 | 点击跳过 6 | 7 | 8 | Hello blank fragment 9 | 10 | -------------------------------------------------------------------------------- /blog/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /blog/src/test/java/com/landptf/blog/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.landptf.blog; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:1.3.0' 10 | classpath 'org.greenrobot:greendao-gradle-plugin:3.2.0' 11 | classpath 'me.tatarka:gradle-retrolambda:3.2.0' 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | //for BaseRecyclerViewAdapterHelper 19 | maven { url "https://jitpack.io" } 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':blog' 2 | --------------------------------------------------------------------------------