Skip to content

Commit

Permalink
接入工具接口;工具页面编写;天气页面部分编写
Browse files Browse the repository at this point in the history
  • Loading branch information
wosojadfjgo committed Sep 12, 2019
1 parent 49303b2 commit c18c480
Show file tree
Hide file tree
Showing 38 changed files with 3,059 additions and 7 deletions.
2 changes: 2 additions & 0 deletions base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ dependencies {
//刷新框架
api "com.scwang.smartrefresh:SmartRefreshLayout:${versions.smartRefreshLayout}"
api "com.scwang.smartrefresh:SmartRefreshHeader:${versions.smartRefreshLayout}"
//lottie动画
api "com.airbnb.android:lottie:${versions.lottie}"

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ public class ConfigConstants {
public static final String PATH_TARGET = "target_path";

//main模块路由路径
public static final String PATH_MAIN = "/main/activity";
public static final String PATH_PLANET_BALL = "/main/planetBall";
public static final String PATH_HOME_PROVIDER = "/home/main/service";
public static final String PATH_MAIN = "/home/main";
public static final String PATH_PLANET_BALL = "/home/planetBall";
public static final String PATH_MOB = "/home/mob";
public static final String PATH_WEATHER = "/home/weather";
public static final String PATH_HOME_PROVIDER = "/home/service";
//user模块路由路径
public static final String PATH_ENCOURAGE = "/user/encourage";
public static final String PATH_KOTLIN = "/user/kotlin";
Expand Down
1 change: 1 addition & 0 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ ext {
jiaozivideoplayer : '7.0.4',
ahbottomnavigation: '2.3.4',
banner : '2.3.16',
lottie : '3.0.7',
]
}
6 changes: 6 additions & 0 deletions main/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
<activity
android:name=".planetball.view.PlanetBallActivity"
android:theme="@style/BaseAppTheme" />
<activity
android:name=".mob.view.MobActivity"
android:theme="@style/BaseAppTheme" />
<activity
android:name=".mob.view.MobWeatherActivity"
android:theme="@style/BaseAppTheme" />
</application>
</manifest>
6 changes: 6 additions & 0 deletions main/src/main/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<activity
android:name=".planetball.view.PlanetBallActivity"
android:theme="@style/BaseAppTheme" />
<activity
android:name=".mob.view.MobActivity"
android:theme="@style/BaseAppTheme" />
<activity
android:name=".mob.view.MobWeatherActivity"
android:theme="@style/BaseAppTheme" />
</application>

</manifest>
13 changes: 10 additions & 3 deletions main/src/main/java/com/heyongrui/main/HomeFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ protected void initData(Bundle savedInstanceState) {
}

private void initPlanetBallView(PlanetBallView planetBallView, List<FloatingDto> floatingDtoList) {
int dp70 = ConvertUtils.dp2px(70);
int dp80 = ConvertUtils.dp2px(80);
int dp30 = ConvertUtils.dp2px(30);
planetBallView.setAdapter(new PlanetAdapter() {
@Override
public int getCount() {
Expand All @@ -110,7 +111,7 @@ public View getView(Context context, int position, ViewGroup parent) {
iconRes = ((FloatingDto) item).getIcon_res();
}
MarqueeTextView marqueeTextView = new MarqueeTextView(context);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(dp70, dp70);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(dp80, dp80);
marqueeTextView.setLayoutParams(layoutParams);
marqueeTextView.setBackgroundResource(R.drawable.bg_circle_shadow);
marqueeTextView.setGravity(Gravity.CENTER);
Expand All @@ -121,7 +122,7 @@ public View getView(Context context, int position, ViewGroup parent) {
marqueeTextView.setTextColor(Color.WHITE);
marqueeTextView.setText(TextUtils.isEmpty(name) ? "" : name);
Drawable drawable = ContextCompat.getDrawable(context, iconRes);
drawable.setBounds(0, 0, 80, 80 * drawable.getIntrinsicHeight() / drawable.getIntrinsicWidth());
drawable.setBounds(0, 0, dp30, dp30 * drawable.getIntrinsicHeight() / drawable.getIntrinsicWidth());
marqueeTextView.setCompoundDrawables(null, drawable, null, null);
marqueeTextView.setFocusable(true);
marqueeTextView.post(() -> marqueeTextView.onWindowFocusChanged(true));
Expand All @@ -130,16 +131,22 @@ public View getView(Context context, int position, ViewGroup parent) {
int type = ((FloatingDto) item).getType();
switch (type) {
case 1://分词解析
ARouter.getInstance().build(ConfigConstants.PATH_MOB).withInt("mobType", 1).navigation();
break;
case 2://航班查询
ARouter.getInstance().build(ConfigConstants.PATH_MOB).withInt("mobType", 2).navigation();
break;
case 3://身份证查询
ARouter.getInstance().build(ConfigConstants.PATH_MOB).withInt("mobType", 3).navigation();
break;
case 4://天气预报
ARouter.getInstance().build(ConfigConstants.PATH_WEATHER).navigation();
break;
case 5://新华字典查询
ARouter.getInstance().build(ConfigConstants.PATH_MOB).withInt("mobType", 5).navigation();
break;
case 6://成语查询
ARouter.getInstance().build(ConfigConstants.PATH_MOB).withInt("mobType", 6).navigation();
break;
case 7://动作布局动画
ARouter.getInstance().build(ConfigConstants.PATH_KOTLIN).navigation();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.heyongrui.main.adapter;

import com.chad.library.adapter.base.BaseItemDraggableAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
* Created by lambert on 2018/11/13.
* 拖拽、滑动适配器
*/
public class DragAndSwipeAdapter extends BaseItemDraggableAdapter<Object, BaseViewHolder> {
private int mItemType;

public DragAndSwipeAdapter(List<Object> data, int itemType) {
super(data);
mItemType = itemType;
}

public DragAndSwipeAdapter(int layoutResId, int itemType, List<Object> data) {
super(layoutResId, data);
mItemType = itemType;
}

@Override
protected void convert(BaseViewHolder helper, Object item) {
switch (mItemType) {

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.heyongrui.main.adapter;

import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.heyongrui.base.utils.UiUtil;
import com.heyongrui.main.R;

import java.util.List;

/**
* Created by lambert on 2018/8/29.
* 可折叠分组适配器
*/
public class ExpandableAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {

public static final int HOTEL_ROOM_TYPE = 10004;

public ExpandableAdapter(List<MultiItemEntity> data) {
super(data);
// addItemType(HOTEL_ROOM_TYPE, R.layout.adapter_item_hotel_room_type);
}

@Override
protected void convert(BaseViewHolder helper, MultiItemEntity item) {
UiUtil.setOnclickFeedBack(mContext, ContextCompat.getColor(mContext, R.color.background), ContextCompat.getColor(mContext, R.color.gray), helper.itemView);
switch (helper.getItemViewType()) {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.heyongrui.main.adapter;

import android.text.TextUtils;

import com.chad.library.adapter.base.BaseSectionMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.heyongrui.main.R;
import com.heyongrui.main.data.dto.FlightDto;

import java.util.List;


/**
* lambert
* 2019/6/25 18:17
*/
public class HomeSectionAdapter extends BaseSectionMultiItemQuickAdapter<HomeSectionEntity, BaseViewHolder> {

public HomeSectionAdapter(List<HomeSectionEntity> data) {
this(0, data);
}

public HomeSectionAdapter(int sectionHeadResId, List<HomeSectionEntity> data) {
super(sectionHeadResId, data);
addItemType(HomeSectionEntity.FLIGHT, R.layout.recycle_item_flight);
}

@Override
protected void convertHead(BaseViewHolder helper, HomeSectionEntity item) {
// switch (item.getItemType()) {
// case HomeSectionEntity.FLIGHT:
// TextView tvHeadSection = helper.getView(android.R.id.text1);
// if (null != tvHeadSection) {
// tvHeadSection.setText(TextUtils.isEmpty(item.header) ? "" : item.header);
// }
// break;
// }
}

@Override
protected void convert(BaseViewHolder helper, HomeSectionEntity item) {
switch (helper.getItemViewType()) {
case HomeSectionEntity.FLIGHT: {
String flightCompany = "", flightNumber = "", flightRate = "", flightTime = "", fromAirport = "",
fromAirportCode = "", fromCity = "", fromCityCode = "", fromTerminal = "", planTime = "",
planArriveTime = "", toAirport = "", toAirportCode = "", toCity = "", toCityCode = "",
toTerminal = "", flightCycle = "";
FlightDto flightDto = item.getFlightDto();
if (null != flightDto) {
flightCompany = flightDto.getAirLines();
flightNumber = flightDto.getFlightNo();
flightRate = flightDto.getFlightRate();
flightTime = flightDto.getFlightTime();
fromAirport = flightDto.getFrom();
fromAirportCode = flightDto.getFromAirportCode();
fromCity = flightDto.getFromCityName();
fromCityCode = flightDto.getFromCityCode();
fromTerminal = flightDto.getFromTerminal();
planTime = flightDto.getPlanTime();
planArriveTime = flightDto.getPlanArriveTime();
toAirport = flightDto.getTo();
toAirportCode = flightDto.getToAirportCode();
toCity = flightDto.getToCityName();
toCityCode = flightDto.getToCityCode();
toTerminal = flightDto.getToTerminal();
flightCycle = flightDto.getWeek();
}
helper.setText(R.id.tv_company, TextUtils.isEmpty(flightCompany) ? "" : flightCompany);
helper.setText(R.id.tv_flight_number, TextUtils.isEmpty(flightNumber) ? "" : flightNumber);
helper.setText(R.id.tv_flight_rate, TextUtils.isEmpty(flightRate) ? "" : flightRate);
helper.setText(R.id.tv_flight_time, TextUtils.isEmpty(flightTime) ? "" : flightTime);
helper.setText(R.id.tv_from_airport, TextUtils.isEmpty(fromAirport) ? "" : fromAirport);
helper.setText(R.id.tv_from_airport_code, TextUtils.isEmpty(fromAirportCode) ? "" : fromAirportCode);
helper.setText(R.id.tv_from_city_name, TextUtils.isEmpty(fromCity) ? "" : fromCity);
helper.setText(R.id.tv_from_city_code, TextUtils.isEmpty(fromCityCode) ? "" : fromCityCode);
helper.setText(R.id.tv_from_terminal, TextUtils.isEmpty(fromTerminal) ? "" : fromTerminal);
helper.setText(R.id.tv_plan_time, TextUtils.isEmpty(planTime) ? "" : planTime);
helper.setText(R.id.tv_plan_arrive_time, TextUtils.isEmpty(planArriveTime) ? "" : planArriveTime);
helper.setText(R.id.tv_to_airport, TextUtils.isEmpty(toAirport) ? "" : toAirport);
helper.setText(R.id.tv_to_airport_code, TextUtils.isEmpty(toAirportCode) ? "" : toAirportCode);
helper.setText(R.id.tv_to_city_name, TextUtils.isEmpty(toCity) ? "" : toCity);
helper.setText(R.id.tv_to_city_code, TextUtils.isEmpty(toCityCode) ? "" : toCityCode);
helper.setText(R.id.tv_to_terminal, TextUtils.isEmpty(toTerminal) ? "" : toTerminal);
helper.setText(R.id.tv_flight_cycle, TextUtils.isEmpty(flightCycle) ? "" : flightCycle);
}
break;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.heyongrui.main.adapter;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.chad.library.adapter.base.entity.SectionMultiEntity;
import com.heyongrui.main.data.dto.FlightDto;

import java.util.List;

/**
* lambert
* 2019/6/25 18:13
*/
public class HomeSectionEntity extends SectionMultiEntity implements MultiItemEntity {

public static final int FLIGHT = 100;

private int itemType;
private int spanSize;

private Object object;
private FlightDto flightDto;

public HomeSectionEntity(boolean isHeader, String header, boolean isShow) {
super(isHeader, header);
}

public HomeSectionEntity(int itemType, Object object) {
this(itemType, 1, object);
}

public HomeSectionEntity(int itemType, int spanSize, Object object) {
super(object);
this.itemType = itemType;
this.spanSize = spanSize;
this.object = object;
if (object != null) {
if (object instanceof List && ((List) object).size() > 0) {
Object o = ((List) object).get(0);
// if (o instanceof BannerDto) {
// this.bannerDtoList = (List<BannerDto>) object;
// }
} else if (object instanceof FlightDto) {
this.flightDto = (FlightDto) object;
}
}
}

@Override
public int getItemType() {
return itemType;
}

public void setItemType(int itemType) {
this.itemType = itemType;
}

public int getSpanSize() {
return spanSize;
}

public void setSpanSize(int spanSize) {
this.spanSize = spanSize;
}

public Object getObject() {
return object;
}

public void setObject(Object object) {
this.object = object;
}

public FlightDto getFlightDto() {
return flightDto;
}

public void setFlightDto(FlightDto flightDto) {
this.flightDto = flightDto;
}
}
12 changes: 12 additions & 0 deletions main/src/main/java/com/heyongrui/main/dagger/ActivityContext.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.heyongrui.main.dagger;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import javax.inject.Qualifier;

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface ActivityContext {

}
27 changes: 27 additions & 0 deletions main/src/main/java/com/heyongrui/main/dagger/HomeComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.heyongrui.main.dagger;

import android.app.Activity;

import androidx.fragment.app.Fragment;

import com.heyongrui.base.dagger.AppComponent;
import com.heyongrui.base.dagger.PerActivity;
import com.heyongrui.main.mob.presenter.MobPresenter;

import dagger.Component;

/**
* 2019/8/26
* lambert
* 此Component依赖AppComponent,由于AppComponent使用了@Singleton,此处只能使用自定义@Scope(@PerActivity)
*/

@PerActivity
@Component(dependencies = AppComponent.class, modules = {HomeModule.class})
public interface HomeComponent {
Activity getActivity();

Fragment getFragment();

void inject(MobPresenter mobPresenter);
}
Loading

0 comments on commit c18c480

Please sign in to comment.