141 lines
5.1 KiB
Java
141 lines
5.1 KiB
Java
package com.ubt.jimu.diy.view.fragment;
|
|
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.recyclerview.widget.GridLayoutManager;
|
|
import butterknife.ButterKnife;
|
|
import butterknife.Unbinder;
|
|
import com.recyclelib.URecyclerView;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
|
import com.ubt.jimu.base.db.diy.DiyHelper;
|
|
import com.ubt.jimu.base.event.BaseEvent;
|
|
import com.ubt.jimu.diy.view.adapter.UserDiyAdapter;
|
|
import com.ubt.jimu.utils.smartScaleTool.ScreenUtils;
|
|
import com.ubt.jimu.widgets.SpaceItemDecoration;
|
|
import com.ubt.jimu.widgets.choosePhotos.media.HPMedia;
|
|
import com.ubtech.utils.DisplayUtil;
|
|
import com.ubtech.view.fragment.BaseFragment;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import org.greenrobot.eventbus.EventBus;
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
import org.greenrobot.eventbus.ThreadMode;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class UserDiyFragment extends BaseFragment {
|
|
public UserDiyAdapter adapter;
|
|
private Unbinder mBind;
|
|
protected URecyclerView recyclerView;
|
|
private List<DiyDBModel> diyRobots = new ArrayList();
|
|
private int count = 1;
|
|
|
|
static /* synthetic */ int access$008(UserDiyFragment userDiyFragment) {
|
|
int i = userDiyFragment.count;
|
|
userDiyFragment.count = i + 1;
|
|
return i;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void configAdapterWidth() {
|
|
this.adapter.setWh(ScreenUtils.a(0.8333333f, this.recyclerView, getResources().getDimension(R.dimen.diy_edit_list_left), 3));
|
|
this.adapter.notifyDataSetChanged();
|
|
}
|
|
|
|
private void initData() {
|
|
this.adapter = new UserDiyAdapter(this.mActivity, this.diyRobots);
|
|
this.recyclerView.setLayoutManager(new GridLayoutManager(this.mActivity, 3));
|
|
this.recyclerView.a(new SpaceItemDecoration(DisplayUtil.a(getContext(), this.mActivity.getResources().getDimension(R.dimen.diy_edit_list_bottom)), DisplayUtil.a(getContext(), this.mActivity.getResources().getDimension(R.dimen.diy_edit_list_left)), 3, true));
|
|
this.recyclerView.setAdapter(this.adapter);
|
|
this.recyclerView.setLoadingListener(new URecyclerView.LoadingListener() { // from class: com.ubt.jimu.diy.view.fragment.UserDiyFragment.1
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onLoadingMore() {
|
|
UserDiyFragment.access$008(UserDiyFragment.this);
|
|
}
|
|
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onRefreshing() {
|
|
UserDiyFragment.this.count = 1;
|
|
UserDiyFragment.this.loadData();
|
|
}
|
|
});
|
|
this.recyclerView.post(new Runnable() { // from class: com.ubt.jimu.diy.view.fragment.UserDiyFragment.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
UserDiyFragment.this.configAdapterWidth();
|
|
}
|
|
});
|
|
this.recyclerView.setLoadingMoreEnabled(false);
|
|
}
|
|
|
|
public static UserDiyFragment newInstance(String str, String str2) {
|
|
return new UserDiyFragment();
|
|
}
|
|
|
|
public View getItemInfo() {
|
|
return this.adapter.getItemView();
|
|
}
|
|
|
|
public void loadData() {
|
|
this.diyRobots.clear();
|
|
this.diyRobots.addAll(DiyHelper.getInstance().getDiyList());
|
|
this.adapter.notifyDataSetChanged();
|
|
this.adapter.notifySelect();
|
|
this.recyclerView.y();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onActivityResult(int i, int i2, Intent intent) {
|
|
super.onActivityResult(i, i2, intent);
|
|
if (-1 != i2 || intent == null) {
|
|
return;
|
|
}
|
|
this.adapter.setPopupwindow(((HPMedia) ((ArrayList) intent.getSerializableExtra("result_data")).get(0)).getPath());
|
|
}
|
|
|
|
@Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
EventBus.b().c(this);
|
|
}
|
|
|
|
@Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment
|
|
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
|
View inflate = layoutInflater.inflate(R.layout.fragment_user_diy, viewGroup, false);
|
|
this.mBind = ButterKnife.a(this, inflate);
|
|
return inflate;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
EventBus.b().d(this);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDestroyView() {
|
|
this.mBind.unbind();
|
|
super.onDestroyView();
|
|
}
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
public void onEventData(BaseEvent baseEvent) {
|
|
loadData();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onResume() {
|
|
super.onResume();
|
|
loadData();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onViewCreated(View view, Bundle bundle) {
|
|
super.onViewCreated(view, bundle);
|
|
initData();
|
|
}
|
|
}
|