-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ivan Del Pino <idelpino@teclib.com>
- Loading branch information
Showing
9 changed files
with
242 additions
and
215 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
app/src/main/java/org/flyve/inventory/agent/adapter/CategoriesAdapter.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,106 @@ | ||
/* | ||
* Copyright Teclib. All rights reserved. | ||
* | ||
* Flyve MDM is a mobile device management software. | ||
* | ||
* Flyve MDM is free software: you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 3 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* Flyve MDM is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* ------------------------------------------------------------------------------ | ||
* @author Ivan Del Pino | ||
* @copyright Copyright Teclib. All rights reserved. | ||
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html | ||
* @link https://github.com/flyve-mdm/android-inventory-agent | ||
* @link https://flyve-mdm.com | ||
* ------------------------------------------------------------------------------ | ||
*/ | ||
|
||
package org.flyve.inventory.agent.adapter; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.support.annotation.NonNull; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
import org.flyve.inventory.agent.R; | ||
import org.flyve.inventory.agent.ui.ActivityDetailServer; | ||
|
||
import java.util.ArrayList; | ||
|
||
|
||
public class CategoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{ | ||
|
||
private ArrayList<String> data; | ||
private Activity activity; | ||
|
||
public CategoriesAdapter(ArrayList<String> data, Activity activity) { | ||
this.data = data; | ||
this.activity = activity; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) { | ||
int resource = R.layout.list_item_categories; | ||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(resource, viewGroup, false); | ||
return new DataViewHolder(v); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | ||
((DataViewHolder) holder).bindData(data.get(position), position); | ||
} | ||
|
||
public class DataViewHolder extends RecyclerView.ViewHolder { | ||
TextView title; | ||
Button showCategory; | ||
View viewSeparatorBottom; | ||
|
||
DataViewHolder(View itemView) { | ||
super(itemView); | ||
title = itemView.findViewById(R.id.title); | ||
showCategory = itemView.findViewById(R.id.showCategory); | ||
viewSeparatorBottom = itemView.findViewById(R.id.viewSeparatorBottom); | ||
} | ||
|
||
void bindData(final String model, int position) { | ||
if (position % 2 == 1) { | ||
itemView.setBackgroundColor(activity.getResources().getColor(R.color.white)); | ||
} else { | ||
itemView.setBackgroundColor(activity.getResources().getColor(R.color.grayDarkList)); | ||
} | ||
|
||
title.setText(model); | ||
|
||
if ((data.size() -1) == position) { | ||
viewSeparatorBottom.setVisibility(View.VISIBLE); | ||
} | ||
|
||
showCategory.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent = new Intent(activity, ActivityDetailServer.class); | ||
intent.putExtra("serverName", model); | ||
activity.startActivity(intent); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return data.size(); | ||
} | ||
|
||
} |
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
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.