|
@@ -0,0 +1,77 @@
|
|
|
|
+package com.xplora.xpchat.activity;
|
|
|
|
+
|
|
|
|
+import android.content.Intent;
|
|
|
|
+
|
|
|
|
+import androidx.recyclerview.widget.GridLayoutManager;
|
|
|
|
+import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
+
|
|
|
|
+import com.xplora.xpchat.R;
|
|
|
|
+import com.xplora.xpchat.adapter.RecyclerAdapter;
|
|
|
|
+import com.xplora.xpchat.model.AppModel;
|
|
|
|
+import com.xplora.xpchat.utils.Constant;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+public class ContactsActivity extends BaseActivity {
|
|
|
|
+ private List<AppModel> mAppsList = new ArrayList<>();
|
|
|
|
+ private int mViewIndex;
|
|
|
|
+ private int mAppIndex;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void onCreateBase() {
|
|
|
|
+ super.onCreateBase();
|
|
|
|
+ setContentView(R.layout.activity_itemlist);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void initDataBase() {
|
|
|
|
+ super.initDataBase();
|
|
|
|
+
|
|
|
|
+ List<AppModel> installedApps = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
+ AppModel model = new AppModel();
|
|
|
|
+ model.setAppLabel("name" + i);
|
|
|
|
+ model.setAppIcon(getDrawable(R.drawable.icon_app_0));
|
|
|
|
+ mAppsList.add(model);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mViewIndex = getIntent().getIntExtra(Constant.INTENT_PAGER_INDEX, 0);
|
|
|
|
+ mAppIndex = getIntent().getIntExtra(Constant.INTENT_ITEM_INDEX, 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void initViewBase() {
|
|
|
|
+ super.initViewBase();
|
|
|
|
+
|
|
|
|
+ RecyclerView mRecyclerView = findViewById(R.id.recyclerView);
|
|
|
|
+ RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this, 2);
|
|
|
|
+ mRecyclerView.setHasFixedSize(true);
|
|
|
|
+ mRecyclerView.setLayoutManager(mLayoutManager);
|
|
|
|
+
|
|
|
|
+ RecyclerAdapter mRecyclerAdapter = new RecyclerAdapter(this, mAppsList, Constant.E_PAGER_TYPE.APPLIST, 0);
|
|
|
|
+ mRecyclerAdapter.setListOnClickListener(onAppItemOnClickListener);
|
|
|
|
+ mRecyclerView.setAdapter(mRecyclerAdapter);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ RecyclerAdapter.AppItemOnClickListener onAppItemOnClickListener = new RecyclerAdapter.AppItemOnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(Constant.E_PAGER_TYPE pagerType, int mViewIndex, int appIndex, AppModel appModel) {
|
|
|
|
+ onSelectItem(appIndex, appModel);
|
|
|
|
+ finish();
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
|
|
+ public void onLongClick(Constant.E_PAGER_TYPE pagerType, int mViewIndex, int appIndex, AppModel appModel) {
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
|
|
+ public void onClickDelete(Constant.E_PAGER_TYPE pagerType, int mViewIndex, int appIndex, AppModel appModel) {
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ private void onSelectItem(int index, AppModel appModel) {
|
|
|
|
+ Intent intent = new Intent(this, ChatActivity.class);
|
|
|
|
+ intent.putExtra(Constant.INTENT_PAGER_INDEX, mViewIndex);
|
|
|
|
+ intent.putExtra(Constant.INTENT_ITEM_INDEX, mAppIndex);
|
|
|
|
+ startActivity(intent);
|
|
|
|
+ }
|
|
|
|
+}
|