Skip to content

Commit

Permalink
modifed
Browse files Browse the repository at this point in the history
  • Loading branch information
Benojir committed Aug 31, 2024
1 parent c387ff1 commit 4f525bc
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
Expand Down Expand Up @@ -75,22 +74,22 @@ public void choosePlayServer(String episodeId, String animeTitle, String animeId

HPSharedPreference hpSharedPreference = new HPSharedPreference(activity);

boolean server_status = hpSharedPreference.getPlayableServersStatus("server_1");
boolean serverStatus = hpSharedPreference.getPlayableServersStatus("server_1");

if (server_status) {
if (serverStatus) {

ProgressDialog pd = new ProgressDialog(activity);
pd.setMessage("Generating playable link...");
pd.setCancelable(false);
pd.show();
MyProgressDialog mpd = new MyProgressDialog(activity);
mpd.setMessage("Generating playable link...");
mpd.setCancelable(false);
mpd.show();

GenerateDirectLink generateDirectLink = new GenerateDirectLink(activity);

generateDirectLink.generate(episodeId, new GenerateDirectLink.OnGenerateDirectLink() {
@Override
public void onComplete(JSONObject object) {

pd.dismiss();
mpd.dismiss();
dialog.dismiss();

try {
Expand All @@ -108,7 +107,7 @@ public void onComplete(JSONObject object) {

@Override
public void onFailed(String error) {
pd.dismiss();
mpd.dismiss();
dialog.dismiss();
Toast.makeText(activity, error, Toast.LENGTH_SHORT).show();
Log.d(TAG, "onFailed: ");
Expand All @@ -126,13 +125,13 @@ public void onFailed(String error) {

HPSharedPreference hpSharedPreference = new HPSharedPreference(activity);

boolean server_status = hpSharedPreference.getPlayableServersStatus("server_2");
boolean serverStatus = hpSharedPreference.getPlayableServersStatus("server_2");

if (server_status) {
if (serverStatus) {

String vidcdn_api = activity.getString(R.string.VIDCDN_API_URL) + episodeId;

ProgressDialog pd = new ProgressDialog(activity);
MyProgressDialog pd = new MyProgressDialog(activity);
pd.setMessage("Generating playable link...");
pd.setCancelable(false);
pd.show();
Expand Down Expand Up @@ -191,7 +190,7 @@ public void onFailed(String error) {

public void choosePlayOrDownload(String animeId, String animeTitle, String episodeId, String refererUrl, String videoHLSUrl, String videoHLSUrl2) {

final Dialog dialog = new Dialog(activity);
Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(true);
dialog.setContentView(R.layout.dialog_play_or_download);
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/java/com/fogplix/anime/dialogs/MyProgressDialog.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
package com.fogplix.anime.dialogs;

import android.app.Activity;
import android.app.Dialog;
import android.widget.TextView;

import com.fogplix.anime.R;

public class MyProgressDialog {

private final Dialog dialog;
private final TextView progressTV;

public MyProgressDialog(Activity activity) {
dialog = new Dialog(activity);
dialog.setContentView(R.layout.dialog_my_progress);
progressTV = dialog.findViewById(R.id.progressTV);
}

public void setMessage(String text) {
progressTV.setText(text);
}

public void setCancelable(boolean cancelable) {
dialog.setCancelable(cancelable);
}

public void show() {
dialog.show();
}

public void dismiss() {
dialog.dismiss();
}
}
25 changes: 3 additions & 22 deletions app/src/main/java/com/fogplix/anime/helpers/CustomMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
Expand All @@ -13,15 +12,13 @@
import android.os.Looper;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;

import androidx.core.content.FileProvider;

import com.fogplix.anime.BuildConfig;
import com.fogplix.anime.R;
import com.fogplix.anime.dialogs.MyProgressDialog;
import com.fogplix.anime.params.Statics;

import org.json.JSONArray;
Expand Down Expand Up @@ -118,29 +115,13 @@ public static void errorAlert(Activity activity, String errorTitle, String error
}
});
builder.setNegativeButton("Report", (dialog, which) -> {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:" + activity.getString(R.string.feedback_email) + "?subject= FogPlix Error v" + BuildConfig.VERSION_NAME + "&body=" + errorBody)));
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:" + activity.getString(R.string.feedback_email) + "?subject= Fogplix Anime Error v" + BuildConfig.VERSION_NAME + "&body=" + errorBody)));
activity.finish();
});
AlertDialog dialog = builder.create();
dialog.show();
}
}
//--------------------------------------------------------------------------------------------------

public static void showKeyBoard(Activity activity, EditText editText) {
if (editText.requestFocus()) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}

public static void hideKeyboard(Context context, View view) {
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

//--------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -283,7 +264,7 @@ public static void checkForUpdateOnStartApp(Activity activity) {

String downloadPath = Objects.requireNonNull(activity.getExternalFilesDir(null)) + "/fogplix_v" + versionName + "_t" + getDateTime() + ".apk";

ProgressDialog pd = new ProgressDialog(activity);
MyProgressDialog pd = new MyProgressDialog(activity);
pd.setCancelable(false);
pd.setMessage("Don't close the app. \nDownloading 0%");
pd.show();
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/dialog_my_progress.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/backgroundColor"
android:background="@color/dark_grey"
android:gravity="center"
android:padding="20dp">

Expand All @@ -15,8 +15,8 @@
style="?android:attr/progressBarStyleLarge" />

<TextView
android:id="@+id/episodeNumTV"
android:layout_width="match_parent"
android:id="@+id/progressTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select one Select one Select one"
android:maxLines="2"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<color name="fade_white">#E0DEDE</color>
<color name="light_red">#EF3977</color>
<color name="dark_yellow">#FFC107</color>
<color name="dark_grey">#181818</color>

<color name="hp_theme_color">#000000</color>
<color name="background_color">#000000</color>
Expand Down

0 comments on commit 4f525bc

Please sign in to comment.