-
Notifications
You must be signed in to change notification settings - Fork 3
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
1fc0f1d
commit 6f49333
Showing
8 changed files
with
229 additions
and
15 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
71 changes: 71 additions & 0 deletions
71
app/src/main/java/com/pangbai/dowork/tool/procAdapter.java
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,71 @@ | ||
package com.pangbai.dowork.tool; | ||
|
||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.pangbai.dowork.Command.cmdExer; | ||
import com.pangbai.dowork.R; | ||
import com.pangbai.dowork.service.serviceCallback; | ||
|
||
import java.util.List; | ||
|
||
public class procAdapter extends RecyclerView.Adapter<procAdapter.ViewHolder> { | ||
private List<procMap> map; | ||
serviceCallback callback; | ||
|
||
public procAdapter(List<procMap> itemList, serviceCallback callback) { | ||
this.map = itemList; | ||
this.callback=callback; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
View view = LayoutInflater.from(parent.getContext()) | ||
.inflate(R.layout.list_proc, parent, false); | ||
return new ViewHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) { | ||
String text = map.get(position).name; | ||
holder.procName.setText(text); | ||
|
||
holder.procKill.setOnClickListener(v -> { | ||
Toast.makeText(v.getContext(),"已结束进程"+ map.get(position).pid,Toast.LENGTH_SHORT).show(); | ||
cmdExer.execute("kill -9 "+map.get(position).pid,true,false); | ||
map.remove(position); | ||
callback.callback(map.size()); | ||
notifyDataSetChanged(); | ||
|
||
//todo | ||
}); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return map.size(); | ||
} | ||
|
||
public class ViewHolder extends RecyclerView.ViewHolder { | ||
TextView procName; | ||
TextView procKill; | ||
|
||
public ViewHolder(@NonNull View itemView) { | ||
super(itemView); | ||
procName = itemView.findViewById(R.id.proc_name); | ||
procKill = itemView.findViewById(R.id.proc_kill); | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
|
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,9 @@ | ||
package com.pangbai.dowork.tool; | ||
|
||
public class procMap { | ||
String pid,name; | ||
public procMap(String pid,String name){ | ||
this.pid=pid; | ||
this.name=name; | ||
} | ||
} |
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
Oops, something went wrong.