gongpm vor 9 Jahren
Ursprung
Commit
270fb48915

+ 0 - 2
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/NoticeMenuActivity.java

@@ -68,10 +68,8 @@ public class NoticeMenuActivity extends BaseActivity {
         mPullToRefreshListView = (PullToRefreshSlideListView) findViewById(R.id.pull_refresh_list);
         mPullToRefreshListView.setShowIndicator(false);
         mPullToRefreshListView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
-
         mAdapter = new NearlyMessageAdapter(NoticeMenuActivity.this);
         mPullToRefreshListView.getRefreshableView().setAdapter(mAdapter);
-
         mPullToRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<SlideListView>() {
             @Override
             public void onRefresh(PullToRefreshBase<SlideListView> refreshView) {

+ 0 - 59
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/message/SubscribeListActivity.java

@@ -1,59 +0,0 @@
-package com.xzjmyk.pm.activity.ui.message;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-
-import com.xzjmyk.pm.activity.AppConfig;
-import com.xzjmyk.pm.activity.MyApplication;
-import com.xzjmyk.pm.activity.R;
-import com.xzjmyk.pm.activity.ui.base.BaseActivity;
-import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
-import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
-import com.xzjmyk.pm.activity.ui.erp.util.Constants;
-
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class SubscribeListActivity extends BaseActivity {
-
-    private AppConfig mConfig;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_subscribe_list);
-        mConfig = MyApplication.getInstance().getConfig();
-
-        initData();
-    }
-
-
-    private Handler handler = new Handler() {
-        @Override
-        public void handleMessage(Message msg) {
-            if (msg.what == 2) {
-                String message = (String) msg.getData().get("result");
-
-
-            } else if (Constants.APP_SOCKETIMEOUTEXCEPTION == msg.what) {
-                String message = (String) msg.getData().get("result");
-                Log.i("gongpengming", message);
-            }
-        }
-    };
-
-    public void initData() {
-        String url = "http://218.17.158.219:8090/ERP//common/desktop/subs/getSubs.action";
-        final Map<String, Object> param = new HashMap<>();
-        param.put("count", 2);
-        param.put("condition", "where 1=1");
-        param.put("sessionId", CommonUtil.getSharedPreferences(this, "sessionId"));
-        LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
-        headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(this, "sessionId"));
-        ViewUtil.httpSendRequest(this, url, param, handler, headers, 2, null, null, "get");
-    }
-
-}

+ 108 - 0
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/tool/ThreadPool.java

@@ -0,0 +1,108 @@
+package com.xzjmyk.pm.activity.ui.tool;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public final class ThreadPool {
+     // 线程池中默认线程的个数为5
+     private static int worker_num = 5;
+     // 工作线程
+     private WorkThread[] workThreads;
+    
+     // 任务队列,作为一个缓冲,List线程不安全
+     private List<Runnable> taskQueue = new LinkedList<Runnable>();
+
+     private static ThreadPool threadPool;
+
+     // 创建具有默认线程个数的线程池
+     private ThreadPool() {
+          this(5);
+     }
+
+     // 创建线程池,worker_num为线程池中工作线程的个数
+     private ThreadPool(int worker_num) {
+          ThreadPool.worker_num = worker_num;
+          workThreads = new WorkThread[worker_num];
+          for (int i = 0; i < worker_num; i++) {
+               workThreads[i] = new WorkThread();
+               workThreads[i].start();// 开启线程池中的线程
+          }
+     }
+
+     // 单态模式,获得一个默认线程个数的线程池
+     public static ThreadPool getThreadPool() {
+          return getThreadPool(ThreadPool.worker_num);
+     }
+
+     // 单态模式,获得一个指定线程个数的线程池,worker_num(>0)为线程池中工作线程的个数
+     // worker_num<=0创建默认的工作线程个数
+     public static ThreadPool getThreadPool(int worker_num1) {
+          if (threadPool == null)
+               threadPool = new ThreadPool(worker_num1);
+          return threadPool;
+     }
+
+     // 执行任务,其实只是把任务加入任务队列,什么时候执行有线程池管理器觉定
+     public void addTask(Runnable task) {
+          synchronized (taskQueue) {
+               taskQueue.add(task);
+               taskQueue. notifyAll();
+          }
+     }
+
+     // 销毁线程池,该方法保证在所有任务都完成的情况下才销毁所有线程,否则等待任务完成才销毁
+     public void destroy() {
+          while (!taskQueue.isEmpty()) {// 如果还有任务没执行完成,就先睡会吧
+               try {
+                    Thread.sleep(10);
+               } catch (InterruptedException e) {
+                    e.printStackTrace();
+               }
+          }
+          // 工作线程停止工作,且置为null
+          for (int i = 0; i < worker_num; i++) {
+               workThreads[i].stopWorker();
+               workThreads[i] = null;
+          }
+          threadPool=null;
+          taskQueue.clear();// 清空任务队列
+     }
+
+     /**
+      * 内部类,工作线程
+      */
+     private class WorkThread extends Thread {
+          // 该工作线程是否有效,用于结束该工作线程
+          private boolean isRunning = true;
+
+          /*
+           * 关键所在啊,如果任务队列不空,则取出任务执行,若任务队列空,则等待
+           */
+          @Override
+          public void run() {
+               Runnable r = null;
+               while (isRunning) {// 注意,若线程无效则自然结束run方法,该线程就没用了
+                    synchronized (taskQueue) {
+                         while (isRunning && taskQueue.isEmpty()) {// 队列为空
+                              try {
+                                   taskQueue.wait(20);
+                              } catch (InterruptedException e) {
+                                   e.printStackTrace();
+                              }
+                         }
+                         if (!taskQueue.isEmpty())
+                              r = taskQueue.remove(0);// 取出任务
+                    }
+                    if (r != null) {
+                         r.run();// 执行任务
+                    }
+                    r = null;
+               }
+          }
+
+          // 停止工作,让该线程自然执行完run方法,自然结束
+          public void stopWorker() {
+               isRunning = false;
+          }
+     }
+}

+ 0 - 10
WeiChat/src/main/res/layout/activity_subscribe_list.xml

@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
-    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
-    android:paddingRight="@dimen/activity_horizontal_margin"
-    android:paddingTop="@dimen/activity_vertical_margin"
-    android:paddingBottom="@dimen/activity_vertical_margin"
-    tools:context="com.xzjmyk.pm.activity.ui.message.SubscribeListActivity">
-
-</RelativeLayout>

+ 334 - 0
WeiChat/src/main/res/layout/message_head.xml

@@ -0,0 +1,334 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <RelativeLayout
+        android:id="@+id/schedule_rl"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/item_height"
+        android:background="@color/item_color1"
+        android:descendantFocusability="blocksDescendants"
+        android:minHeight="@dimen/item_height"
+        android:paddingLeft="15dp"
+        android:paddingRight="15dp">
+        <!--android:background="@color/item_color1"-->
+        <FrameLayout
+            android:id="@+id/schedule_head_area"
+            android:layout_width="57dp"
+            android:layout_height="64dp"
+            android:layout_centerVertical="true">
+
+            <ImageView
+                android:id="@+id/schedule_avatar_img"
+                android:layout_width="@dimen/item_img_height"
+                android:layout_height="@dimen/item_img_width"
+                android:layout_gravity="center_vertical"
+                android:background="@color/transparent"
+                android:contentDescription="@string/app_name"
+                android:padding="1dp"
+                android:src="@drawable/home_image_01_u" />
+
+            <TextView
+                android:id="@+id/schedule_num_tv"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="top|right"
+                android:background="@drawable/tab_unread_bg"
+                android:gravity="center"
+                android:textColor="@android:color/white"
+                android:textSize="10.0dip"
+                android:visibility="visible" />
+        </FrameLayout>
+
+        <RelativeLayout
+            android:id="@+id/schedule_content"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_centerVertical="true"
+            android:layout_marginLeft="3dp"
+            android:layout_toRightOf="@id/schedule_head_area"
+            android:gravity="center_vertical">
+
+            <TextView
+                android:id="@+id/schedule_name_tv"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@+id/schedule_time_tv"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:text="待审批流"
+                android:textColor="@color/text_main"
+                android:textSize="16sp" />
+
+            <TextView
+                android:id="@+id/schedule_time_tv"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentRight="true"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textColor="@color/text_hine"
+                android:textSize="14sp" />
+
+            <TextView
+                android:id="@+id/schedule_content_tv"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/schedule_name_tv"
+                android:layout_marginTop="8dp"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textColor="@color/text_hine"
+                android:textSize="14sp" />
+        </RelativeLayout>
+
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:id="@+id/task_rl"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/item_height"
+        android:background="@color/item_color2"
+        android:descendantFocusability="blocksDescendants"
+        android:minHeight="@dimen/item_height"
+        android:paddingLeft="15dp"
+        android:paddingRight="15dp">
+        <!--android:background="@color/item_color1"-->
+        <FrameLayout
+            android:id="@+id/task_head_area"
+            android:layout_width="57dp"
+            android:layout_height="64dp"
+            android:layout_centerVertical="true">
+
+            <ImageView
+                android:id="@+id/task_avatar_img"
+                android:layout_width="@dimen/item_img_height"
+                android:layout_height="@dimen/item_img_width"
+                android:layout_gravity="center_vertical"
+                android:background="@color/transparent"
+                android:contentDescription="@string/app_name"
+                android:padding="1dp"
+                android:src="@drawable/home_image_02_u" />
+
+            <TextView
+                android:id="@+id/task_num_tv"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="top|right"
+                android:background="@drawable/tab_unread_bg"
+                android:gravity="center"
+                android:textColor="@android:color/white"
+                android:textSize="10.0dip"
+                android:visibility="visible" />
+        </FrameLayout>
+
+        <RelativeLayout
+            android:id="@+id/task_content"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_centerVertical="true"
+            android:layout_marginLeft="3dp"
+            android:layout_toRightOf="@id/task_head_area"
+            android:gravity="center_vertical">
+
+            <TextView
+                android:id="@+id/task_name_tv"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@+id/task_time_tv"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:text="我的任务"
+                android:textColor="@color/text_main"
+                android:textSize="16sp" />
+
+            <TextView
+                android:id="@+id/task_time_tv"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentRight="true"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textColor="@color/text_hine"
+                android:textSize="14sp" />
+
+            <TextView
+                android:id="@+id/task_content_tv"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/task_name_tv"
+                android:layout_marginTop="8dp"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textColor="@color/text_hine"
+                android:textSize="14sp" />
+        </RelativeLayout>
+
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:id="@+id/notice_rl"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/item_height"
+        android:background="@color/item_color1"
+        android:descendantFocusability="blocksDescendants"
+        android:minHeight="@dimen/item_height"
+        android:paddingLeft="15dp"
+        android:paddingRight="15dp">
+        <!--android:background="@color/item_color1"-->
+        <FrameLayout
+            android:id="@+id/notice_head_area"
+            android:layout_width="57dp"
+            android:layout_height="64dp"
+            android:layout_centerVertical="true">
+
+            <ImageView
+                android:id="@+id/notice_avatar_img"
+                android:layout_width="@dimen/item_img_height"
+                android:layout_height="@dimen/item_img_width"
+                android:layout_gravity="center_vertical"
+                android:background="@color/transparent"
+                android:contentDescription="@string/app_name"
+                android:padding="1dp"
+                android:src="@drawable/home_image_03_u" />
+
+            <TextView
+                android:id="@+id/notice_num_tv"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="top|right"
+                android:background="@drawable/tab_unread_bg"
+                android:gravity="center"
+                android:textColor="@android:color/white"
+                android:textSize="10.0dip"
+                android:visibility="visible" />
+        </FrameLayout>
+
+        <RelativeLayout
+            android:id="@+id/notice_content"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_centerVertical="true"
+            android:layout_marginLeft="3dp"
+            android:layout_toRightOf="@id/notice_head_area"
+            android:gravity="center_vertical">
+
+            <TextView
+                android:id="@+id/notice_name_tv"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@+id/notice_time_tv"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:text="通知公告"
+                android:textColor="@color/text_main"
+                android:textSize="16sp" />
+
+            <TextView
+                android:id="@+id/notice_time_tv"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentRight="true"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textColor="@color/text_hine"
+                android:textSize="14sp" />
+
+            <TextView
+                android:id="@+id/notice_content_tv"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/notice_name_tv"
+                android:layout_marginTop="8dp"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textColor="@color/text_hine"
+                android:textSize="14sp" />
+        </RelativeLayout>
+
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:id="@+id/_rl"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/item_height"
+        android:background="@color/item_color2"
+        android:descendantFocusability="blocksDescendants"
+        android:minHeight="@dimen/item_height"
+        android:paddingLeft="15dp"
+        android:paddingRight="15dp">
+        <!--android:background="@color/item_color1"-->
+        <FrameLayout
+            android:id="@+id/head_area"
+            android:layout_width="57dp"
+            android:layout_height="64dp"
+            android:layout_centerVertical="true">
+
+            <ImageView
+                android:id="@+id/avatar_img"
+                android:layout_width="@dimen/item_img_height"
+                android:layout_height="@dimen/item_img_width"
+                android:layout_gravity="center_vertical"
+                android:background="@color/transparent"
+                android:contentDescription="@string/app_name"
+                android:padding="1dp"
+                android:src="@drawable/tingyue" />
+
+            <TextView
+                android:id="@+id/num_tv"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="top|right"
+                android:background="@drawable/tab_unread_bg"
+                android:gravity="center"
+                android:textColor="@android:color/white"
+                android:textSize="10.0dip"
+                android:visibility="visible" />
+        </FrameLayout>
+
+        <RelativeLayout
+            android:id="@+id/content"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_centerVertical="true"
+            android:layout_marginLeft="3dp"
+            android:layout_toRightOf="@id/head_area"
+            android:gravity="center_vertical">
+
+            <TextView
+                android:id="@+id/nick_name_tv"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@+id/time_tv"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:text="订阅号"
+                android:textColor="@color/text_main"
+                android:textSize="16sp" />
+
+            <TextView
+                android:id="@+id/time_tv"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentRight="true"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textColor="@color/text_hine"
+                android:textSize="14sp" />
+
+            <TextView
+                android:id="@+id/content_tv"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/nick_name_tv"
+                android:layout_marginTop="8dp"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textColor="@color/text_hine"
+                android:textSize="14sp" />
+        </RelativeLayout>
+
+    </RelativeLayout>
+</LinearLayout>