-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0598eef
commit cae2258
Showing
14 changed files
with
319 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
module2/src/main/java/com/heyongrui/module2/data/api/ModuleApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.heyongrui.module2.data.api | ||
|
||
import com.heyongrui.module2.data.dto.HistoryTodayDto | ||
import io.reactivex.Observable | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface ModuleApi { | ||
|
||
/** | ||
* 历史上的今天 | ||
* | ||
* @param day 查询的日期,例:0918(月日) | ||
*/ | ||
@GET("history/query?duid=&day=0918") | ||
fun getTodayHistory(@Query("key") key: String, | ||
@Query("duid") duid: String, | ||
@Query("day") day: String): Observable<HistoryTodayDto> | ||
|
||
|
||
} |
75 changes: 75 additions & 0 deletions
75
module2/src/main/java/com/heyongrui/module2/data/dto/HistoryTodayDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.heyongrui.module2.data.dto | ||
|
||
import android.os.Parcel | ||
import android.os.Parcelable | ||
|
||
data class HistoryTodayDto( | ||
var msg: String,//success | ||
var retCode: String,//200 | ||
var result: List<HistoryTodayBean>) : Parcelable { | ||
constructor(parcel: Parcel) : this( | ||
parcel.readString(), | ||
parcel.readString(), | ||
parcel.createTypedArrayList(HistoryTodayBean)) { | ||
} | ||
|
||
data class HistoryTodayBean( | ||
var id: String,//569881b6590146d407332c49 | ||
var title: String, | ||
var date: String,//20190918 | ||
var month: Int,//9 | ||
var day: Int,//18 | ||
var event: String) : Parcelable { | ||
constructor(parcel: Parcel) : this( | ||
parcel.readString(), | ||
parcel.readString(), | ||
parcel.readString(), | ||
parcel.readInt(), | ||
parcel.readInt(), | ||
parcel.readString()) { | ||
} | ||
|
||
override fun writeToParcel(parcel: Parcel, flags: Int) { | ||
parcel.writeString(id) | ||
parcel.writeString(title) | ||
parcel.writeString(date) | ||
parcel.writeInt(month) | ||
parcel.writeInt(day) | ||
parcel.writeString(event) | ||
} | ||
|
||
override fun describeContents(): Int { | ||
return 0 | ||
} | ||
|
||
companion object CREATOR : Parcelable.Creator<HistoryTodayBean> { | ||
override fun createFromParcel(parcel: Parcel): HistoryTodayBean { | ||
return HistoryTodayBean(parcel) | ||
} | ||
|
||
override fun newArray(size: Int): Array<HistoryTodayBean?> { | ||
return arrayOfNulls(size) | ||
} | ||
} | ||
} | ||
|
||
override fun writeToParcel(parcel: Parcel, flags: Int) { | ||
parcel.writeString(msg) | ||
parcel.writeString(retCode) | ||
parcel.writeTypedList(result) | ||
} | ||
|
||
override fun describeContents(): Int { | ||
return 0 | ||
} | ||
|
||
companion object CREATOR : Parcelable.Creator<HistoryTodayDto> { | ||
override fun createFromParcel(parcel: Parcel): HistoryTodayDto { | ||
return HistoryTodayDto(parcel) | ||
} | ||
|
||
override fun newArray(size: Int): Array<HistoryTodayDto?> { | ||
return arrayOfNulls(size) | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
module2/src/main/java/com/heyongrui/module2/data/service/ModuleService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.heyongrui.module2.data.service | ||
|
||
import com.heyongrui.module2.data.api.ModuleApi | ||
import com.heyongrui.module2.data.dto.HistoryTodayDto | ||
import com.heyongrui.network.configure.RxHelper | ||
import com.heyongrui.network.service.ApiService | ||
import io.reactivex.Observable | ||
|
||
class ModuleService { | ||
|
||
/** | ||
* 历史上的今天 | ||
* | ||
* @param day 查询的日期,例:0918(月日) | ||
*/ | ||
fun getTodayHistory(day: String): Observable<HistoryTodayDto> { | ||
return ApiService.createApi(ModuleApi::class.java, "http://apicloud.mob.com/appstore/") | ||
.getTodayHistory("moba6b6c6d6", "43275ff45b034bffaf6b9941a216fe6dbae31dc9", day) | ||
.compose(RxHelper.rxSchedulerHelper()) | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
module2/src/main/java/com/heyongrui/module2/grocery/view/TodayHistoryActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package com.heyongrui.module2.grocery.view | ||
|
||
import android.graphics.Color | ||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.core.content.ContextCompat | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.alibaba.android.arouter.facade.annotation.Route | ||
import com.blankj.utilcode.util.ConvertUtils | ||
import com.blankj.utilcode.util.ToastUtils | ||
import com.chad.library.adapter.base.BaseQuickAdapter | ||
import com.heyongrui.base.app.BaseApplication | ||
import com.heyongrui.base.assist.ConfigConstants | ||
import com.heyongrui.base.assist.RxManager | ||
import com.heyongrui.base.base.BaseActivity | ||
import com.heyongrui.base.base.BasePresenter | ||
import com.heyongrui.base.utils.DrawableUtil | ||
import com.heyongrui.base.utils.TimeUtil | ||
import com.heyongrui.base.widget.itemdecoration.RecycleViewItemDecoration | ||
import com.heyongrui.module2.R | ||
import com.heyongrui.module2.adapter.Module2SectionAdapter | ||
import com.heyongrui.module2.adapter.Module2SectionEntity | ||
import com.heyongrui.module2.dagger.DaggerModule2Component | ||
import com.heyongrui.module2.dagger.Module2Module | ||
import com.heyongrui.module2.data.dto.HistoryTodayDto | ||
import com.heyongrui.module2.data.service.ModuleService | ||
import com.heyongrui.network.configure.ResponseDisposable | ||
import kotlinx.android.synthetic.main.activity_today_history.* | ||
import java.util.* | ||
import javax.inject.Inject | ||
|
||
@Route(path = ConfigConstants.PATH_TODAY_HISTORY) | ||
class TodayHistoryActivity : BaseActivity<BasePresenter<*>>(), | ||
View.OnClickListener, | ||
BaseQuickAdapter.OnItemClickListener { | ||
|
||
@Inject | ||
lateinit var mModuleService: ModuleService | ||
@Inject | ||
lateinit var mRxManager: RxManager | ||
|
||
lateinit var mTodayHistoryAdapter: Module2SectionAdapter | ||
|
||
fun adapterIsInit() = ::mTodayHistoryAdapter.isInitialized | ||
|
||
override fun initializeInjector() { | ||
DaggerModule2Component.builder().appComponent(BaseApplication.getAppComponent()) | ||
.module2Module(Module2Module(this@TodayHistoryActivity)).build().inject(this) | ||
} | ||
|
||
override fun getLayoutId(): Int { | ||
return R.layout.activity_today_history | ||
} | ||
|
||
override fun onClick(p0: View?) { | ||
if (p0 != null) { | ||
if (p0 == iv_back) { | ||
finish() | ||
} | ||
} | ||
} | ||
|
||
override fun init(savedInstanceState: Bundle?) { | ||
addOnClickListeners(this@TodayHistoryActivity, iv_back) | ||
|
||
val tintDrawable = DrawableUtil.tintDrawable(this@TodayHistoryActivity, | ||
R.drawable.ic_back, ContextCompat.getColor(this@TodayHistoryActivity, R.color.background)) | ||
iv_back.setImageDrawable(tintDrawable) | ||
|
||
mTodayHistoryAdapter = initRecyclerView(rlv_today_history, this) | ||
|
||
val day = TimeUtil.getDateString(Date(), "MMdd") | ||
getTodayHistory(day) | ||
} | ||
|
||
fun initRecyclerView(recyclerView: RecyclerView, listener: BaseQuickAdapter.OnItemClickListener): Module2SectionAdapter { | ||
val data = ArrayList<Module2SectionEntity>() | ||
val moduleSectionAdapter = Module2SectionAdapter(data) | ||
recyclerView.layoutManager = LinearLayoutManager(this@TodayHistoryActivity) | ||
moduleSectionAdapter.bindToRecyclerView(recyclerView) | ||
val dp1 = ConvertUtils.dp2px(1f) | ||
recyclerView.addItemDecoration(RecycleViewItemDecoration(this@TodayHistoryActivity, dp1, Color.TRANSPARENT)) | ||
moduleSectionAdapter.setSpanSizeLookup({ gridLayoutManager, position -> data[position].getSpanSize() }) | ||
if (null != listener) { | ||
moduleSectionAdapter.setOnItemClickListener(listener) | ||
} | ||
return moduleSectionAdapter | ||
} | ||
|
||
override fun onItemClick(adapter: BaseQuickAdapter<*, *>?, view: View?, position: Int) { | ||
|
||
} | ||
|
||
fun getTodayHistory(day: String) { | ||
mRxManager.add(mModuleService.getTodayHistory(day).subscribeWith( | ||
object : ResponseDisposable<HistoryTodayDto>(this@TodayHistoryActivity, true) { | ||
override fun onSuccess(historyTodayDto: HistoryTodayDto) { | ||
setData(historyTodayDto) | ||
} | ||
|
||
override fun onFailure(errorCode: Int, errorMsg: String) { | ||
ToastUtils.showShort(errorMsg) | ||
} | ||
})) | ||
} | ||
|
||
fun setData(historyTodayDto: HistoryTodayDto) { | ||
if (!adapterIsInit()) return | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.