This repository has been archived by the owner on Sep 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from ExploiTR/patch_1
update 1.1.2
- Loading branch information
Showing
41 changed files
with
3,087 additions
and
96 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 was deleted.
Oops, something went wrong.
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
45 changes: 45 additions & 0 deletions
45
app/src/main/java/app/exploitr/nsg/youp3/Book/BookMark.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,45 @@ | ||
package app.exploitr.nsg.youp3.Book; | ||
|
||
import io.realm.RealmObject; | ||
import io.realm.annotations.PrimaryKey; | ||
|
||
public class BookMark extends RealmObject { | ||
|
||
@PrimaryKey | ||
private int id; | ||
private String title; | ||
private String url; | ||
private String favicon; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
public String getFavicon() { | ||
return favicon; | ||
} | ||
|
||
public void setFavicon(String favicon) { | ||
this.favicon = favicon; | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
app/src/main/java/app/exploitr/nsg/youp3/Book/BookMarkAdapter.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,126 @@ | ||
package app.exploitr.nsg.youp3.Book; | ||
|
||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.util.Base64; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.mikhaellopez.circularimageview.CircularImageView; | ||
|
||
import java.util.List; | ||
|
||
import app.exploitr.nsg.youp3.R; | ||
|
||
|
||
|
||
/* | ||
* Created by exploitr on 28-09-2017. | ||
*/ | ||
|
||
public class BookMarkAdapter extends RecyclerView.Adapter<BookMarkAdapter.ViewHolder> { | ||
|
||
private List<String> mData; | ||
private LayoutInflater mInflater; | ||
private ItemClickListener mClickListener; | ||
private ItemLongClickListener mLongClickListener; | ||
|
||
public BookMarkAdapter(Context context, List<String> data) { | ||
this.mInflater = LayoutInflater.from(context); | ||
this.mData = data; | ||
} | ||
|
||
public void notifyDataSetChangedCustom(List<String> newdata) { | ||
mData.clear(); | ||
mData.addAll(newdata); | ||
this.notifyDataSetChanged(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
View view = mInflater.inflate(R.layout.row_bookmarks_list_item, parent, false); | ||
return new ViewHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) { | ||
String[] x = mData.get(position).split(","); | ||
holder.titleTextView.setText(x[1]); | ||
holder.urlTextView.setText(x[2]); | ||
holder.id = Integer.parseInt(x[0]); | ||
|
||
byte[] decodedString = Base64.decode(x[3], Base64.DEFAULT); | ||
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); | ||
|
||
holder.favicon.setImageBitmap(decodedByte); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return mData.size(); | ||
} | ||
|
||
public void setClickListener(ItemClickListener itemClickListener) { | ||
this.mClickListener = itemClickListener; | ||
} | ||
|
||
public void setLongClickListener(ItemLongClickListener itemLongClickListener) { | ||
this.mLongClickListener = itemLongClickListener; | ||
} | ||
|
||
public interface ItemClickListener { | ||
void onOpenClick(String url); | ||
} | ||
|
||
public interface ItemLongClickListener { | ||
void onDeleteClick(int id); | ||
} | ||
|
||
class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { | ||
TextView urlTextView, titleTextView; | ||
CircularImageView favicon; | ||
LinearLayout clicker; | ||
int id; | ||
|
||
ViewHolder(View itemView) { | ||
super(itemView); | ||
id = 0; | ||
urlTextView = itemView.findViewById(R.id.urlView); | ||
titleTextView = itemView.findViewById(R.id.titleView); | ||
favicon = itemView.findViewById(R.id.favicon); | ||
clicker = itemView.findViewById(R.id.bookmarkClickable); | ||
|
||
clicker.setOnClickListener(this); | ||
clicker.setOnLongClickListener(this); | ||
itemView.setOnClickListener(this); | ||
} | ||
|
||
@Override | ||
public void onClick(View view) { | ||
if (mClickListener != null) { | ||
if (view.getId() == clicker.getId()) { | ||
mClickListener.onOpenClick(urlTextView.getText().toString()); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onLongClick(View view) { | ||
if (mLongClickListener != null) { | ||
if (view.getId() == clicker.getId()) { | ||
mLongClickListener.onDeleteClick(id); | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
app/src/main/java/app/exploitr/nsg/youp3/Book/BookMarkManager.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,50 @@ | ||
package app.exploitr.nsg.youp3.Book; | ||
|
||
/* | ||
* Created by exploitr on 25-09-2017. | ||
* | ||
* I've created a new instance for each getters. | ||
* I don't know but think If the data is updated at the middle, | ||
* an old instance wouldn't return the updated data | ||
*/ | ||
|
||
import io.realm.Realm; | ||
|
||
public class BookMarkManager { | ||
|
||
private Realm realm; | ||
|
||
public BookMarkManager() { | ||
realm = Realm.getDefaultInstance(); | ||
} | ||
|
||
private BookRealmController getController() { | ||
return new BookRealmController(); | ||
} | ||
|
||
public void push(int id, String title, String url, String favicon) { | ||
BookMark info = new BookMark(); | ||
|
||
info.setId(id); | ||
info.setTitle(title); | ||
info.setUrl(url); | ||
info.setFavicon(favicon); | ||
|
||
realm.beginTransaction(); | ||
realm.copyToRealmOrUpdate(info); | ||
realm.commitTransaction(); | ||
} | ||
|
||
|
||
public String getTitleById(int id) { | ||
return getController().getBookMark(id).getTitle(); | ||
} | ||
|
||
public int getTotalInfoCount() { | ||
return getController().getBookMarks().size(); | ||
} | ||
|
||
public void removeInfoById(int id) { | ||
getController().deleteBookMark(id); | ||
} | ||
} |
Oops, something went wrong.