reader(一)

此阅读项目是师兄的毕设项目,用了知乎日报的接口,类似知乎日报。这是一个精简版。

参照知乎日报,主要有欢迎页、登录注册界面以及主界面。

在开发这个项目之前我们要用到的开源库有以下开源库:okhttp ,UIL框架,Gson等

总目录:

      

在开始的时候要修改Application

新建一个Application文件继承自Application
public class ReaderApplication  extends Application {
    @Override
    public void  onCreate() {
        super.onCreate() ;
        initImageLoader(getApplicationContext()) ;
        Stetho. initializeWithDefaults( this) ;
        MyHttpClient. initInstance() ;
    }
    private void  initImageLoader(Context context) {
        ImageLoaderConfiguration config= ImageLoaderConfiguration. createDefault(context) ;
        ImageLoader. getInstance().init(config) ;
    }
}

并在 manifests文件修改Application

<application
    android :name= ".ReaderApplication"

在ReaderApplication中使用到UIL框架
ImageLoader中除非你需要自定义设置,模版我们可以调用它给的默认构造方法。

       ImageLoaderConfiguration configuration=ImageLoaderConfiguration.createDefault(this);

       ImageLoader.getInstance().init(configuration);

如果是想要自定义设置一些东西,可以这样子:
File cacheDir= StorageUtils. getCacheDirectory(context) ;
ImageLoaderConfiguration config= new ImageLoaderConfiguration.Builder(context)
        .threadPoolSize( 3)
        .threadPriority(Thread. NORM_PRIORITY- 2)
        .memoryCache( new LruMemoryCache( 2* 1024* 1024))
        .denyCacheImageMultipleSizesInMemory()
        .diskCacheFileNameGenerator( new Md5FileNameGenerator())
        .tasksProcessingOrder(QueueProcessingType. LIFO)
        .diskCache( new UnlimitedDiskCache(cacheDir)).writeDebugLogs()
        .build() ;
ImageLoader. getInstance().init(config) ;

接下来是欢迎页的创建,新建Activity并在mainifests文件设置其为Main,使其能够每次都第一次启动。

欢迎页布局很简单
<RelativeLayout
    xmlns: android = "http://schemas.android.com/apk/res/android"
    xmlns: tools = "http://schemas.android.com/tools"
    android :layout_width= "match_parent"
    android :layout_height= "match_parent"
    tools :context= "com.example.reader20.WelcomeActivity" >

    <ImageView
        android :layout_width= "match_parent"
        android :layout_height= "match_parent"
        android :id= "@+id/iv_splash"
        android :scaleType= "fitXY"
        android :src= "@drawable/bg_welcome" />

    <TextView
        android :textSize= "50sp"
        android :text= "@string/app_name"
        android :textColor= "@android:color/white"
        android :layout_alignParentBottom= "true"
        android :layout_marginBottom= "100dp"
        android :layout_centerHorizontal= "true"
        android :layout_width= "wrap_content"
        android :layout_height= "wrap_content" />
</RelativeLayout>

使用ButterKnife依赖注入,
public class WelcomeActivity  extends Activity {
    @Bind(R.id. iv_splash) ImageView  iv_splash ;
    private boolean  mIsLogin= false;
    @Override
    protected void  onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState) ;
        requestWindowFeature(Window. FEATURE_NO_TITLE) ;
        getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
                WindowManager.LayoutParams. FLAG_FULLSCREEN) ;
        setContentView(R.layout. activity_welcome) ;
        ButterKnife. bind( this) ;
        initView() ;
    }
    private void  initView() {
        //是否已经登录,如果之前登录过,直接进入主界面,若没有。则进入登录界面
        mIsLogin= SPUtils. get( this,SPUtils. EMAIL)== null? false: true;
        //动画加载
        Animation anim= AnimationUtils. loadAnimation( this,R.anim. splash) ; //从<set文件直接加载动画
        iv_splash.startAnimation(anim) ;
        //动画监听
        anim.setAnimationListener( new Animation.AnimationListener() {
            @Override
            public void  onAnimationStart(Animation animation) {
            }
            //动画结束后实现的逻辑
            @Override
            public void  onAnimationEnd(Animation animation) {
                //判断是否联网 如果没有联网,则进行相应提醒
                if (!NetWorkUtils. isNetWorkConnected(WelcomeActivity. this)){
                    Utils. ToastMsg(WelcomeActivity. this,NetWorkUtils. NetWork_ERROR Toast. LENGTH_LONG) ;
                }
                //判断是否登录,如果已经登录,则跳转进入主界面,如果没有登录,则进入登录界面
                if ( mIsLogin){
                    Intent intent= new Intent(WelcomeActivity. this,MainActivity. class) ;
                    startActivity(intent) ;
                } else {
                    Intent intent= new Intent(WelcomeActivity. this,LoginActivity. class) ;
                    startActivity(intent) ;
                }
                finish() ;
            }
            @Override
            public void  onAnimationRepeat(Animation animation) {
            }
        }) ;
    }
    @Override
    protected void  onDestroy() {
        super.onDestroy() ;
        ButterKnife. unbind( this) ;
    }
}
private void  startMainActivity() {

    if ( mIsLogin){
        Intent intent= new Intent(WelcomeActivity. this,MainActivity. class) ;
        startActivity(intent) ;
    } else {
        Intent intent= new Intent(WelcomeActivity. this,LoginActivity. class) ;
        startActivity(intent) ;
    }
    overridePendingTransition(android.R.anim. fade_in
            ,android.R.anim. fade_out) ;
    finish() ;
}



Material-login的使用,注册与登录界面的实现

material-login的修改。
修改了该开源库,使界面更加好看。
要修改最好下载来。先下载,然后导入module,最后删掉自己的那个module。在导入前,修改gradle文件,5个

https://github.com/shem8/MaterialLogin直接下载,然后用
替换下载解压后的文件,导入module,添加进app,这样就可以修改了。


主要修改的方面:
登录界面用 LinearLayout替代CardView,同时去掉Login的TextView.
注册界面也一样,都是让原先cardView的内容充满整个布局,不显得突兀
同时也要修改MaterialLoginView里的代码,主要是把关于Cardiew的内容换掉。具体看代码。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值