liuzhenxing1118 3 年之前
父節點
當前提交
3cb5f250ee

+ 2 - 2
.idea/deploymentTargetDropDown.xml

@@ -7,11 +7,11 @@
         <deviceKey>
           <Key>
             <type value="VIRTUAL_DEVICE_PATH" />
-            <value value="$USER_HOME$/.android/avd/xplora_watch_400.avd" />
+            <value value="$USER_HOME$/.android/avd/xp_watch_400_API_33.avd" />
           </Key>
         </deviceKey>
       </Target>
     </targetSelectedWithDropDown>
-    <timeTargetWasSelectedWithDropDown value="2022-06-19T06:41:23.518497Z" />
+    <timeTargetWasSelectedWithDropDown value="2022-07-03T06:39:04.663413Z" />
   </component>
 </project>

+ 0 - 1
.idea/gradle.xml

@@ -13,7 +13,6 @@
             <option value="$PROJECT_DIR$/app" />
           </set>
         </option>
-        <option name="resolveModulePerSourceSet" value="false" />
       </GradleProjectSettings>
     </option>
   </component>

+ 1 - 0
.idea/misc.xml

@@ -43,6 +43,7 @@
         <entry key="app/src/main/res/layout/item_app.xml" value="0.1" />
         <entry key="app/src/main/res/layout/item_app_title.xml" value="0.1" />
         <entry key="app/src/main/res/layout/item_contact.xml" value="0.13829787234042554" />
+        <entry key="app/src/main/res/layout/item_recent.xml" value="0.30842391304347827" />
         <entry key="app/src/main/res/layout/layout_appitem.xml" value="0.11018518518518519" />
         <entry key="app/src/main/res/layout/layout_appitem_title.xml" value="0.1" />
         <entry key="app/src/main/res/layout/view_face_0.xml" value="0.1" />

+ 1 - 1
app/src/main/java/com/xplora/xplauncher/activity/MainActivity.java

@@ -105,7 +105,7 @@ public class MainActivity extends BaseActivity {
     }
 
     private void initContactsPager() {
-        List<RecentModel> recentModelList = DataManager.shareInstance().getRecentList();
+        List<ContactModel> recentModelList = DataManager.shareInstance().getRecentList();
         List<ContactModel> contactModelList = DataManager.shareInstance().getContactList();
         BasePager contactsPager = new ContactsPager(this, recentModelList, contactModelList, onContactItemOnClickListener);
         mPagesDatas.add(contactsPager.mBaseView);

+ 10 - 12
app/src/main/java/com/xplora/xplauncher/adapter/ContactsRecyclerAdapter.java

@@ -26,15 +26,13 @@ import java.util.List;
 public class ContactsRecyclerAdapter extends RecyclerView.Adapter<RecentItemView> {
     private Context mContext;
     private int mViewType = 0;
-    private List<RecentModel> mRecentList = new ArrayList<>();
-    private List<ContactModel> mContactsList = new ArrayList<>();
+    private List<ContactModel> mDataList = new ArrayList<>();
     private ContactItemOnClickListener mItemOnClickListener;
 
-    public ContactsRecyclerAdapter(Context context, int viewType, List<RecentModel> recentList, List<ContactModel> contactsList) {
+    public ContactsRecyclerAdapter(Context context, int viewType, List<ContactModel> dataList) {
         mContext = context;
         mViewType = viewType;
-        mRecentList = recentList;
-        mContactsList = contactsList;
+        mDataList = dataList;
     }
 
     @NonNull
@@ -48,15 +46,15 @@ public class ContactsRecyclerAdapter extends RecyclerView.Adapter<RecentItemView
 
     @Override
     public void onBindViewHolder(@NonNull RecentItemView viewHolder, @SuppressLint("RecyclerView") int i) {
-        RecentModel recentModel = mRecentList.get(i);
-        setAppViewHolder(viewHolder, i, recentModel);
+        ContactModel model = mDataList.get(i);
+        setAppViewHolder(viewHolder, i, model);
     }
 
-    public void setAppViewHolder(@NonNull RecentItemView viewHolder, int index, RecentModel recentModel) {
+    public void setAppViewHolder(@NonNull RecentItemView viewHolder, int index, ContactModel model) {
 
         //viewHolder.mContactIcon.setImageDrawable(mContext.getDrawable(recentModel.getCallType()));
         //viewHolder.mContactHead.setImageDrawable(mContext.getDrawable(recentModel.getContactIcon()));
-        viewHolder.mContactName.setText(recentModel.getContactName());
+        viewHolder.mContactName.setText(model.getContactName());
 
 //        viewHolder.mAppIcon.setOnClickListener(new View.OnClickListener() {
 //            @Override
@@ -75,11 +73,11 @@ public class ContactsRecyclerAdapter extends RecyclerView.Adapter<RecentItemView
 
     @Override
     public int getItemCount() {
-        return mRecentList.size();
+        return mDataList.size();
     }
 
-    public void setAppList(List<RecentModel> appList) {
-        mRecentList = appList;
+    public void setDataList(List<ContactModel> appList) {
+        mDataList = appList;
     }
 
     public void setViewType(int type) {

+ 7 - 6
app/src/main/java/com/xplora/xplauncher/data/DataManager.java

@@ -24,7 +24,7 @@ public class DataManager {
     private int mDeleteStatus = 0;
     private List<AppModel> mInstalledAppsList = new ArrayList<>();
     private List<AppModel> mQuickAppsList = new ArrayList<>(Constant.COUNT_QUICK_APP);
-    private List<RecentModel> mRecentList = new ArrayList<>();
+    private List<ContactModel> mRecentList = new ArrayList<>();
     private List<ContactModel> mContactList = new ArrayList<>();
 
     public static DataManager shareInstance() {
@@ -51,10 +51,11 @@ public class DataManager {
         loadQuickApps();
 
         loadRecent();
+        loadContacts();
     }
 
     public void loadFaceIndex() {
-        mFaceIndex = 2;
+        mFaceIndex = 0;
     }
 
     public int getFaceIndex() {
@@ -125,8 +126,8 @@ public class DataManager {
     }
 
     public void loadRecent() {
-        for (int i = 0; i < 10; i++) {
-            RecentModel model = new RecentModel();
+        for (int i = 0; i < 3; i++) {
+            ContactModel model = new ContactModel();
             model.setContactIcon(R.drawable.contact_head);
             model.setContactName("name" + i);
             model.setCallType(0);
@@ -135,12 +136,12 @@ public class DataManager {
         }
     }
 
-    public List<RecentModel> getRecentList() {
+    public List<ContactModel> getRecentList() {
         return mRecentList;
     }
 
     public void loadContacts() {
-        for (int i = 0; i < 10; i++) {
+        for (int i = 0; i < 6; i++) {
             ContactModel model = new ContactModel();
             model.setCallType(R.drawable.call_type_0);
             model.setContactIcon(R.drawable.contact_head);

+ 15 - 8
app/src/main/java/com/xplora/xplauncher/view/ContactsPager.java

@@ -17,14 +17,19 @@ import com.xplora.xplauncher.model.ContactModel;
 import com.xplora.xplauncher.model.RecentModel;
 import com.xplora.xplauncher.utils.Constant;
 
+import java.util.ArrayList;
 import java.util.List;
 
 
 public class ContactsPager extends BasePager {
     private ContactsRecyclerAdapter mRecyclerAdapter;
+    private List<ContactModel> mRecentList = new ArrayList<>();
+    private List<ContactModel> mContactsList = new ArrayList<>();
 
-    public ContactsPager(Context context, List<RecentModel> recentList, List<ContactModel> contactsList, ContactsRecyclerAdapter.ContactItemOnClickListener listener) {
+    public ContactsPager(Context context, List<ContactModel> recentList, List<ContactModel> contactsList, ContactsRecyclerAdapter.ContactItemOnClickListener listener) {
         super(context);
+        mRecentList = recentList;
+        mContactsList = contactsList;
 
         mBaseView = LayoutInflater.from(mContext).inflate(R.layout.view_screen_contacts, null);
         RecyclerView mRecyclerView = (RecyclerView)mBaseView.findViewById(R.id.recyclerView);
@@ -35,7 +40,7 @@ public class ContactsPager extends BasePager {
         mRecyclerView.setHasFixedSize(true);
         mRecyclerView.setLayoutManager(mLayoutManager);
 
-        mRecyclerAdapter = new ContactsRecyclerAdapter(mContext, 0, recentList, contactsList);
+        mRecyclerAdapter = new ContactsRecyclerAdapter(mContext, 0, recentList);
         mRecyclerAdapter.setListOnClickListener(listener);
         mRecyclerView.setAdapter(mRecyclerAdapter);
 
@@ -43,20 +48,22 @@ public class ContactsPager extends BasePager {
             @SuppressLint("NotifyDataSetChanged")
             @Override
             public void onClick(View v) {
-                //((GridLayoutManager) mLayoutManager).setSpanCount(1);
+                ((GridLayoutManager) mLayoutManager).setSpanCount(1);
+                ((GridLayoutManager) mLayoutManager).onItemsChanged(mRecyclerView);
                 mRecyclerAdapter.setViewType(0);
-                //mRecyclerAdapter.notifyDataSetChanged();
-                mRecyclerAdapter.notifyAll();
+                mRecyclerAdapter.setDataList(mRecentList);
+                mRecyclerAdapter.notifyDataSetChanged();
             }
         });
         mContactButton.setOnClickListener(new View.OnClickListener() {
             @SuppressLint("NotifyDataSetChanged")
             @Override
             public void onClick(View v) {
-                //((GridLayoutManager) mLayoutManager).setSpanCount(2);
+                ((GridLayoutManager) mLayoutManager).setSpanCount(2);
+                ((GridLayoutManager) mLayoutManager).onItemsChanged(mRecyclerView);
                 mRecyclerAdapter.setViewType(1);
-                //mRecyclerAdapter.notifyDataSetChanged();
-                mRecyclerAdapter.notifyAll();
+                mRecyclerAdapter.setDataList(mContactsList);
+                mRecyclerAdapter.notifyDataSetChanged();
             }
         });
     }

+ 2 - 2
app/src/main/res/layout/item_contact.xml

@@ -11,17 +11,17 @@
         >
 
         <ImageView
+            android:id="@+id/item_head"
             android:layout_width="55dp"
             android:layout_height="55dp"
             android:src = "@mipmap/ic_launcher"
             android:scaleType="fitXY"
-            android:id="@+id/contact_head"
             />
 
         <TextView
+            android:id="@+id/item_title"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:id="@+id/contact_name"
             android:visibility="gone"
             />
     </LinearLayout>

+ 1 - 1
app/src/main/res/layout/view_screen_contacts.xml

@@ -38,7 +38,7 @@
     </RelativeLayout>
 
     <androidx.recyclerview.widget.RecyclerView
-        android:layout_width="wrap_content"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="5dp"
         android:layout_marginBottom="10dp"