GithubHelp home page GithubHelp logo

sl-y / adstar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tmtbb/adstar

0.0 1.0 0.0 45.25 MB

License: Apache License 2.0

Java 99.03% HTML 0.13% JavaScript 0.04% GLSL 0.01% Makefile 0.01% C++ 0.72% C 0.06%

adstar's Introduction

adstar

项目用到的技术

  • 1.个推服务框架
  • 2.LeakCanary内存泄漏排查框架
  • 3.BufferKnife注解绑定框架
  • 4.GreenDao数据库框架

关于项目网络框架

  • 1.项目检查更新,下载安装包使用的是http协议
  • 2.项目和服务器的通讯使用TCP/IP协议,封装socket进行数据交互

简单描述SplashActivity的逻辑:

1>初始化BugOut框架

2>handler延时2秒,然后开启新的Activity

3>Thread开启线程

步骤1:使用GetIPAddressUtils的getIpAddress()获取IP地址相关信息,内部使用一个HttpUtils对象,而HttpUtils的内部是使用Android原生的HttpURLConnection来进行数据请求的; 请求 http://ip.chinaz.com/getip.aspx; 获取到Json数据,封装为一个MyIpBean对象:

final MyAddressBean ipAddress = GetIPAddressUtils.getIpAddress();

{ip:'125.122.238.73',address:'浙江省杭州市 电信'}

步骤2:继续请求: http://ip.taobao.com/service/getIpInfo.php?ip=125.122.238.73; 后面的IP地址就是我们初次获取到的,继续获取到Json数据,封装成一个yAddressBean的对象。

  {"country":"**","country_id":"CN","area":"华东","area_id":"300000","region":"浙江省","region_id":"330000","city":"杭州市","city_id":"330100","county":"","county_id":"-1","isp":"电信","isp_id":"100017","ip":"125.121.228.115"}

步骤3:把获取到的MyAddressBean对象的重要信息 (Area_id_区域ID,area_区域名称,isp_id_运行商IP,isp_运行商名称) 赋值给一个全局对象AppConfig

    AppConfig.AREA_ID = Long.valueOf(ipAddress.getData().getArea_id());
    AppConfig.AREA = ipAddress.getData().getArea();
    AppConfig.ISP_ID = Long.valueOf(ipAddress.getData().getIsp_id());
    AppConfig.ISP = ipAddress.getData().getIsp();

步骤4:使用NetworkAPIFactoryImpl

SocketAPINettyBootstrap对象使用startConnect方法,内部bootstrap.connect(new InetSocketAddress(networkAPIConfig.getSocketServerIp(), networkAPIConfig.getSocketServerPort())).sync()和数据服务器进行初始化连接

项目的底层使用的是SocketChannel和服务器进行数据交互的

1、SplashActivity调用NetWorkAPIFactoryImp对象, 2、NetWorkAPIFactoryImp对象继续调用SocketAPIFactoryImpl對象 3、SocketAPIFactoryImpl對象继续调用SocketUserAPI 4、SocketUserAPI继续调用自身的getQiNiuPicDress()方法获取图片服务器IP地址

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.