Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
anujd64 committed Sep 14, 2022
1 parent cec0343 commit 2263d1f
Show file tree
Hide file tree
Showing 34 changed files with 792 additions and 607 deletions.
8 changes: 4 additions & 4 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.theflexproject.thunder.adapter;

import static com.theflexproject.thunder.utils.SendPostRequest.postRequestGDIndex;
import static com.theflexproject.thunder.utils.SendPostRequest.postRequestGoIndex;
import static com.theflexproject.thunder.utils.SendPostRequest.postRequestMapleIndex;

import android.content.Context;
import android.os.Build;
import android.view.LayoutInflater;
Expand All @@ -13,10 +17,11 @@
import androidx.recyclerview.widget.RecyclerView;

import com.theflexproject.thunder.R;
import com.theflexproject.thunder.utils.SendPostRequest;
import com.theflexproject.thunder.database.DatabaseClient;
import com.theflexproject.thunder.model.IndexLink;

import org.json.JSONException;

import java.io.IOException;
import java.util.List;

Expand All @@ -26,7 +31,6 @@ public class IndexAdapter extends RecyclerView.Adapter<IndexAdapter.IndexViewHol
private List<IndexLink> indexLinkList;



public IndexAdapter(Context mCtx, List<IndexLink> indexLinkList) {
this.mCtx = mCtx;
this.indexLinkList = indexLinkList;
Expand All @@ -45,6 +49,8 @@ public void onBindViewHolder(IndexViewHolder holder, int position) {
holder.textViewUsername.setText(t.getUsername());
holder.textViewPassword.setText(t.getPassword());



if(t.getUsername().length()>0 && t.getPassword().length()>0){
holder.textViewUsername.setVisibility(View.VISIBLE);
holder.textViewPassword.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -101,16 +107,23 @@ void refreshIndexMovies(){
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void run() {
SendPostRequest snd = new SendPostRequest();
try {
DatabaseClient.getInstance(null).getAppDatabase().fileDao().deleteAllFromthisIndex(textViewLink.getText().toString());
if(textViewUsername.getText().toString().length()<1 && textViewUsername.toString().length()<1){
snd.postRequest(textViewLink.getText().toString());
}
else {
snd.postRequest(textViewLink.getText().toString(),textViewUsername.getText().toString(), textViewPassword.getText().toString());
String link = textViewLink.getText().toString();
IndexLink indexLink =DatabaseClient.getInstance(null).getAppDatabase().indexLinksDao().find(link);
switch (indexLink.getType()) {
case "GDIndex":
postRequestGDIndex(textViewLink.getText().toString(), textViewUsername.getText().toString(), textViewPassword.getText().toString());
break;
case "GoIndex":
postRequestGoIndex(textViewLink.getText().toString(), textViewUsername.getText().toString(), textViewPassword.getText().toString());

break;
case "MapleIndex":
postRequestMapleIndex(textViewLink.getText().toString(), textViewUsername.getText().toString(), textViewPassword.getText().toString());
break;
}
} catch (IOException e) {
} catch (IOException | JSONException e) {
e.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.theflexproject.thunder.Constants;
import com.theflexproject.thunder.R;
import com.theflexproject.thunder.model.File;
import com.theflexproject.thunder.utils.sizetoReadablesize;
import com.theflexproject.thunder.Constants;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.theflexproject.thunder.model.IndexLink;
import com.theflexproject.thunder.model.ResFormat;

@Database(entities = {ResFormat.class, File.class, IndexLink.class}, version = 10)
@Database(entities = {ResFormat.class, File.class, IndexLink.class}, version = 14)
@TypeConverters({Converters.class})

public abstract class AppDatabase extends RoomDatabase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ public interface FileDao {
@Query("SELECT * FROM File")
List<File> getAll();

@Query("SELECT * FROM file WHERE title LIKE :name")
File getbyName(String name);

@Query("SELECT * FROM file WHERE name LIKE '%' || :fileName || '%'")
List<File> getSearchQuery(String fileName);
@Query("SELECT * FROM file WHERE name LIKE '%' || :string || '%' OR title like '%' || :string || '%' OR urlString like '%' || :string || '%' or overview like '%' || :string || '%'")
List<File> getSearchQuery(String string);

@Query("SELECT * FROM file WHERE name LIKE :fileName")
File getByFileName(String fileName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
package com.theflexproject.thunder.fragments;

import static com.theflexproject.thunder.utils.SendPostRequest.postRequestGDIndex;
import static com.theflexproject.thunder.utils.SendPostRequest.postRequestGoIndex;
import static com.theflexproject.thunder.utils.SendPostRequest.postRequestMapleIndex;

import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;

import com.theflexproject.thunder.MainActivity;
import com.theflexproject.thunder.R;
import com.theflexproject.thunder.database.DatabaseClient;
import com.theflexproject.thunder.model.IndexLink;
import com.theflexproject.thunder.utils.SendPostRequest;

import org.json.JSONException;

import java.io.IOException;


public class AddNewIndexFragment extends Fragment {
public class AddNewIndexFragment extends BaseFragment {

public static final String TAG = "ActionBottomDialog";
private EditText indexLinkView;
Expand All @@ -32,6 +38,8 @@ public class AddNewIndexFragment extends Fragment {
private Button save;
private TextView refreshSuggest;

private RadioGroup radioIndexTypeGroup;
private RadioButton radioIndexTypeButton;

public static AddNewIndexFragment newInstance(){
return new AddNewIndexFragment();
Expand All @@ -46,9 +54,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.fragment_add_index, container, false);

return view;
return inflater.inflate(R.layout.fragment_add_index, container, false);
}


Expand All @@ -60,6 +66,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
save = view.findViewById(R.id.save);
refreshSuggest = view.findViewById(R.id.suggestRefresh);

radioIndexTypeGroup=(RadioGroup)mActivity.findViewById(R.id.rb_group);





Expand All @@ -71,56 +80,82 @@ public void onClick(View v) {
indexLink.setLink(indexLinkView.getText().toString());
indexLink.setUsername(userNameView.getText().toString());
indexLink.setPassword(passWordView.getText().toString());
if(indexLink.getUsername().length()<1 && indexLink.getPassword().length()<1){
userNameView.setVisibility(View.GONE);
passWordView.setVisibility(View.GONE);
}



int selectedId=radioIndexTypeGroup.getCheckedRadioButtonId();
radioIndexTypeButton= mActivity.findViewById(selectedId);
try{
if(indexLink.getLink().length()<1){
refreshSuggest.setVisibility(View.VISIBLE);
refreshSuggest.setText("Enter Index Link");
}

if(radioIndexTypeButton ==null){
refreshSuggest.setVisibility(View.VISIBLE);
refreshSuggest.setText("Select Index Type");
}
if(indexLink.getUsername().length()<1 && indexLink.getPassword().length()<1){
userNameView.setVisibility(View.GONE);
passWordView.setVisibility(View.GONE);
}

indexLink.setType(radioIndexTypeButton.getText().toString());

Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if(DatabaseClient.getInstance(MainActivity.mCtx).getAppDatabase().indexLinksDao().find(indexLink.getLink())!=null){
//refresh instead
getActivity().runOnUiThread(new Runnable() {
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
refreshSuggest.setVisibility(View.VISIBLE);
}
});
}else {
DatabaseClient.getInstance(MainActivity.mCtx).getAppDatabase().indexLinksDao().insert(indexLink);
SendPostRequest snd = new SendPostRequest();
save.setText("Adding");
try {
if(indexLink.getUsername().length()<1 && indexLink.getPassword().length()<1){
snd.postRequest(indexLink.getLink());
switch(radioIndexTypeButton.getText().toString()){
//Case statements
case "GDIndex":
try {
postRequestGDIndex(indexLink.getLink(),indexLink.getUsername(),indexLink.getPassword());
} catch (IOException e) {
e.printStackTrace();
}
break;
case "GoIndex":
try {
postRequestGoIndex(indexLink.getLink(),indexLink.getUsername(),indexLink.getPassword());
} catch (IOException | JSONException e) {
e.printStackTrace();
}
break;
case "MapleIndex":
try {
postRequestMapleIndex(indexLink.getLink(),indexLink.getUsername(),indexLink.getPassword());
} catch (IOException e) {
e.printStackTrace();
}
break;
}
else {
snd.postRequest(indexLink.getLink(),indexLink.getUsername(),indexLink.getPassword());
}
save.setText("Done");
} catch (IOException e) {
e.printStackTrace();
}
save.setText("Done");
}

}
});
thread.start();
if(save.getText().equals("Done")){
getActivity().getSupportFragmentManager().popBackStack();
thread.start();
} catch (NullPointerException e) {
e.printStackTrace();
}



if(save.getText().equals("Done")){
mActivity.getSupportFragmentManager().popBackStack();
}

}
});




}

}
Loading

0 comments on commit 2263d1f

Please sign in to comment.